submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s611575563
p03663
C++
#include <iostream> #include <vector> #include <map> #include <set> #include <queue> #include <algorithm> #include <string> #include <cmath> #include <cstdio> #include <iomanip> #include <fstream> #include <cassert> #include <cstring> #include <unordered_set> #include <unordered_map> #include <numeric> #include <ctime> #include <bitset> #include <complex> #include <chrono> #include <random> #include <functional> using namespace std; mt19937 rng(10); #define int long long #ifdef LOCAL int n; #endif int query(int N) { #ifdef LOCAL assert(N <= 1e18); if (n <= N && to_string(n) <= to_string(N)) return 1; if (n > N && to_string(n) > to_string(N)) return 1; return 0; #else cout << "? " << N << endl; char c; cin >> c; return c == 'Y'; #endif } int chpref(int N) { while (N <= 1e17) { N = 10 * N + 9; } return query(N); } void run() { int pr = 0; for (int j = 0; j < 20; j++) { if (j > 0 && chpref(10 * pr + 0)) { if (query(pr + 1) == chpref(pr + 1)) break; // if (chpref(pr + 1)) break; } int l = 0; if (j > 0) l = -1; int r = 9; while (r - l > 1) { int m = (r + l) / 2; if (!chpref(10 * pr + m)) l = m; else r = m; } pr = 10 * pr + r; } #ifdef LOCAL if (n != pr) { cerr << "WA: " << n << endl; cerr << pr << endl; exit(0); } else { cerr << "AC" << endl; } #else cout << "! " << n << endl; #endif } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); #ifdef LOCAL while (true) { n = rng() % (int)(1e9) + 1; run(); } #else run(); #endif }
a.cc: In function 'void run()': a.cc:81:25: error: 'n' was not declared in this scope; did you mean 'yn'? 81 | cout << "! " << n << endl; | ^ | yn
s348837260
p03663
C++
#include <iostream> #include <vector> #include <map> #include <set> #include <queue> #include <algorithm> #include <string> #include <cmath> #include <cstdio> #include <iomanip> #include <fstream> #include <cassert> #include <cstring> #include <unordered_set> #include <unordered_map> #include <numeric> #include <ctime> #include <bitset> #include <complex> #include <chrono> #include <random> #include <functional> using namespace std; mt19937 rng(10); #define int long long #ifdef LOCAL int n; #endif int query(int N) { #ifdef LOCAL assert(N <= 1e18); if (n <= N && to_string(n) <= to_string(N)) return 1; if (n > N && to_string(n) > to_string(N)) return 1; return 0; #else cout << "? " << N << endl; char c; cin >> c; return c == 'Y'; #endif } int chpref(int N) { while (N <= 1e17) { N = 10 * N + 9; } return query(N); } void run() { int pr = 0; for (int j = 0; j < 20; j++) { if (j > 0 && chpref(10 * pr + 0)) { if (query(pr + 1) == chpref(pr + 1)) break; // if (chpref(pr + 1)) break; } int l = 0; if (j > 0) l = -1; int r = 9; while (r - l > 1) { int m = (r + l) / 2; if (!chpref(10 * pr + m)) l = m; else r = m; } pr = 10 * pr + r; } if (n != pr) { cerr << "WA: " << n << endl; cerr << pr << endl; exit(0); } else { cerr << "AC" << endl; } } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); #ifdef LOCAL while (true) { n = rng() % (int)(1e9) + 1; run(); } #else run(); #endif }
a.cc: In function 'void run()': a.cc:72:13: error: 'n' was not declared in this scope; did you mean 'yn'? 72 | if (n != pr) { | ^ | yn
s336177711
p03663
C++
#include <bits/stdc++.h> #ifdef __LOCAL #define DBG(X) cout << #X << " = " << (X) << endl; #define SAY(X) cout << (X) << endl; #include <filesystem> namespace fs = std::filesystem; #else #define DBG(X) #define SAY(X) #endif using namespace std; using ll = long long int; using ull = unsigned long long int; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; int dx[]={1, 0, -1, 0, 1,-1, 1,-1}; int dy[]={0, 1, 0, -1, 1, 1,-1,-1}; const int INT_INF = (int)(2e9); const ll LL_INF = (ll)(2e18); static mt19937 _g(time(nullptr)); inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); } inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }; template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; } template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; } template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; } template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; } void input(){ // fast_io(); #ifdef __LOCAL fs::path __p = __FILE__; fs::path __input, __output; __input = __output = __p.parent_path(); __input += string("/input/") + string(__p.stem()) + string(".txt"); __output += string("/output/") + string(__p.stem()) + string(".txt"); freopen(__input.c_str(), "r", stdin); freopen(__output.c_str(), "w", stdout); #endif } bool get_q(){ char a; cin >> a; if(a=='Y') return true; return false; } bool throw_q(string t){ cout << "? " << stol(t) << endl; return get_q(); } bool throw_q(ll t){ cout << "? " << t << endl; return get_q(); } void throw_a(string t){ cout << "! " << stol(t) << endl; } void throw_a(ll t){ cout << "! " << t << endl; } int solve(){ string N; for (int i = 0; i < 9; i++) { int ng=0,ok=10; if(i==0) ng=1; while(ok-ng>1){ int mid=(ok+ng)/2; string t=N; t+=to_string(mid); t+=string((10-t.length()),'0'); DBG(t) if(throw_q(t)) ok=mid; else ng = mid; } N += to_string(ng); } // int ng=0,ok=10; // while(ok-ng>1){ // int mid=(ok+ng)/2; // string mi = N.substr(0,mid); // ll m = stol(mi)+1; // if(throw_q(m)) ok=mid; // else ng = mid; // } // int j; // for (int i = N.length(); i > 0 ; i--) // { // int m = stol(N.substr(0,i)); // m++; // if(throw_q(m)) continue; // else {j=i; break;} // } int j; ll ans=0; ll ans=stol(N); ans++; ans/=10; while(ans%10==0) ans/=10; // for (int i = N.length(); i > 0 ; i--) // { // int m = stol(N.substr(0,i)); // m--; // if(throw_q(m)) {ans=m++; break;} // } throw_a(ans); return 0; } int main() { // input(); solve(); return 0; }
a.cc: In function 'int solve()': a.cc:112:8: error: redeclaration of 'll ans' 112 | ll ans=stol(N); | ^~~ a.cc:111:8: note: 'll ans' previously declared here 111 | ll ans=0; | ^~~
s611652954
p03663
C++
#include<bits/stdc++.h> using namespace std; #define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++) #define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++) #define MOD 1000000007 #define int long long #define ALL(a) (a).begin(),(a).end() #define vi vector<int> #define vii vector<vi> #define pii pair<int,int> #define priq priority_queue<int> #define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key))) #define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key))) #define tii tuple<int,int,int> #define Priq priority_queue<int,vi,greater<int>> #define pb push_back #define mp make_pair #define INF (1ll<<62)-1 #define MAX 1000000000 bool f(int X){ printf("? %lld\n",X*10); char S; cin>>S; return S=='Y'; } signed main(){ int memo=10; int cnt=0; while(1){ printf("? %lld\n",memo); string S; cin>>S; cnt++; if(S=="N") break; printf("? %lld\n",memo-1); cin>>S; cnt++; if(S=="Y") break; memo*=10; } int left=memo/10,right=memo-1; while(left+1<right){ int mid=(left+right)/2; if(f(mid)) right=mid; cnt++; else left=mid; } int ans=right; if(f(left)) ans=left; cnt++; if(cnt>=64){ while(1){} } printf("! %lld\n",ans); }
a.cc: In function 'int main()': a.cc:44:9: error: 'else' without a previous 'if' 44 | else left=mid; | ^~~~
s693880928
p03663
C++
#include <bits/stdc++.h> typedef long long ll; int qry(ll x){ printf("? %lld\n",x); fflush(stdout); char s[3]; scanf("%s",s); if (s[0]=='Y') return 1; return 0; } int main(){ int w=0;ll L=1; for (;qry(L) && w<=9;w++,L*=10); if (w>9){ w=0,L=10; for (;!qry(L-1);w++,L*=10); printf("! %lld\n",L/10); fflush(stdout); return 0; } ll R=L-1,ans; w--,L/=10; while (L<=R){ ll mid=(L+R)>>1; if (qry(mid*10)) ans=max(ans,mid),R=mid-1; else L=mid+1; } printf("! %lld\n",ans); fflush(stdout); return 0; }
a.cc: In function 'int main()': a.cc:25:38: error: 'max' was not declared in this scope; did you mean 'std::max'? 25 | if (qry(mid*10)) ans=max(ans,mid),R=mid-1; | ^~~ | std::max In file included from /usr/include/c++/14/algorithm:61, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~
s780681768
p03663
C++
#include <bits/stdc++.h> using namespace std; #define int long long bool query(int x){ printf("? %lld\n", x); fflush(stdout); char s[20]; scanf("%s", s); return str[0] == 'Y'; } int pows(int x, int y) { int z = 1; while(y) { if(y & 1) z *= x; x *= x, y >>= 1; } return z; } signed main() { int len = 1; query(1); //while(query(pows(10, len) - 1)) len++; int l = pows(10, len - 1), r = pows(10, len) - 1; /*while(l < r) { int m = (l + r + 1) >> 1; if(query(m)) l = m; else r = m + 1; }*/ printf("! %lld\n", l); return 0; }
a.cc: In function 'bool query(long long int)': a.cc:8:16: error: 'str' was not declared in this scope; did you mean 'std'? 8 | return str[0] == 'Y'; | ^~~ | std
s617742151
p03663
C++
#include <bits/stdc++.h> using namespace std; #define int long long bool query(int x){ printf("? %lld\n", x); fflush(stdout); char s[20]; scanf("%s", s); return str[0] == 'Y'; } int pows(int x, int y) { int z = 1; while(y) { if(y & 1) z *= x; x *= x, y >>= 1; } return z; } signed main() { int len = 1; while(query(pows(10, len) - 1)) len++; int l = pows(10, len - 1), r = pows(10, len) - 1; /*while(l < r) { int m = (l + r + 1) >> 1; if(query(m)) l = m; else r = m + 1; }*/ printf("! %lld\n", l); return 0; }
a.cc: In function 'bool query(long long int)': a.cc:8:16: error: 'str' was not declared in this scope; did you mean 'std'? 8 | return str[0] == 'Y'; | ^~~ | std
s392130570
p03663
C++
#include <bits/stdc++.h> using namespace std; using ll = long long; using Pi = pair<int, int>; using Pl = pair<ll, ll>; using vint = vector<int>; using vll = vector<ll>; using uint = unsigned int; using ull = unsigned long long; template<typename T> using uset = unordered_set<T>; template<typename T1, typename T2> using umap = unordered_map<T1, T2>; constexpr int INF = (1 << 30) - 1; constexpr ll LLINF = 1LL << 60; constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1}; constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}; constexpr char el = '\n'; constexpr int mod = 1000000007; template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); } template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); } template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; } template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; } template<typename T> ostream& operator <<(ostream &os, vector<T> &v) { for (auto &u : v) os << u << el; return (os); } template<typename T> istream& operator >>(istream &is, vector<T> &v) { for (auto &u : v) is >> u; return (is); } int N; char judge(string &T) { #ifdef DEBUG if (stoi(T) <= N && T <= to_string(N) || stoi(T) > N && T > to_string(N) ) { c = 'Y'; } else { c = 'N'; } #else cin >> c; #endif return (c); } int main() { #ifdef DEBUG cin >> N; #endif string S; while (true) { int ok, ng; char c; //sakini 9 situmon suru { string T = S + '9'; cout << "? " << T << el; fflush(stdout); c = judge(T); } if (c == 'N') { ok = 0, ng = 9; while (abs(ok-ng) > 1) { int m = (ok+ng)/2; string T = S + (char)(m + '0'); cout << "? " << T << el; fflush(stdout); c = judge(T); if (c == 'Y') ok = m; else ng = m; } S += (ok + '0'); continue; } ok = 10, ng = -1; while (abs(ok-ng) > 1) { int m = (ok+ng)/2; string T = S + (char)(m + '0'); if (count(begin(T), end(T), '0') == T.size()) { ng = m; continue; } while (T.size() < 15) T += '0'; cout << "? " << T << el; fflush(stdout); c = judge(T); if (c == 'Y') ok = m; else ng = m; } if (ok == 10) { S += '9'; continue; } else { S += (ok + '0'); cout << "! " << S << el; fflush(stdout); break; } } return (0); }
a.cc: In function 'char judge(std::string&)': a.cc:49:16: error: 'c' was not declared in this scope 49 | cin >> c; | ^
s580885574
p03663
C++
#include<bits/stdc++.h> using namespace std; #define int long long int N; string hoge(int n){ string res; //cout<<"N = "<<N<<" n = "<<n<<endl; if(n <= N && to_string(n) <= to_string(N)) res = "Y"; else if(n > N && to_string(n) > to_string(N)) res = "Y"; else res = "N"; // cout<<"res = "<<res<<endl; cout<<res<<endl; //string hogehoge; //cin>>hogehoge; return res; } bool checkt(int m){ string ans; m *= 10; cout<<"? "<<m<<endl; //cout<<flush; ans = hoge(m); //cin>>ans; return ans == "Y"; } void solvet(){ int con = 0; for(int i = 1; ;i *= 10){ int n = i; string ans; cout<<"? "<<n<<endl; //cout<<flush; // cin>>ans; ans = hoge(n); if(ans == "Y") { con++; } else{ break; } } // cout<<con<<endl; int l = 1, h = 10, m = 0; for(int i = 1; i < con; i++){ l *= 10; h *= 10; } while(l + 1< h){ m = (l + h)/2; if(!checkt(m)){ l = m; } else { h = m; } } cout<<"! "<<h<<endl; cout<<flush; } void test(){ while(true){ cin>>N; solvet(); while(true){ int x; cin>>x; cout<<hoge(x)<<endl; } } } bool check(int m){ string ans; m *= 10; cout<<"? "<<m<<endl; cout<<flush; cin>>ans; return ans == "Y"; } void solve(){ int con = 0; for(int i = 1; ;i *= 10){ int n = i; string ans; cout<<"? "<<n<<endl; cout<<flush; cin>>ans; if(ans == "Y") { con++; } else if(ans == "N"){ break; } } // cout<<con<<endl; int l = 1, h = 10, m = 0; for(int i = 1; i < con; i++){ l *= 10; h *= 10; } while(l + 1< h){ m = (l + h)/2; if(!check(m)){ l = m; } else { h = m; } } cout<<"! "<<h<<endl; cout<<flush; } signed main(){ // test(); sovle(); return 0; }
a.cc: In function 'int main()': a.cc:165:3: error: 'sovle' was not declared in this scope; did you mean 'solve'? 165 | sovle(); | ^~~~~ | solve
s546335126
p03663
C++
#include<bits/stdc++.h> #define mo 1000000007 #define pi 3.1415926535898 #define eps 1e-9 using namespace std; long long read(){#include<bits/stdc++.h> #define mo 1000000007 #define pi 3.1415926535898 #define eps 1e-9 using namespace std; long long read(){ long long xx=0,flagg=1; char ch=getchar(); while((ch<'0'||ch>'9')&&ch!='-') ch=getchar(); if(ch=='-'){ flagg=-1; ch=getchar(); } while(ch>='0'&&ch<='9'){ xx=xx*10+ch-'0'; ch=getchar(); } return xx*flagg; } void pus(long long xx,long long flagg){ if(xx<0){ putchar('-'); xx=-xx; } if(xx>=10) pus(xx/10,0); putchar(xx%10+'0'); if(flagg==1) putchar(' '); if(flagg==2) putchar('\n'); return; } long long i,l,r,mid,min1,y; char s[15]; void query(long long x){ printf("? %lld\n",x); fflush(stdout); scanf("%s",s); } int main(){ //freopen("camp.in","r",stdin); //freopen("camp.out","w",stdout); y=1000000000; query(y); if(s[0]=='Y'){ i=9; while(i){ query(y-1); if(s[0]!='Y') break; y/=10; i--; } cout<<"! "<<y<<endl; return 0; } for(i=1;;i=i*10){ query(i); if(s[0]=='N'){ i/=10; l=i; r=i*10-1; mid=(l+r)/2; break; } } min1=r+1; while(l<=r){ query(mid*10); if(s[0]=='Y'){ min1=min(min1,mid); r=mid-1; } else l=mid+1; mid=(l+r)/2; } cout<<"! "<<min1<<endl; return 0; } long long xx=0,flagg=1; char ch=getchar(); while((ch<'0'||ch>'9')&&ch!='-') ch=getchar(); if(ch=='-'){ flagg=-1; ch=getchar(); } while(ch>='0'&&ch<='9'){ xx=xx*10+ch-'0'; ch=getchar(); } return xx*flagg; } void pus(long long xx,long long flagg){ if(xx<0){ putchar('-'); xx=-xx; } if(xx>=10) pus(xx/10,0); putchar(xx%10+'0'); if(flagg==1) putchar(' '); if(flagg==2) putchar('\n'); return; } long long i,l,r,mid,min1,y; char s[15]; void query(long long x){ printf("? %lld\n",x); fflush(stdout); scanf("%s",s); } int main(){ //freopen("camp.in","r",stdin); //freopen("camp.out","w",stdout); for(i=1;;i=i*10){ query(i); if(s[0]=='N'){ i/=10; l=i; r=i*10-1; mid=(l+r)/2; break; } } min1=r+1; while(l<=r){ query(mid*10); if(s[0]=='Y'){ min1=min(min1,mid); r=mid-1; } else l=mid+1; mid=(l+r)/2; } cout<<"! "<<min1<<endl; return 0; }
a.cc:6:18: error: stray '#' in program 6 | long long read(){#include<bits/stdc++.h> | ^ a.cc: In function 'long long int read()': a.cc:6:19: error: 'include' was not declared in this scope 6 | long long read(){#include<bits/stdc++.h> | ^~~~~~~ a.cc:6:27: error: 'bits' was not declared in this scope 6 | long long read(){#include<bits/stdc++.h> | ^~~~ a.cc:6:32: error: 'stdc' was not declared in this scope; did you mean 'std'? 6 | long long read(){#include<bits/stdc++.h> | ^~~~ | std a.cc:10:1: error: expected primary-expression before 'using' 10 | using namespace std; | ^~~~~ a.cc:11:15: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 11 | long long read(){ | ^~ a.cc:11:15: note: remove parentheses to default-initialize a variable 11 | long long read(){ | ^~ | -- a.cc:11:15: note: or replace parentheses with braces to value-initialize a variable a.cc:11:17: error: a function-definition is not allowed here before '{' token 11 | long long read(){ | ^ a.cc:26:39: error: a function-definition is not allowed here before '{' token 26 | void pus(long long xx,long long flagg){ | ^ a.cc:42:24: error: a function-definition is not allowed here before '{' token 42 | void query(long long x){ | ^ a.cc:47:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 47 | int main(){ | ^~ a.cc:47:9: note: remove parentheses to default-initialize a variable 47 | int main(){ | ^~ | -- a.cc:47:9: note: or replace parentheses with braces to value-initialize a variable a.cc:47:11: error: a function-definition is not allowed here before '{' token 47 | int main(){ | ^
s008679719
p03663
C++
#include<bits/stdc++.h> #define mo 1000000007 #define pi 3.1415926535898 #define eps 1e-9 using namespace std; long long read(){ long long xx=0,flagg=1; char ch=getchar(); while((ch<'0'||ch>'9')&&ch!='-') ch=getchar(); if(ch=='-'){ flagg=-1; ch=getchar(); } while(ch>='0'&&ch<='9'){ xx=xx*10+ch-'0'; ch=getchar(); } return xx*flagg; } void pus(long long xx,long long flagg){ if(xx<0){ putchar('-'); xx=-xx; } if(xx>=10) pus(xx/10,0); putchar(xx%10+'0'); if(flagg==1) putchar(' '); if(flagg==2) putchar('\n'); return; } long long i,l,r,mid,max1,y; char s[15]; void query(long long x){ printf("? %lld\n",x); fflush(stdout); scanf("%s",s); } int main(){ //freopen("camp.in","r",stdin); //freopen("camp.out","w",stdout); for(i=1;;i=i*10){ query(i); if(s[0]=='N'){ i/=10; l=i; r=i*10-1; mid=(l+r)/2; break; } } while(l<=r){ query(mid*10); if(s[0]=='Y'){ min1=min(min1,mid); r=mid-1; } else l=mid+1; mid=(l+r)/2; } cout<<"! "<<max1<<endl; return 0; }
a.cc: In function 'int main()': a.cc:58:25: error: 'min1' was not declared in this scope 58 | min1=min(min1,mid); | ^~~~
s731193321
p03663
C++
#include <bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(false); cin.tie(0); #define FOR(i,s,n) for(int i = s; i < (n); i++) #define REP(i,n) FOR(i,0,n) #define ALL(n) (n).begin(), (n).end() #define RALL(n) (n).rbegin(), (n).rend() #define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n'; #define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n'; #define OUT(n) cout << (n) << '\n'; using ll = long long; using ull = unsigned long long; using pii = pair<int,int>; using pll = pair<ll,ll>; int main(void) { const int I = 64; const int D = 10; const char Y = 'Y'; const char N = 'N'; auto qout = [](ll x){cout << "? " << to_string(x) << endl; cout.flush();return;}; auto aout = [](ll x){cout << "! " << to_string(x) << endl; cout.flush();return;}; auto qin = []{char c; cin >> c; return c == Y;}; int n = 9; int i = 0; vector<bool> visit(D); vector<bool> yn(D); ll ans = 1e9; while(true) { qout(ans+1); i++; if (qin()) { qout(ans); i++; if (qin()) { aout(ans): return 0; } break; } else { ans /= 10; n--; if (n == 0) break; } } bool nl = false; int x = 1; int d = 8; ans = 0; while(i < I) { if(nl) { visit = vector<bool>(D); yn = vector<bool>(D); x = 0; d = 9; nl = false; } visit[x] = true; if (n == 0) { qout(ans*100 + x*10); } else { qout(ans*10 + x); } bool b = qin(); yn[x] = b; if (b) { if (n == 0) { aout(ans*10+x); return 0; } else if (x == 9) { ans = ans * 10 + x; n--; nl = true; } else if (visit[x+1] && !yn[x+1]) { ans = ans * 10 + x; n--; nl = true; } else { x += d; } } else { if (n == 0) { x++; } else if (visit[x-1] && yn[x-1]) { ans = ans * 10 + x-1; n--; nl = true; } else { x -= d; } } d /= 2; if (d == 0) d = 1; i++; } return 0; }
a.cc: In function 'int main()': a.cc:40:26: error: expected ';' before ':' token 40 | aout(ans): | ^ | ;
s360375120
p03663
C++
? 1000
a.cc:1:1: error: expected unqualified-id before '?' token 1 | ? 1000 | ^
s598343993
p03663
C++
? 1000
a.cc:1:1: error: expected unqualified-id before '?' token 1 | ? 1000 | ^
s938521292
p03663
C++
? 1000
a.cc:1:1: error: expected unqualified-id before '?' token 1 | ? 1000 | ^
s416452538
p03663
C++
//todo 文字数を少なくする //mintより高速に計算したい時用に modmul() modadd (正の値限定) を作る //#pragma GCC optimize ("-O3") #include <bits/stdc++.h> using namespace std; //@起動時 struct initon { initon() { cin.tie(0); ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(16); srand((unsigned) clock() + (unsigned) time(NULL)); }; } __initon; //衝突対策 #define ws ___ws //@必須構造 struct T { int f, s, t; T() { f = -1, s = -1, t = -1; } T(int f, int s, int t) : f(f), s(s), t(t) {} bool operator<(const T &r) const { return f != r.f ? f < r.f : s != r.s ? s < r.s : t < r.t; //return f != r.f ? f > r.f : s != r.s ? s > r.s : t > r.t; 大きい順 } bool operator>(const T &r) const { return f != r.f ? f > r.f : s != r.s ? s > r.s : t > r.t; //return f != r.f ? f > r.f : s != r.s ? s > r.s : t > r.t; 小さい順 } bool operator==(const T &r) const { return f == r.f && s == r.s && t == r.t; } bool operator!=(const T &r) const { return f != r.f || s != r.s || t != r.t; } int operator[](int i) { assert(i < 3); return i == 0 ? f : i == 1 ? s : t; } }; struct F { int a, b, c, d; F() { a = -1, b = -1, c = -1, d = -1; } F(int a, int b, int c, int d) : a(a), b(b), c(c), d(d) {} bool operator<(const F &r) const { return a != r.a ? a < r.a : b != r.b ? b < r.b : c != r.c ? c < r.c : d < r.d; // return a != r.a ? a > r.a : b != r.b ? b > r.b : c != r.c ? c > r.c : d > r.d; } bool operator>(const F &r) const { return a != r.a ? a > r.a : b != r.b ? b > r.b : c != r.c ? c > r.c : d > r.d; // return a != r.a ? a < r.a : b != r.b ? b < r.b : c != r.c ? c < r.c : d < r.d; } bool operator==(const F &r) const { return a == r.a && b == r.b && c == r.c && d == r.d; } bool operator!=(const F &r) const { return a != r.a || b != r.b || c != r.c || d != r.d; } int operator[](int i) { assert(i < 4); return i == 0 ? a : i == 1 ? b : i == 2 ? c : d; } }; T mt(int a, int b, int c) { return T(a, b, c); } //@マクロ省略系 型,構造 #define int long long #define ll long long #define double long double #define ull unsigned long long using dou = double; using itn = int; using str = string; using bo= bool; #define au auto using P = pair<ll, ll>; using pd =pair<dou, dou>; #define fi first #define se second #define vec vector #define beg begin #define rbeg rbegin #define con continue #define bre break #define brk break #define is == #define maxq 1 #define minq -1 #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) #define MALLOC(type, len) (type*)malloc((len) * sizeof(type)) //マクロ省略系 コンテナ using vi = vector<int>; #define _overloadvvi(_1, _2, _3, _4, name, ...) name #define vvi0() vec<vi> #define vvi1(a) vec<vi> a #define vvi2(a, b) vec<vi> a(b) #define vvi3(a, b, c) vec<vi> a(b,vi(c)) #define vvi4(a, b, c, d) vec<vi> a(b,vi(c,d)) #define vvi(...) _overloadvvi(__VA_ARGS__,vvi4,vvi3,vvi2 ,vvi1,vvi0)(__VA_ARGS__) using vl = vector<ll>; #define _overloadvvl(_1, _2, _3, _4, name, ...) name #define vvl1(a) vec<vl> a #define vvl2(a, b) vec<vl> a(b) #define vvl3(a, b, c) vec<vl> a(b,vl(c)) #define vvl4(a, b, c, d) vec<vl> a(b,vl(c,d)) #define vvl(...) _overloadvvl(__VA_ARGS__,vvl4,vvl3,vvl2 ,vvl1)(__VA_ARGS__) using vb = vector<bool>; #define _overloadvvb(_1, _2, _3, _4, name, ...) name #define vvb1(a) vec<vb> a #define vvb2(a, b) vec<vb> a(b) #define vvb3(a, b, c) vec<vb> a(b,vb(c)) #define vvb4(a, b, c, d) vec<vb> a(b,vb(c,d)) #define vvb(...) _overloadvvb(__VA_ARGS__,vvb4,vvb3,vvb2 ,vvb1)(__VA_ARGS__) using vs = vector<string>; #define _overloadvvs(_1, _2, _3, _4, name, ...) name #define vvs1(a) vec<vs> a #define vvs2(a, b) vec<vs> a(b) #define vvs3(a, b, c) vec<vs> a(b,vs(c)) #define vvs4(a, b, c, d) vec<vs> a(b,vs(c,d)) #define vvs(...) _overloadvvs(__VA_ARGS__,vvs4,vvs3,vvs2 ,vvs1)(__VA_ARGS__) using vd = vector<double>; #define _overloadvvd(_1, _2, _3, _4, name, ...) name #define vvd1(a) vec<vd> a #define vvd2(a, b) vec<vd> a(b) #define vvd3(a, b, c) vec<vd> a(b,vd(c)) #define vvd4(a, b, c, d) vec<vd> a(b,vd(c,d)) #define vvd(...) _overloadvvd(__VA_ARGS__,vvd4,vvd3,vvd2 ,vvd1)(__VA_ARGS__) using vc=vector<char>; #define _overloadvvc(_1, _2, _3, _4, name, ...) name #define vvc1(a) vec<vc> a #define vvc2(a, b) vec<vc> a(b) #define vvc3(a, b, c) vec<vc> a(b,vc(c)) #define vvc4(a, b, c, d) vec<vc> a(b,vc(c,d)) #define vvc(...) _overloadvvc(__VA_ARGS__,vvc4,vvc3,vvc2 ,vvc1)(__VA_ARGS__) using vp = vector<P>; #define _overloadvvp(_1, _2, _3, _4, name, ...) name #define vvp1(a) vec<vp> a #define vvp2(a, b) vec<vp> a(b) #define vvp3(a, b, c) vec<vp> a(b,vp(c)) #define vvp4(a, b, c, d) vec<vp> a(b,vp(c,d)) #define vvp(...) _overloadvvp(__VA_ARGS__,vvp4,vvp3,vvp2 ,vvp1)(__VA_ARGS__) using vt = vector<T>; #define _overloadvvt(_1, _2, _3, _4, name, ...) name #define vvt1(a) vec<vt> a #define vvt2(a, b) vec<vt> a(b) #define vvt3(a, b, c) vec<vt> a(b,vt(c)) #define vvt4(a, b, c, d) vec<vt> a(b,vt(c,d)) #define vvt(...) _overloadvvt(__VA_ARGS__,vvt4,vvt3,vvt2 ,vvt1)(__VA_ARGS__) #define v3i(a, b, c, d) vector<vector<vi>> a(b, vector<vi>(c, vi(d))) #define v3d(a, b, c, d) vector<vector<vd>> a(b, vector<vd>(c, vd(d))) #define v3m(a, b, c, d) vector<vector<vm>> a(b, vector<vm>(c, vm(d))) #define _vvi vector<vi> #define _vvl vector<vl> #define _vvb vector<vb> #define _vvs vector<vs> #define _vvd vector<vd> #define _vvc vector<vc> #define _vvp vector<vp> template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); } template<typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); } #define vni(name, ...) auto name = make_v<int>(__VA_ARGS__) #define vnb(name, ...) auto name = make_v<bool>(__VA_ARGS__) #define vns(name, ...) auto name = make_v<string>(__VA_ARGS__) #define vnd(name, ...) auto name = make_v<double>(__VA_ARGS__) #define vnc(name, ...) auto name = make_v<char>(__VA_ARGS__) #define vnp(name, ...) auto name = make_v<P>(__VA_ARGS__) #define PQ priority_queue<ll, vector<ll>, greater<ll> > #define tos to_string using mapi = map<int, int>; using mapp = map<P, int>; using mapd = map<dou, int>; using mapc = map<char, int>; using maps = map<str, int>; using seti = set<int>; using setd = set<dou>; using setc = set<char>; using sets = set<str>; using qui = queue<int>; #define bset bitset #define uset unordered_set #define mset multiset #define umap unordered_map #define umapi unordered_map<int,int> #define umapp unordered_map<P,int> #define mmap multimap //マクロ 繰り返し #define _overloadrep(_1, _2, _3, _4, name, ...) name # define _rep(i, n) for(int i = 0,_lim=n; i < _lim ; i++) #define repi(i, m, n) for(int i = m,_lim=n; i < _lim ; i++) #define repadd(i, m, n, ad) for(int i = m,_lim=n; i < _lim ; i+= ad) #define rep(...) _overloadrep(__VA_ARGS__,repadd,repi,_rep,)(__VA_ARGS__) #define _rer(i, n) for(int i = n; i >= 0 ; i--) #define reri(i, m, n) for(int i = m,_lim=n; i >= _lim ; i--) #define rerdec(i, m, n, dec) for(int i = m,_lim=n; i >= _lim ; i-=dec) #define rer(...) _overloadrep(__VA_ARGS__,rerdec,reri,_rer,)(__VA_ARGS__) #define reps2(i, j, n) for(int i = 0,_lim=n; i < _lim ; i++)for(int j = 0; j < _lim ; j++) #define reps3(i, j, k, n) for(int i = 0,_lim=n; i < _lim ; i++)for(int j = 0; j < _lim ; j++)for(int k = 0; k < _lim ; k++) #define reps4(i, j, k, l, n) for(int i = 0,_lim=n; i < _lim ; i++)for(int j = 0; j < _lim ; j++)for(int k = 0; k < _lim ; k++)for(int l = 0; l < _lim ; l++) #define _overloadreps(_1, _2, _3, _4, _5, name, ...) name #define reps(...) _overloadreps(__VA_ARGS__,reps4,reps3,reps2,_rep,)(__VA_ARGS__) #define fora(a, b) for(auto&& a : b) #define forg(gi, ve) for (int gi = 0,_lim=ve.size(), f, t, c; gi < _lim && (f = ve[gi].f, t = ve[gi].t, c = ve[gi].c, true); gi++) #define fort(gi, ve) for (int gi = 0, f, t, c; gi < ve.size() && (f = ve[gi].f, t = ve[gi].t, c = ve[gi].c, true); gi++)if(t!=p) //#define fort(gi, ve) for (int gi = 0, f, t, c;gi<ve.size()&& (gi+= (ve[gi].t==p))< ve.size() && (f = ve[gi].f,t=ve[gi].t, c = ve[gi].c,true); gi++) //マクロ 定数 #define k3 1010 #define k4 10101 #define k5 101010 #define k6 1010101 #define k7 10101010 const int inf = (int) 1e9 + 100; const ll linf = (ll) 1e18 + 100; const char infc = '{'; const string infs = "{"; const double eps = 1e-9; const double PI = 3.1415926535897932384626433832795029L; ll ma = numeric_limits<ll>::min(); ll mi = numeric_limits<ll>::max(); const int y4[] = {-1, 1, 0, 0}; const int x4[] = {0, 0, -1, 1}; const int y8[] = {0, 1, 0, -1, -1, 1, 1, -1}; const int x8[] = {1, 0, -1, 0, 1, -1, 1, -1}; //マクロ省略形 関数等 #define arsz(a) (sizeof(a)/sizeof(a[0])) #define sz(a) ((int)(a).size()) //#define rs resize #define mp make_pair #define pb push_back #define pf push_front #define eb emplace_back #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() constexpr bool ev(int a) { return !(a & 1); } constexpr bool od(int a) { return (a & 1); } //@拡張系 こう出来るべきというもの //埋め込み 存在を意識せずに機能を増やされているもの namespace std { template<> class hash<std::pair<signed, signed>> { public: size_t operator()(const std::pair<signed, signed> &x) const { return hash<ll>()(((ll) x.first << 32) + x.second); } }; template<> class hash<std::pair<ll, ll>> { public: //大きいllが渡されると、<<32でオーバーフローするがとりあえず問題ないと判断 size_t operator()(const std::pair<ll, ll> &x) const { return hash<ll>()(((ll) x.first << 32) + x.second); } }; } istream &operator>>(istream &iss, P &a) { iss >> a.first >> a.second; return iss; } template<typename T> istream &operator>>(istream &iss, vector<T> &vec) { for (T &x: vec) iss >> x; return iss; } template<class T, class U> ostream &operator<<(ostream &os, pair<T, U> p) { os << p.fi << " " << p.se << endl; return os; } ostream &operator<<(ostream &os, T p) { os << p.f << " " << p.s << " " << p.t; return os; } ostream &operator<<(ostream &os, F p) { os << p.a << " " << p.b << " " << p.c << " " << p.d; return os; } template<typename T> ostream &operator<<(ostream &os, vector <T> &vec) { for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " "); return os; } template<typename T> ostream &operator<<(ostream &os, vector <vector<T>> &vec) { for (int i = 0; i < vec.size(); i++) { for (int j = 0; j < vec[0].size(); j++) { os << vec[i][j]; } os << endl; } return os; } template<typename V, typename H> void resize(vector<V> &vec, const H head) { vec.resize(head); } template<typename V, typename H, typename ... T> void resize(vector<V> &vec, const H &head, const T ... tail) { vec.resize(head); for (auto &v: vec) resize(v, tail...); } template<typename T, typename _Pr> bool all_of(const vector<T> &vec, _Pr pred) { return std::all_of(vec.begin(), vec.end(), pred); } template<typename T, typename _Pr> bool any_of(const vector<T> &vec, _Pr pred) { return std::any_of(vec.begin(), vec.end(), pred); } template<typename T, typename _Pr> bool none_of(const vector<T> &vec, _Pr pred) { return std::none_of(vec.begin(), vec.end(), pred); } template<typename T, typename _Pr> const typename vector<T>::const_iterator find_if(const vector<T> &vec, _Pr pred) { return std::find_if(vec.begin(), vec.end(), pred); } template<typename T> bool contains(const vector<T> &vec, const T &val) { return std::find(vec.begin(), vec.end(), val) != vec.end(); } template<typename T, typename _Pr> bool contains_if(const vector<T> &vec, _Pr pred) { return std::find_if(vec.begin(), vec.end(), pred) != vec.end(); } template<class T, class U> void replace(vector<T> &a, T key, U v) { replace(a.begin(), a.end(), key, v); } template<class T> void replace(str &a, T key, T v) { a.replace(all(a), key, v); } //keyと同じかどうか01で置き換える template<class T, class U> void replace(T &a, U k) { rep(i, sz(a)) a[i] = a[i] == k; } template<class T, class U> void replace(T &a) { replace(a, '#'); } template<class T> bool includes(vector<T> &a, vector<T> &b) { vi c = a; vi d = b; sort(all(c)); sort(all(d)); return includes(all(c), all(d)); } template<class T> bool is_permutation(vector<T> &a, vector<T> &b) { return is_permutation(all(a), all(b)); } template<class T> bool next_permutation(vector<T> &a) { return next_permutation(all(a)); } template<class T> T pop(set<T> &set) { T res = *set.begin(); set.erase(set.find(res)); return res; } template<class T> T pop(mset<T> &set) { T res = *set.begin(); set.erase(set.find(res)); return res; } template<class T> T popBack(set<T> &set) { T res = *set.rbegin(); set.erase(set.find(res)); return res; } template<class T> T popBack(mset<T> &set) { T res = *set.rbegin(); set.erase(set.find(res)); return res; } inline void sort(string &a) { sort(a.begin(), a.end()); } template<class T> inline void sort(vector<T> &a) { sort(a.begin(), a.end()); } template<class T> inline void sort(vector<T> &a, int len) { sort(a.begin(), a.begin() + len); } template<class T, class F> inline void sort(vector<T> &a, F f) { sort(a.begin(), a.end(), [&](T a, T b) { return f(a) < f(b); }); } enum ___pcomparator { fisi, fisd, fdsi, fdsd, sifi, sifd, sdfi, sdfd }; inline void sort(vector<P> &a, ___pcomparator type) { switch (type) { case fisi: sort(all(a), [&](P l, P r) { return l.fi != r.fi ? l.fi < r.fi : l.se < r.se; }); break; case fisd: sort(all(a), [&](P l, P r) { return l.fi != r.fi ? l.fi < r.fi : l.se > r.se; }); break; case fdsi: sort(all(a), [&](P l, P r) { return l.fi != r.fi ? l.fi > r.fi : l.se < r.se; }); break; case fdsd: sort(all(a), [&](P l, P r) { return l.fi != r.fi ? l.fi > r.fi : l.se > r.se; }); break; case sifi: sort(all(a), [&](P l, P r) { return l.se != r.se ? l.se < r.se : l.fi < r.fi; }); break; case sifd: sort(all(a), [&](P l, P r) { return l.se != r.se ? l.se < r.se : l.fi > r.fi; }); break; case sdfi: sort(all(a), [&](P l, P r) { return l.se != r.se ? l.se > r.se : l.fi < r.fi; }); break; case sdfd: sort(all(a), [&](P l, P r) { return l.se != r.se ? l.se > r.se : l.fi > r.fi; }); break; } }; inline void sort(vector<T> &a, ___pcomparator type) { switch (type) { case fisi: sort(all(a), [&](T l, T r) { return l.f != r.f ? l.f < r.f : l.s < r.s; }); break; case fisd: sort(all(a), [&](T l, T r) { return l.f != r.f ? l.f < r.f : l.s > r.s; }); break; case fdsi: sort(all(a), [&](T l, T r) { return l.f != r.f ? l.f > r.f : l.s < r.s; }); break; case fdsd: sort(all(a), [&](T l, T r) { return l.f != r.f ? l.f > r.f : l.s > r.s; }); break; case sifi: sort(all(a), [&](T l, T r) { return l.s != r.s ? l.s < r.s : l.f < r.f; }); break; case sifd: sort(all(a), [&](T l, T r) { return l.s != r.s ? l.s < r.s : l.f > r.f; }); break; case sdfi: sort(all(a), [&](T l, T r) { return l.s != r.s ? l.s > r.s : l.f < r.f; }); break; case sdfd: sort(all(a), [&](T l, T r) { return l.s != r.s ? l.s > r.s : l.f > r.f; }); break; } }; template<class T> inline void rsort(vector<T> &a) { sort(a.begin(), a.end(), greater<T>()); }; template<class T> inline void rsort(vector<T> &a, int len) { sort(a.begin(), a.begin() + len, greater<T>()); }; template<class U, class F> inline void rsort(vector<U> &a, F f) { sort(a.begin(), a.end(), [&](U l, U r) { return f(l) > f(r); }); }; template<class U> inline void sortp(vector<U> &a, vector<U> &b) { vp c; int n = sz(a); assert(n == sz(b)); rep(i, n)c.eb(a[i], b[i]); sort(c); rep(i, n) { a[i] = c[i].first; b[i] = c[i].second;; } }; //F = T<T> //例えばreturn p.fi + p.se; template<class U, class F> inline void sortp(vector<U> &a, vector<U> &b, F f) { vp c; int n = sz(a); assert(n == sz(b)); rep(i, n)c.eb(a[i], b[i]); sort(c, f); rep(i, n) { a[i] = c[i].first; b[i] = c[i].second; } }; template<class U, class F> inline void sortp(vector<U> &a, vector<U> &b, char type) { vp c; int n = sz(a); assert(n == sz(b)); rep(i, n)c.eb(a[i], b[i]); sort(c, type); rep(i, n) { a[i] = c[i].first; b[i] = c[i].second; } }; template<class U> inline void rsortp(vector<U> &a, vector<U> &b) { vp c; int n = sz(a); assert(n == sz(b)); rep(i, n)c.eb(a[i], b[i]); rsort(c); rep(i, n) { a[i] = c[i].first; b[i] = c[i].second; } }; template<class U, class F> inline void rsortp(vector<U> &a, vector<U> &b, F f) { vp c; int n = sz(a); assert(n == sz(b)); rep(i, n)c.eb(a[i], b[i]); rsort(c, f); rep(i, n) { a[i] = c[i].first; b[i] = c[i].second; } }; template<class U> inline void sortt(vector<U> &a, vector<U> &b, vector<U> &c) { vt r; int n = sz(a); assert(n == sz(b)); assert(n == sz(c)); rep(i, n)r.eb(a[i], b[i], c[i]); sort(r); rep(i, n) { a[i] = r[i].f; b[i] = r[i].s; c[i] = r[i].t; } }; template<class U, class F> inline void sortt(vector<U> &a, vector<U> &b, vector<U> &c, F f) { vt r; int n = sz(a); assert(n == sz(b)); assert(n == sz(c)); rep(i, n)r.eb(a[i], b[i], c[i]); sort(r, f); rep(i, n) { a[i] = r[i].f; b[i] = r[i].s; c[i] = r[i].t; } }; template<class U, class F> inline void rsortt(vector<U> &a, vector<U> &b, vector<U> &c, F f) { vt r; int n = sz(a); assert(n == sz(b)); assert(n == sz(c)); rep(i, n)r.eb(a[i], b[i], c[i]); rsort(r, f); rep(i, n) { a[i] = r[i].f; b[i] = r[i].s; c[i] = r[i].t; } }; //indexをつけてsortする (second) template<class T> auto sorti(vector<T> &a) { int n = sz(a); vp ret(n); rep(i, n)ret[i] = P(a[i], i); sort(ret); return ret; }; template<class T> auto rsorti(vector<T> &a) { int n = sz(a); vp ret(n); rep(i, n)ret[i] = P(a[i], i); rsort(ret); return ret; }; template<class T> inline void sort2(vector<vector<T>> &a) { for (int i = 0, n = a.size(); i < n; i++)sort(a[i]); } template<class T> inline void rsort2(vector<vector<T>> &a) { for (int i = 0, n = a.size(); i < n; i++)rsort(a[i]); } template<typename A, size_t N, typename T> inline void fill(A (&a)[N], const T &v) { rep(i, N)a[i] = v; } template<typename A, size_t N, size_t O, typename T> inline void fill(A (&a)[N][O], const T &v) { rep(i, N)rep(j, O)a[i][j] = v; } template<typename A, size_t N, size_t O, size_t P, typename T> inline void fill(A (&a)[N][O][P], const T &v) { rep(i, N)rep(j, O)rep(k, P)a[i][j][k] = v; } template<typename A, size_t N, size_t O, size_t P, size_t Q, typename T> inline void fill(A (&a)[N][O][P][Q], const T &v) { rep(i, N)rep(j, O)rep(k, P)rep(l, Q)a[i][j][k][l] = v; } template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, typename T> inline void fill(A (&a)[N][O][P][Q][R], const T &v) { rep(i, N)rep(j, O)rep(k, P)rep(l, Q)rep(m, R)a[i][j][k][l][m] = v; } template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, size_t S, typename T> inline void fill(A (&a)[N][O][P][Q][R][S], const T &v) { rep(i, N)rep(j, O)rep(k, P)rep(l, Q)rep(m, R)rep(n, S)a[i][j][k][l][m][n] = v; } template<typename A, size_t N> A sum(A (&a)[N]) { A res = 0; rep(i, N)res += a[i]; return res; } template<typename A, size_t N, size_t O> A sum(A (&a)[N][O]) { A res = 0; rep(i, N)rep(j, O)res += a[i][j]; return res; } template<typename A, size_t N, size_t O, size_t P> A sum(A (&a)[N][O][P]) { A res = 0; rep(i, N)rep(j, O)rep(k, P)res += a[i][j][k]; return res; } template<typename A, size_t N, size_t O, size_t P, size_t Q> A sum(A (&a)[N][O][P][Q]) { A res = 0; rep(i, N)rep(j, O)rep(k, P)rep(l, Q)res += a[i][j][k][l]; return res; } template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R> A sum(A (&a)[N][O][P][Q][R]) { A res = 0; rep(i, N)rep(j, O)rep(k, P)rep(l, Q)rep(m, R)res += a[i][j][k][l][m]; return res; } template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, size_t S> A sum(A (&a)[N][O][P][Q][R][S]) { A res = 0; rep(i, N)rep(j, O)rep(k, P)rep(l, Q)rep(m, R)rep(n, S)res += a[i][j][k][l][m][n]; return res; } template<typename V, typename T> void fill(V &xx, const T vall) { xx = vall; } template<typename V, typename T> void fill(vector<V> &vecc, const T vall) { for (auto &&vx: vecc) fill(vx, vall); } //@汎用便利関数 入力 inline int in() { int ret; // scanf("%lld", &ret); cin >> ret; return ret; } inline string sin() { string ret; cin >> ret; return ret; } template<class T> inline void in(T &head) { cin >> head; } template<class T, class... U> inline void in(T &head, U &... tail) { cin >> head; in(tail...); } #define _overloaddin(_1, _2, _3, _4, name, ...) name #define din1(a) int a;cin>>a #define din2(a, b) int a,b;cin>>a>> b #define din3(a, b, c) int a,b,c;cin>>a>>b>>c #define din4(a, b, c, d) int a,b,c,d;cin>>a>>b>>c>>d #define din(...) _overloaddin(__VA_ARGS__,din4,din3,din2 ,din1)(__VA_ARGS__) #define _overloaddind(_1, _2, _3, _4, name, ...) name #define din1d(a) din1(a);a-- #define din2d(a, b) din2(a,b);a--,b-- #define din3d(a, b, c) din3(a,b,c);a--,b--,c-- #define din4d(a, b, c, d) din4(a,b,c,d);a--,b--,c--,d-- #define dind(...) _overloaddind(__VA_ARGS__,din4d,din3d,din2d ,din1d)(__VA_ARGS__) #define _overloadout(_1, _2, _3, _4, name, ...) name #define out1(a) cout<<a<<endl #define out2(a, b) cout<<a<<" "<< b<<endl #define out3(a, b, c) cout<<a<<" "<<b<<" "<<c<<endl #define out4(a, b, c, d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl #define out(...) _overloadout(__VA_ARGS__,out4,out3,out2,out1)(__VA_ARGS__) template<class T> void outl(vector<T> &a) { fora(v, a)cout << v << endl; } #define na(a, n) a.resize(n); rep(_i,n) cin >> a[_i]; #define nao(a, n) a.resize(n+1); rep(_i,n) cin >> a[_i+1]; #define nad(a, n) a.resize(n); rep(_i,n){ cin >> a[_i]; a[_i]--;} #define na2(a, b, n) a.resize(n),b.resize(n);rep(_i, n)cin >> a[_i] >> b[_i]; #define nao2(a, b, n) a.resize(n+1),b.resize(n+1);rep(_i, n)cin >> a[_i+1] >> b[_i+1]; #define na2d(a, b, n) a.resize(n),b.resize(n);rep(_i, n){cin >> a[_i] >> b[_i];a[_i]--,b[_i]--;} #define na3(a, b, c, n) a.resize(n),b.resize(n),c.resize(n); rep(_i, n)cin >> a[_i] >> b[_i] >> c[_i]; #define na3d(a, b, c, n) a.resize(n),b.resize(n),c.resize(n); rep(_i, n){cin >> a[_i] >> b[_i] >> c[_i];a[_i]--,b[_i]--,c[_i]--;} #define nt(a, h, w) resize(a,h,w);rep(_hi,h)rep(_wi,w) cin >> a[_hi][_wi]; #define ntd(a, h, w) rs(a,h,w);rep(_hi,h)rep(_wi,w) cin >> a[_hi][_wi], a[_hi][_wi]--; #define ntp(a, h, w) fill(a,'#');rep(_hi,1,h+1)rep(_wi,1,w+1) cin >> a[_hi][_wi]; //デバッグ #define sp << " " << #define debugName(VariableName) # VariableName #define _deb1(x) debugName(x)<<" = "<<x #define _deb2(x, ...) _deb1(x) <<", "<< _deb1(__VA_ARGS__) #define _deb3(x, ...) _deb1(x) <<", "<< _deb2(__VA_ARGS__) #define _deb4(x, ...) _deb1(x) <<", "<< _deb3(__VA_ARGS__) #define _deb5(x, ...) _deb1(x) <<", "<< _deb4(__VA_ARGS__) #define _deb6(x, ...) _deb1(x) <<", "<< _deb5(__VA_ARGS__) #define _deb7(x, ...) _deb1(x) <<", "<< _deb6(__VA_ARGS__) #define _deb8(x, ...) _deb1(x) <<", "<< _deb7(__VA_ARGS__) #define _deb9(x, ...) _deb1(x) <<", "<< _deb8(__VA_ARGS__) #define _deb10(x, ...) _deb1(x) <<", "<< _deb9(__VA_ARGS__) #define _overloadebug(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, name, ...) name #ifdef _DEBUG #define deb(...) cerr<< _overloadebug(__VA_ARGS__,_deb10,_deb9,_deb8,_deb7,_deb6,_deb5,_deb4,_deb3,_deb2,_deb1)(__VA_ARGS__) <<endl #else #define deb(...) ; #endif #define debugline(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n' //よく使うクラス、構造体 class UnionFind { public: vi par, rank, sizes; int n, trees; UnionFind(int n) : n(n), trees(n) { par.resize(n), rank.resize(n), sizes.resize(n); rep(i, n)par[i] = i, sizes[i] = 1; } int root(int x) { if (par[x] == x)return x; else return par[x] = root(par[x]); } int find(int x) { return root(x); } void unite(int x, int y) { x = root(x); y = root(y); if (x == y)return; if (rank[x] < rank[y])swap(x, y); trees--; par[y] = x; sizes[x] += sizes[y]; if (rank[x] == rank[y])rank[x]++; } bool same(int x, int y) { return root(x) == root(y); } int size(int x) { return sizes[root(x)]; } //順不同 umapなので vec<vi> sets() { vec<vi> res(trees); umap<int, vi> map; rep(i, n) map[root(i)].push_back(i); int i = 0; for (auto &&p:map) { int r = p.fi; res[i].push_back(r); for (auto &&v:p.se) { if (r == v)continue; res[i].push_back(v); } i++; } return res; } }; using bint =__int128; using u32 = unsigned int; using u64 = unsigned long long; using u128 = __uint128_t; std::ostream &operator<<(std::ostream &dest, __int128_t value) { std::ostream::sentry s(dest); if (s) { __uint128_t tmp = value < 0 ? -value : value; char buffer[128]; char *d = std::end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = std::end(buffer) - d; if (dest.rdbuf()->sputn(d, len) != len) { dest.setstate(std::ios_base::badbit); } } return dest; } __int128 toi128(string &s) { __int128 ret = 0; for (int i = 0; i < s.length(); i++) if ('0' <= s[i] && s[i] <= '9') ret = 10 * ret + s[i] - '0'; return ret; } template<typename T> T minv(T a, T m); template<typename T> T minv(T a); template<typename T> class Modular { public: using Type = typename decay<decltype(T::value)>::type; constexpr Modular() : value() {} template<typename U> Modular(const U &x) { value = normalize(x); } template<typename U> static Type normalize(const U &x) { Type v; if (-mod() <= x && x < mod()) v = static_cast<Type>(x); else v = static_cast<Type>(x % mod()); if (v < 0) v += mod(); return v; } const Type &operator()() const { return value; } template<typename U> explicit operator U() const { return static_cast<U>(value); } constexpr static Type mod() { return T::value; } Modular &operator+=(const Modular &other) { if ((value += other.value) >= mod()) value -= mod(); return *this; } Modular &operator-=(const Modular &other) { if ((value -= other.value) < 0) value += mod(); return *this; } template<typename U> Modular &operator+=(const U &other) { return *this += Modular(other); } template<typename U> Modular &operator-=(const U &other) { return *this -= Modular(other); } Modular &operator++() { return *this += 1; } Modular &operator--() { return *this -= 1; } Modular operator++(signed) { Modular result(*this); *this += 1; return result; } Modular operator--(signed) { Modular result(*this); *this -= 1; return result; } Modular operator-() const { return Modular(-value); } template<typename U = T> typename enable_if<is_same<typename Modular<U>::Type, signed>::value, Modular>::type &operator*=(const Modular &rhs) { #ifdef _WIN32 uint64_t x = static_cast<int64_t>(value) * static_cast<int64_t>(rhs.value); uint32_t xh = static_cast<uint32_t>(x >> 32), xl = static_cast<uint32_t>(x), d, m; asm( "divl %4; \n\t" : "=a" (d), "=d" (m) : "d" (xh), "a" (xl), "r" (mod()) ); value = m; #else value = normalize(static_cast<int64_t>(value) * static_cast<int64_t>(rhs.value)); #endif return *this; } template<typename U = T> typename enable_if<is_same<typename Modular<U>::Type, int64_t>::value, Modular>::type &operator*=(const Modular &rhs) { int64_t q = static_cast<int64_t>(static_cast<double>(value) * rhs.value / mod()); value = normalize(value * rhs.value - q * mod()); return *this; } template<typename U = T> typename enable_if<!is_integral<typename Modular<U>::Type>::value, Modular>::type &operator*=(const Modular &rhs) { value = normalize(value * rhs.value); return *this; } Modular &operator/=(const Modular &other) { return *this *= Modular(minv(other.value)); } template<typename U> friend bool operator==(const Modular<U> &lhs, const Modular<U> &rhs); template<typename U> friend bool operator<(const Modular<U> &lhs, const Modular<U> &rhs); template<typename U> friend std::istream &operator>>(std::istream &stream, Modular<U> &number); operator int() { return normalize(value); } private: Type value; }; template<typename T> bool operator==(const Modular<T> &lhs, const Modular<T> &rhs) { return lhs.value == rhs.value; } template<typename T, typename U> bool operator==(const Modular<T> &lhs, U rhs) { return lhs == Modular<T>(rhs); } template<typename T, typename U> bool operator==(U lhs, const Modular<T> &rhs) { return Modular<T>(lhs) == rhs; } template<typename T> bool operator!=(const Modular<T> &lhs, const Modular<T> &rhs) { return !(lhs == rhs); } template<typename T, typename U> bool operator!=(const Modular<T> &lhs, U rhs) { return !(lhs == rhs); } template<typename T, typename U> bool operator!=(U lhs, const Modular<T> &rhs) { return !(lhs == rhs); } template<typename T> bool operator<(const Modular<T> &lhs, const Modular<T> &rhs) { return lhs.value < rhs.value; } template<typename T> Modular<T> operator+(const Modular<T> &lhs, const Modular<T> &rhs) { return Modular<T>(lhs) += rhs; } template<typename T, typename U> Modular<T> operator+(const Modular<T> &lhs, U rhs) { return Modular<T>(lhs) += rhs; } template<typename T, typename U> Modular<T> operator+(U lhs, const Modular<T> &rhs) { return Modular<T>(lhs) += rhs; } template<typename T> Modular<T> operator-(const Modular<T> &lhs, const Modular<T> &rhs) { return Modular<T>(lhs) -= rhs; } template<typename T, typename U> Modular<T> operator-(const Modular<T> &lhs, U rhs) { return Modular<T>(lhs) -= rhs; } template<typename T, typename U> Modular<T> operator-(U lhs, const Modular<T> &rhs) { return Modular<T>(lhs) -= rhs; } template<typename T> Modular<T> operator*(const Modular<T> &lhs, const Modular<T> &rhs) { return Modular<T>(lhs) *= rhs; } template<typename T, typename U> Modular<T> operator*(const Modular<T> &lhs, U rhs) { return Modular<T>(lhs) *= rhs; } template<typename T, typename U> Modular<T> operator*(U lhs, const Modular<T> &rhs) { return Modular<T>(lhs) *= rhs; } template<typename T> Modular<T> operator/(const Modular<T> &lhs, const Modular<T> &rhs) { return Modular<T>(lhs) /= rhs; } template<typename T, typename U> Modular<T> operator/(const Modular<T> &lhs, U rhs) { return Modular<T>(lhs) /= rhs; } template<typename T, typename U> Modular<T> operator/(U lhs, const Modular<T> &rhs) { return Modular<T>(lhs) /= rhs; } constexpr signed MOD = 1e9 + 7;//MOD using mint = Modular<std::integral_constant<decay<decltype(MOD)>::type, MOD>>; constexpr int mint_len = 1400001; vi fac, finv, inv, p2; void setmod() { fac.resize(mint_len); finv.resize(mint_len); inv.resize(mint_len); p2.resize(mint_len); inv[1] = fac[0] = finv[0] = p2[0] = 1; for (int i = 2; i < mint_len; ++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD; for (int i = 1; i < mint_len; ++i) fac[i] = fac[i - 1] * i % MOD, finv[i] = finv[i - 1] * inv[i] % MOD, p2[i] = p2[i - 1] * 2 % MOD; } #define smod setmod inline mint com(int n, int r) { if (r < 0 || r > n) return 0; return mint(finv[r] * fac[n] % MOD * finv[n - r]); } inline mint pom(int n, int r) { // if (!sz(fac)) com(0, -1); if (r < 0 || r > n) return 0; return mint(fac[n] * finv[n - 1]); } inline mint npr(int n, int r) { // if (!sz(fac)) com(0, -1); if (r < 0 || r > n) return 0; return mint(fac[n] * finv[n - r]); } inline int nprin(int n, int r) { // if (!sz(fac)) com(0, -1); if (r < 0 || r > n) return 0; return fac[n] * finv[n - r] % MOD; } inline int icom(int n, int r) { const int NUM_ = 1400001; static ll fac[NUM_ + 1], finv[NUM_ + 1], inv[NUM_ + 1]; if (fac[0] == 0) { inv[1] = fac[0] = finv[0] = 1; for (int i = 2; i <= NUM_; ++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD; for (int i = 1; i <= NUM_; ++i) fac[i] = fac[i - 1] * i % MOD, finv[i] = finv[i - 1] * inv[i] % MOD; } if (r < 0 || r > n) return 0; return ((finv[r] * fac[n] % MOD) * finv[n - r]) % MOD; } #define ncr com #define ncri icom inline mint nhr(int n, int r) { return com(n + r - 1, r); } inline mint hom(int n, int r) { return com(n + r - 1, r); } inline int nhri(int n, int r) { return icom(n + r - 1, r); } template<typename T> inline T minv(T a, T m) { T u = 0, v = 1; while (a != 0) { T t = m / a; m -= t * a; swap(a, m); u -= t * v; swap(u, v); } assert(m == 1); return u; } template<typename T> inline T minv(T a) { if (a < mint_len)return inv[a]; T u = 0, v = 1; T m = MOD; while (a != 0) { T t = m / a; m -= t * a; swap(a, m); u -= t * v; swap(u, v); } assert(m == 1); return u; } template<typename T, typename U> inline Modular<T> mpow(const Modular<T> &a, const U &b) { assert(b >= 0); int x = a(), res = 1; U p = b; while (p > 0) { if (p & 1) (res *= x) %= MOD; (x *= x) %= MOD; p >>= 1; } return res; } template<typename T, typename U, typename V> inline mint mpow(const T a, const U b, const V m = MOD) { assert(b >= 0); int x = a, res = 1; U p = b; while (p > 0) { if (p & 1) (res *= x) %= m; (x *= x) %= m; p >>= 1; } return res; } template<typename T, typename U> inline mint mpow(const T a, const U b) { assert(b >= 0); int x = a, res = 1; U p = b; while (p > 0) { if (p & 1) (res *= x) %= MOD; (x *= x) %= MOD; p >>= 1; } return res; } template<typename T, typename U, typename V> inline int mpowi(const T &a, const U &b, const V &m = MOD) { assert(b >= 0); int x = a, res = 1; U p = b; while (p > 0) { if (p & 1) (res *= x) %= m; (x *= x) %= m; p >>= 1; } return res; } template<typename T> inline string to_string(const Modular<T> &number) { return to_string(number()); } template<typename T> std::ostream &operator<<(std::ostream &stream, const Modular<T> &number) { return stream << number(); } template<typename T> std::istream &operator>>(std::istream &stream, Modular<T> &number) { typename common_type<typename Modular<T>::Type, int64_t>::type x; stream >> x; number.value = Modular<T>::normalize(x); return stream; } using PM = pair<mint, mint>; using vm = vector<mint>; using mapm = map<int, mint>; using umapm = umap<int, mint>; #define _overloadvvm(_1, _2, _3, _4, name, ...) name #define vnm(name, ...) auto name = make_v<mint>(__VA_ARGS__) #define vvm1(a) vec<vm> a #define vvm2(a, b) vec<vm> a(b) #define vvm3(a, b, c) vec<vm> a(b,vm(c)) #define vvm4(a, b, c, d) vec<vm> a(b,vm(c,d)) #define vvm(...) _overloadvvm(__VA_ARGS__,vvm4,vvm3,vvm2 ,vvm1)(__VA_ARGS__) //エラー void ole() { #ifdef _DEBUG debugline("ole"); exit(0); #endif string a = "a"; rep(i, 30)a += a; rep(i, 1 << 17)cout << a << endl; cout << "OLE 出力長制限超過" << endl; exit(0); } void tle() { while (inf)cout << inf << endl; } //便利関数 //テスト用 char ranc() { return (char) ('a' + rand() % 26); } int rand(int min, int max) { assert(min <= max); if (min >= 0 && max >= 0) { return rand() % (max + 1 - min) + min; } else if (max < 0) { return -rand(-max, -min); } else { //+ if (rand() % 2) { return rand(0, max); //- } else { return -rand(0, -min); } } } vi ranv(int n, int min, int max) { vi v(n); rep(i, n)v[i] = rand(min, max); return v; } //単調増加 vi ranvi(int n, int min, int max) { vi v(n); bool bad = 1; while (bad) { bad = 0; v.resize(n); rep(i, n) { if (i && min > max - v[i - 1]) { bad = 1; break; } if (i)v[i] = v[i - 1] + rand(min, max - v[i - 1]); else v[i] = rand(min, max); } } return v; } void ranvlr(int n, int min, int max, vi &l, vi &r) { l.resize(n); r.resize(n); rep(i, n) { l[i] = rand(min, max); r[i] = l[i] + rand(0, max - l[i]); } } //便利 汎用 vp run_length(vi &a) { vp ret; ret.eb(a[0], 1); rep(i, 1, sz(a)) { if (ret.back().fi == a[i]) { ret.back().se++; } else { ret.eb(a[i], 1); } } return ret; } vector<pair<char, int>> run_length(string &a) { vector<pair<char, int>> ret; ret.eb(a[0], 1); rep(i, 1, sz(a)) { if (ret.back().fi == a[i]) { ret.back().se++; } else { ret.eb(a[i], 1); } } return ret; } template<class F> inline int mgr(int ok, int ng, F f) { #define _mgrbody int mid = (ok + ng) / 2; if (f(mid))ok = mid; else ng = mid; if (ok < ng)while (ng - ok > 1) { _mgrbody } else while (ok - ng > 1) { _mgrbody } return ok; } template<class F> inline int mgr(int ok, int ng, int second, F f) { #define _mgrbody2 int mid = (ok + ng) / 2; if (f(mid, second))ok = mid; else ng = mid; if (ok < ng) while (ng - ok > 1) { _mgrbody2 } else while (ok - ng > 1) { _mgrbody2 } return ok; } //strを整数として比較 string smax(str &a, str b) { if (sz(a) < sz(b)) { return b; } else if (sz(a) > sz(b)) { return a; } else { rep(i, sz(a)) { if (a[i] < b[i]) { return b; } else if (a[i] > b[i])return a; } } return a; } //strを整数として比較 string smin(str &a, str b) { if (sz(a) < sz(b)) { return a; } else if (sz(a) > sz(b)) { return b; } else { rep(i, sz(a)) { if (a[i] < b[i]) { return a; } else if (a[i] > b[i])return b; } } return a; } template<typename V, typename T> int find(vector<V> &a, const T key) { rep(i, sz(a))if (a[i] == key)return i; return -1; } template<typename V, typename T> P find(vector<vector<V>> &a, const T key) { rep(i, sz(a)) rep(j, sz(a[0]))if (a[i][j] == key)return mp(i, j); return mp(-1, -1); } template<typename V, typename U> T find(vector<vector<vector<V>>> &a, const U key) { rep(i, sz(a))rep(j, sz(a[0]))rep(k, sz(a[0][0]))if (a[i][j][k] == key)return mt(i, j, k); return mt(-1, -1, -1); } template<typename V, typename T> int count(V &a, const T k) { return a == k; } template<typename V, typename T> int count(vector<V> &a, const T k) { int ret = 0; fora(v, a)ret += count(v, k); return ret; } template<typename T> int count(char &a, const T k) { return a == k; } template<typename T> int count(str &a, const T k) { int ret = 0; rep(i, sz(a))ret += count(a[i], k); return ret; } template<typename V> int count_odd(V &a) { return a % 2; } template<typename V> int count_odd(vector<V> &a) { int ret = 0; fora(v, a)ret += count_odd(v); return ret; } template<typename V> int count_even(V &a) { return a % 2 == 0; } template<typename V> int count_even(vector<V> &a) { int ret = 0; fora(v, a)ret += count_even(v); return ret; } //algorythm void iota(vector<int> &ve, int s, int n) { ve.resize(n); iota(all(ve), s); } vi iota(int s, int n) { vi ve(n); iota(all(ve), s); return ve; } inline ll rev(ll a) { ll res = 0; while (a) { res *= 10; res += a % 10; a /= 10; } return res; } template<class T> inline void rev(vector<T> &a) { reverse(all(a)); } void inline rev(string &a) { reverse(all(a)); } int get(int a, int keta) { return (a / (int) pow(10, keta)) % 10; } int keta(int v) { int cou = 0; while (v) { cou++, v %= 10; } return cou; } int dsum(int v) { int ret = 0; for (; v; v /= 10)ret += v % 10; return ret; } inline int sumd(int v) { return dsum(v); } //変換系 template<class T, class U> inline vector<T> keys(vector<pair<T, U>> a) { vector<T> res; for (auto &&k :a)res.pb(k.fi); return res; } template<class T, class U> inline vector<U> keys(map<T, U> a) { vector<U> res; for (auto &&k :a)res.pb(k.fi); return res; } template<class T, class U> inline vector<U> keys(umap<T, U> a) { vector<U> res; for (auto &&k :a)res.pb(k.fi); return res; } template<class T, class U> vector<U> inline values(vector<pair<T, U>> a) { vector<U> res; for (auto &&k :a)res.pb(k.se); return res; } template<class T, class U> inline vector<T> values(map<T, U> a) { vector<T> res; for (auto &&k :a)res.pb(k.se); return res; } template<class T, class U> inline vector<T> values(umap<T, U> a) { vector<T> res; for (auto &&k :a)res.pb(k.se); return res; } template<class T, class U> inline bool chma(T &a, const U &b) { if (a < b) { a = b; return true; } return false; } template<class U> inline bool chma(const U &b) { return chma(ma, b); } template<class T, class U> inline bool chmi(T &a, const U &b) { if (b < a) { a = b; return true; } return false; } template<class U> inline bool chmi(const U &b) { return chmi(mi, b); } template<class T> inline T min(T a, signed b) { return a < b ? a : b; } template<class T> inline T max(T a, signed b) { return a < b ? b : a; } template<class T> inline T min(T a, T b, T c) { return a >= b ? b >= c ? c : b : a >= c ? c : a; } template<class T> inline T max(T a, T b, T c) { return a <= b ? b <= c ? c : b : a <= c ? c : a; } template<class T> inline T min(vector<T> a) { return *min_element(all(a)); } template<class T> inline T mini(vector<T> a) { return min_element(all(a)) - a.begin(); } template<class T> inline T min(vector<T> a, int n) { return *min_element(a.begin(), a.begin() + min(n, sz(a))); } template<class T> inline T min(vector<T> a, int s, int n) { return *min_element(a.begin() + s, a.begin() + min(n, sz(a))); } template<class T> inline T max(vector<T> a) { return *max_element(all(a)); } template<class T> inline T maxi(vector<T> a) { return max_element(all(a)) - a.begin(); } template<class T> inline T max(vector<T> a, int n) { return *max_element(a.begin(), a.begin() + min(n, sz(a))); } template<class T> inline T max(vector<T> a, int s, int n) { return *max_element(a.begin() + s, a.begin() + min(n, sz(a))); } template<typename A, size_t N> inline A max(A (&a)[N]) { A res = a[0]; rep(i, N)res = max(res, a[i]); return res; } template<typename A, size_t N, size_t O> inline A max(A (&a)[N][O]) { A res = max(a[0]); rep(i, N)res = max(res, max(a[i])); return res; } template<typename A, size_t N, size_t O, size_t P> inline A max(A (&a)[N][O][P]) { A res = max(a[0]); rep(i, N)res = max(res, max(a[i])); return res; } template<typename A, size_t N, size_t O, size_t P, size_t Q> inline A max(A (&a)[N][O][P][Q], const T &v) { A res = max(a[0]); rep(i, N)res = max(res, max(a[i])); return res; } template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R> inline A max(A (&a)[N][O][P][Q][R]) { A res = max(a[0]); rep(i, N)res = max(res, max(a[i])); return res; } template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, size_t S> inline A max(A (&a)[N][O][P][Q][R][S]) { A res = max(a[0]); rep(i, N)res = max(res, max(a[i])); return res; } template<typename A, size_t N> inline A min(A (&a)[N]) { A res = a[0]; rep(i, N)res = min(res, a[i]); return res; } template<typename A, size_t N, size_t O> inline A min(A (&a)[N][O]) { A res = min(a[0]); rep(i, N)res = min(res, max(a[i])); return res; } template<typename A, size_t N, size_t O, size_t P> inline A min(A (&a)[N][O][P]) { A res = min(a[0]); rep(i, N)res = min(res, min(a[i])); return res; } template<typename A, size_t N, size_t O, size_t P, size_t Q> inline A min(A (&a)[N][O][P][Q], const T &v) { A res = min(a[0]); rep(i, N)res = min(res, min(a[i])); return res; } template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R> inline A min(A (&a)[N][O][P][Q][R]) { A res = min(a[0]); rep(i, N)res = min(res, min(a[i])); return res; } template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, size_t S> inline A min(A (&a)[N][O][P][Q][R][S]) { A res = min(a[0]); rep(i, N)res = min(res, min(a[i])); return res; } template<class T> inline T sum(T &v) { return v; } template<class T> inline auto sum(vector<T> &v) { auto ret = sum(v[0]); rep(i, 1, sz(v))ret += sum(v[i]); return ret; } template<class T, class U, class... V> inline auto sum(vector<T> &v, U head, V... tail) { auto ret = sum(v[0], tail...); rep(i, 1, min(sz(v), head))ret += sum(v[i], tail...); return ret; } inline P sump(vp &v, int len = -1) { if (len == -1)len = v.size(); P res = {0, 0}; chmi(len, v.size()); rep(i, len) { res.fi += v[i].fi; res.se += v[i].se; } return res; } ///要素が0の時、返り値は0か1か template<class T> inline T mul(vector<T> &v, int len = -1) { if (len == -1)len = v.size(); T res = 1; chmi(len, v.size()); rep(i, len)res *= v[i]; return res; } inline void clear(PQ &q) { while (q.size())q.pop(); } template<class T> inline void clear(queue<T> &q) { while (q.size())q.pop(); } template<class T> inline T *negarr(int size) { T *body = (T *) malloc((size * 2 + 1) * sizeof(T)); return body + size; } template<class T> inline T *negarr2(int h, int w) { double **dummy1 = new double *[2 * h + 1]; double *dummy2 = new double[(2 * h + 1) * (2 * w + 1)]; dummy1[0] = dummy2 + w; for (int i = 1; i <= 2 * h + 1; i++) { dummy1[i] = dummy1[i - 1] + 2 * w + 1; } double **a = dummy1 + h; return a; } //imoは0-indexed //ruiは1-indexed template<class T> inline vector<T> imo(vector<T> &v) { vector<T> ret = v; rep(i, sz(ret) - 1)ret[i + 1] += ret[i]; return ret; } //漸化的に最小を持つ template<class T> inline vector<T> imi(vector<T> &v) { vector<T> ret = v; rep(i, sz(ret) - 1)chmi(ret[i + 1], ret[i]); return ret; } template<class T> struct ruiC { const vector<T> rui; ruiC(vector<T> &ru) : rui(ru) {} inline T operator()(int l, int r) { assert(l <= r); return rui[r] - rui[l]; } inline T operator[](int i) { return rui[i]; } }; template<class T> struct rruic { const T *rrui; rruic(T *ru) : rrui(ru) {} //n-1から-1へ inline T operator()(int l, int r) { assert(l >= r); return rrui[r] - rrui[l]; } inline T operator[](int i) { return rrui[i]; } }; template<class T> inline vector<T> ruiv(vector<T> &a) { vector<T> ret(a.size() + 1); rep(i, a.size())ret[i + 1] = ret[i] + a[i]; return ret; } template<class T> inline ruiC<T> ruic(vector<T> &a) { vector<T> ret = ruiv(a); return ruiC<T>(ret); } //kと同じものの数 template<class T, class U> inline vi ruiv(T &a, U k) { vi ret(a.size() + 1); rep(i, a.size())ret[i + 1] = ret[i] + (a[i] == k); return ret; } template<class T, class U> inline ruiC<int> ruic(T &a, U k) { vi ret = ruiv(a, k); return ruiC<int>(ret); } //xor template<class T> inline vector<T> ruix(vector<T> &a) { vector<T> ret(a.size() + 1); rep(i, a.size())ret[i + 1] = ret[i] ^ a[i]; return ret; } template<class T> inline vector<T> ruim(vector<T> &a) { vector<T> res(a.size() + 1, 1); rep(i, a.size())res[i + 1] = res[i] * a[i]; return res; } //漸化的に最小を1indexで持つ template<class T> inline vector<T> ruimi(vector<T> &a) { int n = sz(a); vector<T> ret(n + 1); rep(i, 1, n) { ret[i] = a[i - 1]; chmi(ret[i + 1], ret[i]); } return ret; } //template<class T> T *rrui(vector<T> &a) { //右から左にかけての半開区間 (-1 n-1] template<class T> rruic<T> rrui(vector<T> &a) { int len = a.size(); T *body = (T *) malloc((len + 1) * sizeof(T)); T *res = body + 1; rer(i, len - 1)res[i - 1] = res[i] + a[i]; return rruic<T>(res); } //掛け算 template<class T> T *rruim(vector<T> &a) { int len = a.size(); T *body = (T *) malloc((len + 1) * sizeof(T)); T *res = body + 1; res[len - 1] = 1; rer(i, len - 1)res[i - 1] = res[i] * a[i]; return res; } template<class T, class U> void inc(T &a, U v = 1) { a += v; } template<class T, class U> void inc(vector<T> &a, U v = 1) { for (auto &u :a)inc(u, v); } template<class T> void inc(vector<T> &a) { for (auto &u :a)inc(u, 1); } template<class T, class U> void plus(T &a, U v = 1) { a += v; } template<class T, class U> void plus(vector<T> &a, U v = 1) { for (auto &u :a)inc(u, v); } template<class T> void plus(vector<T> &a) { for (auto &u :a)inc(u, 1); } template<class T, class U> void dec(T &a, U v = 1) { a -= v; } template<class T, class U> void dec(vector<T> &a, U v = 1) { for (auto &u :a)dec(u, v); } template<class T> void dec(vector<T> &a) { for (auto &u :a)dec(u, 1); } template<class T, class U> void minu(T &a, U v = 1) { a -= v; } template<class T, class U> void minu(vector<T> &a, U v = 1) { for (auto &u :a)dec(u, v); } template<class T> void minu(vector<T> &a) { for (auto &u :a)dec(u, 1); } template<class U> void minu(string &a, U v = 1) { for (auto &u :a)dec(u, v); } void minu(string &a) { for (auto &u :a)dec(u, 1); } inline bool inside(int h, int w, int H, int W) { return h >= 0 && w >= 0 && h < H && w < W; } inline bool inside(int l, int v, int r) { return l <= v && v < r; } #define ins inside ll u(ll a) { return a < 0 ? 0 : a; } template<class T> vector<T> u(const vector<T> &a) { vector<T> ret = a; fora(v, ret)v = u(v); return ret; } #define MIN(a) numeric_limits<a>::min() #define MAX(a) numeric_limits<a>::max() ll goldd(ll left, ll right, function<ll(ll)> calc) { double GRATIO = 1.6180339887498948482045868343656; ll lm = left + (ll) ((right - left) / (GRATIO + 1.0)); ll rm = lm + (ll) ((right - lm) / (GRATIO + 1.0)); ll fl = calc(lm); ll fr = calc(rm); while (right - left > 10) { if (fl < fr) { right = rm; rm = lm; fr = fl; lm = left + (ll) ((right - left) / (GRATIO + 1.0)); fl = calc(lm); } else { left = lm; lm = rm; fl = fr; rm = lm + (ll) ((right - lm) / (GRATIO + 1.0)); fr = calc(rm); } } ll minScore = MAX(ll); ll resIndex = left; for (ll i = left; i < right + 1; i++) { ll score = calc(i); if (minScore > score) { minScore = score; resIndex = i; } } return resIndex; } ll goldt(ll left, ll right, function<ll(ll)> calc) { double GRATIO = 1.6180339887498948482045868343656; ll lm = left + (ll) ((right - left) / (GRATIO + 1.0)); ll rm = lm + (ll) ((right - lm) / (GRATIO + 1.0)); ll fl = calc(lm); ll fr = calc(rm); while (right - left > 10) { if (fl > fr) { right = rm; rm = lm; fr = fl; lm = left + (ll) ((right - left) / (GRATIO + 1.0)); fl = calc(lm); } else { left = lm; lm = rm; fl = fr; rm = lm + (ll) ((right - lm) / (GRATIO + 1.0)); fr = calc(rm); } } if (left > right) { ll l = left; left = right; right = l; } ll maxScore = MIN(ll); ll resIndex = left; for (ll i = left; i < right + 1; i++) { ll score = calc(i); if (maxScore < score) { maxScore = score; resIndex = i; } } return resIndex; } template<class T> T min(vector<vector<T>> &a) { T res = MAX(T); rep(i, a.size())chmi(res, *min_element(all(a[i]))); return res; } template<class T> T max(vector<vector<T>> &a) { T res = MIN(T); rep(i, a.size())chma(res, *max_element(all(a[i]))); return res; } constexpr bool bget(ll m, int keta) { assert(keta < 64); return (m >> keta) & 1; } int bget(ll m, int keta, int sinsuu) { m /= (ll) pow(sinsuu, keta); return m % sinsuu; } inline ll bit(int n) { return (1LL << (n)); } inline ll bit(int n, int sinsuu) { return (ll) pow(sinsuu, n); } //int bcou(ll m) { return __builtin_popcount(m & 0xFFFFFFFF) + __builtin_popcount(m >> 32); } #define bcou __builtin_popcountll //最下位ビット int lbit(int n) { return n & -n; } //最上位ビット int hbit(int n) { n |= (n >> 1); n |= (n >> 2); n |= (n >> 4); n |= (n >> 8); n |= (n >> 16); n |= (n >> 32); return n - (n >> 1); } //初期化は0を渡す ll nextComb(ll &mask, int n, int r) { if (!mask)return mask = (1LL << r) - 1; ll x = mask & -mask; //最下位の1 ll y = mask + x; //連続した下の1を繰り上がらせる ll res = ((mask & ~y) / x >> 1) | y; if (bget(res, n))return mask = 0; else return mask = res; } //n桁以下でビットがr個立っているもののvectorを返す vl bitCombList(int n, int r) { vl res; int m = 0; while (nextComb(m, n, r)) { res.pb(m); } return res; } //大文字小文字を区別する int altoiaZ(char c) { if ('A' <= c && c <= 'Z')return c - 'A'; return c - 'a' + 26; } char itoalaZ(int i) { if (i < 26)return 'A' + i; return 'a' + i - 26; } //aもAも0を返す 基本小文字 int altoi(char c) { if ('A' <= c && c <= 'Z')return c - 'A'; return c - 'a'; } char itoal(int i) { return 'a' + i; } int ctoi(char c) { return c - '0'; } char itoc(int i) { return i + '0'; } int vtoi(vi &v) { int res = 0; if (sz(v) > 18) { debugline("vtoi"); deb(sz(v)); ole(); } rep(i, sz(v)) { res *= 10; res += v[i]; } return res; } vi itov(int i) { vi res; while (i) { res.pb(i % 10); i /= 10; } rev(res); return res; } vi stov(string &a) { int n = sz(a); vi ret(n); rep(i, n) { ret[i] = a[i] - '0'; } return ret; } vector<vector<int>> ctoi(vector<vector<char>> s, char c) { int n = sz(s), m = sz(s[0]); vector<vector<int>> res(n, vector<int>(m)); rep(i, n)rep(j, m)res[i][j] = s[i][j] == c; return res; } #define unique(v) v.erase( unique(v.begin(), v.end()), v.end() ); void compress(vi &a) { vi b; int len = a.size(); for (int i = 0; i < len; ++i) { b.push_back(a[i]); } sort(b); unique(b); for (int i = 0; i < len; ++i) { a[i] = lower_bound(all(b), a[i]) - b.begin(); } } void compress(int a[], int len) { vi b; for (int i = 0; i < len; ++i) { b.push_back(a[i]); } sort(b); unique(b); for (int i = 0; i < len; ++i) { a[i] = lower_bound(all(b), a[i]) - b.begin(); } } //要素が見つからなかったときに困る #define binarySearch(a, v) (binary_search(all(a),v)) #define lowerIndex(a, v) (lower_bound(all(a),v)-a.begin()) #define lowerBound(a, v) (*lower_bound(all(a),v)) #define upperIndex(a, v) (upper_bound(all(a),v)-a.begin()) #define upperBound(a, v) (*upper_bound(all(a),v)) #define ans(a) cout<<a<<endl;continue; #define poll(a) q.front();q.pop() #define dpoll(a) q.front();q.pop_front() #define pollLast(a) q.back();q.pop_back() #define pollBack(a) q.back();q.pop_back() template<class T> inline void fin(T s) { cout << s << endl, exit(0); } //便利 数学 math int mod(int a, int m) { return (a % m + m) % m; } int pow(int a) { return a * a; }; ll fact(int v) { return v <= 1 ? 1 : v * fact(v - 1); } ll comi(int n, int r) { assert(n < 100); static vvi(pas, 100, 100); if (pas[0][0])return pas[n][r]; pas[0][0] = 1; rep(i, 1, 100) { pas[i][0] = 1; rep(j, 1, i + 1)pas[i][j] = pas[i - 1][j - 1] + pas[i - 1][j]; } return pas[n][r]; } double comd(int n, int r) { assert(n < 2020); static vvd(comb, 2020, 2020); if (comb[0][0] == 0) { comb[0][0] = 1; rep(i, 2000) { comb[i + 1][0] = 1; rep(j, 1, i + 2) { comb[i + 1][j] = comb[i][j] + comb[i][j - 1]; } } } return comb[n][r]; } int gcd(int a, int b) { while (b) a %= b, swap(a, b); return abs(a); } int gcd(vi b) { ll res = b[0]; rep(i, 1, sz(b))res = gcd(b[i], res); return res; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } ll ceil(ll a, ll b) { if (b == 0) { debugline("ceil"); deb(a, b); ole(); return -1; } else if (a < 0) { return 0; } else { return (a + b - 1) / b; } } //v * v >= aとなる最小のvを返す ll sqrt(ll a) { if (a < 0) { debugline("sqrt"); deb(a); ole(); } ll res = (ll) std::sqrt(a); while (res * res < a)res++; return res; } double log(double e, double x) { return log(x) / log(e); } ll sig(ll t) { return (1 + t) * t / 2; } ll sig(ll s, ll t) { return (s + t) * (t - s + 1) / 2; } namespace pnumber_tools { #define Eratosthenes30_2 class Eratosthenes {public:virtual void initialize() {} virtual void generate(const int64_t x) = 0; virtual void generate(const int64_t from, const int64_t to) = 0; virtual int64_t count() = 0; virtual bool prime(int x) = 0; virtual int32_t version() = 0; inline uint64_t PopCnt(uint64_t); inline int BitToIndex(uint8_t); }; uint64_t Eratosthenes::PopCnt(uint64_t bits) { bits = (bits & 0x5555555555555555ULL) + ((bits >> 1) & 0x5555555555555555ULL); bits = (bits & 0x3333333333333333ULL) + ((bits >> 2) & 0x3333333333333333ULL); bits = (bits & 0x0f0f0f0f0f0f0f0fULL) + ((bits >> 4) & 0x0f0f0f0f0f0f0f0fULL); return (bits * 0x0101010101010101ULL) >> (64 - 8); } int Eratosthenes::BitToIndex(uint8_t b) { switch (b) { case 1 << 0: return 0; case 1 << 1: return 1; case 1 << 2: return 2; case 1 << 3: return 3; case 1 << 4: return 4; case 1 << 5: return 5; case 1 << 6: return 6; case 1 << 7: return 7; } return -1; } namespace { const uint64_t kSegmentSize = 1000000; const int32_t kMod30[] = {1, 7, 11, 13, 17, 19, 23, 29}; const int C1[] = {6, 4, 2, 4, 2, 4, 6, 2}; const int C0[][8] = { {0, 0, 0, 0, 0, 0, 0, 1}, {1, 1, 1, 0, 1, 1, 1, 1}, {2, 2, 0, 2, 0, 2, 2, 1}, {3, 1, 1, 2, 1, 1, 3, 1}, {3, 3, 1, 2, 1, 3, 3, 1}, {4, 2, 2, 2, 2, 2, 4, 1}, {5, 3, 1, 4, 1, 3, 5, 1}, {6, 4, 2, 4, 2, 4, 6, 1}, }; const uint8_t kMask[][8] = { {0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f}, {0xfd, 0xdf, 0xef, 0xfe, 0x7f, 0xf7, 0xfb, 0xbf}, {0xfb, 0xef, 0xfe, 0xbf, 0xfd, 0x7f, 0xf7, 0xdf}, {0xf7, 0xfe, 0xbf, 0xdf, 0xfb, 0xfd, 0x7f, 0xef}, {0xef, 0x7f, 0xfd, 0xfb, 0xdf, 0xbf, 0xfe, 0xf7}, {0xdf, 0xf7, 0x7f, 0xfd, 0xbf, 0xfe, 0xef, 0xfb}, {0xbf, 0xfb, 0xf7, 0x7f, 0xfe, 0xef, 0xdf, 0xfd}, {0x7f, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0xfe}, }; const int64_t kSievedPrimes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23}; const int64_t kInitialSize = 7 * 11 * 13 * 17 * 19 * 23;class Eratosthenes2 final : public Eratosthenes { public: void generate(const int64_t x) override; void generate(const int64_t, const int64_t) override { assert(false); } bool prime(int x) override; int64_t count() override; int32_t version() override { return 2; } std::vector<uint8_t> flags_; }; void Eratosthenes2::generate(const int64_t x) { flags_.clear(); if (x > 10000000000) return; int64_t size = x / 30 + (x % 30 != 0); flags_.resize(size, 0xff); if (int r = x % 30) { if (r <= 1) flags_[size - 1] = 0x0; else if (r <= 7) flags_[size - 1] = 0x1; else if (r <= 11) flags_[size - 1] = 0x3; else if (r <= 13) flags_[size - 1] = 0x7; else if (r <= 17) flags_[size - 1] = 0xf; else if (r <= 19) flags_[size - 1] = 0x1f; else if (r <= 23) flags_[size - 1] = 0x3f; else if (r <= 29) flags_[size - 1] = 0x7f; } flags_[0] = 0xfe; const uint64_t sqrt_x = std::ceil(std::sqrt(x) + 0.1); const uint64_t sqrt_xi = sqrt_x / 30 + 1; for (uint64_t i = 0; i < sqrt_xi; ++i) { for (uint8_t flags = flags_[i]; flags; flags &= flags - 1) { uint8_t lsb = flags & (-flags); int ibit = BitToIndex(lsb); const int32_t m = kMod30[ibit]; int32_t pm = 30 * i + 2 * m; for (uint64_t j = i * pm + (m * m) / 30, k = ibit; j < flags_.size(); j += i * C1[k] + C0[ibit][k], k = (k + 1) & 7) { flags_[j] &= kMask[ibit][k]; } } } }int64_t Eratosthenes2::count() { if (flags_.empty()) return -1; int64_t ret = 3; for (uint8_t f : flags_) { ret += PopCnt(f); } return ret; } inline bool Eratosthenes2::prime(int x) { static unordered_map<int, int> imap = {{1, 0}, {7, 1}, {11, 2}, {13, 3}, {17, 4}, {19, 5}, {23, 6}, {29, 7}}; if (x == 2 || x == 3 || x == 5)return true; else if (!(x & 1) || x % 3 == 0 || x % 5 == 0)return false; return (flags_[x / 30] >> imap[x % 30]) & 1; }} Eratosthenes30_2 Eratosthenes2 era; int prime_len = 3e6; vector<int> primes; void setprime(int size = 3e6) { prime_len = size; era.generate(size); primes = {2, 3, 5}; int nums[129] = {}; nums[1] = 1; nums[2] = 7; nums[4] = 11; nums[8] = 13; nums[16] = 17; nums[32] = 19; nums[64] = 23; nums[128] = 29; //p = 30i + j int j = 0; int sflim = era.flags_.size(); int i30 = 0; for (int i = 0; i < sflim; i++, i30 += 30) { uint8_t m = era.flags_[i]; while (m) { j = m & -m; primes.push_back(i30 + nums[j]); m ^= j; } } } using u32 = unsigned int;//longlongになっていると思うが放置していいと思う using u64 = unsigned long long; using u128 = __uint128_t; //O(k log(n)^3) //32bit -> 270回程度 //64bit -> 1260回程度 //64bit以下で精度100% template<class BinOp> bool miller_rabin(const uint64_t &n, const uint64_t *witness, BinOp modmul) { if (n == 2) return true; if (n < 2 || n % 2 == 0) return false; const int64_t m = n - 1, d = m / (m & -m); auto modpow = [&](int64_t a, int64_t b) { int64_t res = 1; for (; b; b /= 2) { if (b & 1) res = modmul(res, a); a = modmul(a, a); } return res; }; auto suspect = [&](uint64_t a, uint64_t t) { a = modpow(a, t); while (t != n - 1 && a != 1 && a != n - 1) { a = modmul(a, a); t = modmul(t, 2); } return a == n - 1 || t % 2 == 1; }; for (const uint64_t *w = witness; *w; w++) { if (*w % n != 0 && !suspect(*w, d)) return false; } return true; } //miller_rabin & エラトステネス bool prime(const int &n) { assert(n < 9223372036854775808ULL); if (!sz(primes))setprime(); //エラトステネスの篩 偶数省略ver //[i] = i*2+1 if (n < prime_len)return era.prime(n); if (n < 4294967296) { rep(i, 30) if (!(n % primes[i]))return false; constexpr uint64_t witness[] = {2, 7, 61, 0}; auto modmul = [&](uint64_t a, uint64_t b) -> uint64_t { return a * b % n; }; return miller_rabin(n, witness, modmul); } else { rep(i, 50) if (!(n % primes[i]))return false; constexpr uint64_t witness[] = {2, 325, 9375, 28178, 450775, 9780504, 1795265022, 0}; auto modmul = [&](uint64_t a, uint64_t b) -> uint64_t { return (uint64_t) ((__uint128_t) a * b % n); }; return miller_rabin(n, witness, modmul); } } vi divisors(int v) { vi res; double lim = std::sqrt(v); for (int i = 1; i <= lim; ++i) { if (v % i == 0) { res.pb(i); if (i != v / i)res.pb(v / i); } } return res; } vp factorization(int v) { assert(v); int tv = v; vp res; if (!sz(primes))setprime(); for (auto &&p :primes) { if (v % p == 0)res.eb(p, 0); while (v % p == 0) { v /= p; res.back().second++; } if (v == 1 || p * p > tv)break; } if (v > 1)res.eb(v, 1); return res; } //注意 gcdを取る間隔 i%10 が場合によってはtleを引き起こす //うまくいかなかったら%1で動かすように変更した vp rho(int v) { assert(v); if (v == 1)return vp(); vi ret; if (!sz(primes)) setprime(); int lim = 300; //64bit if (v < 4294967296)lim = 80; //32bit else if (v < 281474976710656LL)lim = 120; //48bit for (int i = 0; i < lim; i += 5) { //v<=1の判定回数を減らせる分高速化できる事を期待している while (v % primes[i] == 0) ret.pb(primes[i]), v /= primes[i]; while (v % primes[i + 1] == 0) ret.pb(primes[i + 1]), v /= primes[i + 1]; while (v % primes[i + 2] == 0) ret.pb(primes[i + 2]), v /= primes[i + 2]; while (v % primes[i + 3] == 0) ret.pb(primes[i + 3]), v /= primes[i + 3]; while (v % primes[i + 4] == 0) ret.pb(primes[i + 4]), v /= primes[i + 4]; if (v <= 1) { sort(ret);//試し割りだけで終わった時 return run_length(ret); } } int lower_prime_bound = primes[lim - 1] * primes[lim - 1]; //試し割りするか mt19937 mr; mr.seed(clock()); int c; auto fac = [&](int v, const int loop = 10) { // if (v == 4)return 2ll; //試し割りで消えた c = mr() % v; int x = mr() % v; int y = x; int d = 1; int lim = std::sqrt(v) + 2; //brentによる改良 差分を一操作で求められる for (int i = 1, mul = 1, next_2pow = 2; d == 1 && i <= lim; i++) { if (i == next_2pow) { y = x; next_2pow <<= 1; } x = ((u128) x * x + c) % v; mul = ((u128) mul * abs(x - y)) % v;//ユークリッドの互除法と同じ原理で因数は保たれる if (i % loop == 0) {//10とかなんとか iによっては死ぬ d = gcd(mul, v); mul = 1; } } if (d == v) return -1ll; return d; }; queue<int> q; q.push(v); while (!q.empty()) { int v = q.front(); q.pop(); if (prime(v)) { ret.pb(v); continue; } int d = -1; //基本loop回数10でやり、駄目なら1で for (int i = 0; d == -1 && i < 5; i++)d = fac(v, 10); if (d == -1)while (d == -1)d = fac(v, 1); int d2 = v / d; rep(_, 2) { if (d <= lower_prime_bound)ret.pb(d); else q.push(d); d = d2; } } sort(ret); return run_length(ret); } } using namespace pnumber_tools; //幾何 Pをcomplexとして扱う template<class T, class U> bool eq(T a, U b) { return fabs(a - b) < eps; } dou atan2(pd a) { return atan2(a.se, a.fi); } dou angle(pd f, pd t) { return atan2(t.se - f.se, t.fi - f.fi); } dou distance(pd a, pd b) { return hypot(a.fi - b.fi, a.se - b.se); } //bを中心とするabcのtheta aからcにかけて時計回り dou angle(pd a, pd b, pd c) { dou ax = a.fi - b.fi; dou ay = a.se - b.se; dou cx = c.fi - b.fi; dou cy = c.se - b.se; double ret = atan2(cy, cx) - atan2(ay, ax); if (ret < 0) ret += 2 * PI; return ret; } dou dot(pd a, pd b) { return a.fi * b.fi + a.se + b.se; } dou cro(pd a, pd b) { return a.fi * b.se - a.se + b.fi; } template<class T> struct edge { int f, t; T c; int id; int type; edge(int f, int t, T c = 1, int id = -1, int ty = -1) : f(f), t(t), c(c), id(id), type(ty) {} bool operator<(const edge &b) const { return c < b.c; } bool operator>(const edge &b) const { return c > b.c; } }; template<class T> ostream &operator<<(ostream &os, edge<T> &e) { os << e.f << " " << e.t << " " << e.c; return os; } template<typename T> class graph { protected: vector<bool> _used; public : vector<vector<edge<T>>> g; vector<edge<T>> edges; int n; graph(int n) : n(n) { g.resize(n), _used.resize(n); } void clear() { g.clear(), edges.clear(); } void resize(int n) { this->n = n; g.resize(n); _used.resize(n); } int size() { return g.size(); } vector<edge<T> > &operator[](int i) { return g[i]; } virtual void add(int f, int t, T c, int id, int ty) = 0; virtual bool used(edge<T> &e) = 0; virtual bool used(int id) = 0; virtual void del(edge<T> &e) = 0; virtual void del(int id) = 0; virtual void set_edges() = 0; }; template<typename T =ll> class digraph : public graph<T> { public: using graph<T>::g; using graph<T>::n; using graph<T>::edges; using graph<T>::_used; int eid = 0; digraph(int n) : graph<T>(n) {} void add(int f, int t, T c = 1, int id = -1, int ty = -1) { if (!(0 <= f && f < n && 0 <= t && t < n)) { debugline("digraph add"); deb(f, t, c, id, ty); ole(); } if (id == -1)id = eid++; g[f].emplace_back(f, t, c, id, ty); edges.emplace_back(f, t, c, id, ty); } bool used(edge<T> &e) { return _used[e.id]; } bool used(int id) { return _used[id]; } void del(edge<T> &e) { _used[e.id] = _used[e.id ^ 1] = 1; } void del(int id) { _used[id] = _used[id ^ 1] = 1; } void set_edges() { if (sz(edges))return; rep(i, n)fora(e, g[i])edges.pb(e); } }; template<class T=int> class undigraph : public graph<T> { public: using graph<T>::g; using graph<T>::n; using graph<T>::edges; using graph<T>::_used; int eid = 0; undigraph(int n) : graph<T>(n) { } void add(int f, int t, T c = 1, int id = -1, int ty = -1) { if (!(0 <= f && f < n && 0 <= t && t < n)) { debugline("undigraph add"); deb(f, t, c, id, ty); ole(); } if (id == -1)id = eid, eid += 2; g[f].emplace_back(f, t, c, id, ty); g[t].emplace_back(t, f, c, id + 1, ty); edges.emplace_back(f, t, c, id, ty); edges.emplace_back(t, f, c, id + 1, ty); } void add(edge<T> &e) { int f = e.f, t = e.t, ty = e.type; T c = e.c; add(f, t, c, ty); } bool used(edge<T> &e) { return _used[e.id]; } bool used(int id) { return _used[id]; } void del(edge<T> &e) { _used[e.id] = _used[e.id ^ 1] = 1; } void del(int id) { _used[id] = _used[id ^ 1] = 1; } void set_edges() { if (sz(edges))return; rep(i, n)fora(e, g[i])edges.pb(e); } }; template<typename T> struct radixheap { vector<pair<u64, T> > v[65]; u64 size, last; radixheap() : size(0), last(0) {} bool empty() const { return size == 0; } inline int getbit(int a) { return a ? 64 - __builtin_clzll(a) : 0; } void push(u64 key, const T &value) { ++size; v[getbit(key ^ last)].emplace_back(key, value); } pair<u64, T> pop() { if (v[0].empty()) { int idx = 1; while (v[idx].empty()) ++idx; last = min_element(begin(v[idx]), end(v[idx]))->first; for (auto &p : v[idx]) v[getbit(p.first ^ last)].emplace_back(p); v[idx].clear(); } --size; auto ret = v[0].back(); v[0].pop_back(); return ret; } }; vi dijkstra2(const graph<int> &g, int s, int cant_arrive = -1) { if (!(0 <= s && s < g.n)) { debugline("dijkstra"); deb(s, g.n); ole(); } int initValue = MAX(int); vi dis(g.n, initValue); radixheap<int> q; dis[s] = 0; q.push(0, s); while (!q.empty()) { int nowc, i; tie(nowc, i) = q.pop(); if (dis[i] != nowc)continue; for (auto &&e : g.g[i]) { int to = e.t; int c = nowc + e.c; if (dis[to] > c) { dis[to] = c; q.push(dis[to], to); } } } //基本、たどり着かないなら-1 if (cant_arrive == -1)for (auto &&d :dis) if (d == initValue)d = -1; return dis; } template<class T> vector<T> dijkstra(const graph<T> &g, int s, int cant_arrive = -1) { if (!(0 <= s && s < g.n)) { debugline("dijkstra"); deb(s, g.n); ole(); } T initValue = MAX(T); vector<T> dis(g.n, initValue); priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> q; dis[s] = 0; q.emplace(0, s); while (q.size()) { T nowc = q.top().fi; int i = q.top().se; q.pop(); if (dis[i] != nowc)continue; for (auto &&e : g.g[i]) { int to = e.t; T c = nowc + e.c; if (dis[to] > c) { dis[to] = c; q.emplace(dis[to], to); } } } //基本、たどり着かないなら-1 if (cant_arrive == -1)for (auto &&d :dis) if (d == initValue)d = -1; return dis; } template<class T> vector<vector<T>> warshall(const graph<T> &g, int cant_arrive = -1) { int n = g.n; vector<vector<T> > dis(n, vector<T>(n, linf)); rep(i, n)fora(e, g.g[i])chmi(dis[e.f][e.t], e.c); rep(i, n)dis[i][i] = 0; rep(k, n)rep(i, n)rep(j, n)chmi(dis[i][j], dis[i][k] + dis[k][j]); //基本、たどり着かないなら-1 if (cant_arrive == -1)rep(i, n)rep(j, n) if (dis[i][j] == linf)dis[i][j] = -1; return dis; } template<class T=int> class tree : public undigraph<T> { public: using undigraph<T>::g; using undigraph<T>::n; using undigraph<T>::edges; using undigraph<T>::_used; vi disv; private: bool never = 1; int root = -1; vi dep;//到着した順の深さ vi vis;//到着した順 vi first;//初めてiに到着した時 vector<int> bestt;//タイミングを持つ int sn = 0;//seg木の底辺の長さ euler tourの長さ void built() { never = 0; n = g.size(); //euler tour disv.resize(n); first.resize(n); dep.resize(n * 2); vis.resize(n * 2); function<void(int, int, int, int &)> dfs = [&](int i, int p, int d, int &k) { first[i] = k; vis[k] = i; dep[k++] = d; forg(gi, g[i]) { if (t == p)continue; disv[t] = disv[i] + c; dfs(t, i, d + 1, k); vis[k] = i; dep[k++] = d; } }; int k = 0; dfs(root, -1, 0, k); //rmq sn = 1; while (sn < n * 2)sn <<= 1; bestt.resize((sn << 1) - 1); rep(i, k)bestt[i + sn - 1] = i;//時間を持つ rer(i, sn - 2) { int lt = (i << 1) + 1, rt = (i << 1) + 2; if (dep[bestt[lt]] < dep[bestt[rt]]) { bestt[i] = bestt[lt]; } else { bestt[i] = bestt[rt]; } } } //最小の深さを持つタイミングが知りたい inline int lca_rmq(int l, int r) { int midv = inf; int midi = -1; l += sn - 1; r += sn - 1; while (l < r) { //右なら、次に右上へ移動してしまうので if (!(l & 1)) { if (chmi(midv, dep[bestt[l]])) { midi = bestt[l]; } } //右なら、左を取らないと機会を逃す if (!(r & 1)) { if (chmi(midv, dep[bestt[r - 1]])) { midi = bestt[r - 1]; } } l >>= 1; r = (r - 1) >> 1; } return vis[midi]; } public: tree(int n, int root = 0) : undigraph<T>(n), root(root) {} bool leaf(int v) { return sz(g[v]) == 1 && v != root; } int lca(int u, int v) { if (never)built(); if (first[u] > first[v])swap(u, v); return lca_rmq(first[u], first[v] + 1); } int dis(int u, int v) { if (never) built(); if (first[u] > first[v])swap(u, v); int p = lca_rmq(first[u], first[v] + 1); return disv[u] + disv[v] - disv[p] * 2; } }; //辺によりメモリを大量消費 // よってedgesを消している //頂点10^6でメモリを190MB(制限の8割)使う //軽量化のため、辺を持たないbig gridクラスがあってもいいかもしれない // template<class T=int> class grid_k6 : public undigraph<T> { public: using undigraph<T>::g; using undigraph<T>::n; using undigraph<T>::edges; using undigraph<T>::_used; int H, W; int eid = 0; void add(int f, int t, T c = 1, int id = -1, int ty = -1) { if (!(0 <= f && f < n && 0 <= t && t < n)) { debugline("grid_k6 add"); deb(f, t, c, id, ty); ole(); } g[f].emplace_back(f, t, c, eid++, ty); g[t].emplace_back(t, f, c, eid++, ty); } int getid(int h, int w) { if (!inside(h, w, H, W))return -1; return W * h + w; } P get2(int id) { return mp(id / W, id % W); } P operator()(int id) { return get2(id); } int operator()(int h, int w) { return getid(h, w); } grid_k6(int H, int W) : H(H), W(W), undigraph<T>(H * W) { rep(h, H) { rep(w, W) { int f = getid(h, w); if (w + 1 < W) add(f, getid(h, w + 1)); if (h + 1 < H)add(f, getid(h + 1, w)); } } } grid_k6(_vvc ba, char wall = '#') : H(sz(ba)), W(sz(ba[0])), undigraph<T>(sz(ba) * sz(ba[0])) { rep(h, H) { rep(w, W) { if (ba[h][w] == wall)con; int f = getid(h, w); if (w + 1 < W && ba[h][w + 1] != wall) { add(f, getid(h, w + 1)); } if (h + 1 < H && ba[h + 1][w] != wall) { add(f, getid(h + 1, w)); } } } } void add(int fh, int fw, int th, int tw) { add(getid(fh, fw), getid(th, tw)); } void set_edges() { rep(i, n)fora(e, g[i])edges.pb(e); } }; //左上から右下に移動できる template<class T=int> class digrid_k6 : public digraph<T> { public: using digraph<T>::g; using digraph<T>::n; using digraph<T>::edges; using digraph<T>::_used; int H, W; int eid = 0; void add(int f, int t, T c = 1, int id = -1, int ty = -1) { if (!(0 <= f && f < n && 0 <= t && t < n)) { debugline("digrid_k6 add"); deb(f, t, c, id, ty); ole(); } g[f].emplace_back(f, t, c, eid++, ty); } int getid(int h, int w) { if (!inside(h, w, H, W))return -1; return W * h + w; } P get2(int id) { return mp(id / W, id % W); } P operator()(int id) { return get2(id); } int operator()(int h, int w) { return getid(h, w); } digrid_k6(int H, int W) : H(H), W(W), digraph<T>(H * W) { rep(h, H) { rep(w, W) { int f = getid(h, w); if (w + 1 < W) add(f, getid(h, w + 1)); if (h + 1 < H)add(f, getid(h + 1, w)); } } } digrid_k6(_vvc ba, char wall = '#') : H(sz(ba)), W(sz(ba[0])), digraph<T>(sz(ba) * sz(ba[0])) { rep(h, H) { rep(w, W) { if (ba[h][w] == wall)con; int f = getid(h, w); if (w + 1 < W && ba[h][w + 1] != wall) { add(f, getid(h, w + 1)); } if (h + 1 < H && ba[h + 1][w] != wall) { add(f, getid(h + 1, w)); } } } } void add(int fh, int fw, int th, int tw) { add(getid(fh, fw), getid(th, tw)); } void set_edges() { rep(i, n)fora(e, g[i])edges.pb(e); } }; template<class T> bool nibu(const graph<T> &g) { int size = 0; rep(i, g.n)size += sz(g.g[i]); if (size == 0)return true; UnionFind uf(g.n * 2); rep(i, g.n)fora(e, g.g[i])uf.unite(e.f, e.t + g.n), uf.unite(e.f + g.n, e.t); rep(i, g.n)if (uf.same(i, i + g.n))return 0; return 1; } //二部グラフを色分けした際の頂点数を返す template<class T> vp nibug(graph<T> &g) { vp cg; if (!nibu(g)) { debugline("nibu"); ole(); } int _n = g.size(); vb _was(_n); queue<P> q; rep(i, _n) { if (_was[i])continue; q.push(mp(i, 1)); _was[i] = 1; int red = 0; int coun = 0; while (q.size()) { int now = q.front().fi; int col = q.front().se; red += col; coun++; q.pop(); forg(gi, g[now]) { if (_was[t])continue; q.push(mp(t, col ^ 1)); _was[t] = 1; } } cg.push_back(mp(red, coun - red)); } return cg; } template<class T> ostream &operator<<(ostream &os, graph<T> &g) { rep(i, sz(g)) { forg(gi, g[i]) { os << f << " " << t << " " << c << endl; } } return os; } //機能拡張 vp vtop(vi &a, vi &b) { vp res(sz(a)); rep(i, sz(a))res[i] = mp(a[i], b[i]); return res; } void ptov(vp &p, vi &a, vi &b) { a.resize(sz(p)); b.resize(sz(p)); rep(i, sz(p))a[i] = p[i].fi, b[i] = p[i].se; } template<typename _CharT, typename _Traits, typename _Alloc> basic_string<_CharT, _Traits, _Alloc> operator+(const basic_string<_CharT, _Traits, _Alloc> &__lhs, const int __rv) { basic_string<_CharT, _Traits, _Alloc> __str(__lhs); __str.append(to_string(__rv)); return __str; } template<typename _CharT, typename _Traits, typename _Alloc> void operator+=(basic_string<_CharT, _Traits, _Alloc> &__lhs, const int __rv) { __lhs += to_string(__rv); } template<typename _CharT, typename _Traits, typename _Alloc> basic_string<_CharT, _Traits, _Alloc> operator+(const basic_string<_CharT, _Traits, _Alloc> &__lhs, const signed __rv) { basic_string<_CharT, _Traits, _Alloc> __str(__lhs); __str.append(to_string(__rv)); return __str; } template<typename _CharT, typename _Traits, typename _Alloc> void operator+=(basic_string<_CharT, _Traits, _Alloc> &__lhs, const signed __rv) { __lhs += to_string(__rv); } template<class T, class U> void operator+=(queue<T> &a, U v) { a.push(v); } template<class T, class U> void operator+=(deque<T> &a, U v) { a.push_back(v); } template<class T, class U> priority_queue<T, vector<T>, greater<T> > &operator+=(priority_queue<T, vector<T>, greater<T> > &a, U v) { a.push(v); return a; } template<class T, class U> priority_queue<T> &operator+=(priority_queue<T> &a, U v) { a.push(v); return a; } template<class T, class U> set<T> &operator+=(set<T> &a, U v) { a.insert(v); return a; } template<class T, class U> set<T, greater<T>> &operator+=(set<T, greater<T>> &a, U v) { a.insert(v); return a; } template<class T, class U> vector<T> &operator+=(vector<T> &a, U v) { a.pb(v); return a; } template<class T, class U> vector<T> operator+(const vector <T> &a, U v) { vector<T> ret = a; ret += v; return ret; } template<class T, class U> vector<T> operator+(U v, const vector <T> &a) { vector<T> ret = a; ret.insert(ret.begin(), v); return ret; } template<class T> vector<T> operator+(vector<T> &a, vector <T> &b) { vector<T> ret; ret = a; fora(v, b)ret += v; return ret; } template<class T> vector<T> &operator+=(vector<T> &a, vector <T> &b) { fora(v, b)a += v; return a; } template<class T, class U> vector<T> &operator+=(vector<T> &a, initializer_list<U> v) { for (auto &&va :v)a.pb(va); return a; } template<class T> vector<T> &operator-=(vector<T> &a, vector <T> &b) { if (sz(a) != sz(b)) { debugline("vector<T> operator-="); deb(a); deb(b); ole(); } rep(i, sz(a))a[i] -= b[i]; return a; } template<class T> vector<T> operator-(vector<T> &a, vector <T> &b) { if (sz(a) != sz(b)) { debugline("vector<T> operator-"); deb(a); deb(b); ole(); } vector<T> res(sz(a)); rep(i, sz(a))res[i] = a[i] - b[i]; return res; } template<typename T> void remove(vector<T> &v, unsigned int i) { v.erase(v.begin() + i); } template<typename T> void remove(vector<T> &v, unsigned int s, unsigned int e) { v.erase(v.begin() + s, v.begin() + e); } template<typename T> void removen(vector<T> &v, unsigned int s, unsigned int n) { v.erase(v.begin() + s, v.begin() + s + n); } template<typename T> void erase(vector<T> &v, unsigned int i) { v.erase(v.begin() + i); } template<typename T> void erase(vector<T> &v, unsigned int s, unsigned int e) { v.erase(v.begin() + s, v.begin() + e); } template<typename T> void erasen(vector<T> &v, unsigned int s, unsigned int n) { v.erase(v.begin() + s, v.begin() + s + n); } template<typename T, typename U> void insert(vector<T> &v, unsigned int i, U t) { v.insert(v.begin() + i, t); } template<typename T, typename U> void push_front(vector<T> &v, U t) { v.insert(v.begin(), t); } template<typename T, typename U> void insert(vector<T> &v, unsigned int i, vector<T> list) { for (auto &&va :list)v.insert(v.begin() + i++, va); } template<typename T, typename U> void insert(vector<T> &v, initializer_list<U> list) { for (auto &&va :list)v.pb(va); } template<typename T, typename U> void insert(vector<T> &v, unsigned int i, initializer_list<U> list) { for (auto &&va :list)v.insert(v.begin() + i++, va); } template<typename T> void insert(set<T> &v, vector<T> list) { for (auto &&va :list)v.insert(va); } template<typename T> void insert(set<T> &v, initializer_list<T> list) { for (auto &&va :list)v.insert(va); } //閉路がなければtrue bool topo(vi &res, digraph<int> &g) { int n = g.g.size(); vi nyu(n); rep(i, n)for (auto &&e :g[i])nyu[e.t]++; queue<int> st; rep(i, n)if (nyu[i] == 0)st.push(i); while (st.size()) { int v = st.front(); st.pop(); res.pb(v); fora(e, g[v]) if (--nyu[e.t] == 0)st.push(e.t); } return res.size() == n; } //辞書順最小トポロジカルソート bool topos(vi &res, digraph<int> &g) { int n = g.g.size(); vi nyu(n); rep(i, n)for (auto &&e :g[i])nyu[e.t]++; //小さい順 priority_queue<int, vector<int>, greater<int> > q; rep(i, n)if (nyu[i] == 0)q.push(i); while (q.size()) { int i = q.top(); q.pop(); res.pb(i); fora(e, g[i])if (--nyu[e.t] == 0)q.push(e.t); } return res.size() == n; } vector<string> split(const string a, const char deli) { string b = a + deli; int l = 0, r = 0, n = b.size(); vector<string> res; rep(i, n) { if (b[i] == deli) { r = i; if (l < r)res.push_back(b.substr(l, r - l)); l = i + 1; } } return res; } vector<string> split(const string a, const string deli) { string b = a + deli; int l = 0, r = 0, n = b.size(), dn = deli.size(); vector<string> res; rep(i, n) { if (i + dn <= n && b.substr(i, i + dn) == deli) { r = i; if (l < r)res.push_back(b.substr(l, r - l)); i += dn - 1; l = i + 1; } } return res; } void yn(bool a) { if (a)cout << "yes" << endl; else cout << "no" << endl; } void Yn(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; } void YN(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; } void fyn(bool a) { if (a)cout << "yes" << endl; else cout << "no" << endl; exit(0); } void fYn(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; exit(0); } void fYN(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; exit(0); } void Possible(bool a) { if (a)cout << "Possible" << endl; else cout << "Impossible" << endl; exit(0); } int n, m, k, d, H, W, x, y, z, q; int cou; vi a, b, c; //vvi (s, 0, 0); vvc (ba, 0, 0); vp p; str s; void solve() { //keta int k=9; while (1){ cout<<"? "<<(int)pow(10,k)<<endl; str t;cin>>t; if(t=='Y')brk; k--; } int ret=0; while(1){ int s=0; rer(d,3){ int v=ret+(s+bit(d))*pow(10,k); std::cout <<"? "<<v << std::endl; str t;cin>>t; if(t=='Y'){ s+=bit(d); } } ret+=s*pow(10,k); k--; if(k<0)brk; } std::cout << res << std::endl; } int my(int n, vi &a) { return 0; } int sister(int n, vi &a) { int ret = 0; return ret; } signed main() { solve(); #define arg n,a #ifdef _DEBUG bool bad = 0; for (int i = 0, ok = 1; i < k5 && ok; i++) { int n = rand(1, 8); vi a = ranv(n, 1, 10); int myres = my(arg); int res = sister(arg); ok = myres == res; if (!ok) { out(arg); cerr << "正解 : " << res << endl; cerr << "自分 : " << myres << endl; bad = 1; break; } } if (!bad) { // cout << "完璧 : solveを書き直そう" << endl; // cout << " : そして、solve()を呼び出すのだ" << endl; // cout << " : cin>>n; na(a,n);も忘れるな" << endl; } #endif return 0; };
a.cc: In function 'void solve()': a.cc:2728:13: error: no match for 'operator==' (operand types are 'str' {aka 'std::__cxx11::basic_string<char>'} and 'char') 2728 | if(t=='Y')brk; | ~^~~~~ | | | | | char | str {aka std::__cxx11::basic_string<char>} a.cc:844:27: note: candidate: 'template<class T> bool operator==(const Modular<T>&, const Modular<T>&)' 844 | template<typename T> bool operator==(const Modular<T> &lhs, const Modular<T> &rhs) { return lhs.value == rhs.value; } | ^~~~~~~~ a.cc:844:27: note: template argument deduction/substitution failed: a.cc:2728:15: note: 'str' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const Modular<T>' 2728 | if(t=='Y')brk; | ^~~ a.cc:845:39: note: candidate: 'template<class T, class U> bool operator==(const Modular<T>&, U)' 845 | template<typename T, typename U> bool operator==(const Modular<T> &lhs, U rhs) { return lhs == Modular<T>(rhs); } | ^~~~~~~~ a.cc:845:39: note: template argument deduction/substitution failed: a.cc:2728:15: note: 'str' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const Modular<T>' 2728 | if(t=='Y')brk; | ^~~ a.cc:846:39: note: candidate: 'template<class T, class U> bool operator==(U, const Modular<T>&)' 846 | template<typename T, typename U> bool operator==(U lhs, const Modular<T> &rhs) { return Modular<T>(lhs) == rhs; } | ^~~~~~~~ a.cc:846:39: note: template argument deduction/substitution failed: a.cc:2728:15: note: mismatched types 'const Modular<T>' and 'char' 2728 | if(t=='Y')brk; | ^~~ In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:4: /usr/include/c++/14/bits/regex.h:1103:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1103 | operator==(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1103:5: note: template argument deduction/substitution failed: a.cc:2728:15: note: 'str' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 2728 | if(t=='Y')brk; | ^~~ /usr/include/c++/14/bits/regex.h:1199:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1199 | operator==(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1199:5: note: template argument deduction/substitution failed: a.cc:2728:15: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'char' 2728 | if(t=='Y')brk; | ^~~ /usr/include/c++/14/bits/regex.h:1274:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1274 | operator==(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1274:5: note: template argument deduction/substitution failed: a.cc:2728:15: note: 'str' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 2728 | if(t=='Y')brk; | ^~~ /usr/include/c++/14/bits/regex.h:1366:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1366 | operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1366:5: note: template argument deduction/substitution failed: a.cc:2728:15: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'char' 2728 | if(t=='Y')brk; | ^~~ /usr/include/c++/14/bits/regex.h:1441:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1441 | operator==(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1441:5: note: template argument deduction/substitution failed: a.cc:2728:15: note: 'str' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 2728 | if(t=='Y')brk; | ^~~ /usr/include/c++/14/bits/regex.h:1534:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1534 | operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1534:5: note: template argument deduction/substitution failed: a.cc:2728:15: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'char' 2728 | if(t=='Y')brk; | ^~~ /usr/include/c++/14/bits/regex.h:1613:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1613 | operator==(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1613:5: note: template argument deduction/substitution failed: a.cc:2728:15: note: 'str' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 2728 | if(t=='Y')brk; | ^~~ /usr/include/c++/14/bits/regex.h:2186:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator==(const match_results<_BiIter, _Alloc>&, const match_results<_BiIter, _Alloc>&)' 2186 | operator==(const match_results<_Bi_iter, _Alloc>& __m1, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:2186:5: note: template argument deduction/substitution failed: a.cc:2728:15: note: 'str' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>' 2728 | if(t=='Y')brk; | ^~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed: a.cc:2728:15: note: 'str' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::pair<_T1, _T2>' 2728 | if(t=='Y')brk; | ^~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 441 | operator==(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed: a.cc:2728:15: note: 'str' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 2728 | if(t=='Y')brk; | ^~~ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 486 | operator==(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed: a.cc:2728:15: note: 'str' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 2728 | if(t=='Y')brk; | ^~~ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1667 | operator==(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed: a.cc:2728:15: note: 'str' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 2728 | if(t=='Y')brk; | ^~~ /usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1737 | operator==(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed: a.cc:2728:15: note: 'str' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 2728 | if(t=='Y')brk; | ^~~ In file included from /usr/include/c++/14/bits/char_traits.h:42, from /usr/include/c++/14/string:42, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)' 192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substituti
s238886664
p03663
C++
#include<bits/stdc++.h> #define ll long long using namespace std; int n=1e9;char s[10]; void query(int x){printf("? %d\n",x);fflush(stdout);scanf("%s",s);} int read(){ int x=0,f=1;char ch=getchar(); while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();} while(isdigit(ch)){x=x*10+ch-48;ch=getchar();} return x*f; } int main(){ while(1){ query(n); if(s[0]=='Y') break; else n/=10; } int base=n;int now=n+base; while(1){ query(now); if(s[0]=='N') now-=base,base/=10; if(!base) break; now+=base; }prinf("! %d\n",now); return 0; }
a.cc: In function 'int main()': a.cc:23:10: error: 'prinf' was not declared in this scope; did you mean 'printf'? 23 | }prinf("! %d\n",now); | ^~~~~ | printf
s489961877
p03663
C++
#include<bits/stdc++.h> #define ll long long using namespace std; int n=1e9;char s[10]; void query(int x){printf("? %d\n",x);fflush(stdout);scanf("%s",s);} int read(){ int x=0,f=1;char ch=getchar(); while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();} while(isdigit(ch)){x=x*10+ch-48;ch=getchar();} return x*f; } int main(){ while(1){ query(n); if(s[0]=='Y') break; else n/=10; }int base=n,now=n+base; while(1){ query(now); if(s[0]=='N') now-=base,base/=10; if(!base) break; now+=base; }prinf("! %d\n",now); return 0; }
a.cc: In function 'int main()': a.cc:22:10: error: 'prinf' was not declared in this scope; did you mean 'printf'? 22 | }prinf("! %d\n",now); | ^~~~~ | printf
s796662681
p03663
C++
/*Program from Luvwgyx*/ #include<cstdio> #include<cstring> #include<algorithm> using namespace std; char s[10]; int read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } void print(int x){ if(x<0)putchar('-'),x=-x; if(x>9)print(x/10); putchar(x%10+'0'); } void write(int x){print(x);puts("");} void query(int x){printf("? %d\n",x);fflush(stdout);scanf("%s",s);} int main() { int x=1e9;query(x); if (s[0]=='Y') { for(int i=9;i;i--) { query(x-1); if (s[0]=='N') break; x/=10; } printf("! %d\n",x); return 0; } for (int i=9;i;i--) { x/=10; query(x); if (s[0]=='Y') { break; } } int l=x+1,r=x*10-1,ans; while(l<=r) { ll mid=(l+r)>>1; query(mid*10); if (s[0]=='Y') ans=mid,r=mid-1; else l=mid+1; } printf("! %d\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:46:9: error: 'll' was not declared in this scope; did you mean 'l'? 46 | ll mid=(l+r)>>1; | ^~ | l a.cc:47:15: error: 'mid' was not declared in this scope 47 | query(mid*10); | ^~~
s272223397
p03663
C++
/*Program from Luvwgyx*/ #include<cstdio> #include<cstring> #include<algorithm> using namespace std; char s[10]; int read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } void print(int x){ if(x<0)putchar('-'),x=-x; if(x>9)print(x/10); putchar(x%10+'0'); } void write(int x){print(x);puts("");} void query(int x){printf("? %lld\n",x);fflush(stdout);scanf("%s",s);} int main(){ int x=1e9;query(x); if (s[0]=='Y'){ for (int i=8;i;i--){ query(x-1); if(s[0]=='N'){printf("! %lld\n",x);return 0;} x/=10; } } for (int i=8;i;i--){ x/=10;query(x); if (s[0]=='Y')break; }int l=x+1,r=x*10-1,ans; while(l<=r){ ll mid=(l+r)>>1; query(mid*10); if (s[0]=='Y') ans=mid,r=mid-1; else l=mid+1; } printf("! %lld\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:34:9: error: 'll' was not declared in this scope; did you mean 'l'? 34 | ll mid=(l+r)>>1; | ^~ | l a.cc:35:15: error: 'mid' was not declared in this scope 35 | query(mid*10); | ^~~
s616718039
p03663
C++
/*Program from Luvwgyx*/ #include<cstdio> #include<cstring> #include<algorithm> #define int long long using namespace std; char s[10]; int read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } void print(int x){ if(x<0)putchar('-'),x=-x; if(x>9)print(x/10); putchar(x%10+'0'); } void write(int x){print(x);puts("");} void query(int x){printf("? %lld\n",x);fflush(stdout);scanf("%s",s);} signed main() { int x=1000000000; query(x); if (S[0]=='Y') { for (int i=8;~i;i--) { query(x-1); if (S[0]=='N') break; x/=10; } printf("! %d\n",x); return 0; } for (int i=8;~i;i--) { x/=10; query(x); if (S[0]=='Y') { len=i+1; break; } } int l=x+1,r=x*10-1; while(l<=r) { ll mid=(l+r)>>1; query(mid*10); if (S[0]=='Y') ans=mid,r=mid-1; else l=mid+1; } printf("! %d\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:25:9: error: 'S' was not declared in this scope 25 | if (S[0]=='Y') | ^ a.cc:40:13: error: 'S' was not declared in this scope 40 | if (S[0]=='Y') | ^ a.cc:42:13: error: 'len' was not declared in this scope; did you mean 'mblen'? 42 | len=i+1; | ^~~ | mblen a.cc:49:9: error: 'll' was not declared in this scope; did you mean 'l'? 49 | ll mid=(l+r)>>1; | ^~ | l a.cc:50:15: error: 'mid' was not declared in this scope 50 | query(mid*10); | ^~~ a.cc:51:13: error: 'S' was not declared in this scope 51 | if (S[0]=='Y') ans=mid,r=mid-1; | ^ a.cc:51:24: error: 'ans' was not declared in this scope; did you mean 'abs'? 51 | if (S[0]=='Y') ans=mid,r=mid-1; | ^~~ | abs a.cc:54:21: error: 'ans' was not declared in this scope; did you mean 'abs'? 54 | printf("! %d\n",ans); | ^~~ | abs
s402913681
p03663
C++
#include <iostream> #include <string.h> #include <stdio.h> #include <map> #include <vector> #include <math.h> #include <algorithm> #include <queue> #include <set> #include <tuple> using namespace std; #define rep(i,a) for(int i=0; i<a; i++) #define rrep(i,a) for(int i=a; i>=0; i--) #define rep1(i,a) for(int i=1; i<=a; i++) #define cout1(a) cout << a << endl; #define cout2(a,b) cout << a << " " << b << endl; #define cout3(a,b,c) cout << a << " " << b << " " << c << endl; #define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl; #define mem(a,n) memset( a, n, sizeof(a)) #define all(a) a.begin(),a.end() typedef long long ll; typedef long double ld; typedef pair<int,int> pii; typedef vector<int> V; typedef vector<V> VV; typedef vector<VV> VVV; const int INF = 1e9; const int MOD = 1e9+7; const ll LLINF = 1e18; static const double pi = 3.141592653589793; bool check(ll n){ cout2("?",n); char c; cin>>c; return (c=='Y'); } int main() { cin.tie(0); ios::sync_with_stdio(false); ll num=1000000000; while(num&&!c(num)) num/=10; if(num!=1000000000){ ll lb=num*10, ub=lb*10-1, mid; while(ub-lb>1){ mid=(ub+lb)/2; if(check(mid)) ub=mid; else lb=mid; } ll ans=lb; if(!check(ans))ans++; cout2("!",ans/10); }else{ ll ans=9; while(!check(ans)) ans*=10; cout2("!",ans/9); } return 0; }
a.cc: In function 'int main()': a.cc:45:17: error: 'c' was not declared in this scope 45 | while(num&&!c(num)) num/=10; | ^
s750007759
p03663
C++
#include <iostream> #include <string.h> #include <stdio.h> #include <map> #include <vector> #include <math.h> #include <algorithm> #include <queue> #include <set> #include <tuple> using namespace std; #define rep(i,a) for(int i=0; i<a; i++) #define rrep(i,a) for(int i=a; i>=0; i--) #define rep1(i,a) for(int i=1; i<=a; i++) #define cout1(a) cout << a << endl; #define cout2(a,b) cout << a << " " << b << endl; #define cout3(a,b,c) cout << a << " " << b << " " << c << endl; #define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl; #define mem(a,n) memset( a, n, sizeof(a)) #define all(a) a.begin(),a.end() typedef long long ll; typedef long double ld; typedef pair<int,int> pii; typedef vector<int> V; typedef vector<V> VV; typedef vector<VV> VVV; const int INF = 1e9; const int MOD = 1e9+7; const ll LLINF = 1e18; static const double pi = 3.141592653589793; bool check(ll n){ cout2("?",n); char c; cin>>c; return (c=='Y'); } int main() { cin.tie(0); ios::sync_with_stdio(false); ll num=1000000000; while(num&&!c(num)) num/=10; if(num!=1000000000){ ll lb=num*10, ub=lb*10-1, mid; while(ub-lb>1){ mid=(ub+lb)/2; if(check(mid)) ub=mid; else lb=mid; } ll ans=lb; if(!check(ans))ans++; cout2("!",ans/10); }else{ ll ans=9; while(!check(ans)) ans*=10; cout2("!",ans/9); } return 0; }
a.cc: In function 'int main()': a.cc:45:17: error: 'c' was not declared in this scope 45 | while(num&&!c(num)) num/=10; | ^
s469159129
p03663
C++
#include <iostream> #include <string.h> #include <stdio.h> #include <map> #include <vector> #include <math.h> #include <algorithm> #include <queue> #include <set> #include <tuple> using namespace std; #define rep(i,a) for(int i=0; i<a; i++) #define rrep(i,a) for(int i=a; i>=0; i--) #define rep1(i,a) for(int i=1; i<=a; i++) #define cout1(a) cout << a << endl; #define cout2(a,b) cout << a << " " << b << endl; #define cout3(a,b,c) cout << a << " " << b << " " << c << endl; #define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl; #define mem(a,n) memset( a, n, sizeof(a)) #define all(a) a.begin(),a.end() typedef long long ll; typedef long double ld; typedef pair<int,int> pii; typedef vector<int> V; typedef vector<V> VV; typedef vector<VV> VVV; const int INF = 1e9; const int MOD = 1e9+7; const ll LLINF = 1e18; static const double pi = 3.141592653589793; bool check(ll n){ cout2("?",n); char c; cin>>c; return (c=='Y'); } int main() { cin.tie(0); ios::sync_with_stdio(false); ll num=1000000000; while(num&&!c(num)) num/=10; if(num!=1000000000){ ll lb=num*10, ub=lb*10-1, mid; while(ub-lb>1){ mid=(ub+lb)/2; if(check(mid)) ub=mid; else lb=mid; } ll ans=lb; if(!check(ans))ans++; cout2("!",ans/10); }else{ ll ans=9; while(!check(ans)) ans*=10; cout2("!",ans/9); } }
a.cc: In function 'int main()': a.cc:45:17: error: 'c' was not declared in this scope 45 | while(num&&!c(num)) num/=10; | ^
s452323871
p03663
C++
#include <vector> #include <string> #include <map> #include <set> #include <iostream> #include <queue> #include <iomanip> using namespace std; #define int long long #define stoi stoll using ll=long long; using vi=vector<int>; using pii=pair<int,int>; #define ALL(c) begin(c),end(c) #define RALL(c) rbegin(c),rend(c) #define ITR(i,b,e) for(auto i=(b);i!=(e);++i) #define FORE(x,c) for(auto &x:c) #define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i) #define REP(i,n) REPF(i,0,n) #define REPR(i,n) for(int i=(int)(n);i>=0;--i) #define SZ(c) ((int)c.size()) #define CONTAIN(c,x) (c.find(x)!=end(c)) #define INSEG(l,x,r) ((l)<=(x)&&(x)<(r)) #define dump(...) #define pb push_back #define _ 0 const signed INF_=1001001001; const long long INF=1001001001001001001LL; const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0}; template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;} template<class T> istream& operator>>(istream &is,vector<T> &v) { ITR(i,begin(v),end(v)) is>>*i;return is;} template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) { is>>p.first>>p.second;return is;} template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;} template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;} template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));} template<class T> using heap=priority_queue<T,vector<T>,greater<T>>; struct before_main_function { before_main_function() { cin.tie(0); ios::sync_with_stdio(false); cout << setprecision(15) << fixed; // #define endl "\n" } } before_main_function; //------------------8<------------------------------------8<-------------------- bool ask(int n) { cout << "? " << n << endl; char resp; cin >> resp; return resp == 'Y'; } void answer(int n) { cout << "! " << n << endl; } signed main() { int num9 = 9999999999ll; int dig = 10; REP(i, 10) { if (!ask(num9)) { break; } dig--; num9 = num9 / 10; } dig++; int num1 = 1000000000ll; int dig2 = 10; REP(i, 10) { if (ask(num1)) { break; } dig2--; num1 /= 10; } dig = max(dig, dig2); cerr << "dig = " << dig << endl; if (dig == 1) { REP(i, 9) { int tmp = (i + 1) * 10; if (ask(tmp)) { answer(i + 1); return 0; } } } else { int L = 1, R = 1; REP(i, dig - 1) R *= 10; L = R / 10; while (R - L > 1) { int M = (L + R) / 2; if (ask(M)) { L = M; } else { R = M; } } REP(i, 10) { int tmp = L * 100 + i * 10 + 0; if (ask(tmp)) { answer(tmp / 10); return 0; } } assert(false); } return (0^_^0); }
a.cc: In function 'int main()': a.cc:109:9: error: 'assert' was not declared in this scope 109 | assert(false); | ^~~~~~ a.cc:8:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' 7 | #include <iomanip> +++ |+#include <cassert> 8 | using namespace std;
s147851294
p03663
C++
#include<bits/stdc++.h> #define int long long using namespace std; signed main(){ char a; int i=10; while(i--){ if(i==0){ cout<<"! 1"; fflush(0); return 0; } cout<<"? "<<(int)pow(10,i)-1<<"\n"; fflush(0); cin>>a; if(a=='N'){ break; } } int l=(int)pow(10,i+1),r=(int)pow(10,i+2)-1; while(l<r){ int mid=(l+rYYYYYYY)/2; cout<<"? "<<(int)mid<<"\n"; fflush(0); cin>>a; if(a=='N') l=mid+1; else r=mid; } cout<<"! "<<l/10; fflush(0); }
a.cc: In function 'int main()': a.cc:22:28: error: 'rYYYYYYY' was not declared in this scope 22 | int mid=(l+rYYYYYYY)/2; | ^~~~~~~~
s773040097
p03663
C++
#include <bits/stdc++.h> #define MOD 1000000007 #define INF 1061109567 #define pb push_back #define in(s) freopen(s,"r",stdin); #define out(s) freopen(s,"w",stdout); #define fi first #define se second #define bw(i,r,l) for (int i=r-1;i>=l;i--) #define fw(i,l,r) for (int i=l;i<r;i++) #define fa(i,x) for (auto i:x) using namespace std; int cnt=0,val=0; void ask() { int beg=0; if (val==0) beg=1; fw (i,beg,10) { cout<<val*10+i<<endl<<flush; char temp; cin>>temp; if (temp=='Y') } } int fpow(int a,int p) { int ans=1; fw (i,0,p) ans*=a; return ans; } signed main() { //in("aome.inp"); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); /* How to get the number of digits N have? Keep asking queries of 1e9 down to 1. Let's say N have k digits. Then 1e(k + 1) will return N and 1ek will return Y. k have been found. Now, binary search on this range simply. Query for mid: mid <= N. How to ask? We can see, mid * 10 > N with all possible mids. Also, it's the same as mid when comparing as strings. So the relations can be found. If we receive a Y, mid > N. Else, mid <= N */ int cur=9; for (int i=1e9;i>=1;i/=10) { cout<<"? "<<i<<endl<<flush; char temp; cin>>temp; if (temp=='Y') {cnt=cur; break;} cur--; } int l=fpow(cnt-1),r=fpow(cnt)-1; while (l<r) { int mid=(l+r)>>1; cout<<"? "<<mid*10<<endl<<flush; char temp; cin>>temp; if (temp=='Y') r=mid-1; else l=mid+1; } cout<<"! "<<l<<endl<<flush; return 0; }
a.cc: In function 'void ask()': a.cc:21:9: error: expected primary-expression before '}' token 21 | } | ^ a.cc: In function 'int main()': a.cc:50:19: error: too few arguments to function 'int fpow(int, int)' 50 | int l=fpow(cnt-1),r=fpow(cnt)-1; | ~~~~^~~~~~~ a.cc:23:5: note: declared here 23 | int fpow(int a,int p) { | ^~~~ a.cc:51:18: error: 'r' was not declared in this scope 51 | while (l<r) { | ^
s905013875
p03663
C++
#include<bits/stdc++.h> using namespace std; #define int long long signed main() { int x = 1; for(; x <= 10 ; ++x) cout << "? " << pow(10, x) << endl; fflush(stdout); char a; cin >> a; if(a == 'N'){ x--; break; } } int l = pow(10, x), r = pow(10, x + 1) - 1; while(l != r){ int mid = (l + r) / 2; cout << "? " << mid * 10 << endl; fflush(stdout); char a; cin >> a; if(a == 'N') l = mid + 1; else r = mid; } cout << "! " << l; return 0; }
a.cc: In function 'int main()': a.cc:15:25: error: break statement not within loop or switch 15 | break; | ^~~~~ a.cc: At global scope: a.cc:18:25: error: 'x' was not declared in this scope 18 | int l = pow(10, x), r = pow(10, x + 1) - 1; | ^ a.cc:19:9: error: expected unqualified-id before 'while' 19 | while(l != r){ | ^~~~~ a.cc:28:9: error: 'cout' does not name a type 28 | cout << "! " << l; | ^~~~ a.cc:29:9: error: expected unqualified-id before 'return' 29 | return 0; | ^~~~~~ a.cc:30:1: error: expected declaration before '}' token 30 | } | ^
s408330433
p03663
C++
#include <iostream> #include <vector> #include <algorithm> #include <cstdio> #include <algorithm> #include <string> #include <climits> #include <cmath> #include <cstdlib> #include "grader.h" using namespace std; string num = ""; char ask(string str) { char ch; cout << "? " << str << endl << flush; cin >> ch; return ch; } void answer(string str) { cout << "! " << str << endl << flush; exit(0); } bool check(char digit) { if (digit == '9') return true; string tmp = num + digit; tmp.append(15 - tmp.size(), '9'); bool res = (ask(tmp) == 'Y'); // cerr << tmp << ": " << res << endl; return res; } int getceil(char l, char r) { while (r > l) { char m = (l + r) / 2; if (check(m)) r = m; else l = m+1; // cerr << l << ' ' << r << endl; } return r; } int solve() { string str = "1"; while (ask(str) == 'Y') { str += '0'; } int numdigits = str.size() - 1; num += getceil('1', '9'); for (int i = 1; i < numdigits; ++i) { num += getceil('0', '9'); } answer(num); return 0; } int main() { return solve(); }
a.cc:10:10: fatal error: grader.h: No such file or directory 10 | #include "grader.h" | ^~~~~~~~~~ compilation terminated.
s260724649
p03663
C++
#include<bits/stdc++.h> using namespace std; #define int long long int pw[22]; signed main(){ pw[0] = 1; char v; int s; for(int i = 1 ; i <=10 ; ++i) pw[i] = pw[i - 1] * 10; for(int i = 10 ; i >= 1 ; --i) { int check = pw[i] - 1; cout << "? " << check; fflush(stdout); cin >> v; if(v == "N") { s = i; break; } } int l = pw[i] , r = pw[i + 1] - 1; while(l < r) { int mid = l + r >> 1; cout << "? " << mid; fflush(stdout); cin >> v; if(v == "Y") r = mid; else l = mid + 1; } cout << "! " << l; }
a.cc: In function 'int main()': a.cc:16:22: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 16 | if(v == "N") | ~~^~~~~~ a.cc:22:20: error: 'i' was not declared in this scope 22 | int l = pw[i] , r = pw[i + 1] - 1; | ^ a.cc:23:19: error: 'r' was not declared in this scope 23 | while(l < r) | ^ a.cc:29:22: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 29 | if(v == "Y") r = mid; | ~~^~~~~~
s493680330
p03663
C++
#include <iostream> #include <vector> #include <algorithm> #include <cstdio> #include <algorithm> #include <string> #include <climits> #include <cmath> #include <cstdlib> #include "grader.h" using namespace std; string num = ""; char ask(string str) { char ch; cout << "? " << str << endl << flush; cin >> ch; return ch; } void answer(string str) { cout << "! " << str << endl << flush; exit(0); } bool check(char digit) { if (digit == '9') return true; string tmp = num + digit; tmp.append(15 - tmp.size(), '9'); bool res = (ask(tmp) == 'Y'); // cerr << tmp << ": " << res << endl; return res; } int getceil(char l, char r) { while (r > l) { char m = (l + r) / 2; if (check(m)) r = m; else l = m+1; // cerr << l << ' ' << r << endl; } return r; } int solve() { while (true) { // maybe already true if (num.size() > 0) { bool full9 = 1; for (int i = 0; i < num.size(); ++i) { if (num[i] != '9') { full9 = 0; break; } } if (full9) { char ch = ask("1" + string(num.size(), '0')); if (ch == 'N') answer(num); } else { char ch = ask(to_string( stoll(num) + 1 )); if (ch == 'Y') answer(num); } } // binary search num += getceil('0', '9'); } return 0; } int main() { return solve(); }
a.cc:10:10: fatal error: grader.h: No such file or directory 10 | #include "grader.h" | ^~~~~~~~~~ compilation terminated.
s561019973
p03663
C++
#include <bits/stdc++.h> using namespace std; #define int long long const double PI = 3.14159265358979323846; typedef vector<int> vint; typedef pair<int, int> P; int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; int val(vint x) { int res = x[0]; for (int i = 1; i < x.size(); i++) (res *= 10) += x[i]; return res; } signed main() { vint ans; for (int i = 0; i <= 10; i++) ans.push_back(0); for (int i = 0; i < 1; i++) { cout << "? 10000000000" << endl; char a; cin >> a; if (a == 'N') break; vint cmp; for (int j = 0; j < 10; j++) cmp.push_back(1); for (int j = 10; j > 0; j--) { cout << "? " << val(cmp) << endl; char a; cin >> a; if (a == 'N') { ans[0] = 1; ans.resize(j + 1); cout << "! " << val(ans) << endl; return 0; } cmp.pop_back(); } cout << "? 2" << endl; char a; cin >> a; if (a == 'Y') cout << "! 1" << endl; else cout << "! 10" << endl; return 0; } for (int i = 0; i < ans.size() - 1; i++) { int lb = 0, ub = 10; while (ub - lb > 1) { int mid = (lb + ub) / 2; ans[i] = mid; cout << "? " << val(ans) << endl; char a; cin >> a; if (a == 'Y') { ub = mid; } else { lb = mid; } } ans[i] = lb; } for (int i = ans.size() - 2; i >= 0; i--) { if (ans[i] == 9) ans[i] = 0; else { ans[i]++; break; } } vint cmp; cmp.push_back(1); for (int i = 1; i < ans.size(); i++) cmp.push_back(0); for (int i = ans.size(); i >= 0; i--) { cout << "? " << val(cmp) << endl; char a; cin >> a; if (a == 'Y') { ans.resize(i); break; } cmp.pop_back(); } cout << "! " << val(ans) << endl; return 0; }
a.cc: In function 'int main()': a.cc:40:14: error: redeclaration of 'char a' 40 | char a; | ^ a.cc:22:14: note: 'char a' previously declared here 22 | char a; | ^
s965156197
p03663
C++
#include<iostream> #include<cstdio> using namespace std; main() { char s[2]; int now,k=1; for(now=1;now<=10;now++,k*=10) { printf("? %d\n",k); fflush(stdout); scanf("%s",s); if(s[0]=='N')break; } now--; if(now==10) { k=2; for(now=1;now<=10;now++,k*=10) { printf("? %d\n",k); fflush(stdout); scanf("%s",s); if(s[0]=='Y'){printf("! %d",k/2);fflush(stdout);return;} } } else { int l=k/10+1,r=k-1; while(l<=r) { if(l==r-1) { printf("? %lld\n",(long long)l*10); fflush(stdout); scanf("%s",s); if(s[0]=='Y'){printf("! %d",l);fflush(stdout);return;} else {printf("! %d",r);fflush(stdout);return;} } int mid=l+r>>1; printf("? %lld\n",(long long)mid*10); fflush(stdout); scanf("%s",s); if(s[0]=='Y')r=mid; else l=mid+1; } } return 0; } //1.控制字典序一定小 1,10,100..., 来确定数字位数或是不是10的次幂 //2.找出位数后,控制数字一定大, 二分ans,给交互库ans*10,比较字典序来确定数字
a.cc:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 4 | main() | ^~~~ a.cc: In function 'int main()': a.cc:24:73: error: return-statement with no value, in function returning 'int' [-fpermissive] 24 | if(s[0]=='Y'){printf("! %d",k/2);fflush(stdout);return;} | ^~~~~~ a.cc:37:79: error: return-statement with no value, in function returning 'int' [-fpermissive] 37 | if(s[0]=='Y'){printf("! %d",l);fflush(stdout);return;} | ^~~~~~ a.cc:38:71: error: return-statement with no value, in function returning 'int' [-fpermissive] 38 | else {printf("! %d",r);fflush(stdout);return;} | ^~~~~~
s786136118
p03663
C++
#include<iostream> #include<cstdio> using namespace std; int main() { char s[2]; int now,k=1; for(now=1;now<=10;now++,k*=10) { printf("? %d\n",k); flush(stdout); scanf("%s",s); if(s[0]=='N')break; } now--; if(now==10) { k=2; for(now=1;now<=10;now++,k*=10) { printf("? %d\n",k); flush(stdout); scanf("%s",s); if(s[0]=='Y')return 0*printf("! %d",k/2); } } else { int l=k/10+1,r=k-1; while(l<=r) { if(l==r-1) { printf("? %lld\n",(long long)l*10); flush(stdout); scanf("%s",s); if(s[0]=='Y')return 0*printf("! %d",l); else return 0*printf("! %d",r); } int mid=l+r>>1; printf("? %lld\n",(long long)mid*10); flush(stdout); scanf("%s",s); if(s[0]=='Y')r=mid; else l=mid+1; } } return 0; } //1.控制字典序一定小 1,10,100..., 来确定数字位数或是不是10的次幂 //2.找出位数后,控制数字一定大, 二分ans,给交互库ans*10,比较字典序来确定数字
a.cc: In function 'int main()': a.cc:11:22: error: no matching function for call to 'flush(FILE*&)' 11 | flush(stdout); | ~~~~~^~~~~~~~ In file included from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/ostream:766:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::flush(basic_ostream<_CharT, _Traits>&)' 766 | flush(basic_ostream<_CharT, _Traits>& __os) | ^~~~~ /usr/include/c++/14/ostream:766:5: note: template argument deduction/substitution failed: a.cc:11:22: note: mismatched types 'std::basic_ostream<_CharT, _Traits>' and 'FILE*' 11 | flush(stdout); | ~~~~~^~~~~~~~ a.cc:22:30: error: no matching function for call to 'flush(FILE*&)' 22 | flush(stdout); | ~~~~~^~~~~~~~ /usr/include/c++/14/ostream:766:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::flush(basic_ostream<_CharT, _Traits>&)' 766 | flush(basic_ostream<_CharT, _Traits>& __os) | ^~~~~ /usr/include/c++/14/ostream:766:5: note: template argument deduction/substitution failed: a.cc:22:30: note: mismatched types 'std::basic_ostream<_CharT, _Traits>' and 'FILE*' 22 | flush(stdout); | ~~~~~^~~~~~~~ a.cc:35:38: error: no matching function for call to 'flush(FILE*&)' 35 | flush(stdout); | ~~~~~^~~~~~~~ /usr/include/c++/14/ostream:766:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::flush(basic_ostream<_CharT, _Traits>&)' 766 | flush(basic_ostream<_CharT, _Traits>& __os) | ^~~~~ /usr/include/c++/14/ostream:766:5: note: template argument deduction/substitution failed: a.cc:35:38: note: mismatched types 'std::basic_ostream<_CharT, _Traits>' and 'FILE*' 35 | flush(stdout); | ~~~~~^~~~~~~~ a.cc:42:30: error: no matching function for call to 'flush(FILE*&)' 42 | flush(stdout); | ~~~~~^~~~~~~~ /usr/include/c++/14/ostream:766:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::flush(basic_ostream<_CharT, _Traits>&)' 766 | flush(basic_ostream<_CharT, _Traits>& __os) | ^~~~~ /usr/include/c++/14/ostream:766:5: note: template argument deduction/substitution failed: a.cc:42:30: note: mismatched types 'std::basic_ostream<_CharT, _Traits>' and 'FILE*' 42 | flush(stdout); | ~~~~~^~~~~~~~
s511663286
p03663
C++
#include<bits/stdc++.h> using namespace std; using ll = long long; // #undef DEBUG // #define DEBUG /// {{{ DEBUG --- /// template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { if(&o == &cerr) { o << '{'; for(size_t i = 0; i < v.size(); i++) o << v[i] << (i + 1 != v.size() ? ", " : ""); o << "}"; } else { for(size_t i = 0; i < v.size(); i++) o << v[i] << (i + 1 != v.size() ? " " : ""); } return o; } #ifdef DEBUG #define dump(...) (cerr<<"["<<__LINE__<< "] "<<#__VA_ARGS__<<" = "<<make_tuple(__VA_ARGS__)<<"\n") template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){} template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":", ") << get<n>(t); _ot<n+1>(os, t); } template<class...T> ostream & operator<<(ostream &o, tuple<T...> const &t){ o << "("; _ot<0>(o, t); o << ")"; return o; } #else #define dump(...) (0) #endif /// }}}--- /// int main() { ios::sync_with_stdio(false), cin.tie(0); ll b = 1; for(int i = 0; i < 9; i++) b *= 10; ll c = b - 1; dump(b, c); ll now = 0; int all9 = 1; ll k = 1; int cnt = 0; while(1) { if(cnt == 9 && now != 1e8) return (cout << now << endl, 0); if(cnt == 9) { cout << "? " << 9e8 << endl; char y; cin >> y; cout << "! " << (y == 'Y' ? 1e8 : 1e9) << endl; return 0; } int ok = 9, ng = cnt ? -1 : 0; while(ok - ng > 1) { ll mid = (ok + ng) >> 1; if((now * 10 + mid) * b + c > 1e18) int x=cin>>x; assert((now * 10 + mid) * b + c <= 1e18); cout << "? " << (now * 10 + mid) * b + c << endl; char y; cin >> y; if(y == 'Y') { ok = mid; } else { ng = mid; } } dump(ok); if(ok == 0) { if(all9) { dump(k); cout << "? " << k << endl; char y; cin >> y; if(y != 'Y') { cout << "! " << now << endl; return 0; } } else { dump(k-1); cout << "? " << k-1 << endl; char y; cin >> y; if(y == 'Y') { cout << "! " << now << endl; return 0; } } } all9 &= ok == 9; now = now * 10 + ok; k *= 10; cnt++; } }
a.cc: In function 'int main()': a.cc:39:52: error: cannot convert 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} to 'int' in initialization 39 | if((now * 10 + mid) * b + c > 1e18) int x=cin>>x; | ~~~^~~ | | | std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}
s873422426
p03663
C++
#include <stdio.h> #pragma warning(disable:4996) //FILE *in = fopen("input.txt", "r"), *out = fopen("output.txt", "w"); FILE *in = stdin, *out = stdout; #include <vector> #include <algorithm> #include <math.h> using namespace std; #define INF 0x7fffffff #define NM 100005 #define MOD 1000000007 #define FOR(i,n,m) for (int i=(n);i<=(m);i++) #define si(n) fscanf(in,"%d",&n) #define sd(n) fscanf(in,"%lf",&n) typedef long long int ll; int ans=123; char test(ll X) { //* fprintf(out, "? %lld\n", X); char ch[5]; fscanf(in, "%s", ch); fflush(stdout);//*/ return ch[0]; } void Find(int X) { fprintf(out, "! %d\n", X); } int getLen() { int L = 0, R = 8, len = 9; while (L <= R) { int m = (L + R) >> 1; int X = 1; FOR(i, 1, m) X *= 10; if (test(X) == 'N') { len = min(len, m); R = m - 1; } else { L = m + 1; } } /*for (ll X = 1; len < 9; len++, X *= 10) { if (test(X) == 'N') { return len; } }*/ return len; } void temp() { int a[10005]; FOR(i, 1, 10000) a[i] = i; sort(a + 1, a + 1 + 10000, [](const int& lhs, const int& rhs) { char t1[20], t2[20]; itoa(lhs, t1, 10); itoa(rhs, t2, 10); return strcmp(t1, t2)<=0; }); FOR(i, 1, 10000) fprintf(out, "%d\n", a[i]); } int main() { int len = getLen(); if (len == 9 && test(1000000000) == 'Y') { // 10^k 꼴 or 9자리 len = 0; for (ll X = 2; len <= 9; len++, X *= 10) { char ch = test(X); if (ch == 'Y') { Find(X / 2); return 0; } } } int ans = 0; FOR(k, 1, len - 1) { int L = 0, R = 9, v = 9; if (k == 1) L = 1; while(L<=R){ int m = (L + R) >> 1; int X = ans * 10 + m; if (test(X) == 'N') { v = min(v, m - 1); R = m - 1; } else { L = m + 1; } } ans = ans * 10 + v; } { // last digit int L = 0, R = 9, v = -1; if (len == 1) L = 1; FOR(i, L, R) { ll X = ((ll)ans * 10 + i) * 10; if (test(X) == 'Y') { Find(ans * 10 + i); return 0; } } } return 0; }
a.cc: In lambda function: a.cc:55:17: error: 'itoa' was not declared in this scope 55 | itoa(lhs, t1, 10); itoa(rhs, t2, 10); | ^~~~ a.cc:56:24: error: 'strcmp' was not declared in this scope 56 | return strcmp(t1, t2)<=0; | ^~~~~~ a.cc:8:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 7 | #include <math.h> +++ |+#include <cstring> 8 | using namespace std;
s258887169
p03663
C++
#include<bits/stdc++.h> #define ll long long using namespace std; bool fuck(char c, ll n) { cout << c << " " << n << endl; if (c == '?') { string s; cin >> s; if (s[0] == 'Y') return 1; return 0; } } int main() { int len = 1, num = 1; while (judge('?', num)) { len *= 10; num = len; } len /= 10; num = len; while (len) { int l = 0, r = 9; while (l < r) { int mid = (l + r + 1) >> 1; if (judge('?', mid * len + num)) l = mid; else r = mid - 1; } num += l * len; len /= 10; } fuck('!', num); return 0; }
a.cc: In function 'int main()': a.cc:14:16: error: 'judge' was not declared in this scope 14 | while (judge('?', num)) { | ^~~~~ a.cc:22:29: error: 'judge' was not declared in this scope 22 | if (judge('?', mid * len + num)) l = mid; | ^~~~~ a.cc: In function 'bool fuck(char, long long int)': a.cc:11:1: warning: control reaches end of non-void function [-Wreturn-type] 11 | } | ^
s299468301
p03663
C++
#include<iostream> #include<vector> #include<string> #include<algorithm> #include<map> #include<set> #include<utility> #include<cmath> #include<cstring> #include<queue> #include<stack> #include<cstdio> #include<sstream> #include<iomanip> #include<assert.h> #define loop(i,a,b) for(int i=a;i<b;i++) #define rep(i,a) loop(i,0,a) #define pb push_back #define all(in) in.begin(),in.end() #define shosu(x) fixed<<setprecision(x) using namespace std; //kaewasuretyuui typedef long long ll; typedef ll Def; typedef pair<Def,Def> pii; typedef vector<Def> vi; typedef vector<vi> vvi; typedef vector<pii> vp; typedef vector<vp> vvp; typedef vector<string> vs; typedef vector<double> vd; typedef vector<vd> vvd; typedef pair<Def,pii> pip; typedef vector<pip>vip; #define mt make_tuple typedef tuple<pii,int,int> tp; typedef vector<tp> vt; template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;} template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;} const double PI=acos(-1); const double EPS=1e-7; Def inf=sizeof(Def)==sizeof(long long)?9e18:1e9; int dx[]={0,1,0,-1,1,1,-1,-1}; int dy[]={1,0,-1,0,1,-1,1,-1}; int main(){ int t=-1; vi in(15); in[0]=1; rep(i,14)in[i+1]=in[i]*10; rep(i,10){ cout<<"? "<<in[i+1]<<endl; char a;cin>>a; if(a!='Y'){ t=i+1; break; } } if(t==-1){ rep(i,11){ cout<<"? "<<2*in[i]<<endl; char a;cin>>a; if(a=='Y'){ t=i+1; break; } } cout<<"! "<<in[t-1]<<endl; return 0; } ll l=in[t-1],r=in[t]-1; while(r-l>1){ ll h=(l+r)/2; cout<<"? "<<10*h<<endl; char a;cin>>a if(a=='Y')r=h; else l=h; } cout<<"! "<<r<<endl; }
a.cc: In function 'int main()': a.cc:74:30: error: expected ';' before 'if' 74 | char a;cin>>a | ^ | ; 75 | if(a=='Y')r=h; | ~~ a.cc:76:17: error: 'else' without a previous 'if' 76 | else l=h; | ^~~~
s657485333
p03663
C++
#include <bits/stdc++.h> using namespace std; #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) #define unless(p) if(!p) #define until(p) while(!p) using ll = long long; using P = std::tuple<int,int>; const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1}; int counter; void ask(std::string n){ std::cout << "? " << n << std::endl; ++counter; } char answer(){ char c; std::cin >> c; return c; } char findDigit(std::string s, int start, std::string suffix){ int64_t lb = 9, ub = start - 1; while(std::abs(ub - lb) > 1){ int64_t mid = (lb + ub) / 2; ask(s + (char)(mid + '0') + suffix); char ans = answer(); if(ans == 'Y'){ lb = mid; }else{ ub = mid; } } return (char)(lb + '0'); } int main(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); std::string res = ""; bool two = false; while(res.size() < 9 || (res.size() == 9 && !two)){ char d = findDigit(res, res.size() == 0 ? 1 : 0, std::string(max(0, 18 - 1 - res.size()), '9')); if(d > '0'){ if(res.size() > 0){two = true;} res += d; }else{ { ask(res + '9' + std::string(max(0, 18 - 1 - 1 - res.size()), '0'));; char ans = answer(); if(ans == 'N'){ res += '0'; continue; } } { ask(res + "1"); char ans = answer(); if(ans == 'N'){ res += '0'; continue; } } { ask(std::string(res.size(), '9')); char ans = answer(); if(ans == 'N'){ res += '0'; } break; } } } // std::cout << "(res, two) = " << "(\"" << res << "\", " << two << ")" << std::endl; std::cout << "! " << res << std::endl; // std::cout << "ask count: " << counter << std::endl; }
a.cc: In function 'int main()': a.cc:54:73: error: no matching function for call to 'max(int, std::__cxx11::basic_string<char>::size_type)' 54 | char d = findDigit(res, res.size() == 0 ? 1 : 0, std::string(max(0, 18 - 1 - res.size()), '9')); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:54:73: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'}) 54 | char d = findDigit(res, res.size() == 0 ? 1 : 0, std::string(max(0, 18 - 1 - res.size()), '9')); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:54:73: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 54 | char d = findDigit(res, res.size() == 0 ? 1 : 0, std::string(max(0, 18 - 1 - res.size()), '9')); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~ a.cc:61:48: error: no matching function for call to 'max(int, std::__cxx11::basic_string<char>::size_type)' 61 | ask(res + '9' + std::string(max(0, 18 - 1 - 1 - res.size()), '0'));; | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:61:48: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'}) 61 | ask(res + '9' + std::string(max(0, 18 - 1 - 1 - res.size()), '0'));; | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:61:48: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 61 | ask(res + '9' + std::string(max(0, 18 - 1 - 1 - res.size()), '0'));; | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
s294666450
p03663
C++
#include <bits/stdc++.h> using namespace std; long long ans; char rt1[5],rt3[5]; int main() { ans = 1; bool flag = true; int bits = 1; while(true) { printf("? %lld", ans); for (int i = bits + 1; i <= 17; i++) printf("9"); puts(""); //printf("? %lld999999999\n",ans); fflush(stdout);x scanf("%s",rt1); if(rt1[0] == 'Y') { printf("? %lld\n",ans+1); fflush(stdout); scanf("%s",rt3); if(ans % 10 != 9) flag = false; if(flag && rt3[0] == 'N') break; if(!flag && rt3[0] == 'Y') break; ans = ans*10; bits++; } else { ans++; } if(ans >= 1000000000) break; } printf("! %lld\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:17:24: error: 'x' was not declared in this scope 17 | fflush(stdout);x | ^
s491558451
p03663
C++
#include <iostream> #include <string> using namespace std; int cur=MOD-7; inline bool check(int x){ cout<<"? "<<x<<endl; string res; cin>>res; return res=="Y"; } int main(){ if(check(cur)){ while(cur>1 && check(cur-1))cur/=10;; cout<<"! "<<cur<<endl; } else{ while(!check(cur/=10)); int lb=cur,ub=cur*10; while(ub-lb>1){ int mid=(lb+ub)/2; if(check(mid*10))ub=mid; else lb=mid; } cout<<"! "<<ub<<endl; } return 0; }
a.cc:4:9: error: 'MOD' was not declared in this scope 4 | int cur=MOD-7; | ^~~
s717756706
p03663
C++
#include <bits/stdc++.h> typedef long long ll; const ll most = 1e9; bool query(ll val){ std::cout << "? " << val << std::endl; char c; std::cin >> c; return (c == 'Y'); } int main(){ ll length = 1; if(!query(9)){ for(ll i = 10; i <= most; i *= 10){ if(query(i * 10 - 1)){ length = i; break; } } } if(!query(most)){ for(ll i = most; i >= 1; i /= 10){ if(query(i)){ length = i; break; } } } ll l = length; ll r = length * 10 - 1; ll best = r; while(l <= r){ ll mid = (l + r) / 2; if(query(mid * 10)){ r = mid - 1; best = mid; } else { l = mid + 1; } } if(best != target){ std::cout << target << ' ' << best << std::endl; return -1; } }
a.cc: In function 'int main()': a.cc:53:20: error: 'target' was not declared in this scope 53 | if(best != target){ | ^~~~~~
s986348418
p03663
C++
#include <iostream> #include <fstream> #include <cstdio> #include <cmath> #include <cstdlib> #include <cstring> #include <string> #include <vector> #include <utility> #include <complex> #include <set> #include <map> #include <queue> #include <stack> #include <deque> #include <tuple> #include <bitset> #include <algorithm> using namespace std; typedef long double ld; typedef long long ll; typedef vector<int> vint; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<double, double> pdd; typedef complex<ld> compd; #define rep(i,n) for(int i=0;i<n;i++) #define srep(i,a,n) for(int i=a;i<n;i++) #define REP(i,n) for(int i=0;i<=n;i++) #define SREP(i,a,n) for(int i=a;i<=n;i++) #define rrep(i,n) for(int i=n-1;i>=0;i--) #define RREP(i,n) for(int i=n;i>=0;i--) #define all(a) (a).begin(),(a).end() #define mp(a,b) make_pair(a,b) #define mt make_tuple #define fst first #define scn second #define bicnt(x) __buildin__popcount(x) #define debug(x) cout<<"debug: "<<x<<endl const ll inf = (ll)1e18; const ll mod = (ll)1e9 + 7; const ld eps = 1e-18; const int dx[] = { 0,1,0,-1 }; const int dy[] = { 1,0,-1,0 }; string query(ll k) { cout << "? " << k << endl; flush(); string ret; cin >> ret; return ret; } void answer(ll k) { cout << "! " << k << endl; exit(0); } int main() { ll ans = 1LL; while (true) { string s = query(ans); if (s == "N") { ans /= 10; break; } else { ans *= 10; if (ans > mod) { answer(1e9); return 0; } } } ll left = ans, right = ans * 10 - 1; while (left + 3 < right) { ll mid = (left + right) / 2; string s = query(mid * 10); if (s == "Y") right = mid; else left = mid; } for (ll i = right; i >= left; i--) { string s = query(i * 10); if (s == "N") { answer(i); return 0; } } return 0; }
a.cc: In function 'std::string query(ll)': a.cc:49:14: error: no matching function for call to 'flush()' 49 | flush(); | ~~~~~^~ In file included from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/ostream:766:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::flush(basic_ostream<_CharT, _Traits>&)' 766 | flush(basic_ostream<_CharT, _Traits>& __os) | ^~~~~ /usr/include/c++/14/ostream:766:5: note: candidate expects 1 argument, 0 provided
s587231179
p03663
C++
#include <iostream> #include <string> #include <map> #include <vector> #include <algorithm> #include <cmath> #include <cstdlib> #include <string> #include <sstream> using namespace std; #define REP(i,k,n) for(int i=k;i<n;i++) #define rep(i,n) for(int i=0;i<n;i++) #define all(v) v.begin(),v.end() #define INF 1<<30 #define mp make_pair #define pb push_back typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vp; typedef long long ll; int main(){ int MAX = 64; char buffer[sizeof(long) * 8 + 1]; string n; char ans; ll mi = pow(10, 17); ll ma = pow(10, 18)-1; ll mid; string check,lcheck; rep(i, MAX){ mid = (mi + ma) / 2; _i64toa_s(mid, buffer, sizeof(long) * 8 + 1, 10); stringstream s; s << buffer; string buff = s.str(); check = buff.substr(0, 10); if (check == lcheck && check[9] == '0'){ break; } lcheck = check; cout << "? " << buffer << endl; //cout << "@: " << i+1 << endl; cin >> ans; if (ans == 'Y'){ ma = mid; } else if(ans=='N'){ mi = mid; } } ll threshold = mid / pow(10, 8); //109 vs 1090 10901 : y y 1091 : y y 110 : y n //99 vs 990 9901:y y 991:y y 100: n : y //199 VS 1990 19901: y y 1991:y y 200: y n ll res = threshold; for (int i = 9; 0 < i; i--){ threshold = 1 + threshold / 10; cout << "? " << threshold << endl; cin >> ans; //99999の時の処理 if (threshold == pow(10, i)){ if (ans == 'Y'){ break; } if (ans == 'N'){ res /= 10; break; } } else{ if (ans == 'N'){ break; } } res /= 10; } /* _i64toa_s(mid, buffer, sizeof(long) * 8 + 1, 10); stringstream s; s << buffer; string buff=s.str(); string highest = ""; string res; rep(i,buff.size()-8){ highest += buff[i]; } for (int i = highest.size() - 1;; i--){ res = highest.substr(0, i); cout << "? " + res << endl; cin >> ans; if (ans == 'Y'){ break; } }*/ cout << "! "; cout << res << endl; return 0; }
a.cc: In function 'int main()': a.cc:42:17: error: '_i64toa_s' was not declared in this scope 42 | _i64toa_s(mid, buffer, sizeof(long) * 8 + 1, 10); | ^~~~~~~~~
s620019433
p03663
C++
#define _GLIBCXX_DEBUG #include <iostream> #include <cstdio> #include <bits/stdc++.h>//"geometry.cpp" #include <iomanip>//"cout<<fixed<<setprecision(n)<<sth<<endl;" #include <queue> #include <string> #include <vector> #include <utility> #include <set> #include <map> #include <algorithm>//"lower_bound(it,it,v)", "next_permutation(a,a+n)" #include <functional>//"greater<T>" Ex. sort(a,a+n,greater<int>()); #include <cmath>//"abs", "sqrt" using namespace std; #define pb push_back #define fi first #define sc second #define mp make_pair #define is insert typedef pair<int,int> pii;//Add other types in the same way. bool q(long long n){ for debuging above char ans; cout<<"? "<<n<<endl; cin>>ans; if(ans=='Y') return true; else return false; } int main(){ long long m=1; for(;m<=1000000000;m*=10){ if(!q(m)) break; } if(m==10000000000){ m=1; for(long long i=2;i<=2000000000;i*=10){ if(q(i)) break; m*=10; } cout<<"! "<<m<<endl; }else{ int lb=m/10,ub=m-1; while(ub-lb>1){ int mid=(lb+ub)/2; if(q(10*mid)){ ub=mid; }else{ lb=mid; } } cout<<"! "<<ub<<endl; } fflush(stdout); }
a.cc: In function 'bool q(long long int)': a.cc:24:13: error: expected '(' before 'debuging' 24 | for debuging above | ^~~~~~~~ | ( a.cc:24:13: error: 'debuging' was not declared in this scope 24 | for debuging above | ^~~~~~~~ a.cc:27:14: error: 'ans' was not declared in this scope; did you mean 'abs'? 27 | cin>>ans; | ^~~ | abs a.cc:27:17: error: expected ')' before ';' token 27 | cin>>ans; | ^ | ) a.cc:24:13: note: to match this '(' 24 | for debuging above | ^~~~~~~~ a.cc:28:12: error: 'ans' was not declared in this scope; did you mean 'abs'? 28 | if(ans=='Y') return true; | ^~~ | abs a.cc:30:1: warning: control reaches end of non-void function [-Wreturn-type] 30 | } | ^
s225061395
p03663
C++
#include <iostream> using namespace std; bool ask(int64_t a){ cout << "? " << a << endl; char c; cin >> c; return c == 'Y'; } void ans(int64_t a){ cout << "! " << a << endl; } int main(){ if(ask(1e9)){ int64_t a = 2; while(!ask(a)) a *= 10; ans(a / 2); }else{ int64_t a = 1e8; while(!ask(a)) a /= 10; int64_t l = a, r = a * 10; while(1 < r - l) (ask(mid * 10) ? l : r) = mid; ans(l); } }
a.cc: In function 'int main()': a.cc:24:39: error: 'mid' was not declared in this scope 24 | while(1 < r - l) (ask(mid * 10) ? l : r) = mid; | ^~~
s217453028
p03663
C++
#include <stdlib.h> #include <iostream> #include <sstream> #include <cmath> #define ll long long using namespace std; void ask(ll x){ cout << "? " << x << endl; fflush(stdout); } bool rec(){ char x; cin >> x; return (x == 'Y'); } ll main(){ //确定N是否为10^k bool is10; ask(1000000000); is10 = rec(); //确定位数 ll wei = 1; if(is10){ ask(2); ll a = 20; while(!rec()){ ask(a); a *= 10; wei++; } cout << "! " << a / 20 << endl; return 0; } ll l,r,mid; for(ll i = 0;i <= 18;i++){ ask(pow(10,i)); if(!rec()){ l = pow(10,i-1); r = pow(10,i); break; } } while(r - l > 1){ mid = (l + r) / 2; ask(mid * 10); if(rec()) r = mid; else l = mid; } cout << "! " << r << endl; return 0; }
cc1plus: error: '::main' must return 'int'
s188670400
p03663
C++
#include<algorithm> #include<cmath> #include<iomanip> #include<iostream> #include<map> #include<numeric> #include<queue> #include<set> #include<sstream> #include<unordered_map> #include<unordered_set> #include<vector> using namespace std; using uint = unsigned int; using ll = long long; const int M = 1e9 + 7; const ll MLL = 1e18L + 9; #pragma unused(M) #pragma unused(MLL) #ifdef LOCAL #include"rprint.hpp" #else template <ostream& out = cout, class... T> void prints(T&&...){ } template <ostream& out = cout, class... T> void printd(T&&...){ } template <ostream& out = cout, class... T> void printb(T&&...){ } template <ostream& out = cout, class... T> void printArr(T&&...){ } #endif int main(){ // stringstream ans; ll num = 0; int ke = 0; for(int i = 0; i <= 9; i++){ ke = i; ll a = pow(10ll, i); prints<cerr>('?', a); cout << "? " << a << endl; char ret; cin >> ret; if(ret == 'Y'){ }else{ break; } if(i == 9){ for(int i = 0; i <= 11; i++){ ke = i; ll a = pow(10ll, i + 1) - 1; cout << "? " << a << endl; char ret; cin >> ret; if(ret == 'Y'){ ke++; break; }else{ } } } } ke--; for(int i = ke; i >= 0; i--){ ll l = 0, r = 9; while(l < r){ // ll cand = (l + r + 1) / 2; ll cand = (l + r) / 2; // ll a = (cand + 1) * 10000000000 - 1;//, b = cand * 10000000000 - 1; ll a = num * pow(10ll, i + 2) + (cand + 1) * pow(10ll, i + 1) - 1;//, b = cand * 10000000000 - 1; // ll a = num * pow(10ll, i + 1) + (cand + 1) * pow(10ll, i + 0) - 1;//, b = cand * 10000000000 - 1; if(cand == 0 && ke == i){ // a++; a /= 10; } // ll a = num * pow(10ll, i + 2) + cand * pow(10ll, i + 1);//, b = cand * 10000000000 - 1; // ll a = cand;//, b = cand * 10000000000 - 1; if(a == 0){ cout << "! " << 1 << endl; return 0; } prints<cerr>('?', a); cout << "? " << a << endl; printde(l, r, num); char ret; cin >> ret; if(ret == 'Y'){ // r = cand - 1; // if(cand == 0){ // a--; // a /= 10; // cout << "? " << a << endl; // cin >> ret; // if(ret == 'N'){ // l = cand + 1; // goto hoge; // } // } r = cand; }else{ // l = cand; l = cand + 1; } // hoge: ; } // ans << l; num = num * 10 + l; } // cout << "! " << stoi(ans.str()) << '\n'; // cout << "! " << num + 1 << endl; // cout << "! " << num << endl; cout << "! " << (num ? num : 1) << endl; return 0; }
a.cc: In function 'int main()': a.cc:78:13: error: 'printde' was not declared in this scope; did you mean 'printd'? 78 | printde(l, r, num); | ^~~~~~~ | printd
s522658974
p03663
C++
#pragma region include #include <iostream> #include <iomanip> #include <stdio.h> #include <sstream> #include <algorithm> #include <cmath> #include <complex> #include <string> #include <cstring> #include <vector> #include <tuple> #include <bitset> #include <queue> #include <complex> #include <set> #include <map> #include <stack> #include <list> #include <fstream> #include <random> //#include <time.h> #include <ctime> #pragma endregion //#include ///////// #define REP(i, x, n) for(int i = x; i < n; ++i) #define rep(i,n) REP(i,0,n) ///////// #pragma region typedef typedef long long LL; typedef long double LD; typedef unsigned long long ULL; #pragma endregion //typedef ////定数 const int INF = (int)1e9; const LL MOD = (LL)1e9+7; const LL LINF = (LL)1e18; const double PI = acos(-1.0); const double EPS = 1e-9; ///////// using namespace::std; LL test = 120; string getString(LL num){ stringstream ss; ss << num; return ss.str(); } bool query(LL num){ cout << "? " << num << endl; //* string res; cin >> res; return (res[0]=='Y'); //*/ string tStr = getString( test ); string nStr = getString( num ); bool B1 = false; bool B2 = false; if( num <= test && nStr <= tStr ){ B1 = true; } if( num > test && nStr > tStr ){ B2 = true; } return B1^B2; } void pow10(){//10^n LL base = 2; while( query(base) == false ){ base *= 10; } cout << "! " << base/2 << endl; } void solve(){ int base = (int)1e9; if( query( base ) ){ pow10(); return; } //桁数の決定 int keta = 9; base /= 10; while( query( base ) == false ){ --keta; base /= 10; } //最上位桁の決定 int H,L; L = 1; H = 10; LL ket10 = powMod(10,keta-1); LL ans; while(H-L>1){ int mid = (L+H)/2; LL temp = mid*ket10; if( query( temp*10 ) ){ H = mid; }else{ L = mid; } } ans = L*ket10; --keta; ket10 /= 10; while( keta ){ L = 0; H = 10; while(H-L>1){ int mid = (L+H)/2; LL temp = (ans + mid*ket10) * 10; if( query( temp ) ){ H = mid; }else{ L = mid; } } if( keta > 1 ){ ans += L * ket10; }else{ ans += H; } --keta; ket10 /= 10; } cout << "! " << ans << endl; } #pragma region main signed main(void){ std::cin.tie(0); std::ios::sync_with_stdio(false); std::cout << std::fixed;//小数を10進数表示 cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別 solve(); } #pragma endregion //main()
a.cc: In function 'void solve()': a.cc:100:20: error: 'powMod' was not declared in this scope 100 | LL ket10 = powMod(10,keta-1); | ^~~~~~
s425758435
p03663
C++
#include<map> #include<set> #include<cmath> #include<queue> #include<stack> #include<vector> #include<cstdio> #include<cassert> #include<iomanip> #include<cstdlib> #include<cstring> #include<iostream> #include<algorithm> #define pi acos(-1) #define ll long long #define mod 1000000007 #define ls l,m,rt<<1 #define rs m+1,r,rt<<1|1 #pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-4; const int N=200000+10,maxn=500+100,inf=0x3f3f3f; int main() { ios::sync_with_stdio(false); cin.tie(0); int l=1,r=11; string s; while(l!=r){ int m=(l+r)/2; if(r-l==1)m=r; cout<<"? 1"<<string(m-1,'0')<<endl; cout.flush(); cin>>s; if(s[0]=='Y')l=m; else r=m-1; } if(l==11) { l=1,r=10; while(l!=r){ int m=(l+r)/2; if(r-l==1)m=r; cout<<"? 1"<<string(t-1,'0')<<endl; cout.flush(); cin>>s; if(s[0]=='Y')r=m; else l=m+1; } cout<<"! 1"<<string(l-1,'0')<<endl; return 0; } int ws=l; // cout<<ws<<endl; string ans=""; for(int i=1;i<=ws;i++) { l=(i==1? 1:0),r=10; while(l!=r){ int m=(l+r)/2; cout<<"? "<<ans<<(char)(m+'0')<<string(10-ans.size(),'9')<<endl; cout.flush(); cin>>s; if(s[0]=='N')l=m+1; else r=m; } ans+=(char)(l+'0'); } cout<<"! "<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:47:33: error: 't' was not declared in this scope 47 | cout<<"? 1"<<string(t-1,'0')<<endl; | ^
s044170292
p03663
C++
#include<algorithm> #include<cmath> #include<iomanip> #include<iostream> #include<map> #include<numeric> #include<queue> #include<set> #include<sstream> #include<unordered_map> #include<unordered_set> #include<vector> using namespace std; using uint = unsigned int; using ll = long long; const int M = 1e9 + 7; const ll MLL = 1e18L + 9; #pragma unused(M) #pragma unused(MLL) #ifdef LOCAL #include"rprint.hpp" #else template <ostream& out = cout, class... T> void prints(T&&...){ } template <ostream& out = cout, class... T> void printd(T&&...){ } template <ostream& out = cout, class... T> void printb(T&&...){ } template <ostream& out = cout, class... T> void printArr(T&&...){ } #endif int main(){ // stringstream ans; ll num = 0; int ke = 0; for(int i = 0; i <= 9; i++){ ke = i; ll a = pow(10ll, i); cout << "? " << a << endl; sleep(0); char ret; cin >> ret; if(ret == 'Y'){ }else{ break; } if(i == 9){ for(int i = 0; i <= 11; i++){ ke = i; ll a = pow(10ll, i + 1) - 1; cout << "? " << a << endl; char ret; cin >> ret; if(ret == 'Y'){ ke++; break; }else{ } } } } ke--; for(int i = ke; i >= 0; i--){ ll l = 0, r = 9; while(l < r){ // ll cand = (l + r + 1) / 2; ll cand = (l + r) / 2; // ll a = (cand + 1) * 10000000000 - 1;//, b = cand * 10000000000 - 1; ll a = num * pow(10ll, i + 2) + (cand + 1) * pow(10ll, i + 1) - 1;//, b = cand * 10000000000 - 1; // ll a = num * pow(10ll, i + 1) + (cand + 1) * pow(10ll, i + 0) - 1;//, b = cand * 10000000000 - 1; if(cand == 0){ // a++; a /= 10; } // ll a = num * pow(10ll, i + 2) + cand * pow(10ll, i + 1);//, b = cand * 10000000000 - 1; // ll a = cand;//, b = cand * 10000000000 - 1; if(a == 0){ cout << "! " << 1 << endl; return 0; } cout << "? " << a << endl; printd(l, r, num); char ret; cin >> ret; if(ret == 'Y'){ // r = cand - 1; // if(cand == 0){ // a--; // a /= 10; // cout << "? " << a << endl; // cin >> ret; // if(ret == 'N'){ // l = cand + 1; // goto hoge; // } // } r = cand; }else{ // l = cand; l = cand + 1; } // hoge: ; } // ans << l; num = num * 10 + l; } // cout << "! " << stoi(ans.str()) << '\n'; // cout << "! " << num + 1 << endl; cout << "! " << num << endl; return 0; }
a.cc: In function 'int main()': a.cc:37:9: error: 'sleep' was not declared in this scope 37 | sleep(0); | ^~~~~
s436924120
p03663
C++
#define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> using namespace std; #define DEBUG(x) cout << '>' << #x << ':' << x << endl; #define FOR0(i,n) for(int i=0, _##i=(n); i<_##i; ++i) #define FOR(i,l,r) for(int i=(l), _##i=(r); i<_##i; ++i) #define FORD(i,l,r) for(int i=(r), _##i=(l); --i>=_##i; ) #define repi(i,a) for(__typeof((a).begin()) i=(a).begin(), _##i=(a).end(); i!=_##i; ++i) #define dwni(i,a) for(__typeof((a).rbegin()) i=(a).rbegin(), _##i=(a).rend(); i!=_##i; ++i) #define SZ(a) ((int)((a).size())) #define printCase() "Case #" << caseNum << ": " #define pb push_back #define mp make_pair #define INF ((int)1e9) #define SYNC std::ios::sync_with_stdio(false); cin.tie(NULL); #define ff first #define ss second typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<int> vi; typedef vector<vi> vvi; bool check1(ll x) { char ans; cout << "? " << x << endl; fflush(stdout); cin >> ans; return (ans == 'Y'); } int main() { ll n = 1; while(1) { if(!check(n)) break; n *= 10; if(n > (ll)1e9) { ll z = 1; while(n) { if(!check(n)) { z = n; break; } else n/= 10; } cout << "! " << z << endl; return 0; } } ll r = n*10 - 1, l = n-1; while(l < r) { ll mid = (l+r) >> 1; if(check(mid)) { n = mid; r = mid - 1; } else l = mid + 1; } cout << "! " << n/10 << endl; fflush(stdout); return 0; }
a.cc: In function 'int main()': a.cc:34:13: error: 'check' was not declared in this scope; did you mean 'check1'? 34 | if(!check(n)) break; | ^~~~~ | check1 a.cc:39:21: error: 'check' was not declared in this scope; did you mean 'check1'? 39 | if(!check(n)) { | ^~~~~ | check1 a.cc:52:12: error: 'check' was not declared in this scope; did you mean 'check1'? 52 | if(check(mid)) { | ^~~~~ | check1
s685757420
p03663
C++
#define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> using namespace std; #define DEBUG(x) cout << '>' << #x << ':' << x << endl; #define FOR0(i,n) for(int i=0, _##i=(n); i<_##i; ++i) #define FOR(i,l,r) for(int i=(l), _##i=(r); i<_##i; ++i) #define FORD(i,l,r) for(int i=(r), _##i=(l); --i>=_##i; ) #define repi(i,a) for(__typeof((a).begin()) i=(a).begin(), _##i=(a).end(); i!=_##i; ++i) #define dwni(i,a) for(__typeof((a).rbegin()) i=(a).rbegin(), _##i=(a).rend(); i!=_##i; ++i) #define SZ(a) ((int)((a).size())) #define printCase() "Case #" << caseNum << ": " #define pb push_back #define mp make_pair #define INF ((int)1e9) #define SYNC std::ios::sync_with_stdio(false); cin.tie(NULL); #define ff first #define ss second typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<int> vi; typedef vector<vi> vvi; bool check1(ll x) { char ans; cout << "? " << x << endl; fflush(stdout); cin >> ans; return (ans == 'Y'); } int main() { ll n = 1; while(1) { if(!check(n)) break; n *= 10; if(n > (ll)1e9) { ll z = 1; while(n) { if(!check(n)) { z = n; break; } else n/= 10; } cout << "! " << z << endl; return 0; } } ll r = n*10 - 1, l = n-1; while(l < r) { ll mid = (l+r) >> 1; if(check(mid)) { n = mid; r = mid - 1; } else l = mid + 1; } cout << "! " << n/10 << endl; fflush(stdout); return 0; }
a.cc: In function 'int main()': a.cc:34:13: error: 'check' was not declared in this scope; did you mean 'check1'? 34 | if(!check(n)) break; | ^~~~~ | check1 a.cc:39:21: error: 'check' was not declared in this scope; did you mean 'check1'? 39 | if(!check(n)) { | ^~~~~ | check1 a.cc:52:12: error: 'check' was not declared in this scope; did you mean 'check1'? 52 | if(check(mid)) { | ^~~~~ | check1
s858954802
p03663
C++
#define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> using namespace std; #define DEBUG(x) cout << '>' << #x << ':' << x << endl; #define FOR0(i,n) for(int i=0, _##i=(n); i<_##i; ++i) #define FOR(i,l,r) for(int i=(l), _##i=(r); i<_##i; ++i) #define FORD(i,l,r) for(int i=(r), _##i=(l); --i>=_##i; ) #define repi(i,a) for(__typeof((a).begin()) i=(a).begin(), _##i=(a).end(); i!=_##i; ++i) #define dwni(i,a) for(__typeof((a).rbegin()) i=(a).rbegin(), _##i=(a).rend(); i!=_##i; ++i) #define SZ(a) ((int)((a).size())) #define printCase() "Case #" << caseNum << ": " #define pb push_back #define mp make_pair #define INF ((int)1e9) #define SYNC std::ios::sync_with_stdio(false); cin.tie(NULL); #define ff first #define ss second typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<int> vi; typedef vector<vi> vvi; bool check1(ll x) { char ans; cout << "? " << x << endl; fflush(stdout); cin >> ans; return (ans == 'Y'); } int main() { ll n = 1; while(1) { if(!check(n)) break; n *= 10; if(n > (ll)1e9) { ll z = 1; while(n) { if(!check(n)) { z = n; break; } else n/= 10; } cout << "! " << z << endl; return 0; } } ll r = n*10 - 1, l = n-1; while(l < r) { ll mid = (l+r) >> 1; if(check(mid)) { n = mid; r = mid - 1; } else l = mid + 1; } cout << "! " << n/10 << endl; fflush(stdout); return 0; }
a.cc: In function 'int main()': a.cc:34:13: error: 'check' was not declared in this scope; did you mean 'check1'? 34 | if(!check(n)) break; | ^~~~~ | check1 a.cc:39:21: error: 'check' was not declared in this scope; did you mean 'check1'? 39 | if(!check(n)) { | ^~~~~ | check1 a.cc:52:12: error: 'check' was not declared in this scope; did you mean 'check1'? 52 | if(check(mid)) { | ^~~~~ | check1
s564992628
p03663
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll Ten(int x){ ll ret=1; while( x-- )ret*=10ll; return ret; } int ask(ll n){ n=max(n,1); cout<<"? "<<n<<endl; cout.flush(); char c; cin>>c; return c=='Y'; } int main(){ int len=0; while( ask(Ten(len)) )len++;len--; ll num=0; for(int i=0;i<len;i++){ int low = (i==0) , high = 9 ; while( low < high ){ int mid = low+high+1>>1; if( ask( num*10 + mid ) )low=mid; else high=mid-1; } num=num*10ll+low; } for(int mid=0;mid<10;mid++) if( ask(num*100ll+mid*10ll+9ll) ){ cout<<"! "<<num*10ll+mid*1ll<<endl; cout.flush(); return 0; } }
a.cc: In function 'int ask(ll)': a.cc:12:10: error: no matching function for call to 'max(ll&, int)' 12 | n=max(n,1); | ~~~^~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:12:10: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 12 | n=max(n,1); | ~~~^~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:12:10: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 12 | n=max(n,1); | ~~~^~~~~
s533023984
p03663
C++
#include<bits/stdc++.h> const int N = 11; typedef long long ll; char s[N]; int ans[N]; bool query(ll n){ printf("? %lld\n", n); fflush(stdout); scanf("%s", s); return s[0] == 'Y'; } ll power[N]; int main(){ power[0] = 1; for (int i = 1; i < N; ++ i){ power[i] = power[i - 1] * 10; } bool flag = query(power[N - 1]); int sit = 0; for (int i = 1; i < N; ++ i){ if (flag && sit){ break; } if (query(power[i - 1]) && query(power[i] - 1)){ sit = i; } } for (int i = 0; i < sit - 1; ++ i){ ll x = 0; for (int j = 0; j < i; ++ j){ x += ans[j] * power[i - j]; } int left = len == 1, right = 9; for (int mid = left + right + 1 >> 1; left < right; mid = left + right + 1 >> 1){ if (query(x + mid)){ left = mid; } else{ right = mid - 1; } } ans[i] = left; } ll x = 0; for (int i = 0; i < sit - 1; ++ i){ x += ans[i] * power[sit - i]; } int left = len == 1, right = 9; for (int mid = left + right >> 1; left < right; mid = left + right >> 1){ if (query(x + mid * 10)){ right = mid; } else{ left = mid + 1; } } ans[sit - 1] = left; printf("! "); for (int i = 0; i < sit; ++ i){ printf("%d", ans[i]); } return printf("\n"), 0; }
a.cc: In function 'int main()': a.cc:38:28: error: 'len' was not declared in this scope 38 | int left = len == 1, right = 9; | ^~~ a.cc:39:39: error: 'right' was not declared in this scope; did you mean 'std::right'? 39 | for (int mid = left + right + 1 >> 1; left < right; mid = left + right + 1 >> 1){ | ^~~~~ | std::right In file included from /usr/include/c++/14/streambuf:43, from /usr/include/c++/14/bits/streambuf_iterator.h:35, from /usr/include/c++/14/iterator:66, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54, from a.cc:1: /usr/include/c++/14/bits/ios_base.h:1070:3: note: 'std::right' declared here 1070 | right(ios_base& __base) | ^~~~~ a.cc:53:20: error: 'len' was not declared in this scope 53 | int left = len == 1, right = 9; | ^~~ a.cc:54:31: error: 'right' was not declared in this scope; did you mean 'std::right'? 54 | for (int mid = left + right >> 1; left < right; mid = left + right >> 1){ | ^~~~~ | std::right /usr/include/c++/14/bits/ios_base.h:1070:3: note: 'std::right' declared here 1070 | right(ios_base& __base) | ^~~~~
s404820381
p03663
C++
#include <bits/stdc++.h> #define _overload(_1,_2,_3,name,...) name #define _rep(i,n) _range(i,0,n) #define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i) #define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__) #define _rrep(i,n) _rrange(i,n,0) #define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i) #define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__) #define _all(arg) begin(arg),end(arg) #define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg)) #define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary) #define clr(a,b) memset((a),(b),sizeof(a)) #define bit(n) (1LL<<(n)) // #define DEBUG #ifdef DEBUG #define dump(...) fprintf(stderr, __VA_ARGS__) #else #define dump(...) #endif template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;} template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;} using namespace std; using ll=long long; using vi=vector<int>; using vll=vector<ll>; const double EPS = 1e-10; const double PI = acos(-1.0); const ll inf =1LL << 62; const ll mod=1000000007LL; const int dx[4]={1,0,-1,0}; const int dy[4]={0,1,0,-1}; ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;} ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;} ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;} ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;} ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);} random_device rd; mt19937 mt(rd()); uniform_int_distribution<int> dice(1,6); uniform_real_distribution<double> score(0.0,10.0); int main(void){ cin.tie(0); ios::sync_with_stdio(false); string res = ""; const int D = 9; bool fst = true; rep(i, D){ int lb = 1, ub = 10; rep(loop, 5){ int mid = (lb + ub) / 2; if(res == "" and mid == 0) break; string cur = res + (char)(mid + '0') + string(16 - (int)res.size(), '9'); cout << "? " << cur << endl << flush; string ret; cin >> ret; if(ret == "N"){ lb = mid; ok = true; } else { assert(ret == "Y"); ub = mid; } } if(not ok) lb = 0; if(fst and lb == 0) continue; res += ('0' + lb); fst = false; cout << "? " << res + '0' << endl << flush; string ho; cin >> ho; if(ho == "N") break; } cout << "! " << res << endl << flush; return 0; }
a.cc: In function 'int main()': a.cc:72:17: error: 'ok' was not declared in this scope 72 | ok = true; | ^~ a.cc:80:16: error: 'ok' was not declared in this scope 80 | if(not ok) lb = 0; | ^~
s504349198
p03663
C++
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define ls rt << 1 #define rs rt << 1 | 1 #define mp make_pair #define pb push_back #define pii pair<int, int> #define X first #define Y second #define pcc pair<char, char> #define rep(i, x, y) for(int i = x; i <= y; i ++) #define eps 1e-9 using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } int main() { LL l, r, mid, no, wei; string res; for(no = 0, wei = 100000000000000000LL; ; wei /= 10) { l = (no ? 0 : 1), r = 9; while(l < r) { mid = (l + r) >> 1; cout << "? " << (no * 10 + mid + 1) * wei - 1 << flush; cin >> res; if(res[0] == 'Y') r = mid; else l = mid + 1; } no = no * 10 + r; cout << "? " << no * wei << flush; cin >> res; if(res[0] == 'Y') { if(no == 1) for(wei = 1;; wei *= 10) { cout << "? " << wei + 1 << flush; cin >> res; if(res[0] == 'Y') { cout << "! " << wei << flush; return 0; } } for(wei = 1;; wei *= 10) { cout << "? " << (no - 1) * wei << flush; cin >> res; if(res[0] == 'N') break; } cout << "! " << no * wei / 10 << flush; return 0; } } return 0; }
a.cc: In function 'int main()': a.cc:24:9: error: 'LL' was not declared in this scope; did you mean 'll'? 24 | LL l, r, mid, no, wei; | ^~ | ll a.cc:26:13: error: 'no' was not declared in this scope 26 | for(no = 0, wei = 100000000000000000LL; ; wei /= 10) | ^~ a.cc:26:21: error: 'wei' was not declared in this scope 26 | for(no = 0, wei = 100000000000000000LL; ; wei /= 10) | ^~~ a.cc:28:17: error: 'l' was not declared in this scope 28 | l = (no ? 0 : 1), r = 9; | ^ a.cc:28:35: error: 'r' was not declared in this scope; did you mean 'rs'? 28 | l = (no ? 0 : 1), r = 9; | ^ | rs a.cc:31:25: error: 'mid' was not declared in this scope 31 | mid = (l + r) >> 1; | ^~~
s401553334
p03663
C++
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define ls rt << 1 #define rs rt << 1 | 1 #define mp make_pair #define pb push_back #define pii pair<int, int> #define X first #define Y second #define pcc pair<char, char> #define rep(i, x, y) for(int i = x; i <= y; i ++) #define eps 1e-9 using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } int main() { LL l, r, mid, no, wei; string res; for(no = 0, wei = 100000000000000000LL; ; wei /= 10) { l = (no ? 0 : 1), r = 9; while(l < r) { mid = (l + r) >> 1; cout << "? " << (no * 10 + mid + 1) * wei - 1 << endl << flush; cin >> res; if(res[0] == 'Y') r = mid; else l = mid + 1; } no = no * 10 + r; cout << "? " << no * wei << endl << flush; cin >> res; if(res[0] == 'Y') { if(no == 1) for(wei = 1;; wei *= 10) { cout << "? " << wei + 1 << endl << flush; cin >> res; if(res[0] == 'Y') { cout << "! " << wei << endl << flush; return 0; } } for(wei = 1;; wei *= 10) { cout << "? " << (no - 1) * wei << endl << flush; cin >> res; if(res[0] == 'N') break; } cout << "! " << no * wei / 10 << endl << flush; return 0; } } return 0; }
a.cc: In function 'int main()': a.cc:24:9: error: 'LL' was not declared in this scope; did you mean 'll'? 24 | LL l, r, mid, no, wei; | ^~ | ll a.cc:26:13: error: 'no' was not declared in this scope 26 | for(no = 0, wei = 100000000000000000LL; ; wei /= 10) | ^~ a.cc:26:21: error: 'wei' was not declared in this scope 26 | for(no = 0, wei = 100000000000000000LL; ; wei /= 10) | ^~~ a.cc:28:17: error: 'l' was not declared in this scope 28 | l = (no ? 0 : 1), r = 9; | ^ a.cc:28:35: error: 'r' was not declared in this scope; did you mean 'rs'? 28 | l = (no ? 0 : 1), r = 9; | ^ | rs a.cc:31:25: error: 'mid' was not declared in this scope 31 | mid = (l + r) >> 1; | ^~~
s923293743
p03663
C++
#include <iostream> #include <fstream> #include <string> #include <vector> #include <algorithm> #include <assert.h> using namespace std; // string s1 = "1000000"; // long v1 = 55; bool get(){ string str; cin >> str; return str=="Y"; } bool ask(string str){ cout << "? " << str << endl; return get(); // cout << "ASK " << str << " " << ((stol(str)<=v1) == (str<=s1)) << endl; // return (stol(str)<=v1) == (str<=s1); } bool ret(string str){ cout << "! " << str << endl; } int main() { std::ios::sync_with_stdio(false); long asks = 0; vector<string> nums; for(long i = 0; i<10; i++){ string str = to_string(i); nums.push_back(str); } string prefix = ""; while(true){ string post = "00"; if(prefix.length()==0){ post = "10"; } asks++; assert(asks<=64); if(!ask(prefix+post)){ long low = 1; if(prefix.length()>0){ low = 0; } long high = 9; while(low<high){ long mid = (low+high)/2; asks++; assert(asks<=64); if(ask(prefix + to_string(mid) + to_string(mid))){ high = mid; } else{ low = mid+1; } } prefix += to_string(low); break; } else{ bool askedFirst = false; bool firstRes = false; long low = 1; if(prefix.length()>0){ low = 0; } asks++; assert(asks<=64); string x = ask(prefix+to_string(low); while(x.length()<15){ x = x+"0"; } if(ask(x))){ asks++; assert(asks<=64); askedFirst = true; firstRes = false; if(ask(prefix+"5")){ prefix += to_string(low); break; } else{ prefix += to_string(low); continue; } } long high = 9; while(low<high){ long mid = (low+high+1)/2; if(askedFirst){ askedFirst = false; if(firstRes){ low = mid; } else{ high = mid-1; } continue; } asks++; assert(asks<=64); if(ask(prefix+to_string(mid))){ low = mid; } else{ high = mid-1; } } prefix += to_string(low); } } ret(prefix); return 0; }
a.cc: In function 'bool ret(std::string)': a.cc:23:1: warning: no return statement in function returning non-void [-Wreturn-type] 23 | } | ^ a.cc: In function 'int main()': a.cc:72:49: error: expected ')' before ';' token 72 | string x = ask(prefix+to_string(low); | ~ ^ | ) a.cc:76:23: error: expected primary-expression before ')' token 76 | if(ask(x))){ | ^
s147062979
p03663
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define fi first #define se second #define mp make_pair #define pb push_back #define sz(x) ((int)(x).size()) #define all(x) (x).begin(),(x).end() #define rep(i,l,r) for(int i=(l);i<(r);++i) //------- char ch; int qry(ll n) { cout << "? " << n << endl; fflush(); cin >> ch; return ch == 'Y'; } ll kpow(ll a, ll b) { ll r = 1; while (b > 0) { if (b & 1) r = r * a; a = a * a, b >>= 1; } return r; } bool check() { rep(i, 0, 10) if (!qry(kpow(10, i))) return false; return true; } int len() { rep(i, 2, 11) if (!qry(kpow(10, i))) return i - 1; } int main() { if (check()) { rep(p, 0, 10) if (qry(kpow(10, p + 1) - 1)) { cout << "! " << kpow(10, p) << endl; break; } } else { int L = len(); ll pre = 0; rep(i, 0, L - 1) { int l = 0, r = 9; while (l + 1 < r) { int m = (l + r) >> 1; !qry(pre * 10 + m) ? r = m - 1 : l = m; } int x; if (l == r) { x = l; } else { x = qry(pre * 10 + r) ? r : l; } pre = pre * 10 + x; } int l = 0, r = 9; while (l + 1 < r) { int m = (l + r) >> 1; !qry(pre * 100 + m * 10) ? l = m + 1 : r = m; } int x; if (l == r) { x = l; } else { x = qry(pre * 100 + r * 10) ? r : l; } pre = pre * 10 + x; cout << "! " << pre << endl; } return 0; }
a.cc: In function 'int qry(ll)': a.cc:15:15: error: too few arguments to function 'int fflush(FILE*)' 15 | fflush(); | ~~~~~~^~ In file included from /usr/include/c++/14/cstdio:42, from /usr/include/c++/14/ext/string_conversions.h:45, from /usr/include/c++/14/bits/basic_string.h:4154, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:1: /usr/include/stdio.h:236:12: note: declared here 236 | extern int fflush (FILE *__stream); | ^~~~~~ a.cc: In function 'int len()': a.cc:37:1: warning: control reaches end of non-void function [-Wreturn-type] 37 | } | ^
s785923323
p03663
C++
#include <iostream> #include <fstream> #include <string> #include <vector> #include <algorithm> #include <assert.h> using namespace std; // string s1 = "1000000"; // long v1 = 55; bool get(){ string str; cin >> str; return str=="Y"; } bool ask(string str){ // cout << "? " << str << endl; // return get(); cout << "ASK " << str << " " << ((stol(str)<=v1) == (str<=s1)) << endl; return (stol(str)<=v1) == (str<=s1); } bool ret(string str){ cout << "! " << str << endl; } int main() { std::ios::sync_with_stdio(false); long asks = 0; vector<string> nums; for(long i = 0; i<10; i++){ string str = to_string(i); nums.push_back(str); } string prefix = ""; while(true){ string post = "00"; if(prefix.length()==0){ post = "10"; } asks++; assert(asks<=64); if(!ask(prefix+post)){ long low = 1; if(prefix.length()>0){ low = 0; } long high = 9; while(low<high){ long mid = (low+high)/2; asks++; assert(asks<=64); if(ask(prefix + to_string(mid) + to_string(mid))){ high = mid; } else{ low = mid+1; } } prefix += to_string(low); break; } else{ bool askedFirst = false; bool firstRes = false; long low = 1; if(prefix.length()>0){ low = 0; } asks++; assert(asks<=64); string x = ask(prefix+to_string(low); while(x.length()<15){ x = x+"0"; } if(ask(x))){ asks++; assert(asks<=64); askedFirst = true; firstRes = false; if(ask(prefix+"5")){ prefix += to_string(low); break; } else{ prefix += to_string(low); continue; } } long high = 9; while(low<high){ long mid = (low+high+1)/2; if(askedFirst){ askedFirst = false; if(firstRes){ low = mid; } else{ high = mid-1; } continue; } asks++; assert(asks<=64); if(ask(prefix+to_string(mid))){ low = mid; } else{ high = mid-1; } } prefix += to_string(low); } } ret(prefix); return 0; }
a.cc: In function 'bool ask(std::string)': a.cc:18:50: error: 'v1' was not declared in this scope; did you mean '__pstl::execution::v1'? 18 | cout << "ASK " << str << " " << ((stol(str)<=v1) == (str<=s1)) << endl; | ^~ | __pstl::execution::v1 In file included from /usr/include/c++/14/pstl/glue_algorithm_defs.h:15, from /usr/include/c++/14/algorithm:86, from a.cc:5: /usr/include/c++/14/pstl/execution_defs.h:19:18: note: '__pstl::execution::v1' declared here 19 | inline namespace v1 | ^~ a.cc:18:63: error: 's1' was not declared in this scope 18 | cout << "ASK " << str << " " << ((stol(str)<=v1) == (str<=s1)) << endl; | ^~ a.cc: In function 'bool ret(std::string)': a.cc:23:1: warning: no return statement in function returning non-void [-Wreturn-type] 23 | } | ^ a.cc: In function 'int main()': a.cc:72:49: error: expected ')' before ';' token 72 | string x = ask(prefix+to_string(low); | ~ ^ | ) a.cc:76:23: error: expected primary-expression before ')' token 76 | if(ask(x))){ | ^
s336160350
p03663
C++
#include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include <algorithm> #include <vector> using namespace std; #define pb push_back #define ri(x) scanf("%d",&x) #define rii(x,y) ri(x),ri(y) #define ms(obj,val) memset(obj,val,sizeof(obj)) #define ms2(obj,val,sz) memset(obj,val,sizeof(obj[0])*sz) #define FOR(i,f,t) for(int i=f;i<(int)t;i++) #define FORR(i,f,t) for(int i=f;i>(int)t;i--) typedef long long ll; typedef vector<int> vi; const int MAXN=0; ll lo, hi; bool check1(int d) { ll n = 0; char t; FOR(i,0,d) n = 10*n + 9; printf("? %lld\n",n); fflush(stdout); scanf("%c\n",t); return t == 'Y'; } bool check1(int d) { ll n = 0; char t; FOR(i,0,d) n = 10*n + 9; printf("? %lld\n",n); fflush(stdout); scanf("%c\n",t); return t == 'Y'; } bool check3(int d) { ll n = 0; char t; FOR(i,0,d) n = 10*n + 9; printf("? %lld\n",n); fflush(stdout); scanf("%c\n",t); return t == 'Y'; } int main() { lo = 1, hi = 18; while(lo < hi) { int med = (lo+hi) / 2; if(check1(med)) hi = med; else lo = med + 1; } int l = lo; lo = 0; FOR(i,0,l) lo *= 10; hi = lo * 10; while(lo < hi) { int med = (lo+hi+1) / 2; if(check2(med)) lo = med; else hi = med - 1; } printf("? %lld\n",n); fflush(stdout); scanf("%c\n",t); if(t == 'Y') printf("! %lld\n",lo); else { lo = 1, hi = 18; while(lo < hi) { int med = (lo+hi+1) / 2; if(check3(med)) lo = med; else hi = med - 1; } } }
a.cc:34:6: error: redefinition of 'bool check1(int)' 34 | bool check1(int d) { | ^~~~~~ a.cc:24:6: note: 'bool check1(int)' previously defined here 24 | bool check1(int d) { | ^~~~~~ a.cc: In function 'int main()': a.cc:67:20: error: 'check2' was not declared in this scope; did you mean 'check3'? 67 | if(check2(med)) lo = med; | ^~~~~~ | check3 a.cc:70:27: error: 'n' was not declared in this scope 70 | printf("? %lld\n",n); | ^ a.cc:72:22: error: 't' was not declared in this scope 72 | scanf("%c\n",t); | ^
s106579181
p03663
C++
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define ls rt << 1 #define rs rt << 1 | 1 #define mp make_pair #define pb push_back #define pii pair<int, int> #define X first #define Y second #define pcc pair<char, char> #define rep(i, x, y) for(int i = x; i <= y; i ++) #define eps 1e-9 using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } int main() { rep(i,1,9) ans[i] = 0; rep(bit,1,9) { int l = (bit==1?1:0), r = 9, mid, pos; while(l <= r) { mid = l + r >> 1; ans[bit] = mid; cur = 0; rep(i,1,bit) cur = cur*10+ans[i]; printf("? %d\n",cur);fflush(stdout); scanf("%s",ch); fflush(stdout); if(ch[0]=='N') { r = mid - 1; } else { ans[bit+1] = 9; cur = 0; rep(i,1,bit+1) cur = cur*10+ans[i]; printf("? %d\n",cur);fflush(stdout); scanf("%s",ch); fflush(stdout); if(ch[0]=='Y') {l = mid + 1; pos = mid;} else {r = mid - 1;} } } ans[bit] = pos; } cur = 0; rep(i,1,9) cur = cur*10+ans[i]; printf("! %d\n",cur); fflush(stdout); return 0; }
a.cc: In function 'int main()': a.cc:24:20: error: 'ans' was not declared in this scope; did you mean 'abs'? 24 | rep(i,1,9) ans[i] = 0; | ^~~ | abs a.cc:31:25: error: 'ans' was not declared in this scope; did you mean 'abs'? 31 | ans[bit] = mid; cur = 0; | ^~~ | abs a.cc:31:41: error: 'cur' was not declared in this scope 31 | ans[bit] = mid; cur = 0; | ^~~ a.cc:33:73: error: 'ch' was not declared in this scope 33 | printf("? %d\n",cur);fflush(stdout); scanf("%s",ch); fflush(stdout); | ^~ a.cc:47:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 47 | ans[bit] = pos; | ^~~ | abs a.cc:49:9: error: 'cur' was not declared in this scope 49 | cur = 0; | ^~~ a.cc:50:33: error: 'ans' was not declared in this scope; did you mean 'abs'? 50 | rep(i,1,9) cur = cur*10+ans[i]; | ^~~ | abs
s075620173
p03663
C++
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define ls rt << 1 #define rs rt << 1 | 1 #define mp make_pair #define pb push_back #define pii pair<int, int> #define X first #define Y second #define pcc pair<char, char> #define rep(i, x, y) for(int i = x; i <= y; i ++) #define eps 1e-9 using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } int main() { rep(i,1,9) ans[i] = 0; rep(bit,1,9) { int l = (bit==1?1:0), r = 9, mid, pos; while(l <= r) { mid = l + r >> 1; ans[bit] = mid; cur = 0; rep(i,1,bit) cur = cur*10+ans[i]; printf("? %d\n",cur);fflush(stdout); scanf("%s",ch); fflush(stdout); if(ch[0]=='N') { r = mid - 1; } else { ans[bit+1] = 9; cur = 0; rep(i,1,bit+1) cur = cur*10+ans[i]; printf("? %d\n",cur);fflush(stdout); scanf("%s",ch); fflush(stdout); if(ch[0]=='Y') {l = mid + 1; pos = mid;} else {r = mid - 1;} } } ans[bit] = pos; } cur = 0; rep(i,1,9) cur = cur*10+ans[i]; printf("! %d\n",cur); fflush(stdout); return 0; }
a.cc: In function 'int main()': a.cc:24:20: error: 'ans' was not declared in this scope; did you mean 'abs'? 24 | rep(i,1,9) ans[i] = 0; | ^~~ | abs a.cc:31:25: error: 'ans' was not declared in this scope; did you mean 'abs'? 31 | ans[bit] = mid; cur = 0; | ^~~ | abs a.cc:31:41: error: 'cur' was not declared in this scope 31 | ans[bit] = mid; cur = 0; | ^~~ a.cc:33:73: error: 'ch' was not declared in this scope 33 | printf("? %d\n",cur);fflush(stdout); scanf("%s",ch); fflush(stdout); | ^~ a.cc:47:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 47 | ans[bit] = pos; | ^~~ | abs a.cc:49:9: error: 'cur' was not declared in this scope 49 | cur = 0; | ^~~ a.cc:50:33: error: 'ans' was not declared in this scope; did you mean 'abs'? 50 | rep(i,1,9) cur = cur*10+ans[i]; | ^~~ | abs
s767749273
p03663
C++
#include <bits/stdc++.h> using namespace std; const long long MOD=1e9+7; const double PI=3.14159265359; long long getLead(){ long long nines=1e11-1ll, mult=1e11; cout<<nines<<endl; long long l=1, r=9; while(l+1<r){ long long mid=(l+r)/2; cout<<"? ""<<mid*mult+nines<<endl; fflush(stdout); char c; cin>>c; if(c=='Y'){ r=mid; } else{ l=mid; } } return l; } pair<int,int> getLength(){ long long ub=getLead(); int lead=(int)ub; bool found=false for(int i=2; i<=10 && !found; i++){ ub*=10; cout<<"? "<<ub<<endl; fflush(stdout); char c; cin>>c; if(c=='N'){ return make_pair(i-1,lead); } } } string getAns(){ auto p=getLength(); int len=p.first,lead=p.second; string ans=to_string(lead); for(int i=0; i<len-1; i++){ int l=0, int r=9; while(l+1<r){ int mid=(l+r)/2; cout<<"? "<<ans<<mid; fflush(stdout); char c; cin>>c; if(c=='Y'){ l=mid; } else{ r=mid; } } ans+=to_string(l); } return ans; } int main() { /* ios_base::sync_with_stdio(0); cin.tie(0); */ cout<<"! "<<getAns(); return 0; }
a.cc:16:19: warning: missing terminating " character 16 | cout<<"? ""<<mid*mult+nines<<endl; | ^ a.cc:16:19: error: missing terminating " character 16 | cout<<"? ""<<mid*mult+nines<<endl; | ^~~~~~~~~~~~~~~~~~~~~~~~ a.cc: In function 'long long int getLead()': a.cc:16:19: error: expected ';' before 'fflush' 16 | cout<<"? ""<<mid*mult+nines<<endl; | ^ | ; 17 | fflush(stdout); | ~~~~~~ a.cc: In function 'std::pair<int, int> getLength()': a.cc:36:5: error: expected ',' or ';' before 'for' 36 | for(int i=2; i<=10 && !found; i++){ | ^~~ a.cc:36:18: error: 'i' was not declared in this scope 36 | for(int i=2; i<=10 && !found; i++){ | ^ a.cc:46:1: warning: no return statement in function returning non-void [-Wreturn-type] 46 | } | ^ a.cc: In function 'std::string getAns()': a.cc:53:18: error: expected unqualified-id before 'int' 53 | int l=0, int r=9; | ^~~ a.cc:54:19: error: 'r' was not declared in this scope 54 | while(l+1<r){ | ^
s992725442
p03663
C++
#include <bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef pair<int, int> ii; typedef long long ll; typedef pair<long long, long long> l4; typedef vector<long long> vll; typedef double db; typedef vector<double> vdb; typedef pair<double, double> dd; typedef set<int> si; typedef set<long long> sll; #define fi first #define se second #define matrix(a) vector< vector<a> > #define sz(a) int((a).size()) #define lop(i,a,b) for (int i=a; i<=b; i++) #define vlop(i,v) lop(i,0,sz(v)-1) #define vlop1(i,v) lop(i,1,sz(v)-1) #define rlop(i,a,b) for (int i=b; i>=a; i--) #define vrlop(i,v) rlop(i,0,sz(v)-1) #define vrlop1(i,v) rlop(i,1,sz(v)-1) #define printv(i,v) vlop(i,v)cout<<v[i]<<" " #define printv1(i,v) vlop1(i,v)cout<<v[i]<<" " #define all(s) (s).begin(),(s).end() #define pb push_back #define enter cout<<'\n' #define lb(i,v) int(lower_bound(all(v),i)-v.begin()) #define ub(i,v) int(upper_bound(all(v),i)-v.begin()) int main() { ll n=1; string ans; while(n<=1e9){ cout<<"? "<<n<<'\n'; fflush(stdout); cin>>ans; if(ans[0]=='N')break; n*=10; } if(n==1e10){ n=1; while(n<=1e9){ cout<<"? "<<n+1<<'\n'; fflush(stdout); cin>>ans; if(ans[0]=='Y')break; n*=10; } cout<<"! "<<n; } else{ LL l=n/10+1,u=n-1,med; while(l<u){ med=(l+u)/2; cout<<"? "<<med*10<<'\n'; fflush(stdout); cin>>ans; if(ans[0]=='Y')u=med; else l=med+1; } cout<<"! "<<l; } return 0; }
a.cc: In function 'int main()': a.cc:54:13: error: 'LL' was not declared in this scope; did you mean 'll'? 54 | LL l=n/10+1,u=n-1,med; | ^~ | ll a.cc:55:19: error: 'l' was not declared in this scope 55 | while(l<u){ | ^ a.cc:55:21: error: 'u' was not declared in this scope 55 | while(l<u){ | ^ a.cc:56:17: error: 'med' was not declared in this scope 56 | med=(l+u)/2; | ^~~ a.cc:63:25: error: 'l' was not declared in this scope 63 | cout<<"! "<<l; | ^
s704011182
p03663
C++
#include <stdio.h> #include <algorithm> using namespace std; using ll = long long; void A(ll x) { printf("! %lld\n", x); fflush(stdout); } bool Q(ll x) { printf("? %lld\n", x); fflush(stdout); char R[2]; scanf("%s", R); return R[0] == 'Y'; } int main() { ll value; { ll up = 10, down = 0, center = (up + down) / 2; while (2 <= up - down) { if (Q(center)) down = center; else up = center; center = (up + down) / 2; } value = center * 10; } while (true) { if (!Q(value)) { value /= 10; break; } ll up = 10, down = 0, center = (up + down) / 2; while (2 <= up - down) { if (Q(value + center)) down = center; else up = center; center = (up + down) / 2; } value = (value + center) * 10; } A(value); return; }
a.cc: In function 'int main()': a.cc:45:9: error: return-statement with no value, in function returning 'int' [-fpermissive] 45 | return; | ^~~~~~
s096152471
p03663
C++
#include <bits/stdc++.h> using namespace std; typedef long long LL; inline bool query(const LL& n) { printf("? %I64d\n",n); char x[4]; scanf("%s",x); return x[0]=='Y'; } inline bool query(const char* s) { printf("? %s\n",s); char x[4]; scanf("%s",x); return x[0]=='Y'; } inline int getlen() { int l=1,r=10; while (l<r) { int mid=(l+r+1)/2; LL x=1; for (int i=1;i<mid;++i) x=x*10; bool f=query(x); if (!f) r=mid-1;else l=mid; } return l; } inline LL getnum(const int& len) { char str[len+3]; for (int i=0;i<len+3;++i) str[i]=0; for (int i=0;i<len-1;++i) { int l=0,r=9; while (l<r) { int mid=(l+r+1)/2; str[i]='0'+mid; bool f=query(str); if (!f) r=mid-1;else l=mid; } str[i]='0'+l; } str[len]='0'; int l=0,r=9; while (l<r){ int mid=(l+r)/2; str[len-1]='0'+mid; bool f=query(str); if (!f) l=mid+1;else r=mid; } str[len-1]='0'+l; str[len]=0; return _atoi64(str); } inline LL prefix_special() { const int MaxLen = 10; char str[MaxLen+3]; for (int i=0;i<MaxLen;++i) str[i]='9'; int l=1,r=10; while (l<r) { int mid=(l+r+1)/2; str[mid]=0; bool f=query(str); str[mid]='9'; if (f) r=mid-1;else l=mid; } LL x=1; for (int i=1;i<=l;++i) x*=10; return x; } int main() { if (query(10000000000LL)) { printf("! %I64d\n",prefix_special()); return 0; } int len=getlen(); printf("! %I64d\n",getnum(len)); return 0; }
a.cc: In function 'LL getnum(const int&)': a.cc:54:16: error: '_atoi64' was not declared in this scope; did you mean 'atoi'? 54 | return _atoi64(str); | ^~~~~~~ | atoi
s909063467
p03663
C++
#include <iostream> #include <ccomplex> #include <vector> #include <cassert> #include <utility> #include <algorithm> #include <string> #include <deque> #include <queue> #include <functional> #include <cmath> #include <iomanip> #include <map> #include <numeric> #include <list> #include <assert.h> #include <math.h> #include <valarray> #include <stdio.h> #include <algorithm> #include <set> #include <complex> #include <list> #include <time.h> #include <stack> #include <locale> #include <clocale> #include <ctype.h> #include <wchar.h> using namespace std; typedef long long int LL; typedef pair<long long int, long long int> pii; typedef pair<double, double> pdd; #define SORT(c) sort((c).begin(),(c).end()) #define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>()) #define FOR(i,a,b) for(LL i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) int xcomp(vector<LL>& a, vector<LL>& b) { return a[0] < b[0]; } #define XSORT(c) sort((c).begin(),(c).end(),xcomp) #define ALL(x) (x).begin(),(x).end() LL mod = 1000000007; int main() { LL keta; for (keta = 1;; keta *= 10) { cout << "? " << keta << endl; char s; cin >> s; if (s == 'N') { keta /= 10; break; } LL upper = keta * 10 - 1; LL lower = keta; LL count = 0; while (lower < upper) { count++; if (count == 50) { break; } LL mid = ((upper + lower) / 2) * 10; cout << "? " << mid << endl; char s; cin >> s; if (s == 'Y') { upper = mid / 10; } else { lower = mid / 10 + 1; } } cout << "! " << lower << endl; }
a.cc: In function 'int main()': a.cc:87:10: error: expected '}' at end of input 87 | } | ^ a.cc:51:12: note: to match this '{' 51 | int main() { | ^
s828503770
p03663
C++
#include<iostream> #include<algorithm> #include<string> using namespace std; bool In(){ char z; cin>>z; if(z=='N')return false; return true; } int main(){ int t=1000000000; while(true){ cout<<"? "<<t<<flush; if(In()){ if(t==1000000000){ cout<<"! 1000000000"<<flush; return 0; } break; } t/=10; } int left=t,right=t*10,mid,ans=0; while(left<right){ mid=(left+right)/2; cout<<"? "<<mid*10<<flush; if(!In()){ left=mid+1; ans=max(ans,mid); } else{ right=mid; } } cout<<"! "ans<<flush; return 0; }
a.cc: In function 'int main()': a.cc:36:15: error: unable to find string literal operator 'operator""ans' with 'const char [3]', 'long unsigned int' arguments 36 | cout<<"! "ans<<flush; | ^~~~~~~
s607805090
p03663
C++
#include<bits\stdc++.h> using namespace std; long long t,l,r,mid; char c; void doit1(long long n) { long long ts=n; while(ts) { ts=(ts-9)/10; cout<<"? "<<ts<<endl; cin>>c; if (c=='N') { cout<<"! "<<ts+1<<endl; exit(0); } } } int main() { fflush(stdout); t=10; while(1) { cout<<"? "<<t<<endl; cin>>c; if (c=='N') { l=t/10; r=t; break; } else { cout<<"? "<<t-1<<endl; cin>>c; if (c=='Y') doit1(t-1); else t*=10; } } while(l<r) { mid=(l+r)/2; cout<<"? "<<mid*10<<endl; cin>>c; if (c=='Y') r=mid-1; else l=mid+1; } cout<<"! "<<l<<endl; return 0; }
a.cc:1:9: fatal error: bits\stdc++.h: No such file or directory 1 | #include<bits\stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s484636486
p03663
C++
#include <bits/stdc++.h> using namespace std; #define int long long #define inf 1000000007LL #define rep(i, n) for(int i = 0; i < (n); i++) #define trep(i, n) for(int i = 0; i <= (n); i++) #define rrep(i, n) for(int i = (n) - 1; i >= 0; i--) #define mfor(i, s, t) for(int i = (s); i < (t); i++) bool comp(string s, bool f = true) { cout << "? " << s; if(f) { rep(i, 13 - s.size()) { cout << "9"; } } cout << endl; string a; cin >> a; if(a == "Y") { return true; } else { return false; } } signed main() { string s; rep(_, 10) { int b = -1; if(s.empty()) { b = 0; } int e = 9; while(b < e - 1) { int m = (b + e) / 2; s.push_back('0' + m); if(comp(s)) { e = m; } else { b = m; } s.pop_back(); } s += '0' + e; } string s2; rep(i, s.size()) { s2.push_back('9'); if(if(s[i + 1] == '0' && comp(s2, false)) { cout << "! " << s.substr(0, i + 1) << endl; break; } } }
a.cc: In function 'int main()': a.cc:54:12: error: expected primary-expression before 'if' 54 | if(if(s[i + 1] == '0' && comp(s2, false)) { | ^~ a.cc:54:12: error: expected ')' before 'if' 54 | if(if(s[i + 1] == '0' && comp(s2, false)) { | ~^~ | ) a.cc:58:5: error: expected primary-expression before '}' token 58 | } | ^
s576203811
p03663
C++
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- int ask(ll v) { string S; cout<<"? "<<v<<endl; cin>>S; return S[0]=='Y'; } /* int na; ll N=5; int ask(ll v) { char bufv[20]; char bufN[20]; sprintf(bufv,"%lld",v); sprintf(bufN,"%lld",N); string sv=bufv; string sN=bufN; na++; cout<<v<<" "<<(v<=N)<<" "<<(sv<=sN)<<" "<<sv<<":"<<sN<<endl; return (v<=N)==(sv<=sN); } */ void ans(ll v) { cout<<"! "<<v<<endl; cout<<na<<endl; exit(0); } void solve() { int i,j,k,l,r,x,y; string s; cin>>N; ll p10=10000000000LL; for(i=10;i>=1;i--) { if(ask(p10)==1) break; p10/=10; } if(i==10) { p10=10000000000LL;; for(i=10;i>=1;i--) { if(ask(p10-1)==0) ans(p10); p10/=10; } } if(i==0) { for(i=10;i<=90;i+=10) { if(ask(i)==1) ans(i/10); } } ll ret=0,cm=0; for(;p10>=1;p10/=10) { int cur=-1; int dd[4]={8,4,2,1}; FOR(j,4) if(cur+dd[j]<10) { ll tmp=ret+(cur+dd[j])*p10; ll tmp2=cm*10+(cur+dd[j]); if(ask(tmp2*1000000000LL)==0) cur+=dd[j]; } cm=cm*10+cur; ret+=p10*cur; } ans(ret+1); } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false), cin.tie(0); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); solve(); return 0; }
a.cc: In function 'void ans(ll)': a.cc:40:15: error: 'na' was not declared in this scope; did you mean 'nan'? 40 | cout<<na<<endl; | ^~ | nan a.cc: In function 'void solve()': a.cc:47:14: error: 'N' was not declared in this scope 47 | cin>>N; | ^
s451642711
p03663
Java
import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; public class CT { static Scanner in; static PrintWriter out; static String INPUT = ""; static boolean q(long n) { out.println("? " + n); out.flush(); return in.next().charAt(0) == 'Y'; } // static long hans = 9; // // static boolean q(long n) // { // return // hans <= n && (""+hans).compareTo("" + n) <= 0 || // hans > n && (""+hans).compareTo("" + n) > 0; // } static void solve() { long low = 10000000000L, high = 100000000000L; while(high - low > 1){ long h = high+low>>1; if(q(h)){ high = h; }else{ low = h; } } String nine = "999999999"; if(high/10 >= 9000000000L){ String ten = "10000000000"; for(int i = 10;i >= 2;i--){ if(q(Long.parseLong(ten.substring(0, i)))){ out.println("! " + Long.toString(high).substring(0, i)); out.flush(); return; } } out.println("! " + Long.toString(high).substring(0, 1)); out.flush(); }else{ for(int i = 9;i >= 1;i--){ if(!q(Long.parseLong(nine.substring(0, i)))){ out.println("! " + Long.toString(high).substring(0, i+1)); out.flush(); return; } } out.println("! " + Long.toString(high).substring(0, 1)); out.flush(); } } public static void main(String[] args) throws Exception { in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT); out = new PrintWriter(System.out); solve(); out.flush(); } static int ni() { return Integer.parseInt(in.next()); } static long nl() { return Long.parseLong(in.next()); } static double nd() { return Double.parseDouble(in.next()); } static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); } }
Main.java:5: error: class CT is public, should be declared in a file named CT.java public class CT { ^ 1 error
s699424586
p03663
Java
package arc78; import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; public class CT { static Scanner in; static PrintWriter out; static String INPUT = ""; static boolean q(long n) { out.println("? " + n); out.flush(); return in.next().charAt(0) == 'Y'; } // static long hans = 9; // // static boolean q(long n) // { // return // hans <= n && (""+hans).compareTo("" + n) <= 0 || // hans > n && (""+hans).compareTo("" + n) > 0; // } static void solve() { long low = 10000000000L, high = 100000000000L; while(high - low > 1){ long h = high+low>>1; if(q(h)){ high = h; }else{ low = h; } } String nine = "999999999"; if(high/10 >= 9000000000L){ String ten = "10000000000"; for(int i = 10;i >= 2;i--){ if(q(Long.parseLong(ten.substring(0, i)))){ out.println("! " + Long.toString(high).substring(0, i)); out.flush(); return; } } out.println("! " + Long.toString(high).substring(0, 1)); out.flush(); }else{ for(int i = 9;i >= 1;i--){ if(!q(Long.parseLong(nine.substring(0, i)))){ out.println("! " + Long.toString(high).substring(0, i+1)); out.flush(); return; } } out.println("! " + Long.toString(high).substring(0, 1)); out.flush(); } } public static void main(String[] args) throws Exception { in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT); out = new PrintWriter(System.out); solve(); out.flush(); } static int ni() { return Integer.parseInt(in.next()); } static long nl() { return Long.parseLong(in.next()); } static double nd() { return Double.parseDouble(in.next()); } static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); } }
Main.java:6: error: class CT is public, should be declared in a file named CT.java public class CT { ^ 1 error
s101597741
p03664
C++
#include <iostream> #include <algorithm> #include <vector> #include <cmath> #include <string> using namespace std; #define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); typedef long long ll; typedef long double ld; const ll SZ = (2 << 16), LG = 18, INF = LLONG_MAX; ll n, m; ll grid[LG][LG], inter[SZ], dp[SZ][LG], mx[SZ]; int main() { fastInp; cin >> n >> m; for (int i = 0; i < LG; i++) { for (int j = 0; j < LG; j++) grid[i][j] = INF; } ll sum = 0; for (int i = 0; i < m; i++) { ll u, v, c; cin >> u >> v >> c; sum += c; u--; v--; grid[u][v] = c; grid[v][u] = c; } ll pw = (1ll << n); for (int i = 0; i < pw; i++) { ll cur = 0; for (int j = 0; j < n; j++) { for (int k = j + 1; k < n; k++) { if (((i >> k) & 1) && ((i >> j) & 1) && grid[k][j] != INF) { cur += grid[k][j]; } } } inter[i] = cur; } for (int i = 0; i < pw; i++) { for (int j = 0; j < LG; j++) dp[i][j] = -INF; } dp[1][0] = 0; for (int i = 2; i < pw; i++) { for (int j = 0; j < LG; j++) { for (int k = 0; k < LG; k++) { if (j != k && (i & (1ll << k)) && (i & (1ll << j)) && grid[j][k] != INF) { ll msk = i ^ (1ll << j); dp[i][j] = max(dp[i][j], dp[msk][k] + grid[k][j]); ll msk2 = i ^ (1ll << k); if (grid[j][k] != INF) dp[i][j] = max(dp[i][j], dp[msk2][j] + grid[j][k]); } } } } ll ans = -INF; for (int i = 0; i < pw; i++) { if (!(i & 1)) continue; ll inv = ((pw - 1) ^ i); for (int sub = inv; true; sub = ((sub - 1) & inv)) { int sub2 = (inv ^ sub); ll vl1 = inter[sub | (1ll)] + inter[sub2 | (1ll << (n - 1))], vl2 = inter[sub | (1ll << (n - 1))] + inter[sub2 | (1ll)]; ans = max(ans, dp[i][n - 1] + vl1); ans = max(ans, dp[i][n - 1] + vl2); if (sub == 0) break; } } cout << sum - ans; return 0; }
a.cc:14:41: error: 'LLONG_MAX' was not declared in this scope 14 | const ll SZ = (2 << 16), LG = 18, INF = LLONG_MAX; | ^~~~~~~~~ a.cc:5:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 4 | #include <cmath> +++ |+#include <climits> 5 | #include <string>
s362548011
p03664
C++
#include<bits/stdc++.h> using namespace std; #define ll long long int n,m,u,v,w; ll bismarck[(1<<15)][15],e[15][15],sum[(1<<15)]; int main() { cin>>n>>m; while(m--) { cin>>u>>v>>w; u--,v--; e[u][v]=e[v][u]=w; } for(int i=0;i<1<<n;i++) { for(int j=0;j<n;j++) if((i>>j)&1) { for(int k=j+1;k<n;k++) if((i>>k)&1) sum[i]+=e[j][k]; } } memset(bismarck,-1,sizeof bismarck); // bismarck[1][0]=0; for(int i=1;i<1<<n;i++) { for(int j=0;j<n;j++) if((i>>j)&1) { int l=i^(1<<j); for(int k=0;k<n;k++) if((i>>k)&1&&e[j][k]) bismarck[i][j]=max(bismarck[i][j],bismarck[x][k]+e[k][j]); for(int k=l;k>0;k=(k-1)&l) bismarck[i][j]=max(bismarck[i][j],bismarck[i^k][j]+sum[k^(1<<j)]); } } cout<<bismarck[(1<<n)-1][n-1]; }
a.cc: In function 'int main()': a.cc:33:90: error: 'x' was not declared in this scope 33 | if((i>>k)&1&&e[j][k]) bismarck[i][j]=max(bismarck[i][j],bismarck[x][k]+e[k][j]); | ^
s104007736
p03664
C++
/* 数据不清空,爆零两行泪。 多测不读完,爆零两行泪。 边界不特判,爆零两行泪。 贪心不证明,爆零两行泪。 D P 顺序错,爆零两行泪。 大小少等号,爆零两行泪。 变量不统一,爆零两行泪。 越界不判断,爆零两行泪。 调试不注释,爆零两行泪。 溢出不 l l,爆零两行泪。 */ #include<bits/stdc++.h> using namespace std; const int inf=0x3f3f3f3f; const int N=15; int n,m; int tb[N][N]; int sum[1<<N]; int tmp[1<<N][N],dp[1<<N][N]; void prt_bitmsk(int x){ for(int i=0;i<n;i++)cout<<!!(x&1<<i); } int main(){ cin>>n>>m; int tot=0; while(m--){ int x,y,z; cin>>x>>y>>z; x--;y--; tb[x][y]=tb[y][x]=z; tot+=z; } for(int i=0;i<1<<n;i++){ for(int j=0;j<n;j++)if(i&1<<j)for(int k=j+1;k<n;k++)if(i&1<<k) sum[i]+=tb[j][k]; // printf("sum[");prt_bitmsk(i);printf("]=%d\n",sum[i]); } for(int i=0;i<1<<n;i++)for(int j=0;j<n;j++)dp[i][j]=tmp[i][j]=-inf; int mx=-inf; for(int i=0;i<1<<n;i++)if(i&1)for(int j=0;j<n;j++)if(i&1<<j){ if(j) for(int k=i^1<<j^1;;k=k-1&(i^1<<j^1)){ dp[i][j]=max(dp[i][j],sum[k|1<<j]+tmp[i^k^1<<j][j]); if(!k)break; } else dp[i][j]=sum[i]; // printf("dp[");prt_bitmsk(i);printf("][%d]=%d\n",j,dp[i][j]); for(int k=0;k<n;k++)if(!(i&1<<k)) if(tb[j][k]) tmp[i][k]=max(tmp[i][k],dp[i][j]+tb[j][k]); } cout<<tot-dp[(1<<n)-1][n-1]; return 0; } /*1 4 6 1 2 100 3 1 100 2 4 100 4 3 100 1 4 100 3 2 100 */ /*2 2 1 1 2 1 */ /*3 15 22 8 13 33418 14 15 55849 7 10 15207 4 6 64328 6 9 86902 15 7 46978 8 14 53526 1 2 8720 14 12 37748 8 3 61543 6 5 32425 4 11 20932 3 12 55123 8 2 45333 9 12 77796 3 9 71922 12 15 70793 2 4 25485 11 6 1436 2 7 81563 7 11 97843 3 1 40491 */ 多测不读完,爆零两行泪。 边界不特判,爆零两行泪。 贪心不证明,爆零两行泪。 D P 顺序错,爆零两行泪。 大小少等号,爆零两行泪。 变量不统一,爆零两行泪。 越界不判断,爆零两行泪。 调试不注释,爆零两行泪。 溢出不 l l,爆零两行泪。 */ #include<bits/stdc++.h> using namespace std; const int inf=0x3f3f3f3f; const int N=15; int n,m; int tb[N][N]; int sum[1<<N]; int tmp[1<<N][N],dp[1<<N][N]; void prt_bitmsk(int x){ for(int i=0;i<n;i++)cout<<!!(x&1<<i); } int main(){ cin>>n>>m; int tot=0; while(m--){ int x,y,z; cin>>x>>y>>z; x--;y--; tb[x][y]=tb[y][x]=z; tot+=z; } for(int i=0;i<1<<n;i++){ for(int j=0;j<n;j++)if(i&1<<j)for(int k=j+1;k<n;k++)if(i&1<<k) sum[i]+=tb[j][k]; // printf("sum[");prt_bitmsk(i);printf("]=%d\n",sum[i]); } for(int i=0;i<1<<n;i++)for(int j=0;j<n;j++)dp[i][j]=tmp[i][j]=-inf; int mx=-inf; for(int i=0;i<1<<n;i++)if(i&1)for(int j=0;j<n;j++)if(i&1<<j){ if(j) for(int k=i^1<<j^1;;k=k-1&(i^1<<j^1)){ dp[i][j]=max(dp[i][j],sum[k|1<<j]+tmp[i^k^1<<j][j]); if(!k)break; } else dp[i][j]=sum[i]; // printf("dp[");prt_bitmsk(i);printf("][%d]=%d\n",j,dp[i][j]); if(j==n-1)mx=max(mx,dp[i][j]); for(int k=0;k<n;k++)if(!(i&1<<k)) if(tb[j][k]) tmp[i][k]=max(tmp[i][k],dp[i][j]+tb[j][k]); } cout<<tot-mx; return 0; } /*1 4 6 1 2 100 3 1 100 2 4 100 4 3 100 1 4 100 3 2 100 */ /*2 2 1 1 2 1 */ /*3 15 22 8 13 33418 14 15 55849 7 10 15207 4 6 64328 6 9 86902 15 7 46978 8 14 53526 1 2 8720 14 12 37748 8 3 61543 6 5 32425 4 11 20932 3 12 55123 8 2 45333 9 12 77796 3 9 71922 12 15 70793 2 4 25485 11 6 1436 2 7 81563 7 11 97843 3 1 40491 */
a.cc:95:1: error: extended character 。 is not valid in an identifier 95 | 多测不读完,爆零两行泪。 | ^ a.cc:96:1: error: extended character 。 is not valid in an identifier 96 | 边界不特判,爆零两行泪。 | ^ a.cc:97:1: error: extended character 。 is not valid in an identifier 97 | 贪心不证明,爆零两行泪。 | ^ a.cc:98:5: error: extended character 。 is not valid in an identifier 98 | D P 顺序错,爆零两行泪。 | ^ a.cc:99:1: error: extended character 。 is not valid in an identifier 99 | 大小少等号,爆零两行泪。 | ^ a.cc:100:1: error: extended character 。 is not valid in an identifier 100 | 变量不统一,爆零两行泪。 | ^ a.cc:101:1: error: extended character 。 is not valid in an identifier 101 | 越界不判断,爆零两行泪。 | ^ a.cc:102:1: error: extended character 。 is not valid in an identifier 102 | 调试不注释,爆零两行泪。 | ^ a.cc:103:10: error: extended character 。 is not valid in an identifier 103 | 溢出不 l l,爆零两行泪。 | ^ a.cc:95:1: error: '\U0000591a\U00006d4b\U00004e0d\U00008bfb\U00005b8c\U0000ff0c\U00007206\U000096f6\U00004e24\U0000884c\U00006cea\U00003002' does not name a type 95 | 多测不读完,爆零两行泪。 | ^~~~~~~~~~~~~~~~~~~~~~~~ a.cc:107:11: error: redefinition of 'const int inf' 107 | const int inf=0x3f3f3f3f; | ^~~ a.cc:15:11: note: 'const int inf' previously defined here 15 | const int inf=0x3f3f3f3f; | ^~~ a.cc:108:11: error: redefinition of 'const int N' 108 | const int N=15; | ^ a.cc:16:11: note: 'const int N' previously defined here 16 | const int N=15; | ^ a.cc:109:5: error: redefinition of 'int n' 109 | int n,m; | ^ a.cc:17:5: note: 'int n' previously declared here 17 | int n,m; | ^ a.cc:109:7: error: redefinition of 'int m' 109 | int n,m; | ^ a.cc:17:7: note: 'int m' previously declared here 17 | int n,m; | ^ a.cc:110:5: error: redefinition of 'int tb [15][15]' 110 | int tb[N][N]; | ^~ a.cc:18:5: note: 'int tb [15][15]' previously declared here 18 | int tb[N][N]; | ^~ a.cc:111:5: error: redefinition of 'int sum [32768]' 111 | int sum[1<<N]; | ^~~ a.cc:19:5: note: 'int sum [32768]' previously declared here 19 | int sum[1<<N]; | ^~~ a.cc:112:5: error: redefinition of 'int tmp [32768][15]' 112 | int tmp[1<<N][N],dp[1<<N][N]; | ^~~ a.cc:20:5: note: 'int tmp [32768][15]' previously declared here 20 | int tmp[1<<N][N],dp[1<<N][N]; | ^~~ a.cc:112:18: error: redefinition of 'int dp [32768][15]' 112 | int tmp[1<<N][N],dp[1<<N][N]; | ^~ a.cc:20:18: note: 'int dp [32768][15]' previously declared here 20 | int tmp[1<<N][N],dp[1<<N][N]; | ^~ a.cc:113:6: error: redefinition of 'void prt_bitmsk(int)' 113 | void prt_bitmsk(int x){ | ^~~~~~~~~~ a.cc:21:6: note: 'void prt_bitmsk(int)' previously defined here 21 | void prt_bitmsk(int x){ | ^~~~~~~~~~ a.cc:116:5: error: redefinition of 'int main()' 116 | int main(){ | ^~~~ a.cc:24:5: note: 'int main()' previously defined here 24 | int main(){ | ^~~~
s475806037
p03664
C++
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define LL long lone #define INF 0x3f3f3f3f #define Inf 1000000000000000000LL #define F first #define S second using namespace std; typedef pair<int,int>pii; struct stane{int a,b;LL c;}; int n,m,N,g[20][20],val[40010],dp[40010][20]; vector<pii>vv; vector<int>vc; inline void update(int &a,int b){ if(a<b) a=b;} int solve(){ memset(g,0,sizeof g); memset(val,0,sizeof val); int i,j,k,r,rest,u,v,w; int sum=0; N=(1<<n); for(i=1;i<=m;i++){ u=vv[i-1].F; v=vv[i-1].S; w=vc[i-1]; g[u][v]=g[v][u]=w; sum+=w; } memset(dp,-1,sizeof dp); for(i=1;i<N;i++){ for(j=0;j<n;j++)if(i&(1<<j))break; val[i]=val[i^(1<<j)]; for(k=j+1;k<n;k++)if(i&(1<<k))val[i]+=g[j][k]; if(j==0)dp[i][0]=val[i]; } for(i=1;i<N;i++) for(j=0;j<n;j++){ if((v=dp[i][j])<0)continue; for(k=0;k<n;k++){ if(i&(1<<k))continue; if(g[j][k]==0)continue; update(dp[i^(1<<k)][k],v+g[j][k]); for(rest=r=(N-1)^i^(1<<k);r;r=(r-1)&rest) update(dp[i^r^(1<<k)][k],v+val[r^(1<<k)]+g[j][k]); } } return sum-dp[N-1][n-1]; return 0; } vector<stane>road; LL cost[1<<16]; LL dp2[1<<16][16]; LL lis[16][16]; LL ddp[1<<16]; LL mt[1<<16][16]; int main(){ cin>>n>>m; if(n==1)return 1; LL S=0; for(int i=0;i<m;i++){ int a,b,c; cin>>a>>b>>c; a--;b--; vv.pb(make_pair(a,b)); vc.pb(c); road.pb({a,b,c}); S+=c; if(lis[a][b])return 1; lis[a][b]=max(lis[a][b],(LL)c); lis[b][a]=max(lis[b][a],(LL)c); } for(int i=0;i<(1<<n);i++){ for(int j=0;j<n;j++){ if((i>>j)&1)continue; for(int k=0;k<n;k++) if((i>>k)&1) mt[i][j]=max(mt[i][j],lis[k][j]); } } for(int i=0;i<(1<<n);i++) for(int j=0;j<road.size();j++) if((i>>road[j].a)&1) if ((i>>road[j].b)&1) cost[i]+=road[j].c; for(int i=0;i<(1<<n);i++) for(int j=0;j<n;j++) dp2[i][j]=LLONG_MIN; dp2[1][0]=0; for(int i=0;i<(1<<n);i++){ for(int j=0;j<n;j++){ if(!(i>>j)&1)continue; if(dp2[i][j]!=LLONG_MIN)for(int k=0;k<n;k++){ if((i>>k)&1)continue; if(lis[j][k]) dp2[i|(1<<k)][k]=max((LL)dp2[i|(1<<k)][k],dp2[i][j]+lis[j][k]); } } } for(int i=0;i<(1<<n);i++)ddp[i]=dp2[i][n-1]; for(int i=0;i<(1<<n);i++){ if(ddp[i]!=LLONG_MIN){ if((!(i>>0)&1)||(!(i>>(n-1)&1)))return 1; for(int j=i;j<(1<<n);j++,j|=i){ if(i==j)continue; int xr=(j^i); if(xr&i)return 1; if(xr==0)return 1; LL cosm=max(cost[1|xr],cost[(1<<(n-1))|xr]); for(int ii=0;ii<n;ii++)if((i>>ii)&1) cosm=max(cosm,cost[1<<(ii)|xr]); ddp[j]=max(ddp[j],ddp[i]+cosm); } } } cout<<S-ddp[(1<<n)-1]<<endl; return 0; }
a.cc:4:17: error: expected ';' at end of member declaration 4 | #define LL long lone | ^~~~ a.cc:11:22: note: in expansion of macro 'LL' 11 | struct stane{int a,b;LL c;}; | ^~ a.cc:11:25: error: 'c' does not name a type 11 | struct stane{int a,b;LL c;}; | ^ a.cc:51:4: error: expected initializer before 'cost' 51 | LL cost[1<<16]; | ^~~~ a.cc:52:4: error: expected initializer before 'dp2' 52 | LL dp2[1<<16][16]; | ^~~ a.cc:53:4: error: expected initializer before 'lis' 53 | LL lis[16][16]; | ^~~ a.cc:54:4: error: expected initializer before 'ddp' 54 | LL ddp[1<<16]; | ^~~ a.cc:55:4: error: expected initializer before 'mt' 55 | LL mt[1<<16][16]; | ^~ a.cc: In function 'int main()': a.cc:8:11: error: expected initializer before 'second' 8 | #define S second | ^~~~~~ a.cc:59:12: note: in expansion of macro 'S' 59 | LL S=0; | ^ a.cc:8:11: error: 'second' was not declared in this scope 8 | #define S second | ^~~~~~ a.cc:67:17: note: in expansion of macro 'S' 67 | S+=c; | ^ a.cc:68:20: error: 'lis' was not declared in this scope 68 | if(lis[a][b])return 1; | ^~~ a.cc:69:17: error: 'lis' was not declared in this scope 69 | lis[a][b]=max(lis[a][b],(LL)c); | ^~~ a.cc:4:12: error: expected primary-expression before 'long' 4 | #define LL long lone | ^~~~ a.cc:69:42: note: in expansion of macro 'LL' 69 | lis[a][b]=max(lis[a][b],(LL)c); | ^~ a.cc:69:42: error: expected ')' before 'long' 69 | lis[a][b]=max(lis[a][b],(LL)c); | ~^ | ) a.cc:4:12: error: expected primary-expression before 'long' 4 | #define LL long lone | ^~~~ a.cc:70:42: note: in expansion of macro 'LL' 70 | lis[b][a]=max(lis[b][a],(LL)c); | ^~ a.cc:70:42: error: expected ')' before 'long' 70 | lis[b][a]=max(lis[b][a],(LL)c); | ~^ | ) a.cc:77:41: error: 'mt' was not declared in this scope; did you mean 'tm'? 77 | mt[i][j]=max(mt[i][j],lis[k][j]); | ^~ | tm a.cc:77:63: error: 'lis' was not declared in this scope 77 | mt[i][j]=max(mt[i][j],lis[k][j]); | ^~~ a.cc:84:41: error: 'cost' was not declared in this scope; did you mean 'cosl'? 84 | cost[i]+=road[j].c; | ^~~~ | cosl a.cc:84:58: error: '__gnu_cxx::__alloc_traits<std::allocator<stane>, stane>::value_type' {aka 'struct stane'} has no member named 'c' 84 | cost[i]+=road[j].c; | ^ a.cc:87:25: error: 'dp2' was not declared in this scope; did you mean 'dup2'? 87 | dp2[i][j]=LLONG_MIN; | ^~~ | dup2 a.cc:88:9: error: 'dp2' was not declared in this scope; did you mean 'dup2'? 88 | dp2[1][0]=0; | ^~~ | dup2 a.cc:94:36: error: 'lis' was not declared in this scope 94 | if(lis[j][k]) | ^~~ a.cc:4:12: error: expected primary-expression before 'long' 4 | #define LL long lone | ^~~~ a.cc:95:63: note: in expansion of macro 'LL' 95 | dp2[i|(1<<k)][k]=max((LL)dp2[i|(1<<k)][k],dp2[i][j]+lis[j][k]); | ^~ a.cc:95:63: error: expected ')' before 'long' 95 | dp2[i|(1<<k)][k]=max((LL)dp2[i|(1<<k)][k],dp2[i][j]+lis[j][k]); | ~^ | ) a.cc:99:34: error: 'ddp' was not declared in this scope; did you mean 'dup'? 99 | for(int i=0;i<(1<<n);i++)ddp[i]=dp2[i][n-1]; | ^~~ | dup a.cc:101:20: error: 'ddp' was not declared in this scope; did you mean 'dup'? 101 | if(ddp[i]!=LLONG_MIN){ | ^~~ | dup a.cc:108:36: error: expected initializer before 'cosm' 108 | LL cosm=max(cost[1|xr],cost[(1<<(n-1))|xr]); | ^~~~ a.cc:110:41: error: 'cosm' was not declared in this scope; did you mean 'cosl'? 110 | cosm=max(cosm,cost[1<<(ii)|xr]); | ^~~~ | cosl a.cc:110:55: error: 'cost' was not declared in this scope; did you mean 'cosl'? 110 | cosm=max(cosm,cost[1<<(ii)|xr]); | ^~~~ | cosl a.cc:111:58: error: 'cosm' was not declared in this scope; did you mean 'cosl'? 111 | ddp[j]=max(ddp[j],ddp[i]+cosm); | ^~~~ | cosl a.cc:8:11: error: 'second' was not declared in this scope 8 | #define S second | ^~~~~~ a.cc:115:15: note: in expansion of macro 'S' 115 | cout<<S-ddp[(1<<n)-1]<<endl; | ^ a.cc:115:17: error: 'ddp' was not declared in this scope; did you mean 'dup'? 115 | cout<<S-ddp[(1<<n)-1]<<endl; | ^~~ | dup
s931850310
p03664
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN=15; const int MAXP=(1<<MAXN); int N,M; int edge[MAXN][MAXN]; int cscore[MAXP]; int dp[MAXN][MAXP]; int main(){ ios_base::sync_with_stdio(0); cin>>N>>M; for (int i=0;i<M;i++){ int a,b,c; cin>>a>>b>>c; a--,b--; edge[a][b]=edge[b][a]=c; } for (int i=0;i<(1<<N);i++){ cscore[i]=0; for (int j=0;j<N;j++){ for (int k=j+1;k<N;k++){ if (i&(1<<j) && i & (1<<k)) cscore[i]+=edge[j][k]; } } } for (int i=0;i<MAXN;i++) for (int j=0;j<MXP;j++) dp[i][j]=-1e9; for (int i=1;i<(1<<N);i+=2) dp[0][i]=cscore[i]; for (int i=0;i<(1<<N);i++){ for (int j=0;j<N;j++){ if (dp[j][i]<0) continue; int mask=(1<<N)-1-i; for (int sub=mask;sub>0;sub=(sub-1)&mask){ for (int k=0;k<N;k++){ if (edge[j][k] && (sub&(1<<k))) dp[k][i+sub]=max(dp[k][i+sub],dp[j][i]+cscore[sub]+edge[j][k]); } } } } ll ctot=0; for (int i=0;i<N;i++) for (int j=i+1;j<N;j++) ctot+=edge[i][j]; cout<<ctot-dp[N-1][(1<<N)-1]<<"\n"; }
a.cc: In function 'int main()': a.cc:29:24: error: 'MXP' was not declared in this scope; did you mean 'MAXP'? 29 | for (int j=0;j<MXP;j++) | ^~~ | MAXP
s574052238
p03664
C++
#include<bits/stdc++.h> using namespace std; inline int read() { int res=0,fh=1; char ch=getchar(); while((ch>'9'||ch<'0')&&ch!='-')ch=getchar(); if(ch=='-')fh=-1,ch=getchar(); while(ch>='0'&&ch<='9')res=res*10+ch-'0',ch=getchar(); return fh*res; } const int maxn=(1<<16); int n,m,mxs,sum[maxn],a[maxn][maxn]; int f[maxn][maxn]; inline int Max(int a,int b){return a>b?a:b;} int main(){ n=read(),m=read(); mxs=(1<<n)-1; for(int i=1;i<=m;i++){ int x=read()-1,y=read()-1,z=read(); a[x][y]=a[y][x]=z; } for(int i=0;i<=mxs;i++){ sum[i]=0; for(int j=0;j<n;j++) if((i&(1<<j))) for(int k=j+1;k<n;k++) if((i&(1<<k))) sum[i]+=a[j][k]; } memset(f,-1,sizeof f); f[1][0]=0; for(int i=1;i<=mxs;i+=2){ for(int j=0;j<n;j++){ if(f[i][j]==-1) continue; if(!(i&(1<<j))) continue; for(int k=0;k<n;k++) if(a[j][k]&&(!(i&(1<<k)))) f[i|(1<<k)][k]=Max(f[i|(1<<k)][k],f[i][j]+a[j][k]); int c=(mxs-i)|(1<<j); for(int k=c;k>=0;k=(k==0?-1:(k-1)&c)) f[i|k][j]=Max(f[i][j]+sum[k],f[i|k][j]); } } int ans=0; for(int i=(mxs>>1)+2;i<=mxs;i+=2) ans=Max(ans,f[i][n-1]); printf("%d\n",sum[mxs]-ans); return 0; }
/tmp/ccdT9yWx.o: in function `main': a.cc:(.text+0x1ed): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccdT9yWx.o a.cc:(.text+0x1fb): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccdT9yWx.o a.cc:(.text+0x238): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccdT9yWx.o a.cc:(.text+0x2cb): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccdT9yWx.o a.cc:(.text+0x325): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccdT9yWx.o a.cc:(.text+0x361): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccdT9yWx.o a.cc:(.text+0x3c6): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccdT9yWx.o a.cc:(.text+0x3eb): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccdT9yWx.o a.cc:(.text+0x438): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccdT9yWx.o a.cc:(.text+0x4c8): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccdT9yWx.o collect2: error: ld returned 1 exit status
s450472676
p03664
C++
/*input 4 6 1 2 100 3 1 100 2 4 100 4 3 100 1 4 100 3 2 100 */ #include <bits/stdc++.h> #pragma GCC optimize("unroll-loops,no-stack-protector") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<double,double> pdd; #define IOS ios_base::sync_with_stdio(0); cin.tie(0) #define ALL(a) a.begin(),a.end() #define SZ(a) ((int)a.size()) #define F first #define S second #define REP(i,n) for(int i=0;i<((int)n);i++) #define pb push_back #define MP(a,b) make_pair(a,b) #define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end())))) #define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin()) template<typename T1,typename T2> ostream& operator<<(ostream& out,pair<T1,T2> P){ out<<'('<<P.F<<','<<P.S<<')'; return out; } //}}} const int maxn=15; const int INF=0x3f3f3f3f; int es[1<<maxn]; int adj[maxn][maxn]; int dp[maxn][1<<maxn]; int main(){ IOS; int n,m; cin>>n>>m; ll tt=0; REP(i,m){ int u,v,d; cin>>u>>v>>d; u--;v--; adj[u][v]=adj[v][u]=d; tt+=d; } for(int i=1;i<(1<<n);i++){ int kk=i&-i; int tmp=0; while(kk%2==0){ kk/=2; tmp++: } // if(tmp>=n) exit(0); int meow=i^(1<<tmp); es[i]=es[i^(1<<tmp)]; for(int j=tmp+1;j<n;j++) if(i&(1<<j)){ es[i]+=adj[tmp][j]; } } REP(i,n) REP(j,1<<n) dp[i][j]=-INF; REP(mask,1<<n) for(int i=0;i<n;i++) if(mask&(1<<i)){ if(i==0) dp[i][mask]=es[mask]; else{ int pre=mask^(1<<i); for(int sub=pre;sub>0;sub=(sub-1)&pre){ REP(j,n) if(sub&(1<<j)){ if(adj[j][i]) dp[i][mask]=max(dp[i][mask],dp[j][sub]+es[sub^mask]+adj[j][i]); } } } } cout<<tt-dp[n-1][(1<<n)-1]<<'\n'; return 0; }
a.cc: In function 'int main()': a.cc:59:30: error: expected ';' before ':' token 59 | tmp++: | ^ | ;
s632322414
p03664
C
15 22 8 13 33418 14 15 55849 7 10 15207 4 6 64328 6 9 86902 15 7 46978 8 14 53526 1 2 8720 14 12 37748 8 3 61543 6 5 32425 4 11 20932 3 12 55123 8 2 45333 9 12 77796 3 9 71922 12 15 70793 2 4 25485 11 6 1436 2 7 81563 7 11 97843 3 1 40491
main.c:1:1: error: expected identifier or '(' before numeric constant 1 | 15 22 | ^~
s469927902
p03664
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N=1<<15; int n,m,c[15][15]; int p[N],dp[N][15]; void init() { memset(p,0,sizeof(p)); for(int i=0;i<(1<<n);i++) for(int j=0;j<n;j++) dp[i][j]=-1; for(int i=0;i<(1<<n);i++) { for(int j=0;j<n;j++) { if(((i>>j)&1)==0) continue; for(int k=j+1;k<n;k++) { if(((i>>k)&1)==0) continue; p[i]+=c[j][k]; } } } } int main() { while(cin>>n>>m) { int sum=0; int u,v,w; memset(c,0,sizeof(c)); while(m--) { scanf("%d%d%d",&u,&v,&w); u--,v--; c[u][v]=c[v][u]=w; sum+=w; } init(); dp[1][0]=0; for(int i=0;i<(1<<n);i++) { for(int j=0;j<n;j++) { if(dp[i][j]==-1) continue; int x=(((1<<n)-1)^i)|(1<<j); //y is some subset of x for(int y=x;y>=0;y--) y&=x,dp[i|y][j]=max(dp[i|y][j],dp[i][j]+p[y]); for(int k=0;k<n;k++) { if((i>>k)&1) continue; if(c[j][k]==0) continue; dp[i|(1<<k)][k]=max(dp[i|(1<<k)][k],dp[i][j]+c[j][k]); } } } int ans=1e9; for(int i=0;i<(1<<n);i++) ans=min(ans,sum-dp[i][n-1]); cout<<ans<<endl; } return 0;
a.cc: In function 'int main()': a.cc:72:18: error: expected '}' at end of input 72 | return 0; | ^ a.cc:30:1: note: to match this '{' 30 | { | ^
s727801196
p03664
C++
#include<bits/stdc++.h> #define lowbit(x) (x&-x) #define mem(a,b) memset(a,b,sizeof(a)) #define For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i) #define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i) using namespace std; typedef long long LL; const int N=16; template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;} template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;} template<typename T>inline void read(T &x) { x=0;int _f(0);char ch=getchar(); while(!isdigit(ch))_f|=(ch=='-'),ch=getchar(); while( isdigit(ch))x=x*10+ch-'0',ch=getchar(); x=_f?-x:x; } inline void file() { #ifndef ONLINE_JUDGE freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); #endif } int n,m,tot,dp[N][1<<N],ans; int c[N],w[N][1<<N],can[1<<N]; int q[1<<N],cnt; int main() { int x,y,z; read(n),read(m); For(i,1,m) { read(x),read(y),read(z); c[x]|=(1<<(y-1)),w[x][1<<(y-1)]=z; c[y]|=(1<<(x-1)),w[y][1<<(x-1)]=z; ans+=z; } For(i,1,n) { cnt=0; for(int x=c[i];x;x=(x-1)&c[i]) q[++cnt]=x; rFor(j,cnt,1) { int x=q[j]; w[i][x]=w[i][x^lowbit(x)]+w[i][lowbit(x)]; } } mem(dp,-inf); dp[1][1]=0; tot=(1<<n)-1; For(x,1,tot) { For(u,1,n) if(x&(1<<(u-1))) can[x]+=w[u][x&c[u]]; can[x]>>=1; } For(x,1,tot) For(u,1,n) if(dp[u][x]>=0){ int bx=tot^x; for(int sm=bx;sm;sm=(sm-1)&bx) chkmax(dp[u][x|sm],dp[u][x]+can[sm|(1<<(u-1))]); For(v,1,n) if(c[u]&(1<<(v-1))&&!(x&(1<<(v-1)))) chkmax(dp[v][x|(1<<(v-1))],dp[u][x]+w[v][1<<(u-1)]); } printf("%d\n",ans-dp[n][tot]); return 0; }
a.cc: In function 'int main()': a.cc:50:17: error: 'inf' was not declared in this scope; did you mean 'ynf'? 50 | mem(dp,-inf); | ^~~ a.cc:3:27: note: in definition of macro 'mem' 3 | #define mem(a,b) memset(a,b,sizeof(a)) | ^
s103210641
p03664
C++
#include <iostream>   int checked[40000][16]; long long dp[40000][16]; long long esum[40000]; using namespace std; int eds[16][16]; int n,m; long long calc(int state,int now); long long calc_sub(int state_base,int state,int dep,int now,int prev) { if(dep==n) { return esum[state_base-state]+eds[now][prev]+calc(state,prev); } long long ret=0; if(dep==prev) { ret=calc_sub(state_base,state+(1<<dep),dep+1,now,prev); } else if(dep==now) { ret=calc_sub(state_base,state,dep+1,now,prev); } else { ret=calc_sub(state_base,state,dep+1,now,prev); if(state_base&(1<<dep)) { long long temp=calc_sub(state_base,state+(1<<dep),dep+1,now,prev); if(ret<temp) ret=temp; } } return ret; } long long calc(int state,int now) { if(checked[state][now]) return dp[state][now]; checked[state][now]=1; if(now==0) { dp[state][now]=esum[state]; } else { dp[state][now]=-1e16; for(int i=0;i<n;i++) { if((state&(1<<i))>0&&i!=now&&eds[i][now]>0) { long long temp=calc_sub(state,1,1,now,i); if(dp[state][now]<temp) dp[state][now]=temp; } } } return dp[state][now]; } int main() { cin >> n >> m; for(int i=0;i<m;i++) { int va,vb,vc; cin >> va >> vb >> vc; va--; vb--; eds[va][vb]=vc; eds[vb][va]=vc; } for(int i=0;i<(1<<n);i++) { for(int j=0;j<n;j++) for(int k=j+1;k<n;k++) { if((i&(1<<j))>0&&(i&(1<<k))>0) esum[i]+=eds[j][k]; } } cout << esum[(1<<n)-1]-calc((1<<n)-1,n-1) << endl; return 0; }
a.cc:2:1: error: extended character   is not valid in an identifier 2 |   | ^ a.cc:2:1: error: '\U000000a0' does not name a type 2 |   | ^ a.cc: In function 'long long int calc(int, int)': a.cc:29:12: error: 'checked' was not declared in this scope 29 | if(checked[state][now]) return dp[state][now]; | ^~~~~~~ a.cc:30:9: error: 'checked' was not declared in this scope 30 | checked[state][now]=1; | ^~~~~~~
s636918228
p03664
C++
#include <iostream>   int checked[40000][16]; long long dp[40000][16]; long long esum[40000]; using namespace std; int eds[16][16]; int n,m; long long calc(int state,int now); long long calc_sub(int state_base,int state,int dep,int now,int prev) { if(dep==n) { return esum[state_base-state]+eds[now][prev]+calc(state,prev); } long long ret=0; if(dep==prev) { ret=calc_sub(state_base,state+(1<<dep),dep+1,now,prev); } else if(dep==now) { ret=calc_sub(state_base,state,dep+1,now,prev); } else { ret=calc_sub(state_base,state,dep+1,now,prev); if(state_base&(1<<dep)) { long long temp=calc_sub(state_base,state+(1<<dep),dep+1,now,prev); if(ret<temp) ret=temp; } } return ret; } long long calc(int state,int now) { if(checked[state][now]) return dp[state][now]; checked[state][now]=1; if(now==0) { dp[state][now]=esum[state]; } else { dp[state][now]=-1e16; for(int i=0;i<n;i++) { if((state&(1<<i))>0&&i!=now&&eds[i][now]>0) { long long temp=calc_sub(state,1,1,now,i); if(dp[state][now]<temp) dp[state][now]=temp; } } } return dp[state][now]; } int main() { cin >> n >> m; for(int i=0;i<m;i++) { int va,vb,vc; cin >> va >> vb >> vc; va--; vb--; eds[va][vb]=vc; eds[vb][va]=vc; } for(int i=0;i<(1<<n);i++) { for(int j=0;j<n;j++) for(int k=j+1;k<n;k++) { if((i&(1<<j))>0&&(i&(1<<k))>0) esum[i]+=eds[j][k]; } } cout << esum[(1<<n)-1]-calc((1<<n)-1,n-1) << endl; return 0; }
a.cc:2:1: error: extended character   is not valid in an identifier 2 |   | ^ a.cc:2:1: error: '\U000000a0' does not name a type 2 |   | ^ a.cc: In function 'long long int calc(int, int)': a.cc:29:12: error: 'checked' was not declared in this scope 29 | if(checked[state][now]) return dp[state][now]; | ^~~~~~~ a.cc:30:9: error: 'checked' was not declared in this scope 30 | checked[state][now]=1; | ^~~~~~~
s718966140
p03664
C++
#include <iostream>   int checked[40000][16]; long long dp[40000][16]; long long esum[40000]; using namespace std; int eds[16][16]; int n,m; long long calc(int state,int now); long long calc_sub(int state_base,int state,int dep,int now,int prev) { if(dep==n) { return esum[state_base-state]+eds[now][prev]+calc(state,prev); } long long ret=0; if(dep==prev) { ret=calc_sub(state_base,state+(1<<dep),dep+1,now,prev); } else if(dep==now) { ret=calc_sub(state_base,state,dep+1,now,prev); } else { ret=calc_sub(state_base,state,dep+1,now,prev); if(state_base&(1<<dep)) { long long temp=calc_sub(state_base,state+(1<<dep),dep+1,now,prev); if(ret<temp) ret=temp; } } return ret; } long long calc(int state,int now) { if(checked[state][now]) return dp[state][now]; checked[state][now]=1; if(now==0) { dp[state][now]=esum[state]; } else { dp[state][now]=-1e16; for(int i=0;i<n;i++) { if((state&(1<<i))>0&&i!=now&&eds[i][now]>0) { long long temp=calc_sub(state,1,1,now,i); if(dp[state][now]<temp) dp[state][now]=temp; } } } return dp[state][now]; } int main() { cin >> n >> m; for(int i=0;i<m;i++) { int va,vb,vc; cin >> va >> vb >> vc; va--; vb--; eds[va][vb]=vc; eds[vb][va]=vc; } for(int i=0;i<(1<<n);i++) { for(int j=0;j<n;j++) for(int k=j+1;k<n;k++) { if((i&(1<<j))>0&&(i&(1<<k))>0) esum[i]+=eds[j][k]; } } cout << esum[(1<<n)-1]-calc((1<<n)-1,n-1) << endl; return 0; }
a.cc:2:1: error: extended character   is not valid in an identifier 2 |   | ^ a.cc:2:1: error: '\U000000a0' does not name a type 2 |   | ^ a.cc: In function 'long long int calc(int, int)': a.cc:29:12: error: 'checked' was not declared in this scope 29 | if(checked[state][now]) return dp[state][now]; | ^~~~~~~ a.cc:30:9: error: 'checked' was not declared in this scope 30 | checked[state][now]=1; | ^~~~~~~
s656884571
p03664
C++
#include <conio.h> #include <bits/stdc++.h> using namespace std; const int N=20; int n,m,k,a[N],p2,T[N],E[N*N][3],ans=1<<30; struct node { int c,a,b; bool operator<(const node &o)const { return c>o.c; } }ed[N*N]; int Findx(int x) { if(T[x]==-1)return x; return T[x]=Findx(T[x]); } void Merge(int a,int b) { int x=Findx(a),y=Findx(b); if(x!=y)T[x]=y; } void solve() { memset(T,-1,sizeof(T)); int i,j,now=0;k=0; for(i=1;i<=m;i++) { if(a[E[i][0]]==2&&a[E[i][1]]==2) ed[++k]=(node){E[i][2],E[i][0],E[i][1]}; else if(a[E[i][0]]!=a[E[i][1]]) if(a[E[i][0]]==2||a[E[i][1]]==2) if((a[E[i][0]]==1&&E[i][1]==1)||(a[E[i][1]]==1&&E[i][0]==1)||(a[E[i][0]]==3&&E[i][1]==n)||(a[E[i][1]]==3&&E[i][0]==n)); else now+=E[i][2]; else now+=E[i][2]; //cerr<<a[E[i][0]]<<" "<<a[E[i][1]]<<" "<<E[i][0]<<" "<<E[i][1]<<" "<<now<<endl; } sort(ed+1,ed+1+k); for(i=1,j=0;i<=k;i++) if(Findx(ed[i].a)!=Findx(ed[i].b)) Merge(ed[i].a,ed[i].b),j++; else now+=ed[i].c; if(j==p2-1) ans=min(ans,now); } void dfs(int i) { if(i>=n) { solve(); return ; } for(int j=1;j<=3;j++) { a[i]=j; if(j==2)p2++; dfs(i+1); if(j==2)p2--; } } int main() { scanf("%d%d",&n,&m); for(int i=1;i<=m;i++) cin>>E[i][0]>>E[i][1]>>E[i][2]; a[1]=a[n]=2;p2=2; dfs(2); cout<<ans; return 0; }
a.cc:1:10: fatal error: conio.h: No such file or directory 1 | #include <conio.h> | ^~~~~~~~~ compilation terminated.
s538373769
p03664
C++
/*あかん*/ #pragma GCC optimize ("O3") #pragma GCC target ("avx") #include "bits/stdc++.h" // define macro "/D__MAI" using namespace std; typedef long long int ll; #define xprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__) #define debugv(v) {printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;} #define debugm(m) {printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}} #define debuga(m,w) {printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;} #define debugaa(m,w,h) {printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}} #define debugaar(m,w,h) {printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[y][x]<<" ";}cout<<endl;}} #define ALL(v) (v).begin(),(v).end() #define repeat(l) for(auto cnt=0;cnt<(l);++cnt) #define iterate(b,e) for(auto cnt=(b);cnt!=(e);++cnt) #define MD 1000000007ll #define PI 3.1415926535897932384626433832795 template<typename T1, typename T2> ostream& operator <<(ostream &o, const pair<T1, T2> p) { o << "(" << p.first << ":" << p.second << ")"; return o; } mt19937 mt(8901016); inline int rand_int(int l, int h) { return uniform_int_distribution<>(l, h)(mt); } #ifdef __MAI #define getchar_unlocked getchar #define putchar_unlocked putchar #endif #ifdef __VSCC #define getchar_unlocked _getchar_nolock #define putchar_unlocked _putchar_nolock #endif namespace { #define isvisiablechar(c) (0x21<=(c)&&(c)<=0x7E) class MaiScanner { public: template<typename T> void input_integer(T& var) { var = 0; T sign = 1; int cc = getchar_unlocked(); for (; cc<'0' || '9'<cc; cc = getchar_unlocked()) if (cc == '-') sign = -1; for (; '0' <= cc&&cc <= '9'; cc = getchar_unlocked()) var = (var << 3) + (var << 1) + cc - '0'; var = var*sign; } inline int c() { return getchar_unlocked(); } inline MaiScanner& operator>>(int& var) { input_integer<int>(var); return *this; } inline MaiScanner& operator>>(long long& var) { input_integer<long long>(var); return *this; } inline MaiScanner& operator>>(string& var) { int cc = getchar_unlocked(); for (; !isvisiablechar(cc); cc = getchar_unlocked()); for (; isvisiablechar(cc); cc = getchar_unlocked()) var.push_back(cc); } template<typename IT> void in(IT begin, IT end) { for (auto it = begin; it != end; ++it) *this >> *it; } }; } MaiScanner scanner; class Flow { public: size_t n; struct Arrow { int from, to; int left; int cap; Arrow(int from = 0, int to = 0, int w = 1) :from(from), to(to), left(w), cap(w) {} bool operator<(const Arrow& a) const { return (from<a.from) | (to<a.to) | (left<a.left) | (cap<a.cap); } bool operator==(const Arrow& a) const { return (from == a.from) && (to == a.to) && (left == a.left) && (cap == a.cap); } }; vector<vector<int>> vertex_to; vector<vector<int>> vertex_from; vector<Arrow> arrow; Flow(int n, int m = 5010) :n(n), vertex_to(n), vertex_from(n) { arrow.reserve(m); } void connect(int from, int to, int left) { vertex_to[from].push_back(arrow.size()); // toto vertex_from[to].push_back(arrow.size()); // fromfrom arrow.emplace_back(from, to, left); } size_t degree(int v) { return vertex_to[v].size() + vertex_from[v].size(); } size_t degree_in(int v) { return vertex_from[v].size(); } size_t degree_out(int v) { return vertex_to[v].size(); } }; int _dinic_path_dfs(Flow& flow, vector<int>& result, vector<int>& flag, const vector<int>& dist, int u, int i_sink, int mini) { // TODO: 経路再利用 if (i_sink == u) return mini; if (flag[u]) return -1; flag[u] = true; int sumw = 0; bool term = true; for (int e : flow.vertex_to[u]) { Flow::Arrow& a = flow.arrow[e]; if (a.left > 0 && dist[u]>dist[a.to]) { int w; if (mini < 0) w = a.left; else w = min(a.left, mini); w = _dinic_path_dfs(flow, result, flag, dist, a.to, i_sink, w); if (w == -1) continue; a.left -= w; result[a.to] += w; sumw += w; mini -= w; term = false; flag[u] = false; // TODO: 末尾では? if (mini == 0) return term ? -1 : sumw; } } for (int e : flow.vertex_from[u]) { Flow::Arrow& a = flow.arrow[e]; if (a.cap>a.left && dist[u]>dist[a.from]) { int w; if (mini < 0) w = a.cap - a.left; else w = min(a.cap - a.left, mini); w = _dinic_path_dfs(flow, result, flag, dist, a.from, i_sink, w); if (w == -1) continue; a.left += w; result[a.to] -= w; sumw += w; mini -= w; term = false; flag[u] = false; if (mini == 0) return term ? -1 : sumw; } } return term ? -1 : sumw; } // flowは書き換えられる. void dinic(Flow &flow, vector<int>& result, int i_source, int i_sink) { assert(i_source != i_sink); result.resize(flow.n); int distbegin = 0; vector<int> dist(flow.n); queue<int> q; vector<int> flag(flow.n); for (int distbegin = 0; ; distbegin += flow.n) { q.emplace(i_sink); // bfsはsinkからsourceへの距離を計算. dist[i_sink] = distbegin + 1; while (!q.empty()) { int v = q.front(); q.pop(); for (int ie : flow.vertex_from[v]) { const Flow::Arrow& e = flow.arrow[ie]; if (0<e.left && dist[e.from] <= distbegin) { dist[e.from] = dist[v] + 1; q.emplace(e.from); } } for (int ie : flow.vertex_to[v]) { const Flow::Arrow& e = flow.arrow[ie]; if (e.left<e.cap && dist[e.to] <= distbegin) { dist[e.to] = dist[v] + 1; q.emplace(e.to); } } } //debugv(dist); fill(ALL(flag), false); if (dist[i_source] <= distbegin) { break; } else { result[i_source] += _dinic_path_dfs(flow, result, flag, dist, i_source, i_sink, -1); } } } ll n, m; int main() { scanner >> n >> m; Flow graph_orig(n); Flow graph(n); map<int, int> link; repeat(m) { int a, b, c; scanner >> a >> b >> c; --a; --b; int ia, ib; ia = graph.arrow.size(); graph.connect(a, b, c); ib = graph.arrow.size(); graph.connect(b, a, c); link[ia] = ib; link[ib] = ia; graph_orig.connect(a, b, c); } vector<int> result; dinic(graph, result, 0, n - 1); int fl = 0; int high = 0; for (int i = 0; i < graph.arrow.size();++i) { auto& a = graph.arrow[i]; auto di = link[i]; auto& d = graph.arrow[di]; if (di < i) continue; if (a.left != a.cap && d.left != d.cap) { high = max(high, a.cap); fl += a.cap; //graph.arrow[di].cap = a.ca; } } cout << (fl - high) << endl; return 0; }
a.cc: In member function '{anonymous}::MaiScanner& {anonymous}::MaiScanner::operator>>(std::string&)': a.cc:66:9: warning: no return statement in function returning non-void [-Wreturn-type] 66 | } | ^ In file included from /usr/include/c++/14/string:43, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:6: /usr/include/c++/14/bits/allocator.h: In destructor 'std::_Vector_base<std::vector<int>, std::allocator<std::vector<int> > >::_Vector_impl::~_Vector_impl()': /usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::vector<int>]': target specific option mismatch 182 | ~allocator() _GLIBCXX_NOTHROW { } | ^ In file included from /usr/include/c++/14/vector:66, from /usr/include/c++/14/functional:64, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53: /usr/include/c++/14/bits/stl_vector.h:132:14: note: called from here 132 | struct _Vector_impl | ^~~~~~~~~~~~
s440617363
p03664
C++
#include <iostream> #include <vector> #include <algorithm> #include <stdio.h> #include <sstream> #include <string> #include <map> #include <set> #include <stdlib.h> #include <cmath> #include <math.h> #include <fstream> #include <bitset> #include <time.h> #include <queue> #include <cassert> #include <cstdio> #include <complex> #define int long long using namespace std; struct Vertex{int f; int r;}; int n, m, x, y, ci; int matrix[15][15]; int INF = -1e13; int answer; int dp[number][n]; vector<vector<int> > data, money; vector<Vertex> snm; int get(int vertex){ if (snm[vertex].f == vertex) return vertex; snm[vertex].f = get(snm[vertex].f); return snm[vertex].f; } void unia(int first, int second){ if (snm[first].r < snm[second].r){ snm[first].f = second; } else if (snm[first].r > snm[second].r){ snm[second].f = first; } else{ snm[second].f = first; snm[first].r++; } } int kraskall(){ vector<vector<int> > edges; for (int i=0; i < data.size(); i++){ for (int j=0; j < data[i].size(); j++){ vector<int> help; help.push_back(money[i][j]); help.push_back(i); help.push_back(data[i][j]); edges.push_back(help); } } sort(edges.begin(), edges.end(), greater<vector<int> > ()); int ostov = 0; for (int i=0; i < data.size(); i++){ Vertex v; v.f = i; v.r = 1; snm.push_back(v); } for (int i=0; i < edges.size(); i++){ int first = edges[i][1]; int second = edges[i][2]; int p1 = get(first); int p2 = get(second); if (p1 == p2) continue; ostov += edges[i][0]; unia(p1, p2); } return ostov; } signed main() { cin >> n >> m; for (int i=0; i < n; i++){ for (int j=0; j < n; j++){ matrix[i][j] = -1; } } for (int i=0;i<m;i++){ cin >> x >> y >> ci; matrix[x-1][y-1] = ci; matrix[y-1][x-1] = ci; } int number = 1 << n; for (int i=0; i < number; i++){ for (int j=0;j<n;j++){ dp[i][j] = INF; } } dp[1][0] = 0; for (int i=0; i < number; i++){ for (int j=0; j < n; j++){ int step = 1 << j; int band = step & i; if (band == 0) continue; int nm = i - step; for (int k=0; k < n; k++){ if (dp[nm][k] == INF) continue; dp[i][j] = max(dp[i][j], dp[nm][k] + matrix[j][k]); } } } answer = 1e18; for (int i=0; i < number; i++){ int tr = 0; int cost = dp[i][n-1]; if (cost == INF) continue; int summ = 0; for (int j=0; j < n; j++){ for (int k=j+1; k < n; k++){ int st1 = 1 << j; int st2 = 1 << k; int band1 = i & st1; int band2 = i & st2; if (band1 == 0 || band2 == 0) continue; summ += matrix[j][k]; } } tr += summ - cost; data.clear(); int counter = 0; vector<int> nin; for (int j=0; j < n; j++){ int nn = 1 << j; int band = nn & i; if (band != 0) counter++; else{ nin.push_back(j); } } for (int j=0; j < n-counter+1;j++){ vector<int> help, h1; money.push_back(h1); data.push_back(help); } for (int j=0; j < n; j++){ for (int k=j+1;k < n; k++){ int i1 = false; int i2 = false; int num1 = -1; int num2 = -1; for (int p=0; p < nin.size(); p++){ if (nin[p] == j){ i1 = true; num1 = p; } if (nin[p] == k){ i2 = true; num2 = p; } } if (i1 && !i2){ data[0].push_back(num1 + 1); data[num1+1].push_back(0); money[0].push_back(matrix[j][k]); money[num1+1].push_back(matrix[j][k]); tr += matrix[j][k]; } else if (!i1 && i2){ data[0].push_back(num2 + 1); data[num2+1].push_back(0); money[0].push_back(matrix[j][k]); money[num1+1].push_back(matrix[j][k]); tr += matrix[j][k]; } } } tr -= kraskall(); answer = min(answer, tr); } cout << answer << endl; return 0; }
a.cc:26:12: error: 'number' was not declared in this scope 26 | int dp[number][n]; | ^~~~~~ a.cc:26:20: error: size of array 'dp' is not an integral constant-expression 26 | int dp[number][n]; | ^ a.cc: In function 'long long int kraskall()': a.cc:48:23: error: reference to 'data' is ambiguous 48 | for (int i=0; i < data.size(); i++){ | ^~~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:27:22: note: 'std::vector<std::vector<long long int> > data' 27 | vector<vector<int> > data, money; | ^~~~ a.cc:49:27: error: reference to 'data' is ambiguous 49 | for (int j=0; j < data[i].size(); j++){ | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:27:22: note: 'std::vector<std::vector<long long int> > data' 27 | vector<vector<int> > data, money; | ^~~~ a.cc:53:28: error: reference to 'data' is ambiguous 53 | help.push_back(data[i][j]); | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:27:22: note: 'std::vector<std::vector<long long int> > data' 27 | vector<vector<int> > data, money; | ^~~~ a.cc:59:23: error: reference to 'data' is ambiguous 59 | for (int i=0; i < data.size(); i++){ | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:27:22: note: 'std::vector<std::vector<long long int> > data' 27 | vector<vector<int> > data, money; | ^~~~ a.cc: In function 'int main()': a.cc:92:13: error: 'dp' was not declared in this scope 92 | dp[i][j] = INF; | ^~ a.cc:95:5: error: 'dp' was not declared in this scope 95 | dp[1][0] = 0; | ^~ a.cc:125:9: error: reference to 'data' is ambiguous 125 | data.clear(); | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:27:22: note: 'std::vector<std::vector<long long int> > data' 27 | vector<vector<int> > data, money; | ^~~~ a.cc:139:13: error: reference to 'data' is ambiguous 139 | data.push_back(help); | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:27:22: note: 'std::vector<std::vector<long long int> > data' 27 | vector<vector<int> > data, money; | ^~~~ a.cc:158:21: error: reference to 'data' is ambiguous 158 | data[0].push_back(num1 + 1); | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:27:22: note: 'std::vector<std::vector<long long int> > data' 27 | vector<vector<int> > data, money; | ^~~~ a.cc:159:21: error: reference to 'data' is ambiguous 159 | data[num1+1].push_back(0); | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Contain
s670684099
p03665
C++
#include <algorithm> #include <bitset> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <fstream> #include <iostream> #include <iomanip> #include <map> #include <math.h> #include <memory> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string> #include <regex> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> Pii; typedef pair<int, ll> Pil; typedef pair<ll, ll> Pll; typedef pair<int, ld> Pid; typedef pair<int, string> Pis; #define rep(i,n) for(int i=0; i<n; i++) #define repm(i,s,n) for(int i=s; i<n; i++) #define all(a) (a).begin(), (a).end() const int INF = 1 << 30; const ll INF_L = 1LL << 58; const int MOD = 1e9+7; // 998244353; void coi(ll i) {cout << i << endl;} void cois(ll i) {cout << i << " ";} void cod(ld d) {cout << fixed << setprecision(16); cout << d << endl;} void cods(ld d) {cout << fixed << setprecision(16); cout << d << " ";} void coc(char c) {cout << c << endl;} void cocs(char c) {cout << c << " ";} void cos(string s) {cout << s << endl;} void coss(string s) {cout << s << " ";} void coynl(bool b) {cos(b ? "Yes" : "No");} void coynu(bool b) {cos(b ? "YES" : "NO");} // ---------------------------------------------------------------- // String Functions // ---------------------------------------------------------------- int ctoi(char c){ if(isdigit(c)) return c - '0'; else if(islower(c)) return c - 'a'; else if(isupper(c)) return c - 'A'; else return -1; } char itocd(int i){char c = i+'0'; if(isdigit(c)) return c; else return 0x00;} char itocl(int i){char c = i+'a'; if(islower(c)) return c; else return 0x00;} char itocu(int i){char c = i+'A'; if(isupper(c)) return c; else return 0x00;} // ---------------------------------------------------------------- // ---------------------------------------------------------------- // Dynamical Programming // ---------------------------------------------------------------- template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } // ---------------------------------------------------------------- // ---------------------------------------------------------------- // Graph Theory // ---------------------------------------------------------------- struct edge {ll to, cost;}; struct GraphList { ll V; vector<vector<edge>> graph; vector<ll> dist; GraphList(ll N){ init(N); } void init(ll N){ V = N; graph.resize(V); dist.resize(V); for (int i = 0; i < V; i++) {dist[i] = INF_L;} } void add_edge(ll from, ll to, ll cost){ edge e; e.to = to; e.cost = cost; graph[from].push_back(e); } void dijkstra(ll s){ for (int i = 0; i < V; i++) {dist[i] = INF_L;} dist[s] = 0; priority_queue<Pll, vector<Pll>, greater<Pll>> que; que.push(Pll(0, s)); while (!que.empty()) { Pll p = que.top(); que.pop(); ll v = p.second; if (dist[v] < p.first) continue; for (auto e : graph[v]) { if (dist[e.to] > dist[v] + e.cost) { dist[e.to] = dist[v] + e.cost; que.push(Pll(dist[e.to], e.to)); } } } } void bellman_ford(ll s){ for (int i = 0; i < V; i++) {dist[i] = INF_L;} dist[s] = 0; /* Under construction */ } }; struct GraphMatrix { ll vertex; vector<vector<edge>> graph; vector<ll> dist; GraphMatrix(ll N){ init(N); } void init(ll N){ vertex = N; graph.resize(vertex); dist.resize(vertex); for (int i = 0; i < vertex; i++) {dist[i] = INF;} } void add_edge(ll s, ll t, ll cost){ edge e; e.to = t; e.cost = cost; graph[s].push_back(e); } void warshall_floyd (ll s){ for (int i = 0; i < vertex; i++) {dist[i] = INF;} dist[s] = 0; /* Under construction */ } }; // ---------------------------------------------------------------- // ---------------------------------------------------------------- // Mathematical Functions // ---------------------------------------------------------------- ll gcd(ll A, ll B) {if(A%B==0){return(B);} else{return(gcd(B, A%B));}} ll lcm(ll A, ll B) {return A<B ? A*(B/gcd(A, B)) : (A/gcd(A, B))*B;} ll getDigit(ll N) {return (ll)(to_string(N).length());} ll getDigitForBase(ll N, ll B) {if(B<2){return -1;} else if(B==10){return getDigit(N);} else{ll r=0; while(N!=0){N/=B;r++;} return r;}} ll getDigitSum(ll N) {ll r=0; string Ns=to_string(N); for(int i=0; i<getDigit(N); i++){r+=ctoi(Ns[i]);} return r;} ll getDivTimes(ll N, ll D) {ll r=0; while(N%D == 0) {N/=D; r++;} return r;} ll powMod(ll B, ll P) { if(P == 0) return 1; if(P%2 == 0){ll t = powMod(B, P/2); return t*t % MOD;} return B * powMod(B, P-1) % MOD; } ll invMod(ll N) {return powMod(N, MOD-2);} /* ---------------------------------- Factorial, Permutation, Combination ---------------------------------- */ const ll FPC_INIT_SIZE_MAX = 1e6; struct FPCMod { ll size; vector<ll> inv, fac, finv; FPCMod(ll N){ init(N); } void init(ll N){ size = (N > 1 && N < FPC_INIT_SIZE_MAX) ? N+9 : FPC_INIT_SIZE_MAX; inv.resize(size); fac.resize(size); finv.resize(size); fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < size; i++){ fac[i] = fac[i-1] * i % MOD; inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; finv[i] = finv[i-1] * inv[i] % MOD; } } ll inverseMod(ll N){return inv[N] % MOD;} ll factrialMod(ll N){return fac[N] % MOD;} ll factrialInverseMod(ll N){return finv[N] % MOD;} ll permutationMod(ll N, ll K){ if (N < 0 || K < 0 || N < K) return 0; else return factrialMod(N) * factrialInverseMod(N-K) % MOD; } ll combinationMod(ll N, ll K){ if (N < 0 || K < 0 || N < K) return 0; else if (N < size){ return factrialMod(N) * (factrialInverseMod(K) * factrialInverseMod(N-K) % MOD) % MOD;} else { ll ans = 1; ll Ks = K < N-K ? K : N-K; for (ll i = N; i > N-Ks; i--) {ans *= i; ans %= MOD;} return ans * factrialInverseMod(Ks) % MOD; } } }; /* ---------------------------------- Sieve Theory ---------------------------------- */ const ll SIEVE_SIZE_MAX = 1e9; struct SieveEratosthenes { private : ll N_max; ll ssize, ssize_sqrt; vector<bool> sieve; bool sieve_fg; vector<ll> sievingp; bool sievingp_fg; vector<ll> primes; bool primes_fg; vector<int> skipPrimes = {2, 3, 5}; vector<int> standReminders = {1, 7, 11, 13, 17, 19, 23, 29}; vector<int> invidxStandReminders = { -1, 0, -1, -1, -1, -1, -1, 1, -1, -1, -1, 2, -1, 3, -1, -1, -1, 4, -1, 5, -1, -1, -1, 6, -1, -1, -1, -1, -1, 7 }; const int SP_prod = 2 * 3 * 5; int SR_size = 8; public : SieveEratosthenes(ll N) { sieve_fg = true; sievingp_fg = true; init(N); } SieveEratosthenes(ll N, int c) { switch (c) { case 1 : sieve_fg = true; sievingp_fg = true; break; default: sieve_fg = true; sievingp_fg = false; break; } init(N); } ll size() {return N_max;} bool isPrime(ll N) { if (!sieve_fg) return false; if (N < 2 || N >= N_max) return false; for (auto p : skipPrimes) { if(N == p) return true; if(N%p == 0) return false; } return sieve[numtoidx(N)]; } ll getSievingPrime(ll N) { if (!sievingp_fg) return -1; if (N < 2 || N >= N_max) return -1; for (auto p : skipPrimes) { if(N%p == 0) return p; } if (isPrime(N)) return N; return sievingp[numtoidx(N)]; } private : void init(ll N) { N_max = (N > 1 && N < SIEVE_SIZE_MAX) ? N+100 : SIEVE_SIZE_MAX; ssize = (N_max/SP_prod + 1) * SR_size; ssize_sqrt = ((ll)sqrt(N_max)/SP_prod + 1) * SR_size; sieve = vector<bool>(ssize, true); sievingp = vector<ll>(ssize, 0); primes.clear(); sieveInit(); } void sieveInit() { for (ll i = 1; i < ssize_sqrt; i++) { if(!sieve[i]) continue; ll num_i = idxtonum(i); for (ll j = num_i*num_i; j < N_max; j += num_i) { ll idx_j = numtoidx(j); if(idx_j > 0) { sieve[idx_j] = false; sievingp[idx_j] = num_i; } } } } ll idxtonum(ll idx) { return (idx/SR_size) * SP_prod + standReminders[idx%SR_size]; } ll numtoidx(ll num) { int iiSR = invidxStandReminders[num%SP_prod]; return iiSR < 0 ? -1 : (num/SP_prod) * SR_size + iiSR; } }; struct SieveAtkinBernstein { private : ll N_max; ll ssize, ssize_sqrt; vector<bool> sieve; public : SieveAtkinBernstein(ll N) { init(N); } ll size() {return N_max;} bool isPrime(ll N) { if (N < 0 || N >= N_max) return false; return sieve[N]; } private : void init(ll N) { N_max = (N > 1 && N < SIEVE_SIZE_MAX) ? N : SIEVE_SIZE_MAX; ssize = N_max; ssize_sqrt = (ll)sqrt(ssize+0.1); sieve.resize(ssize); sieveInit(); } void sieveInit() { sieve[2] = sieve[3] = true; int n = 0; for (int z = 1; z <= 5; z += 4) { for (int y = z; y <= ssize_sqrt; y += 6) { for (int x = 1; x <= ssize_sqrt && (n = 4*x*x+y*y) < ssize; x++) sieve[n] = !sieve[n]; for (int x = y+1; x <= ssize_sqrt && (n = 3*x*x-y*y) < ssize; x += 2) sieve[n] = !sieve[n]; } } for (int z = 2; z <= 4; z += 2) { for (int y = z; y <= ssize_sqrt; y += 6) { for (int x = 1; x <= ssize_sqrt && (n = 3*x*x+y*y) < ssize; x += 2) sieve[n] = !sieve[n]; for (int x = y+1; x <= ssize_sqrt && (n = 3*x*x-y*y) < ssize; x += 2) sieve[n] = !sieve[n]; } } for (int z = 1; z <= 2; z++) { for (int y = 3; y <= ssize_sqrt; y += 6) { for (int x = z; x <= ssize_sqrt && (n = 4*x*x+y*y) < ssize; x += 3) sieve[n] = !sieve[n]; } } for (int k = 5; k <= ssize_sqrt; k++) if (sieve[k]) for (int n = k*k; n < ssize; n += k*k) sieve[n] = false; } }; /* ---------------------------------- Prime Factorization ---------------------------------- */ const ll PRIME_FACTORIZATION_SIZE_MAX = 1e12; struct primeFactrization { private : map<ll, ll> idxVec, idxMap; vector<vector<ll>> primeFactorVec; vector<map<ll, ll>> primeFactorMap; public : primeFactrization() { init(); } void calc_primeFactrization_vec(ll N) { if (N < 2 || N > PRIME_FACTORIZATION_SIZE_MAX) return; primeFactorVec.push_back(vector<ll>()); ll idx = (int)primeFactorVec.size() - 1; idxVec[N] = idx; add_vec(N, idx); sort(primeFactorVec[idx].begin(), primeFactorVec[idx].end()); } void calc_primeFactrization_map(ll N) { if (N < 2 || N > PRIME_FACTORIZATION_SIZE_MAX) return; primeFactorMap.push_back(map<ll, ll>()); ll idx = (int)primeFactorMap.size() - 1; idxMap[N] = idx; add_map_withoutSieve(N, idx); } void calc_primeFactrization_map_withSieve(ll N, SieveEratosthenes sieve) { if (N < 2 || N > PRIME_FACTORIZATION_SIZE_MAX) return; if (N > sieve.size()) return; primeFactorMap.push_back(map<ll, ll>()); ll idx = (int)primeFactorMap.size() - 1; idxMap[N] = idx; add_map_withSieve(N, idx, sieve); } vector<ll> getPrimeFactorizeVec(ll N) { if(idxVec[N] == 0) return vector<ll>(); return primeFactorVec[idxVec[N]]; } map<ll, ll> getPrimeFactorizeMap(ll N) { if(idxMap[N] == 0) return map<ll, ll>(); return primeFactorMap[idxMap[N]]; } private : void init() { idxVec.clear(); primeFactorVec.clear(); primeFactorVec.push_back(vector<ll>()); idxMap.clear(); primeFactorMap.clear(); primeFactorMap.push_back(map<ll, ll>()); } void add_vec(ll N, ll idx) { primeFactorVec[idx].push_back(1); primeFactorVec[idx].push_back(N); for (ll div = 2; div<=(ll)sqrt(N+0.1); div++){ if(N%div == 0) { if(div < N/div) { primeFactorVec[idx].push_back(div); primeFactorVec[idx].push_back(N/div); } if (div == N/div) { primeFactorVec[idx].push_back(div); } } } } void add_map_withoutSieve(ll N, ll idx) { ll Nc = N; while(Nc > 1) { for (ll div = 2; div<=(ll)sqrt(N+0.1); div++){ while(Nc%div == 0) { primeFactorMap[idx][div]++; Nc /= div; } if(Nc == 1) break; } if(Nc > 1) { primeFactorMap[idx][Nc]++; Nc /= Nc; } } } void add_map_withSieve(ll N, ll idx, SieveEratosthenes sieve) { ll Nc = N; while(Nc > 1) { ll div = sieve.getSievingPrime(Nc); primeFactorMap[idx][div]++; Nc /= div; } } }; // ---------------------------------------------------------------- //* **************** GLOBAL VARIABLES **************** *// //* **************************************************** *// void input() { } void solve() { ll N, P; cin >> N >> P; vector<ll> cnt(2, 0); rep(i, N) {ll A; cin >> A; cnt[A%2]++;} ll ans = pow(2, cnt[0]) * pow(2, max(cnt[1]-1, 0)); coi(P == 1 && cnt[1] == 0 ? 0 : ans); } int main() { std::ifstream in("input.txt"); std::cin.rdbuf(in.rdbuf()); cin.tie(0); ios::sync_with_stdio(false); input(); solve(); return 0; }
a.cc: In function 'void solve()': a.cc:501:41: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type, int)' 501 | ll ans = pow(2, cnt[0]) * pow(2, max(cnt[1]-1, 0)); | ~~~^~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:501:41: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 501 | ll ans = pow(2, cnt[0]) * pow(2, max(cnt[1]-1, 0)); | ~~~^~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:501:41: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 501 | ll ans = pow(2, cnt[0]) * pow(2, max(cnt[1]-1, 0)); | ~~~^~~~~~~~~~~~~
s542120867
p03665
C
#include<bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,n) for(ll i=0;i<(ll)n;++i) using P = pair<ll,ll>; ll factorial( ll n ){ if( n == 1 ) return 1; return n*factorial(n-1); } ll comb( ll n, ll r ){ if( n < r ) return 0; if( r == 0 || n == r ) return 1; if( r == 1 || n == r+1 ) return n; return factorial(n)/factorial(r)/factorial(n-r); } ll pow( ll x, ll n ){ if( n == 0 ) return 1; ll t = pow(x,n/2); if( n%2 == 0 ){ return t*t; }else{ return t*t*x; } } int main() { ll n,p;cin >> n >> p; ll even = 0; ll odd = 0; rep(i,n){ ll num;cin >> num; if( num%2 == 0 ) even++; else odd++; } if( p == 0 ){ cout << pow(2,even)*pow(2,odd)/2 << endl; }else{ if( odd == 0 ){ cout << 0 << endl; }else{ cout << (ll)pow(2,even)*(ll)pow(2,odd)/2 << endl; } } return 0; }
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory 1 | #include<bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s645434886
p03665
C++
int main() { int N,P; cin >>N >> P; vector<int>vec(N); long long cou0=0,cou1=0; long long ans=1,ans2=0,ansa,muri,ansb=0; for(int i=0;i<N;i++){ cin >> vec.at(i); if(vec.at(i)%2==0)cou0++; else cou1++; } for(int i=0;i<cou0;i++){ ans*=2; } if(P==1){ for(int i=1;i<=cou1;i=i+2){ int j= min(i,cou1-i); ansa = kaizyo(cou1,j)/ kaizyo(j,1); ansb+=ansa; } muri=ans*ansb; cout <<muri <<endl; } else{ for(int i=0; i<=cou1; i=i+2){ ansa = kaizyo(cou1,j)/kaizyo(j,1); ansb+=ansa; } muri=ans*ansb; cout <<muri <<endl; } }
a.cc: In function 'int main()': a.cc:3:3: error: 'cin' was not declared in this scope 3 | cin >>N >> P; | ^~~ a.cc:4:3: error: 'vector' was not declared in this scope 4 | vector<int>vec(N); | ^~~~~~ a.cc:4:10: error: expected primary-expression before 'int' 4 | vector<int>vec(N); | ^~~ a.cc:9:12: error: 'vec' was not declared in this scope 9 | cin >> vec.at(i); | ^~~ a.cc:23:16: error: 'min' was not declared in this scope; did you mean 'main'? 23 | int j= min(i,cou1-i); | ^~~ | main a.cc:24:15: error: 'kaizyo' was not declared in this scope 24 | ansa = kaizyo(cou1,j)/ kaizyo(j,1); | ^~~~~~ a.cc:28:5: error: 'cout' was not declared in this scope; did you mean 'cou1'? 28 | cout <<muri <<endl; | ^~~~ | cou1 a.cc:28:19: error: 'endl' was not declared in this scope 28 | cout <<muri <<endl; | ^~~~ a.cc:32:26: error: 'j' was not declared in this scope 32 | ansa = kaizyo(cou1,j)/kaizyo(j,1); | ^ a.cc:32:14: error: 'kaizyo' was not declared in this scope 32 | ansa = kaizyo(cou1,j)/kaizyo(j,1); | ^~~~~~ a.cc:36:5: error: 'cout' was not declared in this scope; did you mean 'cou1'? 36 | cout <<muri <<endl; | ^~~~ | cou1 a.cc:36:19: error: 'endl' was not declared in this scope 36 | cout <<muri <<endl; | ^~~~
s784872655
p03665
C++
int main() { int n, p; scanf("%d%d", &n, &p); int m = 0; rep(i, n) { int a; scanf("%d", &a); if(a % 2 == 1) m++; } if(m == 0) { ll ans = 1ll << n; //2^n if(p == 0) printf("%lld\n", ans); else printf("0\n"); } else { ll ans = 1ll << (n - 1); //2^n-1 printf("%lld\n", ans); } return 0; }
a.cc: In function 'int main()': a.cc:4:9: error: 'scanf' was not declared in this scope 4 | scanf("%d%d", &n, &p); | ^~~~~ a.cc:6:13: error: 'i' was not declared in this scope 6 | rep(i, n) { | ^ a.cc:6:9: error: 'rep' was not declared in this scope 6 | rep(i, n) { | ^~~ a.cc:12:17: error: 'll' was not declared in this scope 12 | ll ans = 1ll << n; //2^n | ^~ a.cc:13:45: error: 'ans' was not declared in this scope 13 | if(p == 0) printf("%lld\n", ans); | ^~~ a.cc:13:28: error: 'printf' was not declared in this scope 13 | if(p == 0) printf("%lld\n", ans); | ^~~~~~ a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | int main() a.cc:14:22: error: 'printf' was not declared in this scope 14 | else printf("0\n"); | ^~~~~~ a.cc:14:22: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' a.cc:17:17: error: 'll' was not declared in this scope 17 | ll ans = 1ll << (n - 1); //2^n-1 | ^~ a.cc:18:34: error: 'ans' was not declared in this scope 18 | printf("%lld\n", ans); | ^~~ a.cc:18:17: error: 'printf' was not declared in this scope 18 | printf("%lld\n", ans); | ^~~~~~ a.cc:18:17: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
s536777682
p03665
C++
#define rep(i,n) for (int i=0; i<(int)(n); i++) #define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n, p; cin >> n >> p; vector<int> A(n); rep(i,n) cin >> A[i]; int oddcnt = 0; rep(i,n) { if (A[i] % 2) oddcnt++; } if (oddcnt == 0) { if (p == 1) { cout << 0 << endl; } else { cout << (1LL<<n) << endl; } } else { cout << (1LL<<n-1) << endl; } return 0; }
a.cc:5:11: error: 'pair' does not name a type 5 | using P = pair<int, int>; | ^~~~ a.cc: In function 'int main()': a.cc:8:13: error: 'cin' was not declared in this scope 8 | int n, p; cin >> n >> p; | ^~~ a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' +++ |+#include <iostream> 1 | #define rep(i,n) for (int i=0; i<(int)(n); i++) a.cc:9:3: error: 'vector' was not declared in this scope 9 | vector<int> A(n); | ^~~~~~ a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' +++ |+#include <vector> 1 | #define rep(i,n) for (int i=0; i<(int)(n); i++) a.cc:9:10: error: expected primary-expression before 'int' 9 | vector<int> A(n); | ^~~ a.cc:10:19: error: 'A' was not declared in this scope 10 | rep(i,n) cin >> A[i]; | ^ a.cc:14:9: error: 'A' was not declared in this scope 14 | if (A[i] % 2) oddcnt++; | ^ a.cc:19:7: error: 'cout' was not declared in this scope 19 | cout << 0 << endl; | ^~~~ a.cc:19:7: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:19:20: error: 'endl' was not declared in this scope 19 | cout << 0 << endl; | ^~~~ a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' +++ |+#include <ostream> 1 | #define rep(i,n) for (int i=0; i<(int)(n); i++) a.cc:21:7: error: 'cout' was not declared in this scope 21 | cout << (1LL<<n) << endl; | ^~~~ a.cc:21:7: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:21:27: error: 'endl' was not declared in this scope 21 | cout << (1LL<<n) << endl; | ^~~~ a.cc:21:27: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' a.cc:24:5: error: 'cout' was not declared in this scope 24 | cout << (1LL<<n-1) << endl; | ^~~~ a.cc:24:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:24:27: error: 'endl' was not declared in this scope 24 | cout << (1LL<<n-1) << endl; | ^~~~ a.cc:24:27: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
s770699903
p03665
C++
n, p = map(int, input().split()) la = [int(i) % 2 for i in input().split()] n0 = sum(1 for a in la if a % 2 == 0) n1 = sum(1 for a in la if a % 2 == 1) def combi(n, k): c = 1 for i in range(1, n + 1): c *= i for i in range(1, k + 1): c //= i for i in range(1, n - k + 1): c //= i return c def answer(): if p == 0: c0 = 2 ** n0 c1 = 0 for i in range(0, n1 + 1, 2): c1 += combi(n1, i) return c0 * c1 else: c0 = 2 ** n0 c1 = 0 for i in range(1, n1 + 1, 2): c1 += combi(n1, i) return c0 * c1 print(answer())
a.cc:1:1: error: 'n' does not name a type 1 | n, p = map(int, input().split()) | ^
s296541214
p03665
C++
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで #include <bits/stdc++.h> #define mod 1000000007 #define INF 1001001001 #define ll long long #define ln cout<<endl #define Yes cout<<"Yes"<<endl #define No cout<<"No"<<endl #define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++) #define rep(i,n) REP(i,0,n) using namespace std; std::vector<std::vector<long long>> comb(int n, int r) { std::vector<std::vector<long long>> v(n + 1,std::vector<long long>(n + 1, 0)); for (int i = 0; i < v.size(); i++) { v[i][0] = 1; v[i][i] = 1; } for (int j = 1; j < v.size(); j++) { for (int k = 1; k < j; k++) { v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]); } } return v; } int main() { cin.tie(0); ios::sync_with_stdio(false); ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0; string str; ll p; cin>>n>>p; vector<ll> v(n); rep(i,n) cin>>v[i]; ll ki=0; ll gu=0; rep(i,n) { if(v[i]%2)ki++; else gu++; } if(p==1&&ki%2==0){ ki--; gu+=ki/2; for(ll i=1;i<gu;i++){ sum+=comb((int)n,(int)i); } cout<<sum<<endl; }else{ gu+=ki/2; for(ll i=1;i<gu;i++){ sum+=(ll) comb((int)n,(int)i); } } return 0; }
a.cc: In function 'int main()': a.cc:48:16: error: no match for 'operator+=' (operand types are 'long long int' and 'std::vector<std::vector<long long int> >') 48 | sum+=comb((int)n,(int)i); | ~~~^~~~~~~~~~~~~~~~~~~~~ a.cc:54:18: error: invalid cast from type 'std::vector<std::vector<long long int> >' to type 'long long int' 54 | sum+=(ll) comb((int)n,(int)i); | ^~~~~~~~~~~~~~~~~~~~~~~~
s378924526
p03665
C++
#include <bits/stdc++.h> using namespace std; map< long long, int > prime_factor(long long n) { map< long long, int > ret; for (long long i = 2; i * i <= n; i++) { while (n % i == 0) { ret[i]++; n /= i; } } if (n != 1) ret[n] = 1; return ret; } int main() { int n, p; cin >> n >> p; vector<int> a(n); int oddcount=0, evencount=0; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] % 2 == 0) { evencount++; } else { oddcount++; } } if(oddcount==0 && p==0){cout << } if (p == 0) { if (oddcount == 0) { cout << (long long)pow(2, n) << endl;; } cout << (long long)pow(2, evencount)*(long long)pow(2, (oddcount) / 2) << endl;; } else { if (oddcount == 0 ) { cout << 0 << endl; } else { cout << (long long)pow(2, evencount)*(long long)pow(2, oddcount) / 2 << endl;; } } return 0; }
a.cc: In function 'int main()': a.cc:34:41: error: expected primary-expression before '}' token 34 | if(oddcount==0 && p==0){cout << } | ^