submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s645253752
p04017
C++
#include<bits/stdc++.h> using namespace std; #define ll long long #define mp make_pair #define pb push_back #define pii pair<int,int> const int maxn = 1e5 + 5; int dp[maxn][21] , a[maxn] , n , L; int ask (int x , int c) { int pos = x; if (pos == -1) return 1e9; for (int i = 20 ; i >= 0 ; i--){ if (c & (1 << i)){ pos = dp[pos][i]; if (pos == -1) return 1e9; } } if (pos == -1) return 1e9; return pos; } void solve () { for (int i = 1 ; i <= n ; i++) { int l = 1 , r = n , mid; while (l <= r){ mid = l + r >> 1; if (a[mid] <= a[i] + L) l = mid + 1; else r = mid - 1; } dp[i][0] = r; } dp[n][0] = -1; for (int i = 1 ; i <= 20 ; i++){ for (int j = 1 ; j <= n; j++){ if (dp[j][i - 1] == -1) dp[j][i] = -1; else dp[j][i] = dp[dp[j][i - 1]][i - 1]; } } for (int i = 1 ; i <= n ; i++){ for (int j = 1 ; j <= 20 ; j++) if (dp[i][j - 1] == 9 || dp[i][j - 1] == -1) dp[i][j] = -1; // cout << i << endl; // cout << endl; // for (int j = 0 ; j <= 5 ; j++) cout << dp[i][j] << " "; } } int main() { ios::sync_with_stdio(false); cin >> n; for (int i = 1 ; i <= n ; i++) cin >> a[i]; cin >> L; solve (); // cout << ask(2 , 7) << endl; int q;cin >> q; while (q--){ int x , y; cin >> x >> y; if (x > y) swap(x , y); int l = 1 , r = n; while (l <= r){ int mid = l + r >> 1; if (ask(x , mid) > y) r = mid - 1; else l = mid + 1; } if (ask(x , r) < y) r++; cout << r << endl; } return 0; } /* 9 1 3 6 13 15 18 19 29 31 10 17 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 9 1 3 6 13 15 18 19 29 31 10 4 2 9 */ v
a.cc:103:1: error: 'v' does not name a type 103 | v | ^
s934720626
p04017
C++
#include <bits/stdc++.h> using namespace std; #define int long long int bs(const int &n, const int &t, const int &a[]){ int l = 0, h = n-1; while (l<=h){ int mid = (l+h)/2; if (a[mid] <= t) l = mid+1; else h = mid-1; } return l-1; } signed main(){ int n, l, q, x, y; cin >> n; int a[n]; for (int i=0; i<n; i++) cin >> a[i]; cin >> l >> q; for (int i=0; i<q; i++){ cin >> x >> y; x--; y--; if (x>y){int tmp = x; x = y; y = tmp;} int t = 0; while (true){ int k = bs(n, a[x]+l, a); t++; if (k>=y) break; x = k; } cout << t << endl; } }
a.cc:5:47: error: declaration of 'a' as array of references 5 | int bs(const int &n, const int &t, const int &a[]){ | ^ a.cc: In function 'long long int bs(...)': a.cc:6:24: error: 'n' was not declared in this scope 6 | int l = 0, h = n-1; | ^ a.cc:9:21: error: 'a' was not declared in this scope 9 | if (a[mid] <= t) l = mid+1; | ^ a.cc:9:31: error: 't' was not declared in this scope 9 | if (a[mid] <= t) l = mid+1; | ^
s673272544
p04017
C++
#include<bits/stdc++.h> using namespace std; #define N 100000 + 5 #define rep(i, l, r) for(int i = l; i <= r; ++i) int n, l, q, a, b, tot, size, x[N], nxt[N], last[N], cntb[N], block[N]; int read(){ char c; int x = 0, f = 1; c = getchar(); while(c > '9' || c < '0'){ if(c == '-') f = -1; c = getchar();} while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar(); return x * f; } int main(){ n = read(), size = sqrt(n), tot = ceil(1.0 * n / size); rep(i, 1, n) x[i] = read(); l = read(); rep(i, 1, n){ int pos = upper_bound(x + 1, x + n + 1, x[i] + l) - x; if(x[pos] < x[i] + l) last[i] = n + 1; else last[i] = pos - 1; } block[n + 1] = tot + 1; rep(i, 1, n) block[i] = i / size + 1; rep(i, 1, n){ int pos = i, cnt = 0; while(block[pos] == block[i]) pos = last[pos], ++cnt; cntb[i] = cnt, nxt[i] = pos; } q = read(); while(q--){ a = read(), b = read(); if(a > b) swap(a, b); int pos = a, ans = 0; while(block[pos] != block[b]) ans += cntb[pos], pos = nxt[pos]; while(pos < b) pos = last[pos], ++ans; printf("%d\n", ans); } return 0; }
a.cc: In function 'int main()': a.cc:14:17: error: reference to 'size' is ambiguous 14 | n = read(), size = sqrt(n), tot = ceil(1.0 * n / size); | ^~~~ In file included from /usr/include/c++/14/string:53, 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/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:5:25: note: 'int size' 5 | int n, l, q, a, b, tot, size, x[N], nxt[N], last[N], cntb[N], block[N]; | ^~~~ a.cc:14:54: error: reference to 'size' is ambiguous 14 | n = read(), size = sqrt(n), tot = ceil(1.0 * n / size); | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:5:25: note: 'int size' 5 | int n, l, q, a, b, tot, size, x[N], nxt[N], last[N], cntb[N], block[N]; | ^~~~ a.cc:23:33: error: reference to 'size' is ambiguous 23 | rep(i, 1, n) block[i] = i / size + 1; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:5:25: note: 'int size' 5 | int n, l, q, a, b, tot, size, x[N], nxt[N], last[N], cntb[N], block[N]; | ^~~~
s224114876
p04017
C++
#include <bits/stdc++.h> using namespace std; const int maxn=112345; int n,x[maxn],l,q,f[maxn][20]; int main() { scanf("%d",&n); for (int i=1;i<=n;++i) scanf("%d",&x[i]); scanf("%d%d",&l,&q); for (int i=1;i<=n;++i) { int t=upper_bound(x+1,x+1+n,x[i]+l)-x-1; f[i][0]=t; } for (int i=1;i<20;++i) for (int j=1;j<=n+1==;++j) f[j][i]=f[f[j][i-1]][i-1]; while (q--) { int a,b;scanf("%d%d",&a,&b); if (a>b) swap(a,b); int num=0; for (int i=19;i>=0;--i) if (f[a][i]<b) { num+=1<<i; a=f[a][i]; } printf("%d\n",num+1); } return 0; }
a.cc: In function 'int main()': a.cc:15:30: error: expected primary-expression before ';' token 15 | for (int j=1;j<=n+1==;++j) | ^
s378932729
p04017
C++
#include "header.hpp" // #define int long long signed main() { //input int N;cin>>N; vector<int> x(N); rep(n, N) cin>>x[n]; int L;cin>>L; int Q;cin>>Q; //solve vector<vector<int>> db(N, vector<int>(20)); rep(n, N){ // fill: db[n][0] // x[n] + L db[n][0] = upos(x, x[n]+L) - 1; } rep(k, 1, 20){ rep(n, N){ // fill: db[n][k]; db[n][k] = db[db[n][k-1]][k-1]; } } rep(q, Q){ int a,b; cin>>a>>b; a--;b--; if (a>b) swap(a, b); dump(a, b); // db[a][x]<=bとなる最大 int ans = 0; while (a!=b){ dump(a, b); int k = upos(db[a], b) - 1; ans += pow(2, k); a = db[a][k]; } cout << ans << endl; } return 0; }
a.cc:1:10: fatal error: header.hpp: No such file or directory 1 | #include "header.hpp" | ^~~~~~~~~~~~ compilation terminated.
s537403908
p04017
C++
#pragma GCC Optimize ("O3") #include <bits/stdc++.h> using namespace std; typedef long long ll; #define lp(i,begin,end) for (int i=begin;i<end;i++) const int N=1e5+5,M=N*N,OO=0x3f3f3f3f; int n,l,q,arr[N],x,y; int lst,far,d; struct query{ int x,y,qnum,ans; }qarr[N]; bool cmp(query a,query b){ if(a.x==b.x)return a.y<b.y; return a.x<b.x; } int mnroot(int t){ int cur=far,dis=d,idx; while(cur<t){ idx=lower_bound(arr,arr+n,arr[cur]+l); if(idx==n){far=n-1; d=dis+1; return d;} if(arr[idx]>arr[cur]+l)idx--; if(arr[idx]>=t){far=idx; d=dis+1; return d;} cur=idx; dis++; } return d; } bool cmp2(query a,query b){ return a.qnum<b.qnum; } int main(){ scanf("%d",&n); lp(i,0,n)scanf("%d",arr+i); scanf("%d%d",&l,&q); lp(i,0,q){ scanf("%d%d",&x,&y); x--,y--; qarr[i].x=min(x,y),qarr[i].y=max(x,y),qarr[i].qnum=i; } sort(qarr,qarr+q,cmp); lst=qarr[0].x,far=qarr[0].x; lp(i,0,q){ if(qarr[i].x!=lst){lst=far=qarr[i].x; d=0;} qarr[i].ans=mnroot(qarr[i].y); } sort(qarr,qarr+q,cmp2); lp(i,0,q){ printf("%d\n",qarr[i].ans); } }
a.cc:6:22: warning: integer overflow in expression of type 'int' results in '1411065433' [-Woverflow] 6 | const int N=1e5+5,M=N*N,OO=0x3f3f3f3f; | ~^~ a.cc: In function 'int mnroot(int)': a.cc:19:24: error: invalid conversion from 'int*' to 'int' [-fpermissive] 19 | idx=lower_bound(arr,arr+n,arr[cur]+l); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ | | | int*
s066596550
p04017
C++
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags //#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX //#pragma GCC target("avx2") //Enable AVX #include<bits/stdc++.h> using namespace std; #define int ll #define all(a) begin(a),end(a) #define F first #define S second #define pb push_back #define mp make_pair typedef long long ll; typedef vector<int> vi; typedef pair<int,int> pi; #ifdef LOCAL #include "debug.h" #else #define debug(...) 42 #endif const int mod=1e9+7; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int mul(int a,int b){ return ((a)*1ll*(b))%mod; } void add(int &a,int b){ a+=b; if(a>=mod)a-=mod; } int sub(int a,int b){ a-=b; if(a<0){ a+=mod; } return a; } int powz(int a,int b){ int res=1; while(b){ if(b&1){ res=mul(res,a); } b/=2; a=mul(a,a); } return res; } template <typename A, typename B> istream& operator>>(istream& input,pair<A,B>& x) { input>>x.F>>x.S; return input; } template <typename A> istream& operator>>(istream& input,vector<A>& x) { for(auto& i:x) input>>i; return input; } template<typename A> ostream& operator<<(ostream& output,vector<A>& x) { for(auto& i:x) output<<i<<' '; return output; } template<typename T> vector<pair<T,int>> getvec(int n){ vector<pair<T,int>>a(n); for(int i=0;i<a.size();i++){ cin>>a[i].F; a[i].S=i; } return a; } void clr(auto &a,int n){ a.clear(); a.resize(n); } void unq(auto &a){ sort(all(a)); a.resize(unique(all(a))-a.begin()); } const int N=100005; int cycleNo[N]; vector<int>adj[N]; bool vis[N]; int nxt[N]; int n; void dfs(int u,int p){ if(vis[u]){ return; } if(u==n-1){ return; } vis[u]=true; cycleNo[u]=p; adj[p].pb(u); dfs(nxt[u],p); } void solve(){ cin>>n; vi a(n); cin>>a; int L; cin>>L; int q; cin>>q; vector<pair<int,int>>queries; for(int i=0;i<q;i++){ int x,y; cin>>x>>y; x--;y--; queries.pb({x,y}); } vector<int>ans(q,-1); vector<int>prf(n); for(int i=0;i<n-1;i++){ prf[i+1]=a[i+1]-a[i]; prf[i+1]+=prf[i]; } for(int i=n-2;i>=0;i--){ int l=i+1,r=n-1; int con=prf[i],val=i+1; while(l<=r){ int mid=(l+r)/2; if((prf[mid]-con)<=L){ l=mid+1; val=max(val,mid); } else{ r=mid-1; } } nxt[i]=val; } for(int i=0;i<n-1;i++){ if(vis[i]==false){ dfs(i,i); sort(all(adj[i])); } } for(int i=0;i<q;i++){ int x,y; tie(x,y)=queries[i]; if(x<y){ auto it=lower_bound(all(adj[cycleNo[x]]),y)-adj[cycleNo[x]].begin(); auto it2=lower_bound(all(adj[cycleNo[x]]),x)-adj[cycleNo[x]].begin(); ans[i]=it-it2; } } for(int i=0;i<n;i++){ adj[i].clear(); nxt[i]=0; vis[i]=false; prf[i]=0; } reverse(all(a)); for(int i=0;i<n-1;i++){ prf[i+1]=abs(a[i+1]-a[i]); prf[i+1]+=prf[i]; } for(int i=n-2;i>=0;i--){ int l=i+1,r=n-1; int con=prf[i],val=i+1; while(l<=r){ int mid=(l+r)/2; if((prf[mid]-con)<=L){ l=mid+1; val=max(val,mid); } else{ r=mid-1; } } nxt[i]=val; } for(int i=0;i<n-1;i++){ if(vis[i]==false){ dfs(i,i); sort(all(adj[i])); } } for(int i=0;i<q;i++){ int x,y; tie(x,y)=queries[i]; x=n-x-1; y=n-y-1; if(x<y){ auto it=lower_bound(all(adj[cycleNo[x]]),y)-adj[cycleNo[x]].begin(); auto it2=lower_bound(all(adj[cycleNo[x]]),x)-adj[cycleNo[x]].begin(); ans[i]=it-it2; } } for(auto i:ans){ cout<<i<<'\n'; } } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int tc=1; //cin>>tc; for(int _=0;_<tc;_++){ //~cout<<"Case #"<<_+1<<": "; solve(); if(_!=tc-1){ cout<<'\n'; } } } //#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags //#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX //#pragma GCC target("avx2") //Enable AVX #include<bits/stdc++.h> using namespace std; #define int ll #define all(a) begin(a),end(a) #define F first #define S second #define pb push_back #define mp make_pair typedef long long ll; typedef vector<int> vi; typedef pair<int,int> pi; #ifdef LOCAL #include "debug.h" #else #define debug(...) 42 #endif const int mod=1e9+7; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int mul(int a,int b){ return ((a)*1ll*(b))%mod; } void add(int &a,int b){ a+=b; if(a>=mod)a-=mod; } int sub(int a,int b){ a-=b; if(a<0){ a+=mod; } return a; } int powz(int a,int b){ int res=1; while(b){ if(b&1){ res=mul(res,a); } b/=2; a=mul(a,a); } return res; } template <typename A, typename B> istream& operator>>(istream& input,pair<A,B>& x) { input>>x.F>>x.S; return input; } template <typename A> istream& operator>>(istream& input,vector<A>& x) { for(auto& i:x) input>>i; return input; } template<typename A> ostream& operator<<(ostream& output,vector<A>& x) { for(auto& i:x) output<<i<<' '; return output; } template<typename T> vector<pair<T,int>> getvec(int n){ vector<pair<T,int>>a(n); for(int i=0;i<a.size();i++){ cin>>a[i].F; a[i].S=i; } return a; } void clr(auto &a,int n){ a.clear(); a.resize(n); } void unq(auto &a){ sort(all(a)); a.resize(unique(all(a))-a.begin()); } const int N=100005; int cycleNo[N]; vector<int>adj[N]; bool vis[N]; int nxt[N]; int n; void dfs(int u,int p){ if(vis[u]){ return; } if(u==n-1){ return; } vis[u]=true; cycleNo[u]=p; adj[p].pb(u); dfs(nxt[u],p); } void solve(){ cin>>n; vi a(n); cin>>a; int L; cin>>L; int q; cin>>q; vector<pair<int,int>>queries; for(int i=0;i<q;i++){ int x,y; cin>>x>>y; x--;y--; queries.pb({x,y}); } vector<int>ans(q,-1); vector<int>prf(n); for(int i=0;i<n-1;i++){ prf[i+1]=a[i+1]-a[i]; prf[i+1]+=prf[i]; } for(int i=n-2;i>=0;i--){ int l=i+1,r=n-1; int con=prf[i],val=i+1; while(l<=r){ int mid=(l+r)/2; if((prf[mid]-con)<=L){ l=mid+1; val=max(val,mid); } else{ r=mid-1; } } nxt[i]=val; } for(int i=0;i<n-1;i++){ if(vis[i]==false){ dfs(i,i); sort(all(adj[i])); } } for(int i=0;i<q;i++){ int x,y; tie(x,y)=queries[i]; if(x<y){ auto it=lower_bound(all(adj[cycleNo[x]]),y)-adj[cycleNo[x]].begin(); auto it2=lower_bound(all(adj[cycleNo[x]]),x)-adj[cycleNo[x]].begin(); ans[i]=it-it2; } } for(int i=0;i<n;i++){ adj[i].clear(); nxt[i]=0; vis[i]=false; prf[i]=0; } reverse(all(a)); for(int i=0;i<n-1;i++){ prf[i+1]=abs(a[i+1]-a[i]); prf[i+1]+=prf[i]; } for(int i=n-2;i>=0;i--){ int l=i+1,r=n-1; int con=prf[i],val=i+1; while(l<=r){ int mid=(l+r)/2; if((prf[mid]-con)<=L){ l=mid+1; val=max(val,mid); } else{ r=mid-1; } } nxt[i]=val; } for(int i=0;i<n-1;i++){ if(vis[i]==false){ dfs(i,i); sort(all(adj[i])); } } for(int i=0;i<q;i++){ int x,y; tie(x,y)=queries[i]; x=n-x-1; y=n-y-1; if(x<y){ auto it=lower_bound(all(adj[cycleNo[x]]),y)-adj[cycleNo[x]].begin(); auto it2=lower_bound(all(adj[cycleNo[x]]),x)-adj[cycleNo[x]].begin(); ans[i]=it-it2; } } for(auto i:ans){ cout<<i<<'\n'; } } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int tc=1; //cin>>tc; for(int _=0;_<tc;_++){ //~cout<<"Case #"<<_+1<<": "; solve(); if(_!=tc-1){ cout<<'\n'; } } }
a.cc:85:10: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts' 85 | void clr(auto &a,int n){ | ^~~~ a.cc:90:10: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts' 90 | void unq(auto &a){ | ^~~~ a.cc:250:11: error: redefinition of 'const ll mod' 250 | const int mod=1e9+7; | ^~~ a.cc:22:11: note: 'const ll mod' previously defined here 22 | const int mod=1e9+7; | ^~~ a.cc:252:9: error: redefinition of 'std::mt19937 rng' 252 | mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); | ^~~ a.cc:24:9: note: 'std::mt19937 rng' previously declared here 24 | mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); | ^~~ a.cc:254:5: error: redefinition of 'll mul(ll, ll)' 254 | int mul(int a,int b){ | ^~~ a.cc:26:5: note: 'll mul(ll, ll)' previously defined here 26 | int mul(int a,int b){ | ^~~ a.cc:258:6: error: redefinition of 'void add(ll&, ll)' 258 | void add(int &a,int b){ | ^~~ a.cc:30:6: note: 'void add(ll&, ll)' previously defined here 30 | void add(int &a,int b){ | ^~~ a.cc:263:5: error: redefinition of 'll sub(ll, ll)' 263 | int sub(int a,int b){ | ^~~ a.cc:35:5: note: 'll sub(ll, ll)' previously defined here 35 | int sub(int a,int b){ | ^~~ a.cc:271:5: error: redefinition of 'll powz(ll, ll)' 271 | int powz(int a,int b){ | ^~~~ a.cc:43:5: note: 'll powz(ll, ll)' previously defined here 43 | int powz(int a,int b){ | ^~~~ a.cc:284:10: error: redefinition of 'template<class A, class B> std::istream& operator>>(std::istream&, std::pair<_T1, _T2>&)' 284 | istream& operator>>(istream& input,pair<A,B>& x) { | ^~~~~~~~ a.cc:56:10: note: 'template<class A, class B> std::istream& operator>>(std::istream&, std::pair<_T1, _T2>&)' previously declared here 56 | istream& operator>>(istream& input,pair<A,B>& x) { | ^~~~~~~~ a.cc:290:10: error: redefinition of 'template<class A> std::istream& operator>>(std::istream&, std::vector<_Tp>&)' 290 | istream& operator>>(istream& input,vector<A>& x) { | ^~~~~~~~ a.cc:62:10: note: 'template<class A> std::istream& operator>>(std::istream&, std::vector<_Tp>&)' previously declared here 62 | istream& operator>>(istream& input,vector<A>& x) { | ^~~~~~~~ a.cc:297:10: error: redefinition of 'template<class A> std::ostream& operator<<(std::ostream&, std::vector<_Tp>&)' 297 | ostream& operator<<(ostream& output,vector<A>& x) { | ^~~~~~~~ a.cc:69:10: note: 'template<class A> std::ostream& operator<<(std::ostream&, std::vector<_Tp>&)' previously declared here 69 | ostream& operator<<(ostream& output,vector<A>& x) { | ^~~~~~~~ a.cc:304:21: error: redefinition of 'template<class T> std::vector<std::pair<T, long long int> > getvec(ll)' 304 | vector<pair<T,int>> getvec(int n){ | ^~~~~~ a.cc:76:21: note: 'template<class T> std::vector<std::pair<T, long long int> > getvec(ll)' previously declared here 76 | vector<pair<T,int>> getvec(int n){ | ^~~~~~ a.cc:313:10: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts' 313 | void clr(auto &a,int n){ | ^~~~ a.cc:313:6: error: redefinition of 'template<class auto:30> void clr(auto:30&, ll)' 313 | void clr(auto &a,int n){ | ^~~ a.cc:85:6: note: 'template<class auto:28> void clr(auto:28&, ll)' previously declared here 85 | void clr(auto &a,int n){ | ^~~ a.cc:318:10: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts' 318 | void unq(auto &a){ | ^~~~ a.cc:318:6: error: redefinition of 'template<class auto:31> void unq(auto:31&)' 318 | void unq(auto &a){ | ^~~ a.cc:90:6: note: 'template<class auto:29> void unq(auto:29&)' previously declared here 90 | void unq(auto &a){ | ^~~ a.cc:323:11: error: redefinition of 'const ll N' 323 | const int N=100005; | ^ a.cc:95:11: note: 'const ll N' previously defined here 95 | const int N=100005; | ^ a.cc:325:5: error: redefinition of 'll cycleNo [100005]' 325 | int cycleNo[N]; | ^~~~~~~ a.cc:97:5: note: 'll cycleNo [100005]' previously declared here 97 | int cycleNo[N]; | ^~~~~~~ a.cc:326:12: error: redefinition of 'std::vector<long long int> adj [100005]' 326 | vector<int>adj[N]; | ^~~ a.cc:98:12: note: 'std::vector<long long int> adj [100005]' previously declared here 98 | vector<int>adj[N]; | ^~~ a.cc:327:6: error: redefinition of 'bool vis [100005]' 327 | bool vis[N]; | ^~~ a.cc:99:6: note: 'bool vis [100005]' previously declared here 99 | bool vis[N]; | ^~~ a.cc:328:5: error: redefinition of 'll nxt [100005]' 328 | int nxt[N]; | ^~~ a.cc:100:5: note: 'll nxt [100005]' previously declared here 100 | int nxt[N]; | ^~~ a.cc:329:5: error: redefinition of 'll n' 329 | int n; | ^ a.cc:101:5: note: 'll n' previously declared here 101 | int n; | ^ a.cc:331:6: error: redefinition of 'void dfs(ll, ll)' 331 | void dfs(int u,int p){ | ^~~ a.cc:103:6: note: 'void dfs(ll, ll)' previously defined here 103 | void dfs(int u,int p){ | ^~~ a.cc:344:6: error: redefinition of 'void solve()' 344 | void solve(){ | ^~~~~ a.cc:116:6: note: 'void solve()' previously defined here 116 | void solve(){ | ^~~~~ a.cc:443:8: error: redefinition of 'int main()' 443 | signed main(){ | ^~~~ a.cc:215:8: note: 'int main()' previously defined here 215 | signed main(){ | ^~~~
s392560074
p04017
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pi; typedef vector <ll> vi; typedef vector <pi> vpi; #define f first #define s second #define FOR(i,s,e) for(ll i=s;i<=ll(e);++i) #define DEC(i,s,e) for(ll i=s;i>=ll(e);--i) #define pb push_back #define all(x) (x).begin(), (x).end() #define lbd(x, y) lower_bound(all(x), y) #define ubd(x, y) upper_bound(all(x), y) #define aFOR(i,x) for (auto i: x) #define mem(x,i) memset(x,i,sizeof x) #define fast ios_base::sync_with_stdio(false),cin.tie(0) #define maxn 200010 #define int ll int N,L,Q; int A[maxn]; vi adj[maxn]; int twok[maxn][100],depth[maxn],dist[maxn][100]; bool vis[maxn]; void twokdecomp(int x,int p){ vis[x] = 1; twok[x][0] = p; for (int i=1;i<=18;i++){ //i <= logmaxn if (twok[x][i-1] == -1) break; twok[x][i] = twok[twok[x][i-1]][i-1]; dist[x][i] = dist[x][i-1] + dist[twok[x][i-1]][i-1]; //only for dist, can change to min/max } for (auto i: adj[x]){ if (i != p){ depth[i] = depth[x] + 1; dist[i][0] = 1; //only for dist twokdecomp(i,x); } } } pi kth_parent(int x,int k){ //pi for dist,logk int distans = 0; //only for dist for (int i=0;i<=17;i++){ if (k&(1<<i)){ x = twok[x][i]; distans += dist[x][i]; //Only for dist, can change to min/max } if (x==-1) break; } return pi(x,distans); //return pi(x,distans) for dist } int32_t main(){ fast; cin>>N; FOR(i,1,N) cin>>A[i]; cin>>L>>Q; FOR(i,1,N-1){ if (A[i+1] - A[i] > L) continue; int idx = lower_bound(A+1,A+N+1,A[i] + L) - A; if (idx == N+1 || A[idx] > A[i] + L) idx--; adj[i].pb(idx); adj[idx].pb(i); } mem(twok,-1); DEC(i,N,1){ if (!vis[i]){ dist[i][0] = -1; twokdecomp(i,-1); } FOR(i,0,Q-1){ int a,b; cin>>a>>b; if (a > b) swap(a,b); int l=0,r=maxn; while (l + 1 < r){ int mid = (l+r)/2; if (kth_parent(a,mid).f == -1) r = mid; else if (kth_parent(a,mid).f > b) r = mid; else l = mid; } cout<<l<<'\n'; } }
a.cc: In function 'int32_t main()': a.cc:112:2: error: expected '}' at end of input 112 | } | ^ a.cc:62:15: note: to match this '{' 62 | int32_t main(){ | ^
s195780863
p04017
C++
#include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> #pragma GCC optimize("O3") #define REP(i,n) for(int i=0;i<n;i++) #define REPP(i,n) for(int i=1;i<=n;i++) #define ALL(obj) (obj).begin(), (obj).end() #define EPS (1e-9) #define INF (1e17) #define PI (acos(-1)) //const double PI = acos(-1); //const double EPS = 1e-15; //long long INF=(long long)1E17; #define i_7 (long long)(1e9+7) //#define i_7 998'244'353 long mod(long a){ long long c=a%i_7; if(c>=0)return c; return c+i_7; } long long po(long a, long b){ if(b==0){ return 1; } long long z = po(a,b/2); z = mod(z*z); if(b%2!=0){ z = mod(a*z); } return z; } using namespace std; //using namespace boost::multiprecision; bool prime_(int n){ if(n==1){ return false; }else if(n==2){ return true; }else{ for(int i=2;i<=sqrt(n);i++){ if(n%i==0){ return false; } } return true; } } long long gcd_(long long a, long long b){ if(a<b){ swap(a,b); } if(a%b==0){ return b; }else{ return gcd_(b,a%b); } } long long lcm_(long long x, long long y){ return (x/gcd_(x,y))*y; } int main(){ int n; cin>>n; int x[n]; REP(i,n){ cin>>x[i]; } int L; cin>>L; int s[n][31]; REP(i,n){ int l = i, r = n;//[l,r) while(r - l > 1){ int m = (l+r)/2; if(x[m] - x[i] <= L){ l = m; }else{ r = m; } } s[i][0] = l; } REP(k,31){ REP(i,n){ if(k == 0)continue; s[i][k] = s[s[i][k-1]][k-1]; } } int q; cin>>q; int a[q],b[q]; REP(i,q){ cin>>a[i]>>b[i]; a[i]--;b[i]--; if(a[i] > b[i]){ swap(a[i], b[i]); } } int ans[q]; REP(i,q){ int l = 0, r = 1e9 + 10;//(l,r] while(r - l > 0){ int d = (l+r)/2; int now = a[i]; REP(k,31){ if(d & (1<<k)){ now = s[now][k]; } } if(now >= b[i]){ r = m; }else{ l = m; } } ans[i] = l; } REP(i,q){ cout<<ans[i]<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:116:13: error: 'm' was not declared in this scope 116 | r = m; | ^ a.cc:118:13: error: 'm' was not declared in this scope 118 | l = m; | ^
s889301407
p04017
C++
nclude <bits/stdc++.h> using namespace std ; #define N 100010 int n , L , m ; int a[ N ] , to[ N ] ; int num , block , belong[ N ] ; int nxt[ N ] , val[ N ] ; int find( int x ) { int l = x + 1 , r = n , ans = 0 ; while( l <= r ) { int mid = ( l + r ) >> 1 ; if( a[ mid ] - a[ x ] <= L ) l = mid + 1 , ans = mid ; else r = mid - 1 ; } return ans ; } int main() { scanf( "%d" , &n ) ; for( int i = 1 ; i <= n ; i ++ ) { scanf( "%d" , &a[ i ] ) ; } sort( a + 1 , a + n + 1 ) ; scanf( "%d%d" , &L , &m ) ; for( int i = 1 ; i < n ; i ++ ) { to[ i ] = find( i ) ; } to[ n ] = n + 1 ; block = sqrt( n ) ; num = n / block ; if( n % block ) num ++ ; for( int i = 1 ; i <= n ; i ++ ) { belong[ i ] = ( i - 1 ) / block + 1 ; } for( int i = 1 ; i < n ; i ++ ) { int t = i , sp = 0 ; while( belong[ t ] == belong[ i ] ) { t=to[ t ] ; sp ++ ; } val[ i ] = sp ; nxt[ i ] = t ; if( i >= block * ( num - 1 ) + 1 ) val[ i ] -- , nxt[ i ] -- ; } for( int i = 1 ; i <= m ; i ++ ) { int x , y , ans = 0 ; scanf( "%d%d" , &x ,&y ) ; if( x > y )swap( x , y ) ; while( belong[ x ] < belong[ y ] ) { ans += val[ x ] ; x = nxt[ x ] ; } while( x < y ) { x = to[ x ] ; ans ++ ; } printf( "%d\n" , ans ) ; } return 0 ; }
a.cc:1:1: error: 'nclude' does not name a type 1 | nclude <bits/stdc++.h> | ^~~~~~ a.cc: In function 'int main()': a.cc:23:5: error: 'scanf' was not declared in this scope 23 | scanf( "%d" , &n ) ; | ^~~~~ a.cc:27:5: error: 'sort' was not declared in this scope; did you mean 'short'? 27 | sort( a + 1 , a + n + 1 ) ; | ^~~~ | short a.cc:33:13: error: 'sqrt' was not declared in this scope 33 | block = sqrt( n ) ; | ^~~~ a.cc:52:20: error: 'swap' was not declared in this scope 52 | if( x > y )swap( x , y ) ; | ^~~~ a.cc:61:9: error: 'printf' was not declared in this scope 61 | printf( "%d\n" , ans ) ; | ^~~~~~ a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | nclude <bits/stdc++.h>
s959755286
p04017
C++
#include <bits/stdc++.h> #define r(i,n) for(int i=0;i<n;i++) #define int long long using namespace std; typedef pair<int,int>P; #define F first #define S second int a[100009][20]; int b[100009]; int n,L,test; signed main(){ cin>>n; r(i,n) cin>>b[i]; cin>>L; r(j,20){ if(j==0){ int id=0,sum=0; r(i,n){ while(id<n-1 && sum+(b[id+1]-b[id])<=L) sum += b[id+1]-b[id],id++; a[i][j] = id; //cout<<id<<endl; if(i!=n-1 && sum)sum -=b[i+1]-b[i]; } } else{ r(i,n){ a[i][j] = a[a[i][j-1]][j-1]; } } } eixt(0); cin>>test; while(test--){ int l,r; cin>>l>>r; l--; r--; if(r<l)swap(l,r); int sum=0; while(l<r){ //cout<<l<<endl; for(int i=19;i>=0;i--){ if(i&&( a[l][i]>r || a[l][i-1]<=r ))continue; l=a[l][i]; sum+=pow(2,i); break; } //cout<<l<<endl; } cout<<sum<<endl; } }
a.cc: In function 'int main()': a.cc:34:9: error: 'eixt' was not declared in this scope; did you mean 'exit'? 34 | eixt(0); | ^~~~ | exit
s420086256
p04017
C++
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace std; typedef long long ll; ll n,len,q; ll num; ll block; ll a[100010]; ll b[100010]; ll to[100010]; ll nxt[100010]; ll step[100010]; ll find(ll x) { ll ans=0; ll l=1,r=n; while(l<=r) { ll mid=(l+r)/2; if(a[mid]-a[x]<=len) { l=mid+1; ans=mid; } else { r=mid-1; } } return ans; } void build() { for(ll i=1;i<=n;i++) { to[i]=find(i); } to[n]=n+1; //这句话一定要加,不然就在下面我写qaq的地方死循环 // for(ll i=1;i<=n;i++) cout<<to[i]<<" "; block=sqrt(n); num=ceil(n/block); for(ll i=1;i<=n;i++) { b[i]=(i-1)/block+1; } for(ll i=1;i<=n;i++) { ll p=i,cnt=0; while(b[p]==b[i]) { // cout<<"qaq"<<" "; p=to[p]; cnt++; } nxt[i]=p; step[i]=cnt; if( i>block*(num-1)) { val[i]--,nxt[i]--; } } // for(ll i=1;i<=n;i++) // { // cout<<i<<"to : "<<nxt[i]<<"step : "<<step[i]<<endl; // } // cout<<endl; } ll query(ll x,ll y) { ll res=0; while(x<=y-len) { res+=step[x]; x=nxt[x]; } while(x<y) { x=to[x]; res++; } return res; } int main() { scanf("%lld",&n); for(ll i=1;i<=n;i++) { scanf("%lld",&a[i]); } sort(a+1,a+n+1); scanf("%lld%lld",&len,&q); build(); for(ll i=1;i<=q;i++) { ll x,y; scanf("%lld%lld",&x,&y); if(x>y) swap(x,y); printf("%lld\n",query(x,y)); } return 0; }
a.cc: In function 'void build()': a.cc:67:25: error: 'val' was not declared in this scope 67 | val[i]--,nxt[i]--; | ^~~
s722080537
p04017
C++
#include<bits/stdc++.h> #define N 100010 #define swap(a,b) a^=b^=a^=b using namespace std; int l,n,m; int f[N][25]={},a[N]={}; int read(){int s=0,w=1;char ch=getchar();while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();if(ch=='-')w=-1;while(ch<='9'&&ch>='0')s=s*10+ch-'0',ch=getchar();return s*w;} struct rode{int l,r;}e[N*2]={}; int main() { n=read(); for(int i=1;i<=n;++i)a[i]=read(); l=read();m=read(); for(int i=1;i<=m;++i)e[i].l=read(),e[i].r=read(),e[i].l<=e[i].r?0:swap(e[i].l,e[i].r); for(int i=1;i<=n;++i) { int k=i; while(k<=n&&a[k]<=a[i]+l)++k; f[i][0]=k-1; // printf("%d\n",f[i][0]); } // for(int j=1;j<=25;++j){ // for(int i=1;i<=n;++i) // f[i][j]=f[f[i][j-1]][j-1],printf("%d ",f[i][j]); // puts(""); } for(int i=1;i<=m;++i) { int ll=e[i].l,s=0;bool p=0; for(int j=25;j>=0;--j)if(f[ll][j]<=e[i].r)ll=f[ll][j],s+=(1<<j),p=1; if(!p)s=1; printf("%d\n",s); } return 0; }
a.cc:27:17: error: expected unqualified-id before 'for' 27 | for(int i=1;i<=m;++i) | ^~~ a.cc:27:29: error: 'i' does not name a type 27 | for(int i=1;i<=m;++i) | ^ a.cc:27:34: error: expected unqualified-id before '++' token 27 | for(int i=1;i<=m;++i) | ^~ a.cc:34:17: error: expected unqualified-id before 'return' 34 | return 0; | ^~~~~~ a.cc:35:1: error: expected declaration before '}' token 35 | } | ^
s210376796
p04017
C
//此程序使用了qt专属名称,请勿模仿。侵权必究!!! //我真是太菜了…… #include<bits/stdc++.h> using namespace std; #define ll long long const int N=1000100; int n,m,l,k; int a[N],f[N][30]; inline int read() { int sum=0,flag=1; char c; for(;c<'0'||c>'9';c=getchar())if(c=='-') flag=-1; for(;c>='0'&&c<='9';c=getchar())sum=(sum<<1)+(sum<<3)+c-'0'; return sum*flag; } int main() { // freopen("trav.in","r",stdin); // freopen("trav.out","w",stdout); n=read(); k=log2(n)+1; for(int i=1;i<=n;++i) { a[i]=read(); } l=read(); for(int i=1,j=2;i<=n;++i) { while(j<=n) { if(a[j]-a[i]<=l) { ++j; } else { break; } } f[i][0]=j-1; } for(int i=1;i<=k;++i) { for(int j=1;j<=n;++j) { f[j][i]=f[f[j][i-1]][i-1]; } } m=read(); while(m--) { int x=read(),y=read(),z=0; if(x>y) { swap(x,y); } for(int i=k;i>=0;--i) { if(f[x][i]<y) { z+=1<<i; x=f[x][i]; } } printf("%d\n",z+1); } return 0; }
main.c:3:9: fatal error: bits/stdc++.h: No such file or directory 3 | #include<bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s561536262
p04017
C++
#include<cstdio> #include<vector> using namespace std; const int N=100002; int n,L,q,x[N],i,j,k,a,b,l,r; int h[N],t[N],v[N],Ans[N]; int dep[N],p[N]; struct Uzi{ int d,id; }; vector<Uzi>g[N]; void add(int a,int b){ t[++k]=h[a]; h[a]=k; v[k]=b; } void init(){ scanf("%d",&n); for(i=1;i<=n;i++) scanf("%d",x+i); scanf("%d",&L); for(l=r=1;l<n;l++){ while(r<n&&x[r+1]-x[l]<=L) r++; add(r,l); } } void dfs1(int i){ for(int j=h[i];j;j=t[j]){ dep[v[j]]=dep[i]+1; dfs1(v[j]); } } void dfs(int i){ p[dep[i]]=i; for(int j=0;j<g[i].size();j++){ if(dep[g[i][j]].d==dep[i]) Ans[g[i][j].id]=1; else{ if(p[dep[g[i][j].d]]>=g[i][j].d) Ans[g[i][j].id]=dep[i]-dep[g[i][j].d]; else Ans[g[i][j].id]=dep[i]-dep[g[i][j].d]+1; } } for(int j=h[i];j;j=t[j]) dfs(v[j]); } void work(){ scanf("%d",&q); for(i=1;i<=q;i++){ scanf("%d%d",&a,&b); if(a>b) a^=b^=a^=b; g[a].push_back((Uzi){b,i}); } dfs1(n); dfs(n); for(i=1;i<=q;i++) printf("%d\n",Ans[i]); //while(1); } int main(){ init(); work(); return 0; }
a.cc: In function 'void dfs(int)': a.cc:37:23: error: no match for 'operator[]' (operand types are 'int [100002]' and '__gnu_cxx::__alloc_traits<std::allocator<Uzi>, Uzi>::value_type' {aka 'Uzi'}) 37 | if(dep[g[i][j]].d==dep[i]) | ^
s219695255
p04017
C
#include<bits/stdc++.h> #define ll long long using namespace std; int a[100005]; int dp[100005][50]; ll read() { ll sum=0;int f=1,c=getchar(); while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();} while(c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();} return sum*f; } int main() { int n=read(); for(int i=1;i<=n;i++) scanf("%d",&a[i]); int l=read(),q=read(); for(int i=1;i<=n;i++) { int id=upper_bound(a+1,a+1+n,a[i]+l)-a-1; if(a[i]+l>=a[n]) dp[i][0]=n; else dp[i][0]=id; } for(int i=1;i<=30;i++) { for(int j=1;j<=n;j++) dp[j][i]=dp[dp[j][i-1]][i-1]; } while(q--) { int s=read(),e=read(); if(e<s) swap(s,e); long long ans=0; for(int i=30;i>=0;i--) { if(dp[s][i]<e) { ans=ans+(1ll<<i); s=dp[s][i]; } } printf("%lld\n",ans+1); } return 0; }
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory 1 | #include<bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s364472942
p04017
C
#include<bits/stdc++.h> #define ll int using namespace std; ll n,l,q; ll x[100005],a[100005],b[100005]; ll le[100005],ri[100005]; ll read() { ll sum=0;int f=1,c=getchar(); while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();} while(c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();} return sum*f; } void pre(int p) { int lll=p,rr=p; int mx=x[p]+l,mn=x[p]-l; for(int i=0;i;i++) { int b=1<<i; if(x[p+b]<=mx) rr=p+b; else break; } for(int i=0;i;i++) { int b=1<<i; if(x[p-b]>=mn) lll=p-b; else break; } while(x[rr+1]<=mx) rr++; while(x[lll-1]>=mn) lll++; le[p]=lll; ri[p]=rr; } int main() { n=read(); for(int i=1;i<=n;i++) x[i]=read(); l=read(),q=read(); for(int i=1;i<=n;i++) pre(i); for(int i=1;i<=q;i++) { int ans=1; int s=read(),e=read(); if(s<e) { while(ri[s]<e) { s=ri[s]; ans++; } } else while(le[s]>e) { s=le[s]; ans++; } printf("%d\n",ans); } }
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory 1 | #include<bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s966629566
p04017
C++
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; typedef long long ll; const int maxn=100010; int n,x[maxn],l,q,a,b,vis[maxn],nextnext[maxn][20]; 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<<1)+(x<<3)+(ch^48); ch=getchar(); } return x*f; } int query(int s,int e) { int ans=0; while(s<e) { for(int i=19; i>=0; i--) { if(nextnext[s][i]<=e&&nextnext[s][i]) { s=nextnext[s][i]; ans+=(1<<i); break; } if(i==0) { s=nextnext[s][i]; ans+=(1<<i); break; } } return ans; } int main() { n=read(); for(int i=1; i<=n; i++) x[i]=read(); l=read(); for(int i=1; i<=n; i++) nextnext[i][0]=upper_bound(x+1+1,x+n+1,x[i]+l)-x-1; for(int i=1; i<=19; i++) for(int j=1; (long long)l*(1<<i)+x[j]<=x[n]; j++) nextnext[j][i]=nextnext[nextnext[j][i-1]][i-1]; q=read(); while(q--) { a=read(),b=read(); if(a>b) swap(a,b); printf("%d\n",query(a,b)); } return 0; }
a.cc: In function 'int query(int, int)': a.cc:49:17: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 49 | int main() | ^~ a.cc:49:17: note: remove parentheses to default-initialize a variable 49 | int main() | ^~ | -- a.cc:49:17: note: or replace parentheses with braces to value-initialize a variable a.cc:50:9: error: a function-definition is not allowed here before '{' token 50 | { | ^ a.cc:69:10: error: expected '}' at end of input 69 | } | ^ a.cc:28:1: note: to match this '{' 28 | { | ^ a.cc:69:10: warning: control reaches end of non-void function [-Wreturn-type] 69 | } | ^
s472430102
p04017
C++
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; typedef long long ll; const int maxn=100010; int n,x[maxn],l,q,a,b,vis[maxn],nextnext[maxn][20]; 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<<1)+(x<<3)+(ch^48); ch=getchar(); } return x*f; } int query(int s,int e) { int ans=0; while(s<e) { for(int i=19; i>=0; i--) { if(nextnext[s][i]<=e&&nextnext[s][i]) { s=nextnext[s][i]; ans+=(1<<i); break; } if(i==0) { s=nextnext[s][i]; ans+=(1<<i); break; } } return ans; } int main() { n=read(); for(int i=1; i<=n; i++) x[i]=read(); l=read(); for(int i=1; i<=n; i++) nextnext[i][0]=upper_bound(x+1+1,x+n+1,x[i]+l)-x-1; for(int i=1; i<=19; i++) for(int j=1; (long long)l*(1<<i)+x[j]<=x[n]; j++) nextnext[j][i]=nextnext[nextnext[j][i-1]][i-1]; q=read(); while(q--) { a=read(),b=read(); if(a>b) swap(a,b); printf("%d\n",query(a,b)); } return 0; }
a.cc: In function 'int query(int, int)': a.cc:49:17: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 49 | int main() | ^~ a.cc:49:17: note: remove parentheses to default-initialize a variable 49 | int main() | ^~ | -- a.cc:49:17: note: or replace parentheses with braces to value-initialize a variable a.cc:50:9: error: a function-definition is not allowed here before '{' token 50 | { | ^ a.cc:69:10: error: expected '}' at end of input 69 | } | ^ a.cc:28:1: note: to match this '{' 28 | { | ^ a.cc:69:10: warning: control reaches end of non-void function [-Wreturn-type] 69 | } | ^
s788887506
p04017
C++
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; typedef long long ll; const int maxn=100010; int n,x[maxn],l,q,a,b,vis[maxn],next[maxn][20]; 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<<1)+(x<<3)+(ch^48); ch=getchar(); } return x*f; } int query(int s,int e) { int ans=0; while(s<e) { for(int i=19;i>=0;i--) if(next[s][i]<=e&&next[s][i]) { s=next[s][i]; ans+=(1<<i); break; } } return ans; } int main() { n=read(); for(int i=1;i<=n;i++) x[i]=read(); l=read(); for(int i=1;i<=n;i++) next[i][0]=upper_bound(x+1+1,x+n+1,x[i]+l)-x-1; for(int i=1;i<=19;i++) for(int j=1;(long long)l*(1<<i)+x[j]<=x[n];j++) next[j][i]=next[next[j][i-1]][i-1]; q=read(); while(q--) { a=read(),b=read(); if(a>b) swap(a,b); printf("%d\n",query(a,b)); } return 0; }
a.cc: In function 'int query(int, int)': a.cc:33:20: error: reference to 'next' is ambiguous 33 | if(next[s][i]<=e&&next[s][i]) | ^~~~ In file included from /usr/include/c++/14/string:47, 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/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:9:33: note: 'int next [100010][20]' 9 | int n,x[maxn],l,q,a,b,vis[maxn],next[maxn][20]; | ^~~~ a.cc:33:35: error: reference to 'next' is ambiguous 33 | if(next[s][i]<=e&&next[s][i]) | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:9:33: note: 'int next [100010][20]' 9 | int n,x[maxn],l,q,a,b,vis[maxn],next[maxn][20]; | ^~~~ a.cc:35:27: error: reference to 'next' is ambiguous 35 | s=next[s][i]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:9:33: note: 'int next [100010][20]' 9 | int n,x[maxn],l,q,a,b,vis[maxn],next[maxn][20]; | ^~~~ a.cc: In function 'int main()': a.cc:49:17: error: reference to 'next' is ambiguous 49 | next[i][0]=upper_bound(x+1+1,x+n+1,x[i]+l)-x-1; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:9:33: note: 'int next [100010][20]' 9 | int n,x[maxn],l,q,a,b,vis[maxn],next[maxn][20]; | ^~~~ a.cc:52:25: error: reference to 'next' is ambiguous 52 | next[j][i]=next[next[j][i-1]][i-1]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:9:33: note: 'int next [100010][20]' 9 | int n,x[maxn],l,q,a,b,vis[maxn],next[maxn][20]; | ^~~~ a.cc:52:36: error: reference to 'next' is ambiguous 52 | next[j][i]=next[next[j][i-1]][i-1]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:9:33: note: 'int next [100010][20]' 9 | int n,x[maxn],l,q,a,b,vis[maxn],next[maxn][20]; | ^~~~ a.cc:52:41: error: reference to 'next' is ambiguous 52 | next[j][i]=next[next[j][i-1]][i-1]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:9:33: note: 'int next [100010][20]' 9 | int n,x[maxn],l,q,a,b,vis[maxn],next[maxn][20]; | ^~~~
s678586346
p04017
C++
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; typedef long long ll; const int maxn=100010; int n,x[maxn],l,q,a,b,vis[maxn],next[maxn][20]; 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<<1)+(x<<3)+(ch^48); ch=getchar(); } return x*f; } int query(int s,int e) { int ans=0; while(s<e) { for(int i=19;i>=0;i--) if(next[s][i]<=e&&next[s][i]) { s=next[s][i]; ans+=(1<<i); break; } } return ans; } int main() { n=read(); for(int i=1;i<=n;i++) x[i]=read(); l=read(); for(int i=1;i<=n;i++) next[i][0]=upper_bound(x+1+1,x+n+1,x[i]+l)-x-1; for(int i=1;i<=19;i++) for(int j=1;(long long)l*(1<<i)+x[j]<=x[n];j++) next[j][i]=next[next[j][i-1]][i-1]; q=read(); while(q--) { a=read(),b=read(); if(a>b) swap(a,b); printf("%d\n",query(a,b)); } return 0; }
a.cc: In function 'int query(int, int)': a.cc:33:20: error: reference to 'next' is ambiguous 33 | if(next[s][i]<=e&&next[s][i]) | ^~~~ In file included from /usr/include/c++/14/string:47, 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/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:9:33: note: 'int next [100010][20]' 9 | int n,x[maxn],l,q,a,b,vis[maxn],next[maxn][20]; | ^~~~ a.cc:33:35: error: reference to 'next' is ambiguous 33 | if(next[s][i]<=e&&next[s][i]) | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:9:33: note: 'int next [100010][20]' 9 | int n,x[maxn],l,q,a,b,vis[maxn],next[maxn][20]; | ^~~~ a.cc:35:27: error: reference to 'next' is ambiguous 35 | s=next[s][i]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:9:33: note: 'int next [100010][20]' 9 | int n,x[maxn],l,q,a,b,vis[maxn],next[maxn][20]; | ^~~~ a.cc: In function 'int main()': a.cc:49:17: error: reference to 'next' is ambiguous 49 | next[i][0]=upper_bound(x+1+1,x+n+1,x[i]+l)-x-1; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:9:33: note: 'int next [100010][20]' 9 | int n,x[maxn],l,q,a,b,vis[maxn],next[maxn][20]; | ^~~~ a.cc:52:25: error: reference to 'next' is ambiguous 52 | next[j][i]=next[next[j][i-1]][i-1]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:9:33: note: 'int next [100010][20]' 9 | int n,x[maxn],l,q,a,b,vis[maxn],next[maxn][20]; | ^~~~ a.cc:52:36: error: reference to 'next' is ambiguous 52 | next[j][i]=next[next[j][i-1]][i-1]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:9:33: note: 'int next [100010][20]' 9 | int n,x[maxn],l,q,a,b,vis[maxn],next[maxn][20]; | ^~~~ a.cc:52:41: error: reference to 'next' is ambiguous 52 | next[j][i]=next[next[j][i-1]][i-1]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:9:33: note: 'int next [100010][20]' 9 | int n,x[maxn],l,q,a,b,vis[maxn],next[maxn][20]; | ^~~~
s680697607
p04017
C++
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #define fre(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout) using namespace std; inline int read(){ int sum=0,f=1;char ch=getchar(); while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){sum=sum*10+ch-'0';ch=getchar();} return f*sum; } const int N=100005; struct node{int l,r,pre,nxt,to2,sp2,to1,sp1;}a[N]; struct ques{int l,r,id,ans;}q[N]; int n,m,L,p[N]; int bl[N],gap; inline bool cmp(ques a,ques b){ return a.l!=b.l? a.l<b.l:a.r<b.r; } inline bool cmp1(ques a,ques b){return a.id<b.id;} inline int work2(int l,int r){ int ans=0; while(bl[l]!=bl[r]) ans+=a[l].sp2,l=a[l].to2; while(l<r) ans++,l=a[l].nxt; return ans; } inline int work1(int l,int r){ int ans=0; while(bl[l]!=bl[r]) ans+=a[l].sp1,l=a[l].to1; while(l>r) ans++,l=a[l].pre; return ans; } signed main(){ n=read();gap=sqrt(n); for(int i=1;i<=n;i++) p[i]=read(); for(int i=1;i<=n;i++) bl[i]=(i-1)/gap+1; L=read();m=read(); for(int i=1;i<=m;i++) q[i].l=read(),q[i].r=read(); for(int i=1;i<=m;i++) q[i].id=i; for(int i=1;i<=m;i++) if(q[i].l>q[i].r) swap(q[i].l,q[i].r); for(int i=1;i<=n;i++){ int k=p[i]+L; k=upper_bound(p+1,p+n+1,k)-p-1; a[i].nxt=k; if(!a[k].l||i<a[k].l) a[k].l=i; a[k].r=max(a[k].r,i); a[i].pre=lower_bound(p+1,p+n+1,p[i]-L)-p; } for(int i=1;i<=n;i++){ int p=i; while(bl[p]==bl[i]&&bl[p]!=bl[n]&&a[p].nxt!=p) p=a[p].nxt,a[i].sp2++; a[i].to2=p; p=i; while(bl[p]==bl[i]&&bl[p]!=bl[1]&&a[p].pre!=p) p=a[p].pre,a[i].sp1++; a[i].to1=p; } for(int i=1;i<=m;i++){ if(q[i].l<q[i].r) q[i].ans=work2(q[i].l,q[i].r); else q[i].ans=work1(q[i].l,q[i].r); } for(int i=1;i<=m;i++) printf("%d\n",q[i].ans); return 0; }
a.cc: In function 'int main()': a.cc:42:22: error: 'sqrt' was not declared in this scope 42 | n=read();gap=sqrt(n); | ^~~~
s166873250
p04017
C++
#include<bits/stdc++.h> #define rg register #define file(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout); using namespace std; int read(){ int x=0,f=1;char c=getchar(); while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar(); while(c>='0'&&c<='9') x=x*10+c-48,c=getchar(); return f*x; } struct node { int to,next; }a[100011]; int head[100011],cnt,x[100010],bin[101]; int fa[100011][32],ans=0; void add(int x,int y){ a[++cnt].next=head[x]; a[cnt].to=y; head[x]=cnt;#include<bits/stdc++.h> #define rg register #define file(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout); using namespace std; int read(){ int x=0,f=1;char c=getchar(); while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar(); while(c>='0'&&c<='9') x=x*10+c-48,c=getchar(); return f*x; } struct node { int to,next; }a[100011]; int head[100011],cnt,x[100010],bin[101]; int fa[100011][32],ans=0; void add(int x,int y){ a[++cnt].next=head[x]; a[cnt].to=y; head[x]=cnt; } void dfs(int x,int f){ fa[x][0]=f; for(int i=1;i<=30;i++) fa[x][i]=fa[fa[x][i-1]][i-1]; for(int i=head[x];i;i=a[i].next){ int v=a[i].to; if(v==f) continue; dfs(v,x); } } int main(){ //file(""); int n=read(),y; for(int i=1;i<=n;i++) x[i]=read(); bin[0]=1; for(int i=1;i<=30;i++) bin[i]=bin[i-1]*2; x[n+1]=2147483647; int L=read(); for(int i=1;i<n;i++) y=lower_bound(x+1,x+2+n,L+x[i]+1)-x-1,add(y,i); dfs(n,0); int Q=read(); while(Q--){ int A=read(),B=read(); if(A>B) swap(A,B); int ans=0; for(int i=30;i>=0;i--) if(fa[A][i]<=B&&fa[A][i]) A=fa[A][i],ans+=bin[i]; cout<<ans<<endl; } return 0; } } void dfs(int x,int f){ fa[x][0]=f; for(int i=1;i<=30;i++) fa[x][i]=fa[fa[x][i-1]][i-1]; for(int i=head[x];i;i=a[i].next){ int v=a[i].to; if(v==f) continue; dfs(v,x); } } int main(){ //file(""); int n=read(),y; for(int i=1;i<=n;i++) x[i]=read(); bin[0]=1; for(int i=1;i<=30;i++) bin[i]=bin[i-1]*2; x[n+1]=2147483647; int L=read(); for(int i=1;i<n;i++) y=lower_bound(x+1,x+2+n,L+x[i]+1)-x-1,add(y,i); dfs(n,0); int Q=read(); while(Q--){ int A=read(),B=read(); if(A>B) swap(A,B); int ans=0; for(int i=30;i>=0;i--) if(fa[A][i]<=B&&fa[A][i]) A=fa[A][i],ans+=bin[i]; cout<<ans<<endl; } return 0; }
a.cc:19:21: error: stray '#' in program 19 | head[x]=cnt;#include<bits/stdc++.h> | ^ a.cc: In function 'void add(int, int)': a.cc:19:22: error: 'include' was not declared in this scope 19 | head[x]=cnt;#include<bits/stdc++.h> | ^~~~~~~ a.cc:19:30: error: 'bits' was not declared in this scope 19 | head[x]=cnt;#include<bits/stdc++.h> | ^~~~ a.cc:19:35: error: 'stdc' was not declared in this scope; did you mean 'std'? 19 | head[x]=cnt;#include<bits/stdc++.h> | ^~~~ | std a.cc:22:1: error: expected primary-expression before 'using' 22 | using namespace std; | ^~~~~ a.cc:23:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 23 | int read(){ | ^~ a.cc:23:9: note: remove parentheses to default-initialize a variable 23 | int read(){ | ^~ | -- a.cc:23:9: note: or replace parentheses with braces to value-initialize a variable a.cc:23:11: error: a function-definition is not allowed here before '{' token 23 | int read(){ | ^ a.cc:32:22: error: declaration of 'int x [100010]' shadows a parameter 32 | int head[100011],cnt,x[100010],bin[101]; | ^ a.cc:16:14: note: 'int x' previously declared here 16 | void add(int x,int y){ | ~~~~^ a.cc:34:22: error: a function-definition is not allowed here before '{' token 34 | void add(int x,int y){ | ^ a.cc:39:22: error: a function-definition is not allowed here before '{' token 39 | void dfs(int x,int f){ | ^ a.cc:49:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 49 | int main(){ | ^~ a.cc:49:9: note: remove parentheses to default-initialize a variable 49 | int main(){ | ^~ | -- a.cc:49:9: note: or replace parentheses with braces to value-initialize a variable a.cc:49:11: error: a function-definition is not allowed here before '{' token 49 | int main(){ | ^
s929249483
p04017
C++
#include <iostream> using namespace std; int d[100002][20]; int power2(int n){ int res = 1; for(int i = 0; i < n; i++) res *= 2; return res; } int main() { int n; cin >> n; int x[100002]; for(int i = 0; i < n; i++) cin >> x[i]; int l; cin >> l; for(int i = 0; i < n; i++){ d[i][0] = (upper_bound(x, x + n, x[i] + l) - x) - 1; } for(int j = 1; j < 20; j++){ for(int i = 0; i < n; i++){ d[i][j] = d[d[i][j - 1]][j - 1]; } } int q; cin >> q; for(int i = 0; i < q; i++){ int a, b; cin >> a >> b; a--; b--; if(a > b) swap(a, b); int ans = 0; while(d[a][0] < b){ for(int j = 0; j < 20; j++){ if(d[a][j] >= b){ a = d[a][j - 1]; ans += power2(j - 1); break; } } } ans++; cout << ans << endl; } }
a.cc: In function 'int main()': a.cc:21:20: error: 'upper_bound' was not declared in this scope 21 | d[i][0] = (upper_bound(x, x + n, x[i] + l) - x) - 1; | ^~~~~~~~~~~
s328269463
p04017
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i,n) for(int i=0; i<int(n); i++) #define FOR(i,m,n) for(int i=int(m); i<int(n); i++) #define ALL(obj) (obj).begin(),(obj).end() #define VI vector<int> #define VLL vector<long long> #define VVI vector<vector<int>> #define VVLL vector<vector<long long>> #define VC vector<char> #define VS vector<string> #define VVC vector<vector<char>> #define VB vector<bool> #define VVB vector<vector<bool>> #define fore(i,a) for(auto &i:a) #define int long long typedef pair <int, int> P; template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } const int INF = 1 << 30; const ll INFL = 1LL << 60; const ll mod = 1000000007; int main() { int n; cin >> n; VI x(n+1); REP(i, n)cin >> x[i]; int l; cin >> l; VVI d(n + 5, VI(30, n+1)); REP(i, n) { d[i][0] = upper_bound(ALL(x), x[i] + l) - x.begin(); d[i][0]--; } REP(j, 29)REP(i, n) { d[i][j + 1] = d[d[i][j]][j]; } int q; cin >> q; REP(i, q) { int a, b; cin >> a >> b; if (a > b)swap(a, b); a--; b--; ll ans = 0; for (int i = 29; i >= 0; i--) { if (d[a][i] < b) { if (d[a][i] == 0)continue; a = d[a][i]; ans += 1 << i; } } ans++; cout << ans << endl; } return 0; }
cc1plus: error: '::main' must return 'int' a.cc: In function 'int main()': a.cc:19:13: error: expected primary-expression before 'long' 19 | #define int long long | ^~~~ a.cc:6:33: note: in expansion of macro 'int' 6 | #define REP(i,n) for(int i=0; i<int(n); i++) | ^~~ a.cc:35:9: note: in expansion of macro 'REP' 35 | REP(i, n)cin >> x[i]; | ^~~ a.cc:19:13: error: expected ';' before 'long' 19 | #define int long long | ^~~~ a.cc:6:33: note: in expansion of macro 'int' 6 | #define REP(i,n) for(int i=0; i<int(n); i++) | ^~~ a.cc:35:9: note: in expansion of macro 'REP' 35 | REP(i, n)cin >> x[i]; | ^~~ a.cc:19:13: error: expected primary-expression before 'long' 19 | #define int long long | ^~~~ a.cc:6:33: note: in expansion of macro 'int' 6 | #define REP(i,n) for(int i=0; i<int(n); i++) | ^~~ a.cc:35:9: note: in expansion of macro 'REP' 35 | REP(i, n)cin >> x[i]; | ^~~ a.cc:19:13: error: expected ')' before 'long' 19 | #define int long long | ^~~~ a.cc:6:33: note: in expansion of macro 'int' 6 | #define REP(i,n) for(int i=0; i<int(n); i++) | ^~~ a.cc:35:9: note: in expansion of macro 'REP' 35 | REP(i, n)cin >> x[i]; | ^~~ a.cc:6:21: note: to match this '(' 6 | #define REP(i,n) for(int i=0; i<int(n); i++) | ^ a.cc:35:9: note: in expansion of macro 'REP' 35 | REP(i, n)cin >> x[i]; | ^~~ a.cc:35:13: error: 'i' was not declared in this scope 35 | REP(i, n)cin >> x[i]; | ^ a.cc:6:41: note: in definition of macro 'REP' 6 | #define REP(i,n) for(int i=0; i<int(n); i++) | ^ a.cc:19:13: error: expected primary-expression before 'long' 19 | #define int long long | ^~~~ a.cc:6:33: note: in expansion of macro 'int' 6 | #define REP(i,n) for(int i=0; i<int(n); i++) | ^~~ a.cc:40:9: note: in expansion of macro 'REP' 40 | REP(i, n) { | ^~~ a.cc:19:13: error: expected ';' before 'long' 19 | #define int long long | ^~~~ a.cc:6:33: note: in expansion of macro 'int' 6 | #define REP(i,n) for(int i=0; i<int(n); i++) | ^~~ a.cc:40:9: note: in expansion of macro 'REP' 40 | REP(i, n) { | ^~~ a.cc:19:13: error: expected primary-expression before 'long' 19 | #define int long long | ^~~~ a.cc:6:33: note: in expansion of macro 'int' 6 | #define REP(i,n) for(int i=0; i<int(n); i++) | ^~~ a.cc:40:9: note: in expansion of macro 'REP' 40 | REP(i, n) { | ^~~ a.cc:19:13: error: expected ')' before 'long' 19 | #define int long long | ^~~~ a.cc:6:33: note: in expansion of macro 'int' 6 | #define REP(i,n) for(int i=0; i<int(n); i++) | ^~~ a.cc:40:9: note: in expansion of macro 'REP' 40 | REP(i, n) { | ^~~ a.cc:6:21: note: to match this '(' 6 | #define REP(i,n) for(int i=0; i<int(n); i++) | ^ a.cc:40:9: note: in expansion of macro 'REP' 40 | REP(i, n) { | ^~~ a.cc:19:13: error: expected primary-expression before 'long' 19 | #define int long long | ^~~~ a.cc:6:33: note: in expansion of macro 'int' 6 | #define REP(i,n) for(int i=0; i<int(n); i++) | ^~~ a.cc:45:9: note: in expansion of macro 'REP' 45 | REP(j, 29)REP(i, n) { | ^~~ a.cc:19:13: error: expected ';' before 'long' 19 | #define int long long | ^~~~ a.cc:6:33: note: in expansion of macro 'int' 6 | #define REP(i,n) for(int i=0; i<int(n); i++) | ^~~ a.cc:45:9: note: in expansion of macro 'REP' 45 | REP(j, 29)REP(i, n) { | ^~~ a.cc:19:13: error: expected primary-expression before 'long' 19 | #define int long long | ^~~~ a.cc:6:33: note: in expansion of macro 'int' 6 | #define REP(i,n) for(int i=0; i<int(n); i++) | ^~~ a.cc:45:9: note: in expansion of macro 'REP' 45 | REP(j, 29)REP(i, n) { | ^~~ a.cc:19:13: error: expected ')' before 'long' 19 | #define int long long | ^~~~ a.cc:6:33: note: in expansion of macro 'int' 6 | #define REP(i,n) for(int i=0; i<int(n); i++) | ^~~ a.cc:45:9: note: in expansion of macro 'REP' 45 | REP(j, 29)REP(i, n) { | ^~~ a.cc:6:21: note: to match this '(' 6 | #define REP(i,n) for(int i=0; i<int(n); i++) | ^ a.cc:45:9: note: in expansion of macro 'REP' 45 | REP(j, 29)REP(i, n) { | ^~~ a.cc:19:13: error: expected primary-expression before 'long' 19 | #define int long long | ^~~~ a.cc:6:33: note: in expansion of macro 'int' 6 | #define REP(i,n) for(int i=0; i<int(n); i++) | ^~~ a.cc:45:9: note: in expansion of macro 'REP' 45 | REP(j, 29)REP(i, n) { | ^~~ a.cc:45:13: error: 'j' was not declared in this scope 45 | REP(j, 29)REP(i, n) { | ^ a.cc:6:41: note: in definition of macro 'REP' 6 | #define REP(i,n) for(int i=0; i<int(n); i++) | ^ a.cc:19:13: error: expected primary-expression before 'long' 19 | #define int long long | ^~~~ a.cc:6:33: note: in expansion of macro 'int' 6 | #define REP(i,n) for(int i=0; i<int(n); i++) | ^~~ a.cc:45:19: note: in expansion of macro 'REP' 45 | REP(j, 29)REP(i, n) { | ^~~ a.cc:19:13: error: expected primary-expression before 'long' 19 | #define int long long | ^~~~ a.cc:6:33: note: in expansion of macro 'int' 6 | #define REP(i,n) for(int i=0; i<int(n); i++) | ^~~ a.cc:51:9: note: in expansion of macro 'REP' 51 | REP(i, q) { | ^~~ a.cc:19:13: error: expected ';' before 'long' 19 | #define int long long | ^~~~ a.cc:6:33: note: in expansion of macro 'int' 6 | #define REP(i,n) for(int i=0; i<int(n); i++) | ^~~ a.cc:51:9: note: in expansion of macro 'REP' 51 | REP(i, q) { | ^~~ a.cc:19:13: error: expected primary-expression before 'long' 19 | #define int long long | ^~~~ a.cc:6:33: note: in expansion of macro 'int' 6 | #define REP(i,n) for(int i=0; i<int(n); i++) | ^~~ a.cc:51:9: note: in expansion of macro 'REP' 51 | REP(i, q) { | ^~~ a.cc:19:13: error: expected ')' before 'long' 19 | #define int long long | ^~~~ a.cc:6:33: note: in expansion of macro 'int' 6 | #define REP(i,n) for(int i=0; i<int(n); i++) | ^~~ a.cc:51:9: note: in expansion of macro 'REP' 51 | REP(i, q) { | ^~~ a.cc:6:21: note: to match this '(' 6 | #define REP(i,n) for(int i=0; i<int(n); i++) | ^ a.cc:51:9: note: in expansion of macro 'REP' 51 | REP(i, q) { | ^~~
s377284705
p04017
C++
#include <assert.h> #include <limits.h> #include <cmath> #include <algorithm> #include <bitset> #include <cctype> #include <complex> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using ll = long long; using P = std::pair<ll, ll>; #define rep(i, a, b) for (ll(i) = (a); i < (b); i++) #define all(i) i.begin(), i.end() #define debug(i) std::cout <<"debug "<< i << "\n" //const ll MOD = 998244353; const ll MOD = 1e9+7; ll max[20][100010]; int main() { std::cin.tie(0); std::ios::sync_with_stdio(false); //問題文中の添え字が0-indexか1-indexか確認! ll n,l,q; std::cin>>n; std::vector<ll> x(n); rep(i,0,n)std::cin>>x[i]; std::cin>>l>>q; rep(i,0,n)max[0][i]=(ll)(std::upper_bound(all(x),x[i]+l)-x.begin())-1; rep(k,1,20){ rep(i,0,n){ max[k][i]=max[k-1][max[k-1][i]]; } } rep(sdf,0,q){ ll a,b; std::cin>>a>>b; a--;b--; if(a>b)std::swap(a,b); ll now=a,temp=0; for(ll i=(1<<19),pow=19;i>0;i/=2,pow--){ if(max[pow][now]<b){ temp+=i; now=max[pow][now]; } } std::cout<<ans+1<<"\n"; } return 0; }
a.cc: In function 'int main()': a.cc:66:16: error: 'ans' was not declared in this scope; did you mean 'abs'? 66 | std::cout<<ans+1<<"\n"; | ^~~ | abs
s169980928
p04017
C++
#include<iostream> #include<string> #include<algorithm> #include<vector> #include<queue> #include<map> #include<math.h> #include<iomanip> #include<set> #include<numeric> #include<cstring> #include<cstdio> #include<functional> #include<bitset> #include<limits.h> #include<cassert> #include <fstream> #include <time.h> #include <iterator> #include<random> #define REP(i, n) for(int i = 0;i < n;i++) #define REPR(i, n) for(int i = n;i >= 0;i--) #define FOR(i, m, n) for(int i = m;i < n;i++) #define FORR(i, m, n) for(int i = m;i >= n;i--) #define SORT(v, n) sort(v, v+n); #define VSORT(v) sort(v.begin(), v.end()); #define REVERSE(v,n) reverse(v,v+n); #define VREVERSE(v) reverse(v.begin(), v.end()); #define ll long long #define pb(a) push_back(a) #define m0(x) memset(x,0,sizeof(x)) #define print(x) cout<<x<<endl; #define pe(x) cout<<x<<" "; #define lb(v,n) lower_bound(v.begin(), v.end(), n); #define ub(v,n) upper_bound(v.begin(), v.end(), n); #define int long long #define all(x) (x).begin(), (x).end() using namespace std; int MOD = (ll)1000000000 + 7; const ll INF = 1e17; const double pi = acos(-1); const double EPS = 1e-10; typedef pair<int, int>P; const int MAX = 500050; vector<int>G[200020]; bool visited[200020]; int dp[100010][30]; vector<int>a; int N, L, Q; int func(int n,int k){ if (dp[n][k] != 0)return dp[n][k]; int pos = a[n]; if (k == 0) { int nex = pos + L; auto itr = ub(a, nex); itr--; int res = itr - a.begin(); dp[n][k] = res; return res; } else { int b = func(n, k - 1); int res = func(b, k - 1); dp[n][k] = res; return res; } } signed main() { cin.tie(0); ios::sync_with_stdio(false); cin >> N; a.resize(N); REP(i, N) { cin >> a[i]; } a.pb(INF); cin >> L >> Q; REP(i, Q) { int a, b; cin >> a >> b; a--, b--; if (a > b)swap(a, b); int ans = 0; bool ok = false; REPR(j, 29, 0) { if (func(a, j) < b) { ans+=1<<j; a = func(a, j); } } ans++; //pe("ans:"); print(ans); } }
a.cc:93:30: error: macro "REPR" passed 3 arguments, but takes just 2 93 | REPR(j, 29, 0) { | ^ a.cc:25:9: note: macro "REPR" defined here 25 | #define REPR(i, n) for(int i = n;i >= 0;i--) | ^~~~ a.cc: In function 'int main()': a.cc:93:17: error: 'REPR' was not declared in this scope 93 | REPR(j, 29, 0) { | ^~~~
s785068698
p04017
C++
#include<bits/stdc++.h> using namespace std; typedef int long long typedef pair<int,int> ii; int n,rmq[200005][20],x[200005],l,q; signed main() { queue<ii> que; cin>>n; for(int i=1;i<=n;i++) { cin>>x[i]; } cin>>l>>q; for(int j=0;j<=18;j++) { for(int i=1;i<=n;i++) { rmq[i][j]=999999; } } int cnt=0; while(1) { if(cnt==n) break; cnt++; que.push(ii(x[cnt],cnt)); while(1) { if(x[cnt]-que.front().first>l) { rmq[que.front().second][0]=cnt-1; que.pop(); } else break; } } while(!que.empty()) { rmq[que.front().second][0]=n; que.pop(); } rmq[n][0]=999999; for(int j=1;(1<<j)<=n;j++) { for(int i=1;i+(1<<j)<n;i++) { if(rmq[i][j-1]!=n) rmq[i][j]=rmq[rmq[i][j-1]][j-1]; } } cout<<rmq[5][1]<<" "<<rmq[7][0]<<"\n"; while(q--) { int u,v,res=0; cin>>u>>v; if(u>v) swap(u,v); for(int i=20;i>=0;i--) { if(rmq[u][i]<v) { res+=(1<<i); u=rmq[u][i]; } } if(u<v) res++; cout<<res<<"\n"; } }
a.cc:4:1: error: duplicate 'typedef' 4 | typedef pair<int,int> ii; | ^~~~~~~ | ------- a.cc:4:23: error: invalid declarator before 'ii' 4 | typedef pair<int,int> ii; | ^~ a.cc: In function 'int main()': a.cc:8:15: error: 'ii' was not declared in this scope 8 | queue<ii> que; | ^~ a.cc:8:17: error: template argument 1 is invalid 8 | queue<ii> que; | ^ a.cc:8:17: error: template argument 2 is invalid a.cc:27:21: error: request for member 'push' in 'que', which is of non-class type 'int' 27 | que.push(ii(x[cnt],cnt)); | ^~~~ a.cc:30:39: error: request for member 'front' in 'que', which is of non-class type 'int' 30 | if(x[cnt]-que.front().first>l) | ^~~~~ a.cc:32:41: error: request for member 'front' in 'que', which is of non-class type 'int' 32 | rmq[que.front().second][0]=cnt-1; | ^~~~~ a.cc:33:37: error: request for member 'pop' in 'que', which is of non-class type 'int' 33 | que.pop(); | ^~~ a.cc:38:20: error: request for member 'empty' in 'que', which is of non-class type 'int' 38 | while(!que.empty()) | ^~~~~ a.cc:40:25: error: request for member 'front' in 'que', which is of non-class type 'int' 40 | rmq[que.front().second][0]=n; | ^~~~~ a.cc:41:21: error: request for member 'pop' in 'que', which is of non-class type 'int' 41 | que.pop(); | ^~~
s251256079
p04017
C++
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Scanner; import java.util.TreeMap; public class Main { static int MOD=1000000007; static long p[][]=new long[405][405]; static long sum[][]=new long[405][405]; static long dp[][]=new long[35][100005]; static long a[]=new long[100005]; static long b[]=new long[405]; public static void main(String[] args) { Scanner in=new Scanner( new BufferedReader(new InputStreamReader(System.in))) ; int n=in.nextInt(); for(int i=0;i<=30;i++) dp[i]=new long[100005]; for(int i=1;i<=n;i++) { a[i]=in.nextLong(); } int L=in.nextInt(); for(int i=1;i<=n;i++) { int pos=find(1,n,a[i]+L); //System.out.println("pos:"+pos); dp[0][i]=pos; } for(int i=1;i<=30;i++) { for(int j=1;j<=n;j++) { dp[i][j]=dp[i-1][(int) dp[i-1][j]]; } } int q=in.nextInt(); while(q-->0) { int l=in.nextInt(); int r=in.nextInt(); if(l>r) {int t=l;l=r;r=t;} long ans=0; for(int i=30;i>=0;i--) { if(dp[i][l]<r) { ans+=(1<<i); l=(int) dp[i][l]; } } System.out.println(ans+1); } return; } private static int find(int l, int r, long v) { // TODO 自动生成的方法存根 while(l<r) { int mid=(l+r+1)>>1; if(a[mid]<=v) l=mid; else r=mid-1; } return l; } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.io.BufferedReader; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.io.InputStreamReader; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import java.util.Scanner; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: 'import' does not name a type 4 | import java.util.TreeMap; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:6:1: error: expected unqualified-id before 'public' 6 | public class Main { | ^~~~~~
s499070196
p04017
C++
#include <iostream> #include <algorithm> #include <vector> #include <map> #include <string> #include <cmath> #include <iomanip> #include <queue> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) #define SORT(c) sort((c).begin(), (c).end()) typedef long long ll; typedef pair<int, int> P; typedef vector<int> V; typedef map<int, int> M; const ll INF = 1e18; const ll MOD = 1e9 + 7; int main() { int n, l, q, x[112345], a[112345], b[112345]; int root[112345]; int cld[112345]; cin >> n; REP(i, n) cin >> x[i]; cin >> l >> q; REP(i, q) { cin >> a[i] >> b[i]; a[i]--; b[i]--; if (a[i] > b[i]) swap(a[i], b[i]); } memset(cld, -1, sizeof(cld)); memset(root, -1, sizeof(root)); for (int i = 0; i < n; i++) { if (root[i] != -1) continue; root[i] = i; int cur = i; int j = i + 1; while (j < n) { if (x[j + 1] - x[cur] > l || j == n - 1) { cld[cur] = j; if (root[j] != -1) break; root[j] = i; cur = j; } j++; } } vector<int> sum[112345]; bool used[112345]; fill(used, used + n, false); for (int i = 0; i < n; i++) { int r = root[i]; if (used[r]) continue; used[r] = true; sum[r].push_back(0); int j = i; while (true) { if (j == n - 1) break; int nex = cld[j]; sum[r].push_back(sum[r][sum[r].size() - 1] + x[nex] - x[j]); j = nex; } } REP(i, q) { int rt = root[a[i]]; int d = x[b[i]] - x[a[i]]; int l = 0, r = sum[rt].size(); while (r - l > 1) { int mid = (r + l) / 2; if (sum[rt][mid] >= d + (x[a[i]] - x[rt])) r = mid; else l = mid; } int l_ = -1, r_ = sum[rt].size(); while (r_ - l_ > 1) { int mid = (r_ + l_) / 2; if (sum[rt][mid] >= (x[a[i]] - x[rt])) r_ = mid; else l_ = mid; } cout << r - r_ << endl; } return 0; }
a.cc: In function 'int main()': a.cc:44:5: error: 'memset' was not declared in this scope 44 | memset(cld, -1, sizeof(cld)); | ^~~~~~ a.cc:9:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 8 | #include <queue> +++ |+#include <cstring> 9 |
s535090386
p04017
C++
#include <bits/stdc++.h> #define sp ' ' #define nyan "(=^・ω・^=)" #define mkp make_pair #define intmax 2147483647 #define llmax 9223372036854775807 #define lP pair<ll,ll> #define iP pair<int,int> typedef long long ll; using namespace std; const int mod = 1000000007; const int mod998 = 998244353; int N, L, Q, x[100000], a, b, p, l[100000][18], r[100000][18]; int fl(int x) { if (x == -1) { if (a == b) { return 0; } else { return 1; } } if (l[a][x] >= b) { return fl(x - 1); } else { a = l[a][x]; return (1 << x) + fl(x - 1); } } int fr(int x) { if (x == -1) { if (a == b) { return 0; } else { return 1; } } if (r[a][x] =< b) { return fr(x - 1); } else { a = r[a][x]; return (1 << x) + fr(x - 1); } return 0; } int main() { cin >> N; for (int i = 0; i < N; ++i) { cin >> x[i]; } cin >> L >> Q; for (int i = 0; i < N; ++i) { for (; p < N && x[p] <= x[i] + L; ++p); l[i][0] = p - 1; } p = N - 1; for (int i = N - 1; i >= 0; --i) { for (; p >= 0 && x[i] - L<=x[p]; --p); r[i][0] = p + 1; } for (int i = 1; i < 18; ++i) { for (int j = 0; j < N; ++j) { l[j][i] = l[l[j][i - 1]][i - 1]; r[j][i] = r[r[j][i - 1]][i - 1]; } } while (Q--) { cin >> a >> b; --a; --b; if (a < b) { cout << fl(17) << endl; } else { cout << fr(17) << endl; } } return 0; }
a.cc: In function 'int fr(int)': a.cc:43:22: error: expected primary-expression before '<' token 43 | if (r[a][x] =< b) { | ^
s687418966
p04017
C++
#include<cstdio> #include<algorithm> #include"lib/graph.hpp" int x[1001]={}; int main(){ int n,l,q; scanf("%d",&n); for(int i=1;i<=n;i++)scanf("%d",&x[i]); scanf("%d%d",&l,&q); if(n>1000||q>1000){ printf("0\n"); return 0; } Graph g(n+1); for(int i=1;i<=n;i++){ for(int j=i+1;j<=n;j++){ if(std::abs(x[i]-x[j])<=l){ g.addEdge(i,j); } } } for(int i=0;i<q;i++){ int a,b; scanf("%d%d",&a,&b); weight minl[1001]; g.dijkstra(minl,a); printf("%lld\n",minl[b]); } return 0; }
a.cc:3:9: fatal error: lib/graph.hpp: No such file or directory 3 | #include"lib/graph.hpp" | ^~~~~~~~~~~~~~~ compilation terminated.
s861514800
p04017
C++
#include<bits/stdc++.h> #define INF 1e9 #define llINF 1e18 #define MOD 1000000007 #define pb push_back #define mp make_pair #define F first #define S second #define ll long long #define ALL(a) (a).begin(),(a).end() #define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl; #define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl; typedef struct aaaaa{ int x,y,t; }Grid; using namespace std; int main(){ int n;cin>>n; vector<ll>ori(n); vector<vector<ll> >vvll(n); unordered_map<int,int>mli; bool used[n+10]={}; for(int i=0;i<n;i++) cin>>ori[i]; ll L;cin>>L; int q;cin>>q; ori.pb(llINF); int cnt=0; for(int i=0;i<n;i++){ if(used[i])continue; vvll[cnt].pb(ori[i]); used[i]=true; ll hoge=ori[i]; mli[i]=cnt; while(hoge!=llINF){ auto po = upper_bound(ALL(ori),hoge+L); if(*po == llINF){ if(ori[ori.size()-2]-hoge<=L){ mli[ori.size()-2]=cnt; used[ori.size()-2]=true; vvll[cnt].pb(ori[ori.size()-2]); break; } } int num=(po-ori.begin())-1; if(num<0)num=0; used[num]=true; hoge = ori[num]; mli[num]=cnt; vvll[cnt].pb(ori[num]); } cnt++; } /* for(int i=0;i<vvll.size();i++){ for(int j=0;j<vvll[i].size();j++) cout<<vvll[i][j]<<" "; cout<<endl; }*/ unordered_map<pair<int,int>,int>mpp; for(int i=0;i<q;i++){ int le,ri;cin>>le>>ri; //cout<<mli[min(le,ri)-1]<<endl; //cout<<ori[min(le,ri)-1]<<" "<<ori[max(le,ri)-1]<<endl; int num=min(le,ri)-1; int hhh=mli[num]; int anum=mpp[mp(min(le,ri)-1,hhh)]; int ann; if(anum == 0){ auto a = lower_bound(ALL(vvll[hhh]),ori[min(le,ri)-1]); ann=(a-vvll[hhh].begin())+10; mpp[mp(min(le,ri)-1,hhh)] = (a-vvll[hhh].begin())+10; }else ann=anum; int bnum = mpp[mp(max(le,ri)-1,hhh)]; int bnn; if(bnum == 0){ auto b = lower_bound(ALL(vvll[hhh]),ori[max(le,ri)-1]); bnn=(b-vvll[hhh].begin())+10; mpp[mp(max(le,ri)-1,hhh)] = (b-vvll[hhh].begin())+10; }else bnn = bnum; printf("%d\n",(bnn-ann)); } return 0; }
a.cc: In function 'int main()': a.cc:60:35: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' 60 | unordered_map<pair<int,int>,int>mpp; | ^~~ In file included from /usr/include/c++/14/unordered_map:41, from /usr/include/c++/14/functional:63, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' is implicitly deleted because the default definition would be ill-formed: 148 | unordered_map() = default; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/unordered_map.h: At global scope: /usr/include/c++/14/bits/unordered_map.h:148:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/unordered_map.h:33: /usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/hashtable.h:35: /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' /usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<int, int> >]': /usr/include/c++/14/bits/hashtable_policy.h:1328:7: required from here 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::pair<int, int> >::hash()' 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ In file included from /usr/include/c++/14/string_view:50, from /usr/include/c++/14/bits/basic_string.h:47, 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: /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::pair<int, int>, false>::__hash_enum()' /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<int, int>; bool <anonymous> = false]' 83 | __hash_enum(__hash_enum&&); | ^~~~~~~~~~~ /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed: 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed: 1242 | struct _Hashtable_ebo_helper<_Nm, _Tp, true> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::pair<int, int> >::~hash()' /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::~hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' /usr/include/c++/14/bits/hashtable_policy.h:1306:12: note: 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' is implicitly deleted because the default definition would be ill-formed: 1306 | struct _Hash_code_base | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1306:12: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable.h:539:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of
s829533656
p04017
C++
#include<bits/stdc++.h> #define INF 1e9 #define llINF 1e18 #define MOD 1000000007 #define pb push_back #define mp make_pair #define F first #define S second #define ll long long #define ALL(a) (a).begin(),(a).end() #define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl; #define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl; typedef struct aaaaa{ int x,y,t; }Grid; using namespace std; int main(){ int n;cin>>n; vector<ll>ori(n); vector<vector<ll> >vvll(n); map<ll,int>mli; bool used[n+10]={}; for(int i=0;i<n;i++) cin>>ori[i]; ll L;cin>>L; int q;cin>>q; ori.pb(llINF); int cnt=0; for(int i=0;i<n;i++){ if(used[i])continue; vvll[cnt].pb(ori[i]); ll hoge=ori[i]; mli[i]=cnt; while(hoge!=llINF){ auto po = upper_bound(ALL(ori),hoge+L); if(*po == llINF){ if(ori[ori.size()-2]-hoge<=L){ mli[ori.size()-2]=cnt; used[ori.size()-2]=true; vvll[cnt].pb(ori[ori.size()-2]); break; } } int num=(po-ori.begin())-1); used[num]=true; hoge = ori[num]; mli[num]=cnt; vvll[cnt].pb(ori[num]); } cnt++; } /* for(int i=0;i<vvll.size();i++){ for(int j=0;j<vvll[i].size();j++) cout<<vvll[i][j]<<" "; cout<<endl; }*/ for(int i=0;i<q;i++){ int le,ri;cin>>le>>ri; //cout<<mli[min(le,ri)-1]<<endl; //cout<<ori[min(le,ri)-1]<<" "<<ori[max(le,ri)-1]<<endl; auto a = lower_bound(ALL(vvll[mli[min(le,ri)-1]]),ori[min(le,ri)-1]); auto b = lower_bound(ALL(vvll[mli[min(le,ri)-1]]),ori[max(le,ri)-1]); cout<<(b-a)<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:45:33: error: expected ',' or ';' before ')' token 45 | int num=(po-ori.begin())-1); | ^
s366285254
p04017
C++
#include<bits/stdc++.h> #define INF 1e9 #define llINF 1e18 #define MOD 1000000007 #define pb push_back #define mp make_pair #define F first #define S second #define ll long long #define ALL(a) (a).begin(),(a).end() #define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl; #define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl; typedef struct aaaaa{ int x,y,t; }Grid; using namespace std; int main(){ int n;cin>>n; vector<ll>ori(n); vector<vector<ll> >vvll(n); map<ll,int>mli; bool used[n+10]={}; for(int i=0;i<n;i++) cin>>ori[i]; ll L;cin>>L; int q;cin>>q; ori.pb(llINF); int cnt=0; for(int i=0;i<n;i++){ if(used[i])continue; vvll[cnt].pb(ori[i]); ll hoge=ori[i]; mli[i]=cnt; while(hoge!=llINF){ auto po = upper_bound(ALL(ori),hoge+L); if(*po == llINF){ if(ori[ori.size()-2]-hoge<=L){ mli[ori.size()-2]=cnt; used[ori.size()-2]=true; vvll[cnt].pb(ori[ori.size()-2]); break; } } int num=max((po-ori.begin())-1,0LL); used[num]=true; hoge = ori[num]; mli[num]=cnt; vvll[cnt].pb(ori[num]); } cnt++; } /* for(int i=0;i<vvll.size();i++){ for(int j=0;j<vvll[i].size();j++) cout<<vvll[i][j]<<" "; cout<<endl; }*/ for(int i=0;i<q;i++){ int le,ri;cin>>le>>ri; //cout<<mli[min(le,ri)-1]<<endl; //cout<<ori[min(le,ri)-1]<<" "<<ori[max(le,ri)-1]<<endl; auto a = lower_bound(ALL(vvll[mli[min(le,ri)-1]]),ori[min(le,ri)-1]); auto b = lower_bound(ALL(vvll[mli[min(le,ri)-1]]),ori[max(le,ri)-1]); cout<<(b-a)<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:45:18: error: no matching function for call to 'max(__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type, long long int)' 45 | int num=max((po-ori.begin())-1,0LL); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~ 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:45:18: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int') 45 | int num=max((po-ori.begin())-1,0LL); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~ /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:45:18: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 45 | int num=max((po-ori.begin())-1,0LL); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~
s111194810
p04017
C++
#include<bits/stdc++.h> #define INF 1e9 #define llINF 1e18 #define MOD 1000000007 #define pb push_back #define mp make_pair #define F first #define S second #define ll long long #define ALL(a) (a).begin(),(a).end() #define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl; #define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl; typedef struct aaaaa{ int x,y,t; }Grid; using namespace std; int main(){ int n;cin>>n; vector<ll>ori(n); vector<vector<ll> >vvll(n); map<ll,int>mli; bool used[n+10]={}; for(int i=0;i<n;i++) cin>>ori[i]; ll L;cin>>L; int q;cin>>q; ori.pb(llINF); int cnt=0; for(int i=0;i<n;i++){ if(used[i])continue; vvll[cnt].pb(ori[i]); ll hoge=ori[i]; mli[i]=cnt; while(hoge!=llINF){ auto po = upper_bound(ALL(ori),hoge+L); if(*po == llINF){ if(ori[ori.size()-2]-hoge<=L){ mli[ori.size()-2]=cnt; used[ori.size()-2]=true; vvll[cnt].pb(ori[ori.size()-2]); break; } } int num=max((po-ori.begin())-1,0); used[num]=true; hoge = ori[num]; mli[num]=cnt; vvll[cnt].pb(ori[num]); } cnt++; } /* for(int i=0;i<vvll.size();i++){ for(int j=0;j<vvll[i].size();j++) cout<<vvll[i][j]<<" "; cout<<endl; }*/ for(int i=0;i<q;i++){ int le,ri;cin>>le>>ri; //cout<<mli[min(le,ri)-1]<<endl; //cout<<ori[min(le,ri)-1]<<" "<<ori[max(le,ri)-1]<<endl; auto a = lower_bound(ALL(vvll[mli[min(le,ri)-1]]),ori[min(le,ri)-1]); auto b = lower_bound(ALL(vvll[mli[min(le,ri)-1]]),ori[max(le,ri)-1]); cout<<(b-a)<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:45:18: error: no matching function for call to 'max(__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type, int)' 45 | int num=max((po-ori.begin())-1,0); | ~~~^~~~~~~~~~~~~~~~~~~~~~ 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:45:18: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'int') 45 | int num=max((po-ori.begin())-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:45:18: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 45 | int num=max((po-ori.begin())-1,0); | ~~~^~~~~~~~~~~~~~~~~~~~~~
s715706618
p04017
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll; #define pb push_back #define mp make_pair #define eps 1e-9 #define INF 2000000000 #define LLINF 100000000000000000ll #define sz(x) ((int)(x).size()) #define fi first #define sec second #define all(x) (x).begin(),(x).end() #define sq(x) ((x)*(x)) #define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++) #define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++) #define EQ(a,b) (abs((a)-(b))<eps) template<class T> void chmin(T& a,const T& b){if(a>b)a=b;} template<class T> void chmax(T& a,const T& b){if(a<b)a=b;} int N,Q; int x[100100]; int next[18][100100]; int L; int solve(int a,int b){ if(a>b)swap(a,b); int res = 0; for(int i=17;i>=0;i--){ if(next[i][a]<=b){ res |= (1<<i); a = next[i][a]; } if(a==b)break; } return res; } int main(){ cin >> N; for(int i=0;i<N;i++)cin >> x[i]; cin >> L; for(int i=0;i<N;i++){ next[0][i]=upper_bound(x,x+N,x[i]+L)-x-1; } for(int i=0;i<17;i++){ for(int j=0;j<N;j++){ next[i+1][j]=next[i][next[i][j]]; } } cin >> Q; for(int i=0;i<Q;i++){ int a,b; cin >> a >> b; a--;b--; cout << solve(a,b) << endl; } return 0; }
a.cc: In function 'int solve(int, int)': a.cc:29:20: error: reference to 'next' is ambiguous 29 | if(next[i][a]<=b){ | ^~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:66, 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_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:23:5: note: 'int next [18][100100]' 23 | int next[18][100100]; | ^~~~ a.cc:31:29: error: reference to 'next' is ambiguous 31 | a = next[i][a]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:23:5: note: 'int next [18][100100]' 23 | int next[18][100100]; | ^~~~ a.cc: In function 'int main()': a.cc:42:17: error: reference to 'next' is ambiguous 42 | next[0][i]=upper_bound(x,x+N,x[i]+L)-x-1; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:23:5: note: 'int next [18][100100]' 23 | int next[18][100100]; | ^~~~ a.cc:46:25: error: reference to 'next' is ambiguous 46 | next[i+1][j]=next[i][next[i][j]]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:23:5: note: 'int next [18][100100]' 23 | int next[18][100100]; | ^~~~ a.cc:46:38: error: reference to 'next' is ambiguous 46 | next[i+1][j]=next[i][next[i][j]]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:23:5: note: 'int next [18][100100]' 23 | int next[18][100100]; | ^~~~ a.cc:46:46: error: reference to 'next' is ambiguous 46 | next[i+1][j]=next[i][next[i][j]]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:23:5: note: 'int next [18][100100]' 23 | int next[18][100100]; | ^~~~
s439254609
p04017
C++
#include <map> #include <set> #include <cmath> #include <ctime> #include <queue> #include <stack> #include <vector> #include <bitset> #include <cstdio> #include <cctype> #include <string> #include <cstring> #include <cassert> #include <climits> #include <cstdlib> #include <iostream> #include <algorithm> #include <functional> using namespace std ; #define rep(i, a, b) for (int (i)=(a);(i)<=(b);(i)++) #define Rep(i, a, b) for (int (i)=(a)-1;(i)<(b);(i)++) #define REP(i, a, b) for (int (i)=(a);(i)>=(b);(i)--) #define reg(i, x) for (int (i)=head[x];(i);i=e[i].next) #define clr(a) memset(a,0,sizeof(a)) #define Sort(a, len) sort(a + 1, a + len + 1) #define Sort2(a, len, cmp) sort(a + 1, a + len + 1, cmp) #define ass(a, sum) memset(a, sum, sizeof(a)) #define ull unsigned long long #define ll long long #define ls ((rt) << 1) #define rs ((rt) << 1 | 1) #define mp make_pair #define pb push_back #define fi first #define se second #define endl '\n' #define Pii pair<int, int> const int N = 25000 ; const int iinf = INT_MAX/2 ; const ll linf = LLONG_MAX/2 ; const int MOD = 1e9+7 ; inline int read(){ int X = 0,w = 0 ; char ch = 0; while(!isdigit(ch)) {w |= ch == '-';ch = getchar();} while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar(); return w ? -X : X; } void write(int x){ if(x < 0) putchar('-'),x = -x; if(x > 9) write(x / 10); putchar(x%10 + '0'); } void print(int x) { cout << x << endl ; exit(0) ; } void douout(double x){ printf("%lf\n", x + 0.0000000001) ; } #include<bits/stdc++.h> #define REP(i,s,n) for(int i=s;i<n;++i) #define rep(i,n) REP(i,0,n) using namespace std; typedef long long ll; #define MAX 100010 ll N,Q,L; ll x[MAX],a,b; int nex[MAX][80]; void compute() { rep(i,N) { nex[i][0] = ( upper_bound(x,x+N,x[i]+L) - x ) - 1; assert( nex[i][0] != 0 ); } rep(j,70) rep(i,N) nex[i][j+1] = nex[nex[i][j]][j]; cin >> Q; rep(_,Q) { cin >> a >> b; --a, --b; if( !( a < b ) ) swap(a,b); ll cost = 0; for(int i=69;i>=0;--i) { if( nex[a][i] < b ) { cost += (1LL<<i); a = nex[a][i]; } } cout << cost+1 << endl; } } int main() { cin >> N; rep(i,N) cin >> x[i]; cin >> L; compute(); return 0; } /* 写代码时请注意: 1.是否要开Long Long?数组边界处理好了么? 2.特殊情况处理好了么? 3.做一些总比不做好。 4.最大值和最小值问题可不可以用二分答案? 5.有没有贪心策略?否则能不能dp? 6.实数精度有没有处理? */
a.cc:71:9: warning: "REP" redefined 71 | #define REP(i,s,n) for(int i=s;i<n;++i) | ^~~ a.cc:23:9: note: this is the location of the previous definition 23 | #define REP(i, a, b) for (int (i)=(a);(i)>=(b);(i)--) | ^~~ a.cc:72:9: warning: "rep" redefined 72 | #define rep(i,n) REP(i,0,n) | ^~~ a.cc:21:9: note: this is the location of the previous definition 21 | #define rep(i, a, b) for (int (i)=(a);(i)<=(b);(i)++) | ^~~ a.cc:31:12: error: 'long long long' is too long for GCC 31 | #define ll long long | ^~~~ a.cc:76:19: note: in expansion of macro 'll' 76 | typedef long long ll; | ^~ a.cc:31:17: error: 'long long long' is too long for GCC 31 | #define ll long long | ^~~~ a.cc:76:19: note: in expansion of macro 'll' 76 | typedef long long ll; | ^~ a.cc:31:17: error: declaration does not declare anything [-fpermissive] 31 | #define ll long long | ^~~~ a.cc:76:19: note: in expansion of macro 'll' 76 | typedef long long ll; | ^~ a.cc:79:4: error: conflicting declaration 'long long int N' 79 | ll N,Q,L; | ^ a.cc:41:11: note: previous declaration as 'const int N' 41 | const int N = 25000 ; | ^ a.cc: In function 'int main()': a.cc:108:7: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'const int') 108 | cin >> N; | ~~~ ^~ ~ | | | | | const int | std::istream {aka std::basic_istream<char>} In file included from /usr/include/c++/14/iostream:42, from a.cc:16: /usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 170 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed: a.cc:108:10: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'int' 108 | cin >> N; | ^ /usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 174 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed: a.cc:108:10: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type 'int' 108 | cin >> N; | ^ /usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 177 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed: a.cc:108:10: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type 'int' 108 | cin >> N; | ^ /usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed: a.cc:108:10: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type 'int' 108 | cin >> N; | ^ /usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed: a.cc:108:10: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type 'int' 108 | cin >> N; | ^ /usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed: a.cc:108:10: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type 'int' 108 | cin >> N; | ^ /usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 199 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed: a.cc:108:10: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'int' 108 | cin >> N; | ^ /usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 203 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed: a.cc:108:10: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type 'int' 108 | cin >> N; | ^ /usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 219 | operator>>(float& __f) | ^~~~~~~~ /usr/include/c++/14/istream:219:7: note: conversion of argument 1 would be ill-formed: a.cc:108:10: error: cannot bind non-const lvalue reference of type 'float&' to a value of type 'int' 108 | cin >> N; | ^ /usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 223 | operator>>(double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:223:7: note: conversion of argument 1 would be ill-formed: a.cc:108:10: error: cannot bind non-const lvalue reference of type 'double&' to a value of type 'int' 108 | cin >> N; | ^ /usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 227 | operator>>(long double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:227:7: note: conversion of argument 1 would be ill-formed: a.cc:108:10: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type 'int' 108 | cin >> N; | ^ /usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 328 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed: a.cc:108:10: error: invalid conversion from 'int' to 'void*' [-fpermissive] 108 | cin >> N; | ^ | | | int a.cc:108:10: error: cannot bind rvalue '(void*)((long int)((int)N))' to 'void*&' /usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed: a.cc:108:10: error: invalid conversion from 'int' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive] 108 | cin >> N; | ^ | | | int /usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]' (near match) 126 | operator>>(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:126:7: note: conversion of argument 1 would be ill-formed: a.cc:108:10: error: invalid conversion from 'int' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} [-fpermissive] 108 | cin >> N; |
s694731465
p04017
C++
# include <cstdio> # include <iostream> # include <algorithm> # define Maxn 100005 using namespace std; inline int read() { int ok=1,k=0; char c=getchar(); while(c<'0'||c>'9') { if(c=='-') ok=-1; c=getchar(); } while(c>='0'&&c<='9') { k=k*10+c-'0'; c=getchar(); } return ok*k; } struct node{ int x; int xh; }sd[Maxn]; bool cmp(node a,node b) { return a.x<b.x; } int f[Maxn],next[Maxn]; int main() { int n,maxn; n=read(); for(int i=1;i<=n;i++) { sd[i].xh=i; f[i]=read(); sd[i].x=f[i]; } int ll; ll=read(); sort(sd+1,sd+n+1,cmp); for(int i=1;i<=n;i++) { int tot=f[i]+ll; int l=1,r=n; while(l<=r) { int mid=(l+r)>>1; if(sd[mid].x>tot) r=mid-1; else l=mid+1; } next[i]=sd[r].xh; } int m; m=read(); for(int i=1;i<=m;i++) { int l,r,ans=0; l=read(); r=read(); if(f[l]>f[r]) swap(l,r); while(f[l]<f[r]) { ans++; l=next[l]; } printf("%d\n",ans); } return 0; }
a.cc: In function 'int main()': a.cc:57:17: error: reference to 'next' is ambiguous 57 | next[i]=sd[r].xh; | ^~~~ In file included from /usr/include/c++/14/string:47, 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:2: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:31:13: note: 'int next [100005]' 31 | int f[Maxn],next[Maxn]; | ^~~~ a.cc:71:27: error: reference to 'next' is ambiguous 71 | l=next[l]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:31:13: note: 'int next [100005]' 31 | int f[Maxn],next[Maxn]; | ^~~~
s696438571
p04017
C++
# include "stdio.h" # include "iostream" # include "algorithm" # define Maxn 100005 using namespace std; inline int read() { int ok=1,k=0; char c=getchar(); while(c<'0'||c>'9') { if(c=='-') ok=-1; c=getchar(); } while(c>='0'&&c<='9') { k=k*10+c-'0'; c=getchar(); } return ok*k; } struct node{ int x; int xh; }sd[Maxn]; bool cmp(node a,node b) { return a.x<b.x; } int f[Maxn],next[Maxn]; int main() { int n,maxn; n=read(); for(int i=1;i<=n;i++) { sd[i].xh=i; f[i]=read(); sd[i].x=f[i]; } int ll; ll=read(); sort(sd+1,sd+n+1,cmp); for(int i=1;i<=n;i++) { int tot=f[i]+ll; int l=1,r=n; while(l<=r) { int mid=(l+r)>>1; if(sd[mid].x>tot) r=mid-1; else l=mid+1; } next[i]=sd[r].xh; } int m; m=read(); for(int i=1;i<=m;i++) { int l,r,ans=0; l=read(); r=read(); if(f[l]>f[r]) swap(l,r); while(f[l]<f[r]) { ans++; l=next[l]; } printf("%d\n",ans); } return 0; }
a.cc: In function 'int main()': a.cc:57:17: error: reference to 'next' is ambiguous 57 | next[i]=sd[r].xh; | ^~~~ In file included from /usr/include/c++/14/string:47, 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:2: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:31:13: note: 'int next [100005]' 31 | int f[Maxn],next[Maxn]; | ^~~~ a.cc:71:27: error: reference to 'next' is ambiguous 71 | l=next[l]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:31:13: note: 'int next [100005]' 31 | int f[Maxn],next[Maxn]; | ^~~~
s725913841
p04017
C
# include "cstdio" # include "iostream" # include "algorithm" # define Maxn 100005 using namespace std; inline int read() { int ok=1,k=0; char c=getchar(); while(c<'0'||c>'9') { if(c=='-') ok=-1; c=getchar(); } while(c>='0'&&c<='9') { k=k*10+c-'0'; c=getchar(); } return ok*k; } struct node{ int x; int xh; }sd[Maxn]; bool cmp(node a,node b) { return a.x<b.x; } int f[Maxn],next[Maxn]; int main() { int n,maxn; n=read(); for(int i=1;i<=n;i++) { sd[i].xh=i; f[i]=read(); sd[i].x=f[i]; } int ll; ll=read(); sort(sd+1,sd+n+1,cmp); for(int i=1;i<=n;i++) { int tot=f[i]+ll; int l=1,r=n; while(l<=r) { int mid=(l+r)>>1; if(sd[mid].x>tot) r=mid-1; else l=mid+1; } next[i]=sd[r].xh; } int m; m=read(); for(int i=1;i<=m;i++) { int l,r,ans=0; l=read(); r=read(); if(f[l]>f[r]) swap(l,r); while(f[l]<f[r]) { ans++; l=next[l]; } printf("%d\n",ans); } return 0; }
main.c:1:11: fatal error: cstdio: No such file or directory 1 | # include "cstdio" | ^~~~~~~~ compilation terminated.
s415650606
p04017
C
# include "cstdio" # include "iostream" # include "algorithm" # define Maxn 100005 using namespace std; inline int read() { int ok=1,k=0; char c=getchar(); while(c<'0'||c>'9') { if(c=='-') ok=-1; c=getchar(); } while(c>='0'&&c<='9') { k=k*10+c-'0'; c=getchar(); } return ok*k; } struct node{ int x; int xh; }sd[Maxn]; bool cmp(node a,node b) { return a.x<b.x; } int f[Maxn],next[Maxn]; int main() { int n,maxn; n=read(); for(int i=1;i<=n;i++) { sd[i].xh=i; f[i]=read(); sd[i].x=f[i]; } int ll; ll=read(); sort(sd+1,sd+n+1,cmp); for(int i=1;i<=n;i++) { int tot=f[i]+ll; int l=1,r=n; while(l<=r) { int mid=(l+r)>>1; if(sd[mid].x>tot) r=mid-1; else l=mid+1; } next[i]=sd[r].xh; } int m; m=read(); for(int i=1;i<=m;i++) { int l,r,ans=0; l=read(); r=read(); if(f[l]>f[r]) swap(l,r); while(f[l]<f[r]) { ans++; l=next[l]; } printf("%d\n",ans); } return 0; }
main.c:1:11: fatal error: cstdio: No such file or directory 1 | # include "cstdio" | ^~~~~~~~ compilation terminated.
s539176619
p04017
C++
# include "cstdio" # include "iostream" # include "algorithm" # define Maxn 100005 using namespace std; inline int read() { int ok=1,k=0; char c=getchar(); while(c<'0'||c>'9') { if(c=='-') ok=-1; c=getchar(); } while(c>='0'&&c<='9') { k=k*10+c-'0'; c=getchar(); } return ok*k; } struct node{ int x; int xh; }sd[Maxn]; bool cmp(node a,node b) { return a.x<b.x; } int f[Maxn],next[Maxn]; int main() { int n,maxn; n=read(); for(int i=1;i<=n;i++) { sd[i].xh=i; f[i]=read(); sd[i].x=f[i]; } int ll; ll=read(); sort(sd+1,sd+n+1,cmp); for(int i=1;i<=n;i++) { int tot=f[i]+ll; int l=1,r=n; while(l<=r) { int mid=(l+r)>>1; if(sd[mid].x>tot) r=mid-1; else l=mid+1; } next[i]=sd[r].xh; } int m; m=read(); for(int i=1;i<=m;i++) { int l,r,ans=0; l=read(); r=read(); if(f[l]>f[r]) swap(l,r); while(f[l]<f[r]) { ans++; l=next[l]; } printf("%d\n",ans); } return 0; }
a.cc: In function 'int main()': a.cc:57:17: error: reference to 'next' is ambiguous 57 | next[i]=sd[r].xh; | ^~~~ In file included from /usr/include/c++/14/string:47, 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:2: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:31:13: note: 'int next [100005]' 31 | int f[Maxn],next[Maxn]; | ^~~~ a.cc:71:27: error: reference to 'next' is ambiguous 71 | l=next[l]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:31:13: note: 'int next [100005]' 31 | int f[Maxn],next[Maxn]; | ^~~~
s203766638
p04017
C++
# include "cstdio" # include "iostream" # include "algorithm" # define Maxn 100005 using namespace std; inline int read() { int ok=1,k=0; char c=getchar(); while(c<'0'||c>'9') { if(c=='-') ok=-1; c=getchar(); } while(c>='0'&&c<='9') { k=k*10+c-'0'; c=getchar(); } return ok*k; } struct node{ int x; int xh; }sd[Maxn]; bool cmp(node a,node b) { return a.x<b.x; } int f[Maxn],next[Maxn]; int main() { int n,maxn; n=read(); for(int i=1;i<=n;i++) { sd[i].xh=i; f[i]=read(); sd[i].x=f[i]; } int ll; ll=read(); sort(sd+1,sd+n+1,cmp); for(int i=1;i<=n;i++) { int tot=f[i]+ll; int l=1,r=n; while(l<=r) { int mid=(l+r)>>1; if(sd[mid].x>tot) r=mid-1; else l=mid+1; } next[i]=sd[r].xh; } int m; m=read(); for(int i=1;i<=m;i++) { int l,r,ans=0; l=read(); r=read(); if(f[l]>f[r]) swap(l,r); while(f[l]<f[r]) { ans++; l=next[l]; } printf("%d\n",ans); } return 0; }
a.cc: In function 'int main()': a.cc:57:17: error: reference to 'next' is ambiguous 57 | next[i]=sd[r].xh; | ^~~~ In file included from /usr/include/c++/14/string:47, 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:2: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:31:13: note: 'int next [100005]' 31 | int f[Maxn],next[Maxn]; | ^~~~ a.cc:71:27: error: reference to 'next' is ambiguous 71 | l=next[l]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:31:13: note: 'int next [100005]' 31 | int f[Maxn],next[Maxn]; | ^~~~
s051285370
p04017
C++
# include "cstdio" # include "iostream" # include "algorithm" # define Maxn 100005 using namespace std; #define BF_N 1<<17 char buf[BF_N]; int sl,sr; char gc(){ return sl==sr&&(sr=(sl=0)+fread(buf,1,BF_N,stdin),sl==sr)?EOF:buf[sl++]; } int read(){ int ans=0,k=1; char c=gc(); while(!isdigit(c)){if(c=='-')k=-1; c=gc();} while(isdigit(c)){ans=ans*10+c-'0'; c=gc();} return k*ans; } struct node{ int x; int xh; }sd[Maxn]; bool cmp(node a,node b) { return a.x<b.x; } int f[Maxn],next[Maxn]; int main() { int n,maxn; n=read(); for(int i=1;i<=n;i++) { sd[i].xh=i; f[i]=read(); sd[i].x=f[i]; } int ll; ll=read(); sort(sd+1,sd+n+1,cmp); for(int i=1;i<=n;i++) { int tot=f[i]+ll; int l=1,r=n; while(l<=r) { int mid=(l+r)>>1; if(sd[mid].x>tot) r=mid-1; else l=mid+1; } next[i]=sd[r].xh; } int m; m=read(); for(int i=1;i<=m;i++) { int l,r,ans=0; l=read(); r=read(); if(f[l]>f[r]) swap(l,r); while(f[l]<f[r]) { ans++; l=next[l]; } printf("%d\n",ans); } return 0; }
a.cc: In function 'int main()': a.cc:52:17: error: reference to 'next' is ambiguous 52 | next[i]=sd[r].xh; | ^~~~ In file included from /usr/include/c++/14/string:47, 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:2: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:26:13: note: 'int next [100005]' 26 | int f[Maxn],next[Maxn]; | ^~~~ a.cc:66:27: error: reference to 'next' is ambiguous 66 | l=next[l]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:26:13: note: 'int next [100005]' 26 | int f[Maxn],next[Maxn]; | ^~~~
s408110557
p04017
C++
#include<bits/stdc++.h> #define N 100005 using namespace std; inline int read(){ int ans=0; char ch=getchar(); while(!isdigit(ch))ch=getchar(); while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar(); return ans; } int l,n,x[N],Q,tim[N],next[N],hd,tl,q[N],blo[N],sig; int main(){ n=read(),sig=sqrt(n); for(int i=1;i<=n;++i)x[i]=read(); l=read(),Q=read(); hd=tl=1,q[tl]=n,tim[n]=0,next[n]=n+1; for(int i=n-1;i;--i){ while(x[q[hd]]-x[i]>l)++hd; next[i]=q[hd],q[++tl]=i; } for(int i=1;i<=n;++i)blo[i]=(i-1)/sig+1; for(int i=n-1;i;--i) if(blo[next[i]]==blo[i])tim[i]=x[i]+l>=x[n]?1:tim[next[i]]+1,next[i]=next[next[i]]; else tim[i]=1; while(Q--){ int a=read(),b=read(),cnt=0; if(a>b)a^=b,b^=a,a^=b; while(blo[a]<blo[b])cnt+=tim[a],a=next[a]; int sum=0; for(int i=a+1;i<=b;++i){ sum+=x[i]-x[i-1]; if(sum>=l)sum=0,++cnt; } printf("%d\n",cnt); } return 0; }
a.cc: In function 'int main()': a.cc:16:34: error: reference to 'next' is ambiguous 16 | hd=tl=1,q[tl]=n,tim[n]=0,next[n]=n+1; | ^~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:66, 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_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:11:23: note: 'int next [100005]' 11 | int l,n,x[N],Q,tim[N],next[N],hd,tl,q[N],blo[N],sig; | ^~~~ a.cc:19:17: error: reference to 'next' is ambiguous 19 | next[i]=q[hd],q[++tl]=i; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:11:23: note: 'int next [100005]' 11 | int l,n,x[N],Q,tim[N],next[N],hd,tl,q[N],blo[N],sig; | ^~~~ a.cc:23:24: error: reference to 'next' is ambiguous 23 | if(blo[next[i]]==blo[i])tim[i]=x[i]+l>=x[n]?1:tim[next[i]]+1,next[i]=next[next[i]]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:11:23: note: 'int next [100005]' 11 | int l,n,x[N],Q,tim[N],next[N],hd,tl,q[N],blo[N],sig; | ^~~~ a.cc:23:67: error: reference to 'next' is ambiguous 23 | if(blo[next[i]]==blo[i])tim[i]=x[i]+l>=x[n]?1:tim[next[i]]+1,next[i]=next[next[i]]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:11:23: note: 'int next [100005]' 11 | int l,n,x[N],Q,tim[N],next[N],hd,tl,q[N],blo[N],sig; | ^~~~ a.cc:23:78: error: reference to 'next' is ambiguous 23 | if(blo[next[i]]==blo[i])tim[i]=x[i]+l>=x[n]?1:tim[next[i]]+1,next[i]=next[next[i]]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:11:23: note: 'int next [100005]' 11 | int l,n,x[N],Q,tim[N],next[N],hd,tl,q[N],blo[N],sig; | ^~~~ a.cc:23:86: error: reference to 'next' is ambiguous 23 | if(blo[next[i]]==blo[i])tim[i]=x[i]+l>=x[n]?1:tim[next[i]]+1,next[i]=next[next[i]]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:11:23: note: 'int next [100005]' 11 | int l,n,x[N],Q,tim[N],next[N],hd,tl,q[N],blo[N],sig; | ^~~~ a.cc:23:91: error: reference to 'next' is ambiguous 23 | if(blo[next[i]]==blo[i])tim[i]=x[i]+l>=x[n]?1:tim[next[i]]+1,next[i]=next[next[i]]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:11:23: note: 'int next [100005]' 11 | int l,n,x[N],Q,tim[N],next[N],hd,tl,q[N],blo[N],sig; | ^~~~ a.cc:28:51: error: reference to 'next' is ambiguous 28 | while(blo[a]<blo[b])cnt+=tim[a],a=next[a]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:11:23: note: 'int next [100005]' 11 | int l,n,x[N],Q,tim[N],next[N],hd,tl,q[N],blo[N],sig; | ^~~~
s269234901
p04017
C++
#include<bits/stdc++.h> #define REP(i,s,n) for(int i=s;i<n;++i) #define rep(i,n) REP(i,0,n) using namespace std; typedef long long ll; #define MAX 100010 ll N,Q,L; ll x[MAX],a,b; int nex[MAX][70]; void compute() { rep(i,N) { nex[i][0] = ( upper_bound(x,x+N,x[i]+L) - x ) - 1; assert( nex[i][0] != 0 ); } rep(j,67) rep(i,N) nex[i][j+1] = nex[nex[i][j]][j]; cin >> Q; rep(_,Q) { cin >> a >> b; --a, --b; if( !( a < b ) ) swap(a,b); //cout << "[*] " << a << " -> " << b << endl; ll cost = 0; while( a != b ) { int go = 0; go = upper_bound(nex[a],nex[a]+67,b) - nex[a] - 1; cost += (1LL<<go); //cout << " " << a <<" -[" << go << "]->" << nex[a][go] << endl; a = nex[a][go]; } cout << cost << endl; } } int main() {
a.cc: In function 'int main()': a.cc:41:13: error: expected '}' at end of input 41 | int main() { | ~^
s588232514
p04017
C++
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; long long N, x[100000], L; int next[100000], before[100000]; int Q; int main(){ cin >> N; for(int i = 0; i < N; i++){ cin >> x[i]; } cin >> L; // dist [l, r) <= L int r = 0; for(int l = 0; l < N; l++){ while(r < N && x[r] - x[l] <= L){ r++; } next[l] = r - 1; } cin >> Q; for(int i = 0; i < Q; i++){ int a, b; cin >> a >> b; a--; b--; if(a > b){ int tmp = a; a = b; b = tmp; } int cnt = 0; while(a < b){ a = next[a]; cnt++; } cout << cnt << endl; } }
a.cc: In function 'int main()': a.cc:26:9: error: reference to 'next' is ambiguous 26 | next[l] = r - 1; | ^~~~ In file included from /usr/include/c++/14/string:47, 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/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:8:5: note: 'int next [100000]' 8 | int next[100000], before[100000]; | ^~~~ a.cc:45:17: error: reference to 'next' is ambiguous 45 | a = next[a]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:8:5: note: 'int next [100000]' 8 | int next[100000], before[100000]; | ^~~~
s768333140
p04017
C++
#include <iostream> #include <stdio.h> #include <fstream> #include <algorithm> #include <string> #include <map> #include <set> #include <queue> #include <stack> #include <vector> #include <limits.h> #include <math.h> #include <functional> #define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i)) #define debug(x) cerr << #x << ": " << x << '\n' #define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n' using namespace std; typedef long long ll; typedef pair<int,int> Pii; typedef vector<int> vint; typedef vector<ll> vll; const ll INF = INT_MAX; const ll MOD = 1e9+7; int main() { int N;cin >> N; vint x(N); repeat(i,N) cin >> x[i]; x.push_back(INF); ll L;cin >> L; vector<vint> rmax(20,vint(N,0)); repeat(i,N){ rmax[0][i] = upper_bound(x.begin(),x.end(),x[i]+L)-x.begin()-1; } repeat(k,18){ repeat(i,N){ rmax[k+1][i] = rmax[k][rmax[k][i]]; } } debugArray(rmax[0],N); int Q;cin >> Q; repeat(q,Q){ int a,b;cin >> a >> b; a--;b--; if(a>b) swap(a,b); ll ans = 0; for(int k=18;k>=0;k--){ //debug(a); if(rmax[k][a] >= b) continue; ans |= 1<<k; a = rmax[k][a]; } ans++; cout << ans <<endl; } cerr << bitset<20>(524287) << endl; return 0; }
a.cc: In function 'int main()': a.cc:59:11: error: 'bitset' was not declared in this scope 59 | cerr << bitset<20>(524287) << endl; | ^~~~~~ a.cc:14:1: note: 'std::bitset' is defined in header '<bitset>'; this is probably fixable by adding '#include <bitset>' 13 | #include <functional> +++ |+#include <bitset> 14 | a.cc:59:30: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<' 59 | cerr << bitset<20>(524287) << endl; | ~~~~~~~~~^~~~~~~
s004906610
p04017
C++
#include <bits/stdc++.h> using namespace std; int hotel[200005]; int jump[200005][20]; /* Phan chuan bi LCA */ void pre_process() { for(int i=1;i<=n;i++) { int p = upper_bound(hotel,hotel+n+2,hotel[i]+k) - hotel ; jump[i][0] = p-1; } for(int j=1;j<20;j++) { for(int i=1;i<=n;i++) { if(jump[i][j-1]!=-1) jump[i][j] = jump[jump[i][j-1]][j-1]; } } } /* Phan tinh LCA */ int solve(int u,int v) { if(u==v) return 0; int ans = 0; for(int i=17;i>=0;i--) { if(jump[u][i]<v) { u = jump[u][i]; ans+=(1<<i); } } return ans+1; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n,k,q; cin>>n; hotel[n+1] = 2e9; memset(jump,-1,sizeof jump); for(int i=1;i<=n;i++) { cin>>hotel[i]; } cin>>k; cin>>q; while(q--) { int u,v; cin>>u>>v; if(u>v) swap(u,v); cout<<solve(u,v)<<'\n'; } }
a.cc: In function 'void pre_process()': a.cc:10:20: error: 'n' was not declared in this scope 10 | for(int i=1;i<=n;i++) | ^ a.cc:12:54: error: 'k' was not declared in this scope 12 | int p = upper_bound(hotel,hotel+n+2,hotel[i]+k) - hotel ; | ^ a.cc:18:24: error: 'n' was not declared in this scope 18 | for(int i=1;i<=n;i++) | ^
s329748701
p04017
C++
#include <bits/stdc++.h> using namespace std; int n, x[100010], l, q, a, b, dp[100010][20]; int main() { memset(dp, -1, sizeof(dp)); scanf("%d", &n); for(int i = 0; i < n; i++) scanf("%d", &x[i]); scanf("%d", &l); for(int i = n-1; i >= 0; i--) { int L = i, R = n; while(L + 1 < R) { int M = (L + R)/2; if(x[M] - x[i] > l) R = M; else L = M; } dp[i][0] = L;a } for(int j = 1; (1<<j) < n; j++) { for(int i = 0; i < n; i++) { if(dp[i][j-1] != -1) dp[i][j] = dp[dp[i][j-1]][j-1]; } } scanf("%d", &q); while(q--) { scanf("%d%d", &a, &b); int ans = 0; if(a > b) swap(a, b); a--, b--; for(int i = 19; i >= 0; i--) { if(dp[a][i] != -1 && x[dp[a][i]] < x[b]) ans += (1<<i), a = dp[a][i]; } printf("%d\n", ans+1); } }
a.cc: In function 'int main()': a.cc:18:23: error: expected ';' before '}' token 18 | dp[i][0] = L;a | ^ | ; 19 | } | ~
s321146403
p04017
C++
#include<bits/stdc++.h> using namespace std; int main() { int n, a[200001], sum[200001], maxi[200001], q, dis, c, b, itr = 1; cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]; cin >> dis; for(int i = 1; i < n; i++){ int l = i + 1, r = n; while(l != r){ int mid = (l + r) / 2; if(a[mid] - a[i] < dis) l = mid + 1; else r = mid; } if(a[l] - a[i] > dis) l--; maxi[i] = l; } maxi[n] = n; sum[1] = 0; while(itr < n){ int itr2 = itr; itr = maxi[itr]; for(int i = itr2 + 1; i <= itr; i++) sum[i] = sum[itr2] + 1; } cin >> q; for(int i = 0; i < q; i++){ cin >> c >> b; if(sum[b] == sum[c]) cout << 1 << endl; else if(abs(b - c) <= l * (sum[b] - sum[c])) cout << abs(sum[b] - sum[c]) << endl; else cout << abs(sum[b] - sum[c]) + 1 << endl; } }
a.cc: In function 'int main()': a.cc:31:31: error: 'l' was not declared in this scope 31 | else if(abs(b - c) <= l * (sum[b] - sum[c])) cout << abs(sum[b] - sum[c]) << endl; | ^
s927144890
p04017
C++
#include<cstdio> #include<vector> #include<algorithm> using namespace std; #define MAXN 100010 int x[MAXN],fa[MAXN][20],step[MAXN],end[MAXN]; vector<int>G[MAXN]; void dfs(int u,int p) { step[u]=step[p]+1; for(int i=1,j=2;j<step[u];i++,j<<=1) fa[u][i]=fa[fa[u][i-1]][i-1],end[u]=i; for(int i=0;i<G[u].size();i++) dfs(G[u][i],u); } int Solve(int a,int b) { if(a>b) swap(a,b); int d=step[a]-step[b]; int ret=0; for(int i=0;(1<<i)<=d;i++) if(d&(1<<i)) a=fa[a][i]; if(a>=b) return d; else if(a<b) return d+1; } int main() { int n,L,q,a,b; scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&x[i]); scanf("%d",&L); int l=1,r=1; while(l<n) { while(r<=n&&x[r]-x[l]<=L) r++; fa[l][0]=r-1; G[r-1].push_back(l); l++; } dfs(n,0); scanf("%d",&q); while(q--) { scanf("%d%d",&a,&b); printf("%d\n",Solve(a,b)); } }
a.cc: In function 'void dfs(int, int)': a.cc:12:46: error: reference to 'end' is ambiguous 12 | fa[u][i]=fa[fa[u][i-1]][i-1],end[u]=i; | ^~~ In file included from /usr/include/c++/14/vector:69, from a.cc:2: /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ In file included from /usr/include/c++/14/bits/stl_vector.h:63, from /usr/include/c++/14/vector:66: /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:6:37: note: 'int end [100010]' 6 | int x[MAXN],fa[MAXN][20],step[MAXN],end[MAXN]; | ^~~ a.cc: In function 'int Solve(int, int)': a.cc:26:1: warning: control reaches end of non-void function [-Wreturn-type] 26 | } | ^
s968831515
p04017
C++
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int MAXN=100005,BLK=320; struct Query { int l,r,id; bool operator < (const Query &t)const { if(l/BLK==t.l/BLK) return r<t.r; return l<t.l; } }; int N,L,Q; int x[MAXN],left[MAXN],right[MAXN]; Query q[MAXN]; int ans[MAXN]; int dis[MAXN]; int main() { scanf("%d",&N); for(int i=1;i<=N;i++) scanf("%d",&x[i]); scanf("%d%d",&L,&Q); for(int i=1;i<=N;i++) left[i]=max(lower_bound(x+1,x+N+1,x[i]-L)-x,1); for(int i=1;i<=N;i++) { right[i]=lower_bound(x+1,x+N+1,x[i]+L)-x; if(x[right[i]]>x[i]+L) right[i]--; } for(int i=2;i<=N;i++) dis[i]=dis[left[i]]+1; for(int i=1;i<=Q;i++) { scanf("%d%d",&q[i].l,&q[i].r); if(q[i].l>q[i].r) swap(q[i].l,q[i].r); printf("%d\n",dis[q[i].r]-dis[q[i].l-1]); q[i].id=i; } sort(q+1,q+Q+1); /*int L=1,R=1,lm=1,rm=1,ti=0; for(int i=1;i<=Q;i++) { if(L>q[i].l) { while(lm>q[i].l) lm=left[lm],ti++; L=q[i].l; } if(R<q[i].r) { while(rm<q[i].r) rm=right[rm],ti++; R=q[i].r; } if(L<q[i].l) { while(lm<q[i].l) lm=min(right[lm],q[i].l),ti--; L=q[i].l; } if(R>q[i].r) { while(rm>q[i].r) rm=max(left[rm],q[i].r),ti--; R=q[i].r; } ans[q[i].id]=ti; } for(int i=1;i<=Q;i++) printf("%d\n",ans[i]);*/ return 0; }
a.cc: In function 'int main()': a.cc:31:28: error: no matching function for call to 'max(long int, int)' 31 | left[i]=max(lower_bound(x+1,x+N+1,x[i]-L)-x,1); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from a.cc:3: /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:31:28: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'int') 31 | left[i]=max(lower_bound(x+1,x+N+1,x[i]-L)-x,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:31:28: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 31 | left[i]=max(lower_bound(x+1,x+N+1,x[i]-L)-x,1); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s641811676
p04017
C++
#include <bits/stdc++.h> using namespace std; using Pint = pair<int, int>; int N, L, Q; vector<int> x; vector<Pint> q; int main() { cin >> N; x.resize(N); for (auto &val : x) cin >> val; x.push_back(x[N-1]+1); cin >> L >> Q; q.resize(Q); for (int i=0; i<Q; i++) { int t1, t2; cin >> t1 >> t2; if (t1>t2) swap(t1, t2); q[i] = Pint(t1-1, t2-1); } int lgN = 1; { int tmp = N; while (tmp) { lgN++; tmp /= 2; } } vector<vector<int> > next(lgN+1, vector<int>(N+1)); for (int i=0; i<=N; i++) { next[1][i] = min(distance(x.begin(), lower_bound(x.begin(), x.end(), x[i]+L+1)) - 1, N); } for (int n=2; n<=lgN; n++) { for (int i=0; i<=N; i++) { next[n][i] = next[n-1][next[n-1][i]]; } } // for (auto vec : next) // { // for (auto val : vec) cout << val << " "; // cout << endl; // } for (auto query : q) { int ans = 0; int now = query.first; for (int n = lgN; n>0; n--) { if (next[n][now] < query.second) { ans += n; now = next[n][now]; } } cout << ans + 1 << endl; } }
a.cc: In function 'int main()': a.cc:37:25: error: no matching function for call to 'min(std::__iterator_traits<__gnu_cxx::__normal_iterator<int*, std::vector<int> >, void>::difference_type, int&)' 37 | next[1][i] = min(distance(x.begin(), lower_bound(x.begin(), x.end(), x[i]+L+1)) - 1, N); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:37:25: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'int') 37 | next[1][i] = min(distance(x.begin(), lower_bound(x.begin(), x.end(), x[i]+L+1)) - 1, N); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281: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:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:37:25: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 37 | next[1][i] = min(distance(x.begin(), lower_bound(x.begin(), x.end(), x[i]+L+1)) - 1, N); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s465944454
p04017
C++
#include <bits/stdc++.h> using namespace std; using Pint = pair<int, int>; int N, L, Q; vector<int> x; vector<Pint> q; int main() { cin >> N; x.resize(N); for (auto &val : x) cin >> val; x.push_back(x[N-1]+1); cin >> L >> Q; q.resize(Q); for (int i=0; i<Q; i++) { int t1, t2; cin >> t1 >> t2; if (t1>t2) swap(t1, t2); q[i] = Pint(t1-1, t2-1); } int lgN = 0; { int tmp = N; while (tmp) { lgN++; tmp /= 2; } } vector<vector<int> > next(lgN+1, vector<int>(N)); for (int i=0; i<N; i++) { next[1][i] = min(lower_bound(x.begin(), x.end(), x[i]+L+1) - x.begin() - 1, N-1); } for (int n=2; n<=lgN; n++) { for (int i=0; i<N; i++) { next[n][i] = next[n-1][next[n-1][i]]; } } for (auto query : q) { int ans = 0; int now = query.first; for (int n = lgN; n>0; n--) { if (next[n][now] < query.second) { ans += n; now = next[n][now]; } } cout << ans + 1 << endl; } }
a.cc: In function 'int main()': a.cc:37:25: error: no matching function for call to 'min(__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type, int)' 37 | next[1][i] = min(lower_bound(x.begin(), x.end(), x[i]+L+1) - x.begin() - 1, 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:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:37:25: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'int') 37 | next[1][i] = min(lower_bound(x.begin(), x.end(), x[i]+L+1) - x.begin() - 1, N-1); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281: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:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:37:25: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 37 | next[1][i] = min(lower_bound(x.begin(), x.end(), x[i]+L+1) - x.begin() - 1, N-1); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s735495040
p04017
C++
#include <iostream> #include <map> #include <queue> using namespace std; typedef long long int ll; ll n, x[110000], l, numq, a, b, nexth[110000], table[30][110000]; void build_sparse() { for (int i = 0; i < 20; i++) { if ((1 << i) >= n) break; for (int j = 0; j < n; j++) { if (i == 0) { table[i][j] = nexth[j]; } else if (table[i - 1][j] == -1) { table[i][j] = -1; } else { if (table[i - 1][table[i - 1][j]] == -1) table[i][j] = -1; else table[i][j] = table[i - 1][table[i - 1][j]]; } } } } int solve(int x1, int y1) { if (x1 >= y1) return 0; int j; for (j = 0; j < 20; j++) { if (table[j][x1] > y1 || table[j][x1] == -1) break; } j--; if (j == -1) return 1; return (solve(table[j][x1], y1) + (1<<j)); } int main() { cin >> n; for (int i = 0; i < n; i++) cin >> x[i]; cin >> l; queue<int> q; q.push(0); for (int i = 1; i < n; i++) { int temp = x[q.front()]; while (x[i]-temp > l) { nexth[q.front()] = i - 1; q.pop(); temp = x[q.front()]; } q.push(i); } while (!q.empty()) { nexth[q.front()] = n - 1; q.pop(); } nexth[n - 1] = -1; memset(table, -1, sizeof(table)); build_sparse(); cin >> numq; for (int i = 0; i < numq; i++) { cin >> a >> b; if (a > b) { int temp = a; a = b; b = temp; } a--; b--; int ans = solve(a, b); cout << ans << endl; } }
a.cc: In function 'int main()': a.cc:81:9: error: 'memset' was not declared in this scope 81 | memset(table, -1, sizeof(table)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <queue> +++ |+#include <cstring> 4 | using namespace std;
s964493443
p04017
C++
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { int n, l, q; int[] xs, as, bs; public static void main(String args[]) { new Main().run(); } void run() { FastReader sc = new FastReader(); n = sc.nextInt(); xs = new int[n]; for (int i = 0; i < n; i++) { xs[i] = sc.nextInt(); } l = sc.nextInt(); q = sc.nextInt(); as = new int[q]; bs = new int[q]; for (int i = 0; i < q; i++) { as[i] = sc.nextInt() - 1; bs[i] = sc.nextInt() - 1; } solve(); } void solve() { int logN = (int)(9 / Math.log(2)) + 1; int[][] doubling = new int[n][logN]; for (int i = 0; i < n; i++) { doubling[i][0] = upper_bound(xs, xs[i] + l) - 1; } for (int i = 1; i < logN; i++) { for (int j = 0; j < n; j++) { doubling[j][i] = doubling[doubling[j][i - 1]][i - 1]; } } for (int i = 0; i < q; i++) { int a = as[i]; int b = bs[i]; if (a > b) { int temp = a; a = b; b = temp; } int ans = 0; while (true) { int next = upper_bound(doubling[a], b) - 1; ans += pow(2, next); if (next == -1) { break; } //System.out.println(a + " " + b + " " + next + " " + doubling[a][next]); if (doubling[a][next] == b) { break; } a = doubling[a][next]; } System.out.println(ans); } } long pow(long x, int n) { long ans = 1; while (n > 0) { if ((n & 1) == 1) { ans = ans * x; } x = x * x; n >>= 1; } return ans; } static int upper_bound(int[] arr, int key) { return upper_bound(arr, 0, arr.length - 1, key); } static int upper_bound(int[] arr, int beginIndex, int endIndex, int key) { int low = beginIndex; int high = endIndex; while (high - low >= 0) { int mid = (low + high) / 2; if (key < arr[mid]) { high = mid - 1; } else { low = mid + 1; } } return low; } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.io.BufferedReader; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.io.IOException; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import java.io.InputStreamReader; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: 'import' does not name a type 4 | import java.util.StringTokenizer; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:6:1: error: expected unqualified-id before 'public' 6 | public class Main { | ^~~~~~
s274732670
p04017
C++
#pragma GCC optimize("O3") #include <iostream> #include <cstdio> #include <cstring> #include <list> #include <cmath> #include <algorithm> #include <vector> #include <map> #include <queue> #include <stack> #include <set> #include <complex> #define in(x) scanf("%d",&x) #define ein(x) ~scanf("%d",&x) #define inl(x) scanf("%lld",&x) #define ins(x) scanf("%s",x) #define inf(x) scanf("%lf",&x) #define inc(x) scanf("%c",&x) #define gc() getchar() #define out(x) printf("%d\n",x) #define outl(x) printf("%lld\n",x) #define od(x, y) printf("%d %d\n",x,y) #define ms(x) memset(x,0,sizeof(x)) #define msc(x, n) memset(x,n,sizeof(x)) #define cp(x) while(!x.empty())x.pop() #define rep(i, a, b) for(int i=a;i<b;++i) #define rvep(i, a, b) for(int i=a;i>=b;--i) #define elif else if #define el else #define wl(x) while(x) #define sn scanf #define bl bool #define mp make_pair #define pii pair<int,int> #define rtn return #define ope operator #define cst const #define it int #define cr char #define ctn continue #define stt struct #define il inline #define tpl template #define cl class #define db double #define sf(x) sizeof(x) #define vt void #define pf printf typedef long long ll; using namespace std; cst it INF = 0x3f3f3f3f; /* * 输入挂 * 场场AK buff */ class endln { }; class iofstream { private: it idx; bl eof; cr buf[100000], *ps, *pe; cr bufout[100000], outtmp[50], *pout, *pend; il vt rnext() { if (++ps == pe) pe = (ps = buf) + fread(buf, sf(cr), sf(buf) / sf(cr), stdin), eof = true; if (ps == pe) eof = false; } il vt write() { fwrite(bufout, sf(cr), pout - bufout, stdout); pout = bufout; } public: iofstream(char *in = NULL, char *out = NULL) : idx(-1), eof(true) { ps = buf, pe = buf + 1; pout = bufout, pend = bufout + 100000; if (in) freopen(in, "r", stdin); if (out) freopen(out, "w", stdout); } tpl<cl T> il bl fin(T &ans) { #ifdef ONLINE_JUDGE ans = 0; T f = 1; if (ps == pe) { eof=false; rtn false;//EOF } do { rnext(); if ('-' == *ps) f = -1; } wl(!isdigit(*ps) && ps != pe); if (ps == pe) { eof=false; rtn false;//EOF } do { ans = (ans << 1) + (ans << 3) + *ps - 48; rnext(); } wl(isdigit(*ps) && ps != pe); ans *= f; #else cin >> ans; #endif rtn true; } tpl<cl T> il bl fdb(T &ans) { #ifdef ONLINE_JUDGE ans = 0; T f = 1; if (ps == pe) rtn false;//EOF do { rnext(); if ('-' == *ps) f = -1; } wl(!isdigit(*ps) && ps != pe); if (ps == pe) rtn false;//EOF do { ans = ans*10 + *ps - 48; rnext(); } wl(isdigit(*ps) && ps != pe); ans *= f; if(*ps=='.') { rnext(); T small=0; do { small=small*10+*ps-48; rnext(); }wl(isdigit(*ps)&&ps!=pe); wl(small>=1) { small/=10; } ans+=small; } #else cin >> ans; #endif rtn true; } /* * 输出挂 * 超强 超快 */ il bl out_char(cst cr c) { #ifdef ONLINE_JUDGE *(pout++) = c; if (pout == pend) write(); write(); #else cout << c; #endif rtn true; } il bl out_str(cst cr *s) { #ifdef ONLINE_JUDGE wl(*s) { *(pout++) = *(s++); if (pout == pend) write(); } write(); #else cout << s; #endif rtn true; } tpl<cl T> il bl out_double(T x, it idx) { char str[50]; string format = "%"; if (~idx) { format += '.'; format += (char) (idx + '0'); } format += "f"; sprintf(str, format.c_str(), x); out_str(str); } tpl<cl T> il bl out_int(T x) { #ifdef ONLINE_JUDGE if (!x) { out_char('0'); rtn true; } if (x < 0) x = -x, out_char('-'); it len = 0; wl(x) { outtmp[len++] = x % 10 + 48; x /= 10; } outtmp[len] = 0; for (it i = 0, j = len - 1; i < j; i++, j--) swap(outtmp[i], outtmp[j]); out_str(outtmp); #else cout << x; #endif rtn true; } tpl<cl T> il bl out_intln(T x) { #ifdef ONLINE_JUDGE out_int(x),out_char('\n'); write(); #else cout << x << endl; #endif rtn true; } tpl<cl T> il bl out_doubleln(T x, it idx) { out_double(x, idx), out_char('\n'); } il iofstream &ope<<(cst db &x) { out_double(x, idx); rtn *this; } il iofstream &ope<<(cst it &x) { out_int(x); rtn *this; } il iofstream &ope<<(cst unsigned long long &x) { out_int(x); rtn *this; } il iofstream &ope<<(cst unsigned &x) { out_int(x); rtn *this; } il iofstream &ope<<(cst long &x) { out_int(x); rtn *this; } il iofstream &ope<<(cst ll &x) { out_int(x); rtn *this; } il iofstream &ope<<(cst endln &x) { out_char('\n'); rtn *this; } il iofstream &ope<<(cst cr *x) { out_str(x); rtn *this; } il iofstream &ope<<(cst string &x) { out_str(x.c_str()); rtn *this; } il iofstream &ope<<(cst char &x) { out_char(x); rtn *this; } il bl setw(it x) { if (x >= 0) { idx = x; rtn true; } rtn false; } il iofstream &ope>>(it &x) { if (!fin(x))eof = false; rtn *this; } il iofstream &ope>>(ll &x) { if (!fin(x))eof = false; rtn *this; } il iofstream &ope>>(db &x) { if (!fdb(x))eof = false; rtn *this; } il iofstream &ope>>(float &x) { if (!fdb(x))eof = false; rtn *this; } il iofstream &ope>>(unsigned &x) { if (!fin(x))eof = false; rtn *this; } il iofstream &ope>>(unsigned long long &x) { if (!fin(x))eof = false; rtn *this; } il ope bl() { rtn eof; } il cr getchar() { #ifdef ONLINE_JUDGE if (ps == pe){ eof=false;//EOF rtn 0; } rnext(); if(ps+1==pe) eof=false; rtn *ps; #else rtn std::getchar(); #endif } il iofstream &ope>>(char *str) { #ifdef ONLINE_JUDGE if (ps == pe){ eof=false;//EOF rtn *this; } do { rnext(); } wl(isspace(*ps)&&iscntrl(*ps) && ps != pe); if (ps == pe){ eof=false;//EOF rtn *this; } do { *str=*ps; ++str; rnext(); } wl(!(isspace(*ps)||iscntrl(*ps)) && ps != pe); *str='\0'; rtn *this; #else cin >> str; rtn *this; #endif } il iofstream &ope>>(string &str) { #ifdef ONLINE_JUDGE str.clear(); if (ps == pe){ eof=false;//EOF rtn *this; } do { rnext(); } wl(isspace(*ps)&&iscntrl(*ps) && ps != pe); if (ps == pe){ eof=false;//EOF rtn *this; } do { str+=*ps; rnext(); } wl(!(isspace(*ps)||iscntrl(*ps)) && ps != pe); rtn *this; #else cin >> str; rtn *this; #endif } il iofstream &getline(char *str) { #ifdef ONLINE_JUDGE if (ps == pe){ eof=false;//EOF rtn *this; } do { rnext(); *str=*ps; }while(*ps!='\n'&&ps!=pe&&str++); *str='\0'; rtn *this; #else gets(str); rtn *this; #endif } il bl endfile() { rtn eof; } }; static iofstream fin; static endln ln; class range { public: class iterator { friend class range; public: int operator*() const { return i_; } iterator &operator++() { ++i_; return *this; } iterator operator++(int) { iterator copy(*this); ++i_; return copy; } bool operator==(const iterator &other) const { return i_ == other.i_; } bool operator!=(const iterator &other) const { return i_ != other.i_; } protected: iterator(int start) : i_(start) {} private: int i_; }; iterator begin() const { return begin_; } iterator end() const { return end_; } range(int begin, int end) : begin_(begin), end_(end) {} private: iterator begin_; iterator end_; }; template<typename T> class reverse_iterator_class { public: explicit reverse_iterator_class(const T &t) : t(t) {} typename T::const_reverse_iterator begin() const { return t.rbegin(); } typename T::const_reverse_iterator end() const { return t.rend(); } private: const T &t; }; using ll = long long; template<typename T> reverse_iterator_class<T> reverse(const T &t) { return reverse_iterator_class<T>(t); } using LL = long long; const LL mod = 1e9 + 7; int x[100000]; int r[17][100000]; int main() { int n; fin>>n; for (auto i:range(0, n)) { fin>>x[i]; } int l, q; fin>>l>>q; for (auto i:range(0, n)) { r[0][i] = upper_bound(x, x + n, x[i] + l) - x - 1; } for (int i = 1; i < 17; i++) { for (auto j:range(0, n)) { r[i][j] = r[i - 1][r[i - 1][j]]; } } for (auto i:range(0, q)) { int a, b; fin>>a>>b; a--; b--; if (a > b)swap(a, b); int cnt = 0; for (int i = 16; i >= 0; i--) { if (r[i][a] < b) { a = r[i][a]; cnt += 1 << i; } } fin<<cnt+1<<ln; } }
a.cc: In member function 'bool iofstream::out_double(T, int)': a.cc:205:5: warning: no return statement in function returning non-void [-Wreturn-type] 205 | } | ^ a.cc: In member function 'bool iofstream::out_doubleln(T, int)': a.cc:245:5: warning: no return statement in function returning non-void [-Wreturn-type] 245 | } | ^ a.cc: In member function 'iofstream& iofstream::getline(char*)': a.cc:424:9: error: 'gets' was not declared in this scope; did you mean 'getw'? 424 | gets(str); | ^~~~ | getw
s702771168
p04017
C++
#pragma GCC optimize("O3") #include <iostream> #include <cstdio> #include <cstring> #include <list> #include <cmath> #include <algorithm> #include <vector> #include <map> #include <queue> #include <stack> #include <set> #include <complex> #define in(x) scanf("%d",&x) #define ein(x) ~scanf("%d",&x) #define inl(x) scanf("%lld",&x) #define ins(x) scanf("%s",x) #define inf(x) scanf("%lf",&x) #define inc(x) scanf("%c",&x) #define gc() getchar() #define out(x) printf("%d\n",x) #define outl(x) printf("%lld\n",x) #define od(x, y) printf("%d %d\n",x,y) #define ms(x) memset(x,0,sizeof(x)) #define msc(x, n) memset(x,n,sizeof(x)) #define cp(x) while(!x.empty())x.pop() #define rep(i, a, b) for(int i=a;i<b;++i) #define rvep(i, a, b) for(int i=a;i>=b;--i) #define elif else if #define el else #define wl(x) while(x) #define sn scanf #define bl bool #define mp make_pair #define pii pair<int,int> #define rtn return #define ope operator #define cst const #define it int #define cr char #define ctn continue #define stt struct #define il inline #define tpl template #define cl class #define db double #define sf(x) sizeof(x) #define vt void #define pf printf typedef long long ll; using namespace std; cst it INF = 0x3f3f3f3f; /* * 输入挂 * 场场AK buff */ class endln { }; class iofstream { private: it idx; bl eof; cr buf[100000], *ps, *pe; cr bufout[100000], outtmp[50], *pout, *pend; il vt rnext() { if (++ps == pe) pe = (ps = buf) + fread(buf, sf(cr), sf(buf) / sf(cr), stdin), eof = true; if (ps == pe) eof = false; } il vt write() { fwrite(bufout, sf(cr), pout - bufout, stdout); pout = bufout; } public: iofstream(char *in = NULL, char *out = NULL) : idx(-1), eof(true) { ps = buf, pe = buf + 1; pout = bufout, pend = bufout + 100000; if (in) freopen(in, "r", stdin); if (out) freopen(out, "w", stdout); } tpl<cl T> il bl fin(T &ans) { #ifdef ONLINE_JUDGE ans = 0; T f = 1; if (ps == pe) { eof=false; rtn false;//EOF } do { rnext(); if ('-' == *ps) f = -1; } wl(!isdigit(*ps) && ps != pe); if (ps == pe) { eof=false; rtn false;//EOF } do { ans = (ans << 1) + (ans << 3) + *ps - 48; rnext(); } wl(isdigit(*ps) && ps != pe); ans *= f; #else cin >> ans; #endif rtn true; } tpl<cl T> il bl fdb(T &ans) { #ifdef ONLINE_JUDGE ans = 0; T f = 1; if (ps == pe) rtn false;//EOF do { rnext(); if ('-' == *ps) f = -1; } wl(!isdigit(*ps) && ps != pe); if (ps == pe) rtn false;//EOF do { ans = ans*10 + *ps - 48; rnext(); } wl(isdigit(*ps) && ps != pe); ans *= f; if(*ps=='.') { rnext(); T small=0; do { small=small*10+*ps-48; rnext(); }wl(isdigit(*ps)&&ps!=pe); wl(small>=1) { small/=10; } ans+=small; } #else cin >> ans; #endif rtn true; } /* * 输出挂 * 超强 超快 */ il bl out_char(cst cr c) { #ifdef ONLINE_JUDGE *(pout++) = c; if (pout == pend) write(); write(); #else cout << c; #endif rtn true; } il bl out_str(cst cr *s) { #ifdef ONLINE_JUDGE wl(*s) { *(pout++) = *(s++); if (pout == pend) write(); } write(); #else cout << s; #endif rtn true; } tpl<cl T> il bl out_double(T x, it idx) { char str[50]; string format = "%"; if (~idx) { format += '.'; format += (char) (idx + '0'); } format += "f"; sprintf(str, format.c_str(), x); out_str(str); } tpl<cl T> il bl out_int(T x) { #ifdef ONLINE_JUDGE if (!x) { out_char('0'); rtn true; } if (x < 0) x = -x, out_char('-'); it len = 0; wl(x) { outtmp[len++] = x % 10 + 48; x /= 10; } outtmp[len] = 0; for (it i = 0, j = len - 1; i < j; i++, j--) swap(outtmp[i], outtmp[j]); out_str(outtmp); #else cout << x; #endif rtn true; } tpl<cl T> il bl out_intln(T x) { #ifdef ONLINE_JUDGE out_int(x),out_char('\n'); write(); #else cout << x << endl; #endif rtn true; } tpl<cl T> il bl out_doubleln(T x, it idx) { out_double(x, idx), out_char('\n'); } il iofstream &ope<<(cst db &x) { out_double(x, idx); rtn *this; } il iofstream &ope<<(cst it &x) { out_int(x); rtn *this; } il iofstream &ope<<(cst unsigned long long &x) { out_int(x); rtn *this; } il iofstream &ope<<(cst unsigned &x) { out_int(x); rtn *this; } il iofstream &ope<<(cst long &x) { out_int(x); rtn *this; } il iofstream &ope<<(cst ll &x) { out_int(x); rtn *this; } il iofstream &ope<<(cst endln &x) { out_char('\n'); rtn *this; } il iofstream &ope<<(cst cr *x) { out_str(x); rtn *this; } il iofstream &ope<<(cst string &x) { out_str(x.c_str()); rtn *this; } il iofstream &ope<<(cst char &x) { out_char(x); rtn *this; } il bl setw(it x) { if (x >= 0) { idx = x; rtn true; } rtn false; } il iofstream &ope>>(it &x) { if (!fin(x))eof = false; rtn *this; } il iofstream &ope>>(ll &x) { if (!fin(x))eof = false; rtn *this; } il iofstream &ope>>(db &x) { if (!fdb(x))eof = false; rtn *this; } il iofstream &ope>>(float &x) { if (!fdb(x))eof = false; rtn *this; } il iofstream &ope>>(unsigned &x) { if (!fin(x))eof = false; rtn *this; } il iofstream &ope>>(unsigned long long &x) { if (!fin(x))eof = false; rtn *this; } il ope bl() { rtn eof; } il cr getchar() { #ifdef ONLINE_JUDGE if (ps == pe){ eof=false;//EOF rtn 0; } rnext(); if(ps+1==pe) eof=false; rtn *ps; #else rtn std::getchar(); #endif } il iofstream &ope>>(char *str) { #ifdef ONLINE_JUDGE if (ps == pe){ eof=false;//EOF rtn *this; } do { rnext(); } wl(isspace(*ps)&&iscntrl(*ps) && ps != pe); if (ps == pe){ eof=false;//EOF rtn *this; } do { *str=*ps; ++str; rnext(); } wl(!(isspace(*ps)||iscntrl(*ps)) && ps != pe); *str='\0'; rtn *this; #else cin >> str; rtn *this; #endif } il iofstream &ope>>(string &str) { #ifdef ONLINE_JUDGE str.clear(); if (ps == pe){ eof=false;//EOF rtn *this; } do { rnext(); } wl(isspace(*ps)&&iscntrl(*ps) && ps != pe); if (ps == pe){ eof=false;//EOF rtn *this; } do { str+=*ps; rnext(); } wl(!(isspace(*ps)||iscntrl(*ps)) && ps != pe); rtn *this; #else cin >> str; rtn *this; #endif } il iofstream &getline(char *str) { #ifdef ONLINE_JUDGE if (ps == pe){ eof=false;//EOF rtn *this; } do { rnext(); *str=*ps; }while(*ps!='\n'&&ps!=pe&&str++); *str='\0'; rtn *this; #else gets(str); rtn *this; #endif } il bl endfile() { rtn eof; } }; static iofstream fin; static endln ln; class range { public: class iterator { friend class range; public: int operator*() const { return i_; } iterator &operator++() { ++i_; return *this; } iterator operator++(int) { iterator copy(*this); ++i_; return copy; } bool operator==(const iterator &other) const { return i_ == other.i_; } bool operator!=(const iterator &other) const { return i_ != other.i_; } protected: iterator(int start) : i_(start) {} private: int i_; }; iterator begin() const { return begin_; } iterator end() const { return end_; } range(int begin, int end) : begin_(begin), end_(end) {} private: iterator begin_; iterator end_; }; template<typename T> class reverse_iterator_class { public: explicit reverse_iterator_class(const T &t) : t(t) {} typename T::const_reverse_iterator begin() const { return t.rbegin(); } typename T::const_reverse_iterator end() const { return t.rend(); } private: const T &t; }; using ll = long long; template<typename T> reverse_iterator_class<T> reverse(const T &t) { return reverse_iterator_class<T>(t); } using LL = long long; const int inf = 0x3f3f3f3f; const int maxn = 1e5 + 6; array<int, maxn> x; array<array<int, maxn>, 20> r; int main() { ios::sync_with_stdio(false); int n; cin >> n; scanf("%d", &n); for (auto i:range(0, n)) { cin >> x[i]; } int l, q; cin >> l >> q; for (auto i:range(0, n)) { r[0][i] = upper_bound(x.begin(), x.begin() + n, x[i] + l) - x.begin() - 1; } for (auto i:range(1, 17)) { for (auto j:range(0, n)) { r[i][j] = r[i - 1][r[i - 1][j]]; } } for (auto i:range(0, q)) { int a, b; cin >> a >> b; --a; --b; if (a > b)swap(a, b); int cnt = 0; for (int i = 16; i >= 0; i--) { if (r[i][a] < b) { a = r[i][a]; cnt += 1 << i; } } cout << cnt + 1 << endl; } }
a.cc: In member function 'bool iofstream::out_double(T, int)': a.cc:205:5: warning: no return statement in function returning non-void [-Wreturn-type] 205 | } | ^ a.cc: In member function 'bool iofstream::out_doubleln(T, int)': a.cc:245:5: warning: no return statement in function returning non-void [-Wreturn-type] 245 | } | ^ a.cc: In member function 'iofstream& iofstream::getline(char*)': a.cc:424:9: error: 'gets' was not declared in this scope; did you mean 'getw'? 424 | gets(str); | ^~~~ | getw a.cc: At global scope: a.cc:501:18: error: aggregate 'std::array<int, 100006> x' has incomplete type and cannot be defined 501 | array<int, maxn> x; | ^ a.cc:15:1: note: 'std::array' is defined in header '<array>'; this is probably fixable by adding '#include <array>' 14 | #include <complex> +++ |+#include <array> 15 | a.cc:502:29: error: aggregate 'std::array<std::array<int, 100006>, 20> r' has incomplete type and cannot be defined 502 | array<array<int, maxn>, 20> r; | ^ a.cc:502:29: note: 'std::array' is defined in header '<array>'; this is probably fixable by adding '#include <array>'
s388740005
p04017
C++
#include<iostream> #include<algorithm> #include<cstdio> #include<cstring> #include<stdlib.h> #include<stack> #include<vector> using namespace std; const int N=1e5+50; const int INF=0x3f3f3f; long long num[N]; int main() { long long n; long long l; int q,a,b,ber; scanf("%lld",&n); for(long long i=1;i<=n;i++) scanf("%lld",&num[i]); num[n+1]=INF; scanf("%lld%d",&l,&q); while(q--) { long long sum=0; scanf("%d%d",&a,&b); long long x=min(a,b); int endd=max(a,b); long long cnt=num[x]+l; ber=1; while(ber<endd) { ber=upper_bound(num,num+n+1,cnt)-num-1; sum++; cnt=num[ber]+l; } sum++; printf("%lld\n",sum); } return 0; }
a.cc: In function 'int main()': a.cc:25:26: error: 'b' was not declared in this scope 25 | scanf("%d%d",&a,&b); | ^ a.cc:29:9: error: 'ber' was not declared in this scope; did you mean 'bzero'? 29 | ber=1; | ^~~ | bzero
s784915458
p04017
C++
#include<iostream> #include<algorithm> #include<cstdio> #include<cstring> #include<stdlib.h> #include<stack> #include<vector> using namespace std; const int N=1e5+50; const int INF=0x3f3f3f; long long num[N]; int main() { long long n; long long l; int q,a,b; scanf("%lld",&n); for(long long i=1;i<=n;i++) scanf("%lld",&num[i]); num[n+1]=INF; scanf("%lld%d",&l,&q); while(q--) { long long sum=0; scanf("%d%d",&a,&b); long long x=min(a,b); int endd=max(a,b); long long cnt=num[x]+l; while(ber<endd) { int ber=upper_bound(num,num+n+1,cnt)-num-1; sum++; cnt=num[ber]+l; } sum++; printf("%lld\n",sum); } return 0; }
a.cc: In function 'int main()': a.cc:29:15: error: 'ber' was not declared in this scope 29 | while(ber<endd) | ^~~
s627059637
p04017
C++
import strutils import sequtils import algorithm import math import queues import tables import logging import future const INF* = int(1e18 + 373) when not defined(release): addHandler(newFileLogger(stderr, lvlAll, "[ $levelname ] ")) proc readInt1*(): int = stdin.readLine().strip().parseInt() proc readInt2*(): (int, int) = let v = stdin.readLine().strip().split().map(parseInt) return (v[0], v[1]) proc readInt3*(): (int, int, int) = let v = stdin.readLine().strip().split().map(parseInt) return (v[0], v[1], v[2]) proc readSeq*(): seq[string] = stdin.readLine().strip().split() proc readSeq*(n: Natural): seq[string] = result = newSeq[string](n) for i in 0..<n: result[i] = stdin.readLine().strip() type seq2*[T] = seq[seq[T]] proc newSeq2*[T](n1, n2: Natural): seq2[T] = newSeqWith(n1, newSeq[T](n2)) #------------------------------------------------------------------------------# #------------------------------------------------------------------------------# type Pred1[T] = T -> bool # [lb, ub) proc nibutanLb(lb, ub: int; f: Pred1[int]): int = var lb = lb var ub = ub while ub - lb > 1: let mid = (ub + lb) div 2 if f(mid): lb = mid else: ub = mid return lb # (lb, ub] proc nibutanUb(lb, ub: int; f: Pred1[int]): int = var lb = lb var ub = ub while ub - lb > 1: let mid = (ub + lb) div 2 if f(mid): ub = mid else: lb = mid return ub #------------------------------------------------------------------------------# const M = 20 proc step(next: seq2[int]; p, t: int): int = var p = p for i in 0..M: if (t and (1 shl i)) > 0: p = next[i][p] return p proc main() = let n = readInt1() let x = readSeq().map(parseInt) let d = readInt1() let q = readInt1() var a = newSeq[int](q) var b = newSeq[int](q) for i in 0..<q: (a[i], b[i]) = readInt2() a[i] -= 1 b[i] -= 1 if a[i] > b[i]: swap(a[i], b[i]) var next = newSeq2[int](M + 1, n) for i in 0..<n: next[0][i] = nibutanLb(0, n, (p: int) => (x[p] <= x[i] + d)) for t in 1..M: for i in 0..<n: next[t][i] = next[t - 1][next[t - 1][i]] for i in 0..<q: let ans = nibutanUb(-1, n, (t: int) => step(next, a[i], t) >= b[i]) echo ans main()
a.cc:26:12: error: too many decimal points in number 26 | for i in 0..<n: | ^~~ a.cc:32:2: error: invalid preprocessing directive #-- 32 | #------------------------------------------------------------------------------# | ^~ a.cc:33:2: error: invalid preprocessing directive #-- 33 | #------------------------------------------------------------------------------# | ^~ a.cc:36:3: error: invalid preprocessing directive #[ 36 | # [lb, ub) | ^ a.cc:48:3: error: invalid preprocessing directive #( 48 | # (lb, ub] | ^ a.cc:60:2: error: invalid preprocessing directive #-- 60 | #------------------------------------------------------------------------------# | ^~ a.cc:67:12: error: too many decimal points in number 67 | for i in 0..M: | ^~~~ a.cc:82:12: error: too many decimal points in number 82 | for i in 0..<q: | ^~~ a.cc:90:12: error: too many decimal points in number 90 | for i in 0..<n: | ^~~ a.cc:93:12: error: too many decimal points in number 93 | for t in 1..M: | ^~~~ a.cc:94:14: error: too many decimal points in number 94 | for i in 0..<n: | ^~~ a.cc:97:12: error: too many decimal points in number 97 | for i in 0..<q: | ^~~ a.cc:1:1: error: 'import' does not name a type 1 | import strutils | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:37:30: error: found ':' in nested-name-specifier, expected '::' 37 | proc nibutanLb(lb, ub: int; f: Pred1[int]): int = | ^ | :: a.cc:37:29: error: 'f' does not name a type 37 | proc nibutanLb(lb, ub: int; f: Pred1[int]): int = | ^ a.cc:49:30: error: found ':' in nested-name-specifier, expected '::' 49 | proc nibutanUb(lb, ub: int; f: Pred1[int]): int = | ^ | :: a.cc:49:29: error: 'f' does not name a type 49 | proc nibutanUb(lb, ub: int; f: Pred1[int]): int = | ^ a.cc:64:28: error: 'p' does not name a type 64 | proc step(next: seq2[int]; p, t: int): int = | ^
s112855568
p04017
C++
#include <iostream> #include<cstdlib> #include<queue> #include<set> #include<vector> #include<stack> #include<map> #include<string> #include<algorithm> #include<cstdio> using namespace std; #define rep(i,a) for(int i=0;i<a;i++) #define mp make_pair #define pb push_back #define P pair<int,int> #define ll __int64 //#define __int64 long long int n,z; ll t[111111]; ll nex[50][111111]; int q; ll che(int x){ ll l=x+1,r=n,mid=(r+l)/2; while(r-l>1){ ll ab=t[mid]-t[x]; if(ab>z)r=mid; else l=mid; mid=(r+l)/2; } return l; } int main(){ cin>>n; rep(i,n)cin>>t[i]; cin>>z; rep(i,n){ nex[0][i]=che(i); } rep(i,40){ rep(j,n){ if(nex[i][j]==n)nex[i+1][j]=n; else nex[i+1][j]=nex[i][nex[i][j]]; } } cin>>q; rep(i,q){ int a,b; cin>>a>>b; if(a>b)swap(a,b); a--;b--; ll l=0,r=n,mid=(r+l)/2; ll tmp=a; while(r-l>1){ tmp=a; ll one=1; rep(j,40){ if((one<<j)&mid)tmp=nex[j][tmp]; } if(tmp>=b)r=mid; else l=mid; mid=(r+l)/2; } cout<<r<<endl; } return 0; }
a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'? 16 | #define ll __int64 | ^~~~~~~ a.cc:19:1: note: in expansion of macro 'll' 19 | ll t[111111]; | ^~ a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'? 16 | #define ll __int64 | ^~~~~~~ a.cc:20:1: note: in expansion of macro 'll' 20 | ll nex[50][111111]; | ^~ a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'? 16 | #define ll __int64 | ^~~~~~~ a.cc:23:1: note: in expansion of macro 'll' 23 | ll che(int x){ | ^~ a.cc: In function 'int main()': a.cc:39:22: error: 't' was not declared in this scope 39 | rep(i,n)cin>>t[i]; | ^ a.cc:43:17: error: 'nex' was not declared in this scope 43 | nex[0][i]=che(i); | ^~~ a.cc:43:27: error: 'che' was not declared in this scope 43 | nex[0][i]=che(i); | ^~~ a.cc:48:28: error: 'nex' was not declared in this scope 48 | if(nex[i][j]==n)nex[i+1][j]=n; | ^~~ a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'? 16 | #define ll __int64 | ^~~~~~~ a.cc:60:17: note: in expansion of macro 'll' 60 | ll l=0,r=n,mid=(r+l)/2; | ^~ a.cc:61:20: error: expected ';' before 'tmp' 61 | ll tmp=a; | ^~~ a.cc:63:23: error: 'r' was not declared in this scope 63 | while(r-l>1){ | ^ a.cc:63:25: error: 'l' was not declared in this scope 63 | while(r-l>1){ | ^ a.cc:64:25: error: 'tmp' was not declared in this scope; did you mean 'tm'? 64 | tmp=a; | ^~~ | tm a.cc:65:28: error: expected ';' before 'one' 65 | ll one=1; | ^~~ a.cc:67:37: error: 'one' was not declared in this scope 67 | if((one<<j)&mid)tmp=nex[j][tmp]; | ^~~ a.cc:67:45: error: 'mid' was not declared in this scope 67 | if((one<<j)&mid)tmp=nex[j][tmp]; | ^~~ a.cc:67:53: error: 'nex' was not declared in this scope 67 | if((one<<j)&mid)tmp=nex[j][tmp]; | ^~~ a.cc:70:37: error: 'mid' was not declared in this scope 70 | if(tmp>=b)r=mid; | ^~~ a.cc:71:32: error: 'mid' was not declared in this scope 71 | else l=mid; | ^~~ a.cc:72:25: error: 'mid' was not declared in this scope 72 | mid=(r+l)/2; | ^~~ a.cc:74:23: error: 'r' was not declared in this scope 74 | cout<<r<<endl; | ^
s013251800
p04017
C++
#include <iostream> #include<cstdlib> #include<queue> #include<set> #include<vector> #include<stack> #include<map> #include<string> #include<algorithm> #include<cstdio> using namespace std; #define rep(i,a) for(int i=0;i<a;i++) #define mp make_pair #define pb push_back #define P pair<int,int> #define ll __int64 //#define __int64 long long int n,z; int t[111111]; int next[30][111111]; int q; int che(int x){ int l=x+1,r=n-1,mid=(r+l)/2; while(r-l>1){ int ab=t[mid]-t[x]; if(ab>z)r=mid; else l=mid; mid=(r+l)/2; } return l; } int main(){ cin>>n; rep(i,n)cin>>t[i]; cin>>z; rep(i,n){ next[0][i]=che(i); } rep(i,29){ rep(j,n){ if(next[i][j]==n)next[i+1][j]=n; else next[i+1][j]=next[i][next[i][j]]; } } cin>>q; rep(i,q){ int a,b; cin>>a>>b; if(a>b)swap(a,b); a--;b--; int ans=0,now=a; for(int j=25;j>=0;j--){ if(next[j][now]>b)continue; ans+=(1<<j); now=next[j][now]; } cout<<ans<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:43:17: error: reference to 'next' is ambiguous 43 | next[0][i]=che(i); | ^~~~ In file included from /usr/include/c++/14/string:47, 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/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:20:5: note: 'int next [30][111111]' 20 | int next[30][111111]; | ^~~~ a.cc:48:28: error: reference to 'next' is ambiguous 48 | if(next[i][j]==n)next[i+1][j]=n; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:20:5: note: 'int next [30][111111]' 20 | int next[30][111111]; | ^~~~ a.cc:48:42: error: reference to 'next' is ambiguous 48 | if(next[i][j]==n)next[i+1][j]=n; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:20:5: note: 'int next [30][111111]' 20 | int next[30][111111]; | ^~~~ a.cc:49:30: error: reference to 'next' is ambiguous 49 | else next[i+1][j]=next[i][next[i][j]]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:20:5: note: 'int next [30][111111]' 20 | int next[30][111111]; | ^~~~ a.cc:49:43: error: reference to 'next' is ambiguous 49 | else next[i+1][j]=next[i][next[i][j]]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:20:5: note: 'int next [30][111111]' 20 | int next[30][111111]; | ^~~~ a.cc:49:51: error: reference to 'next' is ambiguous 49 | else next[i+1][j]=next[i][next[i][j]]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:20:5: note: 'int next [30][111111]' 20 | int next[30][111111]; | ^~~~ a.cc:63:28: error: reference to 'next' is ambiguous 63 | if(next[j][now]>b)continue; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:20:5: note: 'int next [30][111111]' 20 | int next[30][111111]; | ^~~~ a.cc:65:29: error: reference to 'next' is ambiguous 65 | now=next[j][now]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:20:5: note: 'int next [30][111111]' 20 | int next[30][111111]; | ^~~~
s492800796
p04017
C++
#include <iostream> #include <utility> #include <algorithm> #define inf 1000000007 using namespace std; int N, L, Q; int x[100005]; int next[17][100005]; int main(void) { cin >> N; for(int i = 0; i < N; i++) cin >> x[i]; x[N] = x[N-1]+1; cin >> L; int p; for(int i = 0; i <= N; i++){ next[0][i] = upper_bound(x, x+N+1, x[i] + L) - x - 1; } for(int i = 1; i < 17; i++){ for(int j = 0; j <= N; j++){ next[i][j] = next[i-1][next[i-1][j]]; } } cin >> Q; int a, b; for(int q = 0; q < Q; q++){ cin >> a >> b; a--, b--; if(a > b){ int t = a; a = b, b = t; } int cur = a, ans = 0; for(int i = 16; i >= 0; i--){ if(x[next[i][cur]] <= x[b]){ cur = next[i][cur]; ans += 1<<i; } } cout << ans << endl; } return 0; }
a.cc: In function 'int main()': a.cc:21:17: error: reference to 'next' is ambiguous 21 | next[0][i] = upper_bound(x, x+N+1, x[i] + L) - x - 1; | ^~~~ In file included from /usr/include/c++/14/string:47, 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/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:10:5: note: 'int next [17][100005]' 10 | int next[17][100005]; | ^~~~ a.cc:25:25: error: reference to 'next' is ambiguous 25 | next[i][j] = next[i-1][next[i-1][j]]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:10:5: note: 'int next [17][100005]' 10 | int next[17][100005]; | ^~~~ a.cc:25:38: error: reference to 'next' is ambiguous 25 | next[i][j] = next[i-1][next[i-1][j]]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:10:5: note: 'int next [17][100005]' 10 | int next[17][100005]; | ^~~~ a.cc:25:48: error: reference to 'next' is ambiguous 25 | next[i][j] = next[i-1][next[i-1][j]]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:10:5: note: 'int next [17][100005]' 10 | int next[17][100005]; | ^~~~ a.cc:41:30: error: reference to 'next' is ambiguous 41 | if(x[next[i][cur]] <= x[b]){ | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:10:5: note: 'int next [17][100005]' 10 | int next[17][100005]; | ^~~~ a.cc:42:39: error: reference to 'next' is ambiguous 42 | cur = next[i][cur]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:10:5: note: 'int next [17][100005]' 10 | int next[17][100005]; | ^~~~
s012639840
p04017
C++
import math import itertools import heapq from sys import stdin, stdout, setrecursionlimit from bisect import bisect, bisect_left, bisect_right from collections import defaultdict, deque # d = defaultdict(lambda: 0) # setrecursionlimit(10**7) # inf = float("inf") ##### stdin #### def LM(t, r): return list(map(t, r)) def R(): return stdin.readline() def RS(): return R().split() def I(): return int(R()) def F(): return float(R()) def LI(): return LM(int,RS()) def LF(): return LM(float,RS()) def ONE_SL(): return list(input()) def ONE_IL(): return LM(int, ONE_SL()) def ALL_I(): return map(int, stdin) def ALL_IL(): return LM(int,stdin) ##### tools ##### def ap(f): return f.append def pll(li): print('\n'.join(LM(str,li))) def pljoin(li, s): print(s.join(li)) ##### main ##### def main(): N = I() X = LI() L = I() Q = I() r = [[0 for _ in range(100010)] for _ in range(20)] for i in range(N): r[0][i] = bisect_right(X, X[i]+L) -1 for i in range(1,20): for j in range(N): r[i][j] = r[i-1][r[i-1][j]] for q in range(Q): a,b =LI() a-=1; b-=1 if a>b: a,b = b,a ans = 0 now = a for i in range(0,20)[::-1]: if r[i][now]<b: now = r[i][now] ans += 2**i print(ans+1) if __name__ == '__main__': main()
a.cc:9:3: error: invalid preprocessing directive #d 9 | # d = defaultdict(lambda: 0) | ^ a.cc:10:3: error: invalid preprocessing directive #setrecursionlimit 10 | # setrecursionlimit(10**7) | ^~~~~~~~~~~~~~~~~ a.cc:11:3: error: invalid preprocessing directive #inf; did you mean #if? 11 | # inf = float("inf") | ^~~ | if a.cc:14:1: error: stray '##' in program 14 | ##### stdin #### | ^~ a.cc:14:3: error: stray '##' in program 14 | ##### stdin #### | ^~ a.cc:14:5: error: stray '#' in program 14 | ##### stdin #### | ^ a.cc:14:13: error: stray '##' in program 14 | ##### stdin #### | ^~ a.cc:14:15: error: stray '##' in program 14 | ##### stdin #### | ^~ a.cc:27:1: error: stray '##' in program 27 | ##### tools ##### | ^~ a.cc:27:3: error: stray '##' in program 27 | ##### tools ##### | ^~ a.cc:27:5: error: stray '#' in program 27 | ##### tools ##### | ^ a.cc:27:13: error: stray '##' in program 27 | ##### tools ##### | ^~ a.cc:27:15: error: stray '##' in program 27 | ##### tools ##### | ^~ a.cc:27:17: error: stray '#' in program 27 | ##### tools ##### | ^ a.cc:34:1: error: stray '##' in program 34 | ##### main ##### | ^~ a.cc:34:3: error: stray '##' in program 34 | ##### main ##### | ^~ a.cc:34:5: error: stray '#' in program 34 | ##### main ##### | ^ a.cc:34:12: error: stray '##' in program 34 | ##### main ##### | ^~ a.cc:34:14: error: stray '##' in program 34 | ##### main ##### | ^~ a.cc:34:16: error: stray '#' in program 34 | ##### main ##### | ^ a.cc:68:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes 68 | if __name__ == '__main__': | ^~~~~~~~~~ a.cc:1:1: error: 'import' does not name a type 1 | import math | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:54:23: error: 'b' does not name a type 54 | a-=1; b-=1 | ^
s337841708
p04017
C++
#include <cstdio> #include <iostream> using namespace std; int main(){ int N; cin >> N; int x[N]; for(int i = 0; i < N; ++i) cin >> x[i]; int L; cin >> L; //Doubling int table[N][30]; for(int i = 0; i < N; ++i){ fill(table[i],table[i]+30,0); table[i][0] = upper_bound(x,x+N,x[i]+L) - x - 1; } for(int j = 1; j < 30; ++j){ for(int i = 0; i < N; ++i){ table[i][j] = table[table[i][j-1]][j-1]; } } /* for(int i = 0; i < N; ++i){ cout << i << " | "; for(int j = 0; j < 30; ++j){ cout << table[i][j] << " "; }cout << endl; } */ //Query int Q; cin >> Q; int a, b; for(int i = 0; i < Q; ++i){ cin >> a >> b; if(a > b) swap(a,b); --a;--b; int ans = 0, r = 29; while(r > 0){ while(r >= 0 && table[a][r] >= b) --r; //cout << r << " "; if(r >= 0) ans += 1<<r; a = table[a][r]; } ++ans; cout << ans << endl; } return 0; }
a.cc: In function 'int main()': a.cc:15:19: error: 'upper_bound' was not declared in this scope 15 | table[i][0] = upper_bound(x,x+N,x[i]+L) - x - 1; | ^~~~~~~~~~~
s885651198
p04017
C++
#include<iostream> #include<cstdio> using namespace std; int n,q,l,a[111111],x,y,pos,prev,cnt; int main() { scanf("%d",&n); for (int i=1;i<=n;i++) scanf("%d",&a[i]); scanf("%d%d",&l,&q); while(q--) { scanf("%d%d",&x,&y); if (x>y) swap(x,y); pos=x;cnt=0; while(pos<y) { prev=pos; while(pos<=y && a[pos]-a[prev]<=l) pos++; pos--; cnt++; } printf("%d\n",cnt); } return 0; }
a.cc: In function 'int main()': a.cc:17:25: error: reference to 'prev' is ambiguous 17 | prev=pos; | ^~~~ In file included from /usr/include/c++/14/string:47, 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/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)' 244 | prev(_BidirectionalIterator __x, typename | ^~~~ a.cc:4:29: note: 'int prev' 4 | int n,q,l,a[111111],x,y,pos,prev,cnt; | ^~~~ a.cc:18:50: error: reference to 'prev' is ambiguous 18 | while(pos<=y && a[pos]-a[prev]<=l) pos++; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)' 244 | prev(_BidirectionalIterator __x, typename | ^~~~ a.cc:4:29: note: 'int prev' 4 | int n,q,l,a[111111],x,y,pos,prev,cnt; | ^~~~
s733908202
p04017
C++
#include<iostream> #include<fstream> #include<stdio.h> #include<string> #include<vector> #include<map> #include<math.h> #include<algorithm> #include<iomanip> #include<set> #define P 1000000007 using namespace std; int fastpow(int e, int x) { if(x == 0) { return 1; } if(x % 2 == 0) { return fastpow(e*e, x / 2); } else { return e * fastpow(e, x - 1); } } int main() { int n; cin >> n; vector<long long> x; x.resize(n); for(int i = 0; i < n; i++) cin >> x[i]; long long l; int q; cin >> l >> q; vector<pair<int, int>> query; query.resize(q); for(int i = 0; i < q; i++) { cin >> query[i].first >> query[i].second; if(query[i].first > query[i].second) { int tmp = query[i].first; query[i].first = query[i].second; query[i].second = tmp; } query[i].first--; query[i].second--; } vector<vector<long long>> path; path.resize(n); for(int i = 0; i < n; i++) { auto it = lower_bound(x.begin(), x.end(), x[i] + l); if(it - x.begin() == i) { path[i].push_back(i); comtinue; } it--; path[i].push_back(it - x.begin()); } for(int k = 1; k < n; k *= 2) { for(int i = 0 ; i < n; i++) { path[i].push_back(path[path[i][k - 1]][k - 1]); } } for(int i = 0; i < q; i++) { long long ans = 0; int now = query[i].first; while(true) { auto p = upper_bound(path[now].begin(), path[now].end(), query[i].second); if(p == path[now].begin()) { ans++; break; } p--; ans += p - path[now].begin() + 1; now = *p; } } return 0; }
a.cc: In function 'int main()': a.cc:55:7: error: 'comtinue' was not declared in this scope 55 | comtinue; | ^~~~~~~~
s089311861
p04017
C++
#include <iostream> #include <vector> #include <cmath> using namespace std; typedef long long lli; lli n; vector<lli> x; lli l; lli q; vector<lli> a; vector<lli> b; lli k; vector<vector<lli> > r; void query(lli a,lli b){ lli ans = 0; if(a > b) swap(a,b); while(a < b){ lli t = upper_bound(r[a].begin(),r[a].end(),b) - r[a].begin() - 1; ans += pow((lli)2,t); a = r[a][t]; } cout << ans << endl; } int main(int argc, char const *argv[]) { cin >> n; for(lli m = 1;m < n;m <<= 1) k++; x = vector<lli> (n+1); r = vector<vector<lli> > (n+1,vector<lli>(k+1)); for(lli i = 1;i <= n;i++) cin >> x[i]; cin >> l; cin >> q; for(lli i = 1;i <= n;i++){ r[i][0] = upper_bound(x.begin(),x.end(),x[i]+l) - x.begin() - 1; } for(lli i = 1;i <= k;i++){ for(lli j = 1;j <= n;j++){ r[j][i] = r[r[j][i-1]][i-1]; } } a = vector<lli> (q); b = vector<lli> (q); for(lli i = 0;i < q;i++) cin >> a[i] >> b[i]; for(lli i = 0;i < q;i++){ query(a[i],b[i]); } return 0; }
a.cc: In function 'void query(lli, lli)': a.cc:18:17: error: 'upper_bound' was not declared in this scope 18 | lli t = upper_bound(r[a].begin(),r[a].end(),b) - r[a].begin() - 1; | ^~~~~~~~~~~ a.cc: In function 'int main(int, const char**)': a.cc:33:19: error: 'upper_bound' was not declared in this scope 33 | r[i][0] = upper_bound(x.begin(),x.end(),x[i]+l) - x.begin() - 1; | ^~~~~~~~~~~
s116904890
p04017
C++
#include<iostream> #include<cstdio> #include<string> #include<cfloat> #include<algorithm> #include<cmath> #include<vector> #include<stack> #include<climits> #include<cstring> #include<queue> #include<map> #include<functional> using namespace std; #define REP(i,n) for(int i=0;i<(int)n;++i) const int mod = 1e9+7; const int INFINT = INT_MAX/2; typedef long long ll; typedef unsigned long long ull; int dp[40][100000]; void makeDoubling(vector<ull> &xs, ull L){ int N = xs.size(); for (int i=0;i<N;i++){ dp[0][i] = lower_bound(xs.begin(), xs.end(), xs[i]+L+1) - xs.begin() - 1; } for (int i=1;i<40;i++){ for (int j=0;j<N;j++){ dp[i][j] = dp[i-1][dp[i-1][j]]; } } return; } int MinimumDays(int a, int b){ if(a > b) swap(a, b); int now = a; int res = 0; for (int i=39;i>=0;i--){ if(dp[i][now] < b){ now = dp[i][now]; res += 1<<i; } } res++; return res; } int main(){ int N, x; cin >> N; vector<ull> xs(N); for(int i=0;i<N;i++){ cin >> x; xs[i] = x; } ull L, a, b; int Q, a, b; cin >> L >> Q; makeDoubling(xs, L); for (int i=0;i<Q;i++){ cin >> a >> b; cout << MinimumDays(a-1, b-1) << endl; } return 0; }
a.cc: In function 'int main()': a.cc:59:12: error: conflicting declaration 'int a' 59 | int Q, a, b; | ^ a.cc:58:12: note: previous declaration as 'ull a' 58 | ull L, a, b; | ^ a.cc:59:15: error: conflicting declaration 'int b' 59 | int Q, a, b; | ^ a.cc:58:15: note: previous declaration as 'ull b' 58 | ull L, a, b; | ^
s947859524
p04017
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashMap ; /** * http://arc060.contest.atcoder.jp/tasks/arc060_c * * @author Cummin */ public class ARC060_E { static int N ; // 2 <= N <= 10^5 static long L ; // 1 <= L <= 10^9 static int Q ; // 2 <= Q <= 10^5 static int X[] ;// 1 <= X <= 10^9, X[0..N-1] // static int DP[][] ; // DP[from][to]の日数 static HashMap <Integer, Integer> DP = new HashMap <>() ; public static void main(String[] args) { // System.out.printf("At Coder ARC060 問題E \n") ; long start = System.currentTimeMillis(); /** / Scanner sc = new Scanner(System.in); N = sc.nextInt() ; for (int i=0 ; i<N; i++) { // X[i]= sc.nextInt() ; X[i] = Integer.parseInt(sc.next()); // この一行(10^5要素)で、113秒 } */ X = fast_read(1) ; N = X[0] ; X = fast_read(N) ; //System.out.printf("N=%d\n", N) ; long end = System.currentTimeMillis(); //System.out.println((end - start) + "ms"); start = System.currentTimeMillis(); int Y[] ; Y = fast_read(2) ; L = Y[0] ; Q = Y[1] ; // L = sc.nextLong() ; // Q = sc.nextInt() ; //System.out.printf("L=%d, Q=%d\n", L, Q) ; int Qs[][] = new int[Q][2] ; // Qs[][from] < Qs[][to] for (int i=0 ; i<Q ; i++) { int from, to ; /* 読み込みが遅いので変更 (これで、10^5*3個が213秒) from = sc.nextInt() ; to = sc.nextInt() ; */ // from = Integer.parseInt(sc.next()); // (これで、10^5*3個が201秒) // to = Integer.parseInt(sc.next()); // この二行(10^5行 2数値)で、92.5秒 Y = fast_read(2) ; from = Y[0] ; to = Y[1] ; if (from>to) { int t ; t = from; from = to ; to = t ; } Qs[i][0] = from - 1 ; Qs[i][1] = to - 1 ; } end = System.currentTimeMillis(); //System.out.println((end - start) + "ms"); //DP = new int[N][N] ; /* for (int i = 0 ; i<Q ; i++) { System.out.println(Solve(Qs[i][0], Qs[i][1])) ; // System.out.println("-----") ; } */ ////// 出力も高速に //////////////// PrintWriter out = new PrintWriter(System.out); for (int i = 0; i < Q; i++) { out.println(Solve2(Qs[i][0], Qs[i][1])); } out.flush(); } static int Solve2(int from, int to) { int cnt = 1 ; int ptr = from+1 ; while (ptr<=to) { if ((X[ptr]-X[from])<=L) { ptr++ ; } else { from = ptr -1 ; cnt ++ ; } } return cnt ; } static int Solve(int from, int to) { if (DP.containsKey(from*100000+to)) return DP.get(from*100000+to) ; //if (DP[from][to] != 0) return DP[from][to] ; int max = from ; for (int i=from+1 ; i<=to; i++){ if ((X[i]-X[from])<=L) { max = i ; } else break ; } if (max == to) { //DP[from][to] = 1 ; DP.put(from*100000+to,1) ; } else { //DP[from][to] = Solve(max, to) +1 ; DP.put(from*100000+to, Solve(max, to)+1) ; } // return DP[from][to] ; return DP.get(from*100000+to) ; } //////////////// 高速読み込み ////////////////////// static int[] fast_read(int N) { int elements[] = new int[N]; int e_cnt = 0; while (e_cnt < N) { char c; c = get_char(); while ((c < '0') || ('9' < c)) { // Skip 非数値文字 c=get_char() ; } elements[e_cnt] = 0; while (('0' <= c) && (c <= '9')) { // 数値文字を変換する elements[e_cnt] = elements[e_cnt] * 10 + (int) c - '0'; c = get_char(); } // System.out.printf("\nelement[%d] = %d \n", e_cnt + 1, elements[e_cnt]); e_cnt++; } return elements; } ///////////////// get_char() ///////////////////////////////// static char c_buf[] = new char[1024*1024]; static int ptr = 0 ; static int c_len = 0 ; static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static char get_char() { char ret; if (ptr >= c_len) { try { c_len = br.read(c_buf); } catch (IOException ex) { ex.printStackTrace(); System.exit(-1); // 終了する } ptr = 0; } ret = c_buf[ptr]; ptr++; return ret; } }
Main.java:12: error: class ARC060_E is public, should be declared in a file named ARC060_E.java public class ARC060_E { ^ 1 error
s289145388
p04017
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.logging.Level; import java.util.logging.Logger; /** * http://arc060.contest.atcoder.jp/tasks/arc060_c * * @author Cummin */ public class Main { static int N ; // 2 <= N <= 10^5 static long L ; // 1 <= L <= 10^9 static int Q ; // 2 <= Q <= 10^5 static int X[] ;// 1 <= X <= 10^9, X[0..N-1] static int DP[][] ; // DP[from][to]の日数 public static void main(String[] args) { // System.out.printf("At Coder ARC060 問題E \n") ; long start = System.currentTimeMillis(); /** / Scanner sc = new Scanner(System.in); N = sc.nextInt() ; for (int i=0 ; i<N; i++) { // X[i]= sc.nextInt() ; X[i] = Integer.parseInt(sc.next()); // この一行(10^5要素)で、113秒 } */ X = fast_read(1) ; N = X[0] ; X = fast_read(N) ; //System.out.printf("N=%d\n", N) ; long end = System.currentTimeMillis(); //System.out.println((end - start) + "ms"); start = System.currentTimeMillis(); int Y[] ; Y = fast_read(2) ; L = Y[0] ; Q = Y[1] ; // L = sc.nextLong() ; // Q = sc.nextInt() ; //System.out.printf("L=%d, Q=%d\n", L, Q) ; int Qs[][] = new int[Q][2] ; // Qs[][from] < Qs[][to] for (int i=0 ; i<Q ; i++) { int from, to ; /* 読み込みが遅いので変更 (これで、10^5*3個が213秒) from = sc.nextInt() ; to = sc.nextInt() ; */ // from = Integer.parseInt(sc.next()); // (これで、10^5*3個が201秒) // to = Integer.parseInt(sc.next()); // この二行(10^5行 2数値)で、92.5秒 Y = fast_read(2) ; from = Y[0] ; to = Y[1] ; if (from>to) { int t ; t = from; from = to ; to = t ; } Qs[i][0] = from - 1 ; Qs[i][1] = to - 1 ; } end = System.currentTimeMillis(); //System.out.println((end - start) + "ms"); DP = new int[N][N] ; for (int i = 0 ; i<Q ; i++) { System.out.println(Solve(Qs[i][0], Qs[i][1])) ; // System.out.println("-----") ; } } static int Solve(int from, int to) { if (DP[from][to] != 0) return DP[from][to] ; int max = from ; for (int i=from+1 ; i<=to; i++){ if ((X[i]-X[from])<=L) { max = i ; } else break ; } // System.out.printf("from =%d, to=%d len=%d \n", from+1, max+1,X[max]-X[from]) ; if (max == to) { DP[from][to] = 1 ; } else { DP[from][to] = Solve(max, to) +1 ; } return DP[from][to] ; } //////////////// 高速読み込み ////////////////////// static int[] fast_read(int N) { // System.out.printf("fast_read(%d) \n", N); int elements[] = new int[N]; int e_cnt = 0; while (e_cnt < N) { char c; c = get_char(); while ((c < '0') || ('9' < c)) { // Skip 非数値文字 // System.out.printf("%c", c) ; c=get_char() ; } elements[e_cnt] = 0; while (('0' <= c) && (c <= '9')) { // 数値文字を変換する // System.out.printf("%c", c[ptr]) ; elements[e_cnt] = elements[e_cnt] * 10 + (int) c - '0'; c = get_char(); } // System.out.printf("\nelement[%d] = %d \n", e_cnt + 1, elements[e_cnt]); e_cnt++; } // continue for return elements; } static char c_buf[] = new char[1024*1024]; static int ptr = 0 ; static int c_len = 0 ; static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static char get_char() { char ret; if (ptr >= c_len) { try { c_len = br.read(c_buf); } catch (IOException ex) { Logger.getLogger(ARC060_E.class.getName()).log(Level.SEVERE, null, ex); } ptr = 0; } ret = c_buf[ptr]; ptr++; return ret; } }
Main.java:130: error: cannot find symbol Logger.getLogger(ARC060_E.class.getName()).log(Level.SEVERE, null, ex); ^ symbol: class ARC060_E location: class Main 1 error
s007315713
p04017
C++
// Author: Mohib Manva #include <bits/stdc++.h> using namespace std; typedef long long int ll; int rig[30][111111]; int n, q, l, u, v; int x[111111]; int main(void) { scanf("%d",&n); int i, j; for(i=0 ; i<n ; i++) { scanf("%d",&x[i]); } scanf("%d %d",&l,&q); for(i=0 ; i<n ; i++) { int lo = i+1,high = n-1; int last = i+(i!=(n-1)); while(lo<=high){ int mi = (lo+high)>>1; if(a[mi]-a[i]<=l) lo = mi+1,last = mi; else high = mi-1; } dp[0][i]=last; } for(i=1; i<=29 ; i++) { for(j=0 ; j<n ; j++) { dp[i][j]=dp[i-1][dp[i-1][j]]; } } while(q--) { scanf("%d %d",&u,&v); u--; v--; if(u>v) { int temp=v; v=u; u=temp; } int ans=1e9; int cur=0; for(i=29 ; i>=0 ; i--) { if(dp[i][u]>=v) { ans=min(ans,cur+(1<<i)); } else { cur+=(1<<i); u=dp[i][u]; } } printf("%d\n",ans); } return 0; }
a.cc: In function 'int main()': a.cc:24:28: error: 'a' was not declared in this scope 24 | if(a[mi]-a[i]<=l) | ^ a.cc:29:17: error: 'dp' was not declared in this scope; did you mean 'dup'? 29 | dp[0][i]=last; | ^~ | dup a.cc:35:25: error: 'dp' was not declared in this scope; did you mean 'dup'? 35 | dp[i][j]=dp[i-1][dp[i-1][j]]; | ^~ | dup a.cc:52:28: error: 'dp' was not declared in this scope; did you mean 'dup'? 52 | if(dp[i][u]>=v) | ^~ | dup
s693462824
p04017
C++
#include<bits/stdc++.h> using namespace std; #define pb push_back #define mk make_pair #define mod 1000000007 #define ff first #define ss second typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; int nxt[20][100010]; int inp[100010]; int main(){ ios::sync_with_stdio(0); int n; cin>>n; for(int i=0;i<n;i++){ cin>>inp[i]; } int l; cin>>l; for(int j=0;j<20;j++){ for(int i=0;i<100010;i++){ nxt[j][i]=100005; } nxt[j][100005]=100005; } int lst = n-1; for(int i=n-2;i>=0;i--){ while(inp[lst]-inp[i]>l){ lst--; } nxt[0][i]=lst; } for(int j=1;j<20;j++){ for(int i=0;i<n;i++){ nxt[j][i]=nxt[j-1][nxt[j-1][i]]; } } int q; cin>>q; while(q--){ int a,b; cin>>a>>b; a--;b--; if(a==b){ cout<<0<<endl; continue; } if(a>b) swap(a,b); int ans = 0; for(int j=19;j>=0;j--){ if(nxt[j][a]<b){ a=nxt[j][a]; ans+=(1<<j); } else if(nxt[j][a]==b){ ans+=(1<<j); break; } } if(j==-1) ans++; cout<<ans<<endl; } }
a.cc: In function 'int main()': a.cc:68:12: error: 'j' was not declared in this scope 68 | if(j==-1) ans++; | ^
s491379178
p04017
C++
hoge
a.cc:1:1: error: 'hoge' does not name a type 1 | hoge | ^~~~
s497469318
p04017
C++
#include <iostream> using namespace std; #define MAX_N 100000 int tab[40][MAX_N]; // mid日でaからbまで行けるか bool C(int a, int b, int mid){ int pos = a; int cnt = 0; while(mid != 0){ if(mid & 1){ pos = tab[cnt][pos]; } mid >>= 1; cnt++; } if(pos >= b) return true; else return false; } int solve(int a, int b){ if(a > b) swap(a, b); int ub = 100000; int lb = 0; while(ub - lb > 1){ int mid = lb + (ub - lb) / 2; if(C(a, b, mid)) ub = mid; else lb = mid; } return ub; } int main(){ cin.tie(0); ios::sync_with_stdio(false); int N, L, Q; int x[MAX_N]; cin >> N; for(int i=0; i<N; i++) cin >> x[i]; cin >> L >> Q; int y[MAX_N]; for(int i=0; i<N; i++){ tab[0][i] = upper_bound(x, x+N, x[i]+L) - x - 1; } for(int k=0; k<40; k++){ for(int i=0; i<N; i++){ tab[k+1][i] = tab[k][min(N-1, tab[k][i])]; } } for(int i=0; i<Q; i++){ int a, b; cin >> a >> b; a--; b--; cout << solve(a, b) << endl; } return 0; }
a.cc: In function 'int main()': a.cc:52:30: error: 'upper_bound' was not declared in this scope 52 | tab[0][i] = upper_bound(x, x+N, x[i]+L) - x - 1; | ^~~~~~~~~~~
s058973345
p04017
C++
5 1 2 3 4 5 100000 10
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 5 | ^
s512693740
p04017
C++
#include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #include<cmath> #include<cstdlib> using namespace std; const int maxn = 1e5 + 10; int s[maxn], n, L, Q; int cnt[maxn], c[maxn]; int main(){ s[0]=0; while(~scanf("%d", &n)){ for(int i=1; i<=n; i++) scanf("%d", &s[i]); scanf("%d", &L); for(int i=1; i<n; i++){ int tmp=cnt[i-1]; while(s[tmp]-s[i]<=L && tmp <=n) tmp++; cnt[i]=tmp-1; } int day=1,st=n; while(day<=1000&&st>0){ int ss=st+1; while(s[ss]-s[st-1]<=L&&st>=1) { c[st]=n; st--; } day++; } while(st>0){ c[st]=c[cnt[st]]; int v=c[st]; while(s[c[st]]-s[v]<=L) v--; c[st]=v+1; st--; } scanf("%d", &Q); while(Q--){ int a, b, ans=0; scanf("%d%d", &a, &b); if(a>b) swap(a,b); int tmp=a, sum=0; while(c[a]<b){ a=c[a]; ans+=1000; } while(a<b){ a=cnt[a]; ans++; } printf("%d\n", ans); } } return 0;
a.cc: In function 'int main()': a.cc:55:18: error: expected '}' at end of input 55 | return 0; | ^ a.cc:12:11: note: to match this '{' 12 | int main(){ | ^
s127139469
p04017
C++
#include <vector> #include <algorithm> #include <set> #include <map> #include <queue> #include <stack> #include <iostream> #include <cstdio> #include <cmath> #include <cstring> using namespace std; typedef pair<int,int> P; typedef long long int lnt; const lnt INF 0xffffffffffffff; lnt n,x[100000],l,q,a[100000],b[100000]; lnt lca[20][100000]; lnt aaa,bbb; int main() { cin>>n; for(lnt i=0;i<n;i++){ cin>>x[i]; } cin>>l>>q; for(lnt i=0;i<q;i++){ cin>>aaa>>bbb; a[i]=min(aaa-1,bbb-1); b[i]=max(aaa-1,bbb-1); } for(lnt i=0;i<20;i++){ for(lnt j=0;j<100000;j++) lca[i][j]=INF; } for(lnt i=0;i<n-1;i++){ if(x[i]+l>=x[n-1]){ lca[0][i]=n-1; continue; } lca[0][i]=upper_bound(x,x+n,x[i]+l)-x-1; } lnt now,ans=0; for(lnt i=0;i<q;i++){ ans=0; now=a[i]; while(now<b[i]){ now=lca[0][now]; ans++; } cout<<ans<<endl; } }
a.cc:14:15: error: expected initializer before numeric constant 14 | const lnt INF 0xffffffffffffff; | ^~~~~~~~~~~~~~~~ a.cc: In function 'int main()': a.cc:31:53: error: 'INF' was not declared in this scope 31 | for(lnt j=0;j<100000;j++) lca[i][j]=INF; | ^~~
s103330445
p04017
Java
#define _CRT_SECURE_NO_WARNINGS #include<sstream> #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<climits> #include<cmath> #include<string> #include<vector> #include<set> #include<map> #include<queue> #include<numeric> #include<functional> #include<algorithm> #include<bitset> #include<tuple> #include<unordered_set> #include<random> using namespace std; #define INF (1<<29) #define rep(i,n) for(int i=0;i<(int)(n);i++) #define all(v) v.begin(),v.end() #define uniq(v) v.erase(unique(all(v)),v.end()) vector<tuple<int, int, int>> s[2][100000]; int N; int x[100000]; int L, Q; int ans[100000]; int dist[100000]; int bs; void solve(int dir) { rep(i, N - 1) { int nxt = upper_bound(x, x + N, x[i] + L) - 1 - x; if(s[dir][i].size() != 3){ return; } if (s[dir][i].size() < bs) { for (const auto &t : s[dir][i]) { int b, j, cost; tie(b, j, cost) = t; if (nxt >= b) { ans[j] = cost + 1; } else { s[dir][nxt].emplace_back(b, j, cost + 1); } } } else { int c = 1, d = 0; dist[i] = 0; for (int j = i + 1; j < N; j++) { d += x[j] - x[j - 1]; if (d > L) { d = x[j] - x[j - 1]; c++; } dist[j] = c; } for (const auto &t : s[dir][i]) { int b, j, cost; tie(b, j, cost) = t; ans[j] = cost + dist[b]; } } { vector<tuple<int, int, int>> a; s[dir][i].swap(a); } } } int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> N; rep(i, N)cin >> x[i]; cin >> L >> Q; bs = sqrt(Q); rep(i, Q) { int a, b; cin >> a >> b; a--; b--; if (a < b) { s[0][a].emplace_back(b, i, 0); } else { a = N - a - 1; b = N - b - 1; s[1][a].emplace_back(b, i, 0); } } solve(0); reverse(x, x + N); rep(i, N)x[i] *= -1; solve(1); rep(i, Q)cout << ans[i] << endl; return 0; }
Main.java:1: error: illegal character: '#' #define _CRT_SECURE_NO_WARNINGS ^ Main.java:2: error: illegal character: '#' #include<sstream> ^ Main.java:3: error: illegal character: '#' #include<iostream> ^ Main.java:4: error: illegal character: '#' #include<cstdio> ^ Main.java:5: error: illegal character: '#' #include<cstdlib> ^ Main.java:6: error: illegal character: '#' #include<cstring> ^ Main.java:7: error: illegal character: '#' #include<climits> ^ Main.java:8: error: illegal character: '#' #include<cmath> ^ Main.java:9: error: illegal character: '#' #include<string> ^ Main.java:10: error: illegal character: '#' #include<vector> ^ Main.java:11: error: illegal character: '#' #include<set> ^ Main.java:12: error: illegal character: '#' #include<map> ^ Main.java:13: error: illegal character: '#' #include<queue> ^ Main.java:14: error: illegal character: '#' #include<numeric> ^ Main.java:15: error: illegal character: '#' #include<functional> ^ Main.java:16: error: illegal character: '#' #include<algorithm> ^ Main.java:17: error: illegal character: '#' #include<bitset> ^ Main.java:18: error: illegal character: '#' #include<tuple> ^ Main.java:19: error: illegal character: '#' #include<unordered_set> ^ Main.java:20: error: illegal character: '#' #include<random> ^ Main.java:22: error: illegal character: '#' #define INF (1<<29) ^ Main.java:22: error: class, interface, enum, or record expected #define INF (1<<29) ^ Main.java:23: error: illegal character: '#' #define rep(i,n) for(int i=0;i<(int)(n);i++) ^ Main.java:23: error: class, interface, enum, or record expected #define rep(i,n) for(int i=0;i<(int)(n);i++) ^ Main.java:23: error: class, interface, enum, or record expected #define rep(i,n) for(int i=0;i<(int)(n);i++) ^ Main.java:24: error: illegal character: '#' #define all(v) v.begin(),v.end() ^ Main.java:25: error: illegal character: '#' #define uniq(v) v.erase(unique(all(v)),v.end()) ^ Main.java:31: error: unnamed classes are a preview feature and are disabled by default. int N; ^ (use --enable-preview to enable unnamed classes) Main.java:32: error: class, interface, enum, or record expected int x[100000]; ^ Main.java:33: error: class, interface, enum, or record expected int L, Q; ^ Main.java:34: error: class, interface, enum, or record expected int ans[100000]; ^ Main.java:35: error: class, interface, enum, or record expected int dist[100000]; ^ Main.java:45: error: not a statement for (const auto &t : s[dir][i]) { ^ Main.java:45: error: not a statement for (const auto &t : s[dir][i]) { ^ Main.java:67: error: not a statement for (const auto &t : s[dir][i]) { ^ Main.java:67: error: not a statement for (const auto &t : s[dir][i]) { ^ Main.java:41: error: ';' expected rep(i, N - 1) { ^ Main.java:45: error: illegal start of expression for (const auto &t : s[dir][i]) { ^ Main.java:45: error: ';' expected for (const auto &t : s[dir][i]) { ^ Main.java:45: error: ';' expected for (const auto &t : s[dir][i]) { ^ Main.java:67: error: illegal start of expression for (const auto &t : s[dir][i]) { ^ Main.java:67: error: ';' expected for (const auto &t : s[dir][i]) { ^ Main.java:67: error: ';' expected for (const auto &t : s[dir][i]) { ^ Main.java:85: error: not a statement ios::sync_with_stdio(0); ^ Main.java:87: error: not a statement cin >> N; ^ Main.java:88: error: not a statement rep(i, N)cin >> x[i]; ^ Main.java:89: error: not a statement cin >> L >> Q; ^ Main.java:93: error: not a statement cin >> a >> b; ^ Main.java:108: error: not a statement rep(i, Q)cout << ans[i] << endl; ^ Main.java:85: error: ';' expected ios::sync_with_stdio(0); ^ Main.java:88: error: ';' expected rep(i, N)cin >> x[i]; ^ Main.java:91: error: ';' expected rep(i, Q) { ^ Main.java:106: error: ';' expected rep(i, N)x[i] *= -1; ^ Main.java:108: error: ';' expected rep(i, Q)cout << ans[i] << endl; ^ 54 errors
s039813013
p04017
Java
import java.io.*; import java.math.*; import java.util.*; import static java.util.Arrays.*; public class D { private static final int mod = (int)1e9+7; final Random random = new Random(0); final IOFast io = new IOFast(); /// MAIN CODE public void run() throws IOException { // int TEST_CASE = Integer.parseInt(new String(io.nextLine()).trim()); int TEST_CASE = 1; while(TEST_CASE-- != 0) { /* // for(long n = 1; n <= 1000; n++) { for(long n = 50; n <= 100000; n++) { int cnt = 0; for(long i = n; i > 2; i--) { if(f(i, n) > f(i-1, n)) { long d = f(i, n) - f(i+1, n); // System.err.println(n + " " + i + " " + d + " " + f(i, n)); if(cnt != 0 && i != (n+cnt+1)/(cnt+1)) { throw new RuntimeException(); } if(++cnt >= 3) break; } } } */ // for(long n = 1; n <= 500; n++) { // for(long s = 1; s <= 500; s++) { // if(func(n, s) != naive(n, s)) { // System.err.println(n + " " + s + " " + func(n, s) + " " + naive(n, s)); // return; // } // } // } long n = io.nextLong(); long s = io.nextLong(); io.out.println(func(n, s)); // io.out.println(naive(n, s)); } } long func(long n, long s) { // if(n <= 50) { // for(int i = 2; i <= n; i++) { // if(f(i, n) == s) { // return i; // } // } // return -1; // } // for(long i = 2; i*i <= n; i++) { // if(f(i, n) == s) { // return i; // } // } long ans = Long.MAX_VALUE; long sqrt = (long)Math.sqrt(n); for(long i = 2, cur = n + 1; cur > 2 && cur > sqrt - 100; i++) { // System.err.println(i + " " + cur); long next = (n+i)/i; long len = cur - next; long a = f(cur - 1, n); // a, a + (i-1), a + 2*(i-1) // System.err.println("ck: " + s + " " + (i - 1) + " " + a + " " + len); // if(s % (i - 1) == a % (i - 1)) { if((s - a) % (i - 1) == 0) { if(s >= a && s <= a + (len-1)*(i-1)) { ans = Math.min(ans, cur - ((s - a) / (i - 1) + 1)); // System.err.println("ans: " + ans); } } cur = next; } for(long i = 2; (i-1)*(i-1) <= n + 100 && i < ans; i++) { if(f(i, n) == s) { return i; } } if(ans == Long.MAX_VALUE) { if(n == s) { return n + 1; } ans = -1; } return ans; } long naive(long n, long s) { for(long i = 2; i <= n + 1; i++) { // System.err.println(i + " " + f(i, n)); if(f(i, n) == s) { return i; } } return -1; } long f(long b, long n) { if(b <= 1) throw new RuntimeException(); return n < b ? n : (f(b, n/b) + n % b); } /// TEMPLATE static int gcd(int n, int r) { return r == 0 ? n : gcd(r, n%r); } static long gcd(long n, long r) { return r == 0 ? n : gcd(r, n%r); } static <T> void swap(T[] x, int i, int j) { T t = x[i]; x[i] = x[j]; x[j] = t; } static void swap(int[] x, int i, int j) { int t = x[i]; x[i] = x[j]; x[j] = t; } void printArrayLn(int[] xs) { for(int i = 0; i < xs.length; i++) io.out.print(xs[i] + (i==xs.length-1?"\n":" ")); } void printArrayLn(long[] xs) { for(int i = 0; i < xs.length; i++) io.out.print(xs[i] + (i==xs.length-1?"\n":" ")); } static void dump(Object... o) { System.err.println(Arrays.deepToString(o)); } void main() throws IOException { // IOFast.setFileIO("rle-size.in", "rle-size.out"); try { run(); } catch (EndOfFileRuntimeException e) { } io.out.flush(); } public static void main(String[] args) throws IOException { new D().main(); } static class EndOfFileRuntimeException extends RuntimeException { private static final long serialVersionUID = -8565341110209207657L; } static public class IOFast { private BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); private PrintWriter out = new PrintWriter(System.out); void setFileIn(String ins) throws IOException { in.close(); in = new BufferedReader(new FileReader(ins)); } void setFileOut(String outs) throws IOException { out.flush(); out.close(); out = new PrintWriter(new FileWriter(outs)); } void setFileIO(String ins, String outs) throws IOException { setFileIn(ins); setFileOut(outs); } private static int pos, readLen; private static final char[] buffer = new char[1024 * 8]; private static char[] str = new char[500*8*2]; private static boolean[] isDigit = new boolean[256]; private static boolean[] isSpace = new boolean[256]; private static boolean[] isLineSep = new boolean[256]; static { for(int i = 0; i < 10; i++) { isDigit['0' + i] = true; } isDigit['-'] = true; isSpace[' '] = isSpace['\r'] = isSpace['\n'] = isSpace['\t'] = true; isLineSep['\r'] = isLineSep['\n'] = true; } public int read() throws IOException { if(pos >= readLen) { pos = 0; readLen = in.read(buffer); if(readLen <= 0) { throw new EndOfFileRuntimeException(); } } return buffer[pos++]; } public int nextInt() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); int i = 0; int ret = 0; if(str[0] == '-') { i = 1; } for(; i < len; i++) ret = ret * 10 + str[i] - '0'; if(str[0] == '-') { ret = -ret; } return ret; } public long nextLong() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); int i = 0; long ret = 0; if(str[0] == '-') { i = 1; } for(; i < len; i++) ret = ret * 10 + str[i] - '0'; if(str[0] == '-') { ret = -ret; } return ret; } public char nextChar() throws IOException { while(true) { final int c = read(); if(!isSpace[c]) { return (char)c; } } } int reads(int len, boolean[] accept) throws IOException { try { while(true) { final int c = read(); if(accept[c]) { break; } if(str.length == len) { char[] rep = new char[str.length * 3 / 2]; System.arraycopy(str, 0, rep, 0, str.length); str = rep; } str[len++] = (char)c; } } catch(EndOfFileRuntimeException e) { ; } return len; } int reads(char[] cs, int len, boolean[] accept) throws IOException { try { while(true) { final int c = read(); if(accept[c]) { break; } cs[len++] = (char)c; } } catch(EndOfFileRuntimeException e) { ; } return len; } public char[] nextLine() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isLineSep); try { if(str[len-1] == '\r') { len--; read(); } } catch(EndOfFileRuntimeException e) { ; } return Arrays.copyOf(str, len); } public String nextString() throws IOException { return new String(next()); } public char[] next() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); return Arrays.copyOf(str, len); } // public int next(char[] cs) throws IOException { int len = 0; cs[len++] = nextChar(); len = reads(cs, len, isSpace); return len; } public double nextDouble() throws IOException { return Double.parseDouble(nextString()); } public long[] nextLongArray(final int n) throws IOException { final long[] res = new long[n]; for(int i = 0; i < n; i++) { res[i] = nextLong(); } return res; } public int[] nextIntArray(final int n) throws IOException { final int[] res = new int[n]; for(int i = 0; i < n; i++) { res[i] = nextInt(); } return res; } public int[][] nextIntArray2D(final int n, final int k) throws IOException { final int[][] res = new int[n][]; for(int i = 0; i < n; i++) { res[i] = nextIntArray(k); } return res; } public int[][] nextIntArray2DWithIndex(final int n, final int k) throws IOException { final int[][] res = new int[n][k+1]; for(int i = 0; i < n; i++) { for(int j = 0; j < k; j++) { res[i][j] = nextInt(); } res[i][k] = i; } return res; } public double[] nextDoubleArray(final int n) throws IOException { final double[] res = new double[n]; for(int i = 0; i < n; i++) { res[i] = nextDouble(); } return res; } } }
Main.java:8: error: class D is public, should be declared in a file named D.java public class D { ^ 1 error
s461236966
p04017
Java
import java.io.*; import java.math.*; import java.util.*; import static java.util.Arrays.*; public class E { private static final int mod = (int)1e9+7; final Random random = new Random(0); final IOFast io = new IOFast(); /// MAIN CODE public void run() throws IOException { // int TEST_CASE = Integer.parseInt(new String(io.nextLine()).trim()); int TEST_CASE = 1; while(TEST_CASE-- != 0) { int n = io.nextInt(); int[] x = io.nextIntArray(n); int L = io.nextInt(); int Q = io.nextInt(); for(int q = 0; q < Q; q++) { int a = io.nextInt() - 1; int b = io.nextInt() - 1; int ans = 0; for(int i = a, j; i < b; i = j - 1) { for(j = i + 1; j < n && x[j] - x[i] <= L; j++); // System.err.println(i + " " + j); ans++; } for(int i = a, j; i > b; i = j + 1) { for(j = i - 1; j >= 0 && x[i] - x[j] <= L; j--); ans++; } io.out.println(ans); } } } /// TEMPLATE static int gcd(int n, int r) { return r == 0 ? n : gcd(r, n%r); } static long gcd(long n, long r) { return r == 0 ? n : gcd(r, n%r); } static <T> void swap(T[] x, int i, int j) { T t = x[i]; x[i] = x[j]; x[j] = t; } static void swap(int[] x, int i, int j) { int t = x[i]; x[i] = x[j]; x[j] = t; } void printArrayLn(int[] xs) { for(int i = 0; i < xs.length; i++) io.out.print(xs[i] + (i==xs.length-1?"\n":" ")); } void printArrayLn(long[] xs) { for(int i = 0; i < xs.length; i++) io.out.print(xs[i] + (i==xs.length-1?"\n":" ")); } static void dump(Object... o) { System.err.println(Arrays.deepToString(o)); } void main() throws IOException { // IOFast.setFileIO("rle-size.in", "rle-size.out"); try { run(); } catch (EndOfFileRuntimeException e) { } io.out.flush(); } public static void main(String[] args) throws IOException { new E().main(); } static class EndOfFileRuntimeException extends RuntimeException { private static final long serialVersionUID = -8565341110209207657L; } static public class IOFast { private BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); private PrintWriter out = new PrintWriter(System.out); void setFileIn(String ins) throws IOException { in.close(); in = new BufferedReader(new FileReader(ins)); } void setFileOut(String outs) throws IOException { out.flush(); out.close(); out = new PrintWriter(new FileWriter(outs)); } void setFileIO(String ins, String outs) throws IOException { setFileIn(ins); setFileOut(outs); } private static int pos, readLen; private static final char[] buffer = new char[1024 * 8]; private static char[] str = new char[500*8*2]; private static boolean[] isDigit = new boolean[256]; private static boolean[] isSpace = new boolean[256]; private static boolean[] isLineSep = new boolean[256]; static { for(int i = 0; i < 10; i++) { isDigit['0' + i] = true; } isDigit['-'] = true; isSpace[' '] = isSpace['\r'] = isSpace['\n'] = isSpace['\t'] = true; isLineSep['\r'] = isLineSep['\n'] = true; } public int read() throws IOException { if(pos >= readLen) { pos = 0; readLen = in.read(buffer); if(readLen <= 0) { throw new EndOfFileRuntimeException(); } } return buffer[pos++]; } public int nextInt() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); int i = 0; int ret = 0; if(str[0] == '-') { i = 1; } for(; i < len; i++) ret = ret * 10 + str[i] - '0'; if(str[0] == '-') { ret = -ret; } return ret; } public long nextLong() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); int i = 0; long ret = 0; if(str[0] == '-') { i = 1; } for(; i < len; i++) ret = ret * 10 + str[i] - '0'; if(str[0] == '-') { ret = -ret; } return ret; } public char nextChar() throws IOException { while(true) { final int c = read(); if(!isSpace[c]) { return (char)c; } } } int reads(int len, boolean[] accept) throws IOException { try { while(true) { final int c = read(); if(accept[c]) { break; } if(str.length == len) { char[] rep = new char[str.length * 3 / 2]; System.arraycopy(str, 0, rep, 0, str.length); str = rep; } str[len++] = (char)c; } } catch(EndOfFileRuntimeException e) { ; } return len; } int reads(char[] cs, int len, boolean[] accept) throws IOException { try { while(true) { final int c = read(); if(accept[c]) { break; } cs[len++] = (char)c; } } catch(EndOfFileRuntimeException e) { ; } return len; } public char[] nextLine() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isLineSep); try { if(str[len-1] == '\r') { len--; read(); } } catch(EndOfFileRuntimeException e) { ; } return Arrays.copyOf(str, len); } public String nextString() throws IOException { return new String(next()); } public char[] next() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); return Arrays.copyOf(str, len); } // public int next(char[] cs) throws IOException { int len = 0; cs[len++] = nextChar(); len = reads(cs, len, isSpace); return len; } public double nextDouble() throws IOException { return Double.parseDouble(nextString()); } public long[] nextLongArray(final int n) throws IOException { final long[] res = new long[n]; for(int i = 0; i < n; i++) { res[i] = nextLong(); } return res; } public int[] nextIntArray(final int n) throws IOException { final int[] res = new int[n]; for(int i = 0; i < n; i++) { res[i] = nextInt(); } return res; } public int[][] nextIntArray2D(final int n, final int k) throws IOException { final int[][] res = new int[n][]; for(int i = 0; i < n; i++) { res[i] = nextIntArray(k); } return res; } public int[][] nextIntArray2DWithIndex(final int n, final int k) throws IOException { final int[][] res = new int[n][k+1]; for(int i = 0; i < n; i++) { for(int j = 0; j < k; j++) { res[i][j] = nextInt(); } res[i][k] = i; } return res; } public double[] nextDoubleArray(final int n) throws IOException { final double[] res = new double[n]; for(int i = 0; i < n; i++) { res[i] = nextDouble(); } return res; } } }
Main.java:8: error: class E is public, should be declared in a file named E.java public class E { ^ 1 error
s513844543
p04017
C++
#include <cstdio> #include <algorithm> #include <vector> #include <queue> #include <string.h> using namespace std; using ll = long long; ll n; ll x[123456];//n ll l; ll q; ll a[123456], b[123456];//q ll lbar[123456];//n ll rbar[123456];//n vector<ll> lgraph[123456]; ll dist[123456]; int bfs(int v1, int v2) { queue<ll> que; memset(dist, 0xFF, sizeof(ll) * n); que.push(v1); while (!que.empty()) { ll vn = que.front(); que.pop(); for (ll vx : lgraph[vn]) { if (vx == v2)return dist[vn] + 1; if (dist[vx] == -1) { dist[vx] = dist[vn] + 1; que.push(vx); } } } return 0; } int main() { scanf("%lld",&n); for (int i = 0; i < n; ++i)scanf("%lld", x + i); scanf("%lld %lld", &l, &q); for (int j = 0; j < q; ++j) { scanf("%lld %lld", a + j, b + j); --a[j]; --b[j]; } for (int i = 0; i < n; ++i) { lbar[i] = lower_bound(x, x + i + 1, x[i] - l) - x; rbar[i] = max(upper_bound(x + i, x + n, x[i] + l) - x - 1, i); } for (int i = 0; i < n; ++i) { for (int vert = lbar[i]; vert < i;++vert) { lgraph[vert].push_back(i); lgraph[i].push_back(vert); } } for (int j = 0; j < q; ++j) { ll ans = bfs(a[j], b[j]); printf("%lld\n",ans); } return 0; }
a.cc: In function 'int main()': a.cc:57:30: error: no matching function for call to 'max(long int, int&)' 57 | rbar[i] = max(upper_bound(x + i, x + n, x[i] + l) - x - 1, i); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from a.cc:3: /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:57:30: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'int') 57 | rbar[i] = max(upper_bound(x + i, x + n, x[i] + l) - x - 1, i); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /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:57:30: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 57 | rbar[i] = max(upper_bound(x + i, x + n, x[i] + l) - x - 1, i); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s720516762
p04017
C++
#include <cstdio> #include <algorithm> #include <vector> #include <queue> using namespace std; using ll = long long; ll n; ll x[123456];//n ll l; ll q; ll a[123456], b[123456];//q ll lbar[123456];//n ll rbar[123456];//n vector<ll> lgraph[123456]; ll dist[123456]; int bfs(int v1, int v2) { queue<ll> que; memset(dist, 0xFF, sizeof(ll) * n); que.push(v1); while (!que.empty()) { ll vn = que.front(); que.pop(); for (ll vx : lgraph[vn]) { if (vx == v2)return dist[vn] + 1; if (dist[vx] == -1) { dist[vx] = dist[vn] + 1; que.push(vx); } } } return 0; } int main() { scanf("%lld",&n); for (int i = 0; i < n; ++i)scanf("%lld", x + i); scanf("%lld %lld", &l, &q); for (int j = 0; j < q; ++j) { scanf("%lld %lld", a + j, b + j); --a[j]; --b[j]; } for (int i = 0; i < n; ++i) { lbar[i] = lower_bound(x, x + i + 1, x[i] - l) - x; rbar[i] = max(upper_bound(x + i, x + n, x[i] + l) - x - 1, i); } for (int i = 0; i < n; ++i) { for (int vert = lbar[i]; vert < i;++vert) { lgraph[vert].push_back(i); lgraph[i].push_back(vert); } } for (int j = 0; j < q; ++j) { ll ans = bfs(a[j], b[j]); printf("%lld\n",ans); } return 0; }
a.cc: In function 'int bfs(int, int)': a.cc:25:9: error: 'memset' was not declared in this scope 25 | memset(dist, 0xFF, sizeof(ll) * n); | ^~~~~~ a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 5 | #include <queue> +++ |+#include <cstring> 6 | a.cc: In function 'int main()': a.cc:56:30: error: no matching function for call to 'max(long int, int&)' 56 | rbar[i] = max(upper_bound(x + i, x + n, x[i] + l) - x - 1, i); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from a.cc:3: /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:56:30: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'int') 56 | rbar[i] = max(upper_bound(x + i, x + n, x[i] + l) - x - 1, i); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /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:56:30: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 56 | rbar[i] = max(upper_bound(x + i, x + n, x[i] + l) - x - 1, i); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s342134016
p04017
C++
#include <bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<string> vs; typedef vector<bool> vb; typedef vector<vb> vvb; typedef pair<int, int> pii; typedef long long ll; typedef unsigned long long ull; #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(), (a).rend() #define pb push_back #define mp make_pair #define loop(i,a,b) for(ull i=(a);i<ull(b);++i) #define rep(i,n) loop(i,0,n) #define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i) #define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i) const double eps = 1e-10; const double pi = acos(-1.0); const double inf = (int)1e8; #define clr(a,i) memset((a), (i) ,sizeof(a)) int main(){ int n,l,q; std::cin >> n; vi x(n); rep(i,n) std::cin >> x[i]; std::cin >> l >> q; long long a,q,ans,w,s,t; rep(i,q){ ans=w=0; std::cin >> a >> q; loop(j,a-1,q){ w+=x[j+1]-x[j]; if(w>l){ w=x[j+1]-x[j]; ans++; } } std::cout << ans << std::endl; } }
a.cc: In function 'int main()': a.cc:34:15: error: conflicting declaration 'long long int q' 34 | long long a,q,ans,w,s,t; | ^ a.cc:29:11: note: previous declaration as 'int q' 29 | int n,l,q; | ^
s629086056
p04017
C++
#include <cstdio> #include <algorithm> #include <vector> #include <queue> using namespace std; using ll = long long; ll n; ll x[123456];//n ll l; ll q; ll a[123456], b[123456];//q ll lbar[123456];//n ll rbar[123456];//n vector<ll> lgraph[123456]; ll dist[123456]; int bfs(int v1, int v2) { queue<ll> que; memset(dist, 0xFF, sizeof(ll) * n); que.push(v1); while (!que.empty()) { ll vn = que.front(); que.pop(); for (ll vx : lgraph[vn]) { if (vx == v2)return dist[vn] + 1; if (dist[vx] == -1) { dist[vx] = min(dist[vn] + 1, dist[vx]); que.push(vx); } } } return 0; } int main() { scanf("%lld",&n); for (int i = 0; i < n; ++i)scanf("%lld", x + i); scanf("%lld %lld", &l, &q); for (int j = 0; j < q; ++j) { scanf("%lld %lld", a + j, b + j); --a[j]; --b[j]; } for (int i = 0; i < n; ++i) { lbar[i] = lower_bound(x, x + i + 1, x[i] - l) - x; rbar[i] = max(upper_bound(x + i, x + n, x[i] + l) - x - 1, i); } for (int i = 0; i < n; ++i) { for (int vert = lbar[i]; vert < i;++vert) { lgraph[vert].push_back(i); lgraph[i].push_back(vert); } } for (int j = 0; j < q; ++j) { ll ans = bfs(a[j], b[j]); printf("%lld\n",ans); } return 0; }
a.cc: In function 'int bfs(int, int)': a.cc:25:9: error: 'memset' was not declared in this scope 25 | memset(dist, 0xFF, sizeof(ll) * n); | ^~~~~~ a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 5 | #include <queue> +++ |+#include <cstring> 6 | a.cc: In function 'int main()': a.cc:56:30: error: no matching function for call to 'max(long int, int&)' 56 | rbar[i] = max(upper_bound(x + i, x + n, x[i] + l) - x - 1, i); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from a.cc:3: /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:56:30: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'int') 56 | rbar[i] = max(upper_bound(x + i, x + n, x[i] + l) - x - 1, i); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /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:56:30: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 56 | rbar[i] = max(upper_bound(x + i, x + n, x[i] + l) - x - 1, i); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s552754371
p04017
C++
#include <bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<string> vs; typedef vector<bool> vb; typedef vector<vb> vvb; typedef pair<int, int> pii; typedef long long ll; typedef unsigned long long ull; #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(), (a).rend() #define pb push_back #define mp make_pair #define loop(i,a,b) for(ull i=(a);i<ull(b);++i) #define rep(i,n) loop(i,0,n) #define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i) #define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i) const double eps = 1e-10; const double pi = acos(-1.0); const double inf = (int)1e8; #define clr(a,i) memset((a), (i) ,sizeof(a)) int main(){ int n,l,q; std::cin >> n; vi x(n); rep(i,n) std::cin >> x[i]; std::cin >> l >> q; long long a,q,ans,w-0,s,t; rep(i,q){ ans=w=0; std::cin >> a >> q; loop(j,a-1,q){ w+=x[j+1]-x[j]; if(w>l){ w=x[j+1]-x[j]; ans++; } } std::cout << ans << std::endl; } }
a.cc: In function 'int main()': a.cc:34:15: error: conflicting declaration 'long long int q' 34 | long long a,q,ans,w-0,s,t; | ^ a.cc:29:11: note: previous declaration as 'int q' 29 | int n,l,q; | ^ a.cc:34:22: error: expected initializer before '-' token 34 | long long a,q,ans,w-0,s,t; | ^ a.cc:36:9: error: 'w' was not declared in this scope 36 | ans=w=0; | ^
s340865250
p04017
C++
int main() { long long N, Q, L; vector<long long> loc(1); cin >> N; long long t; for (long long i = 0; i < N; ++i){ cin >> t; loc.push_back(t); } cin >> L >> Q; vector<vector<pair<long long, long long>>> days(N + 1, vector<pair<long long, long long>>(N + 1, { 0, 0 })); for (long long i = 1; i < N; ++i){ for (long long j = i+1; j <= N; ++j){ long long dist = loc[j] - loc[j - 1]; if (days[i][j - 1].second>=dist){ days[i][j] = { days[i][j - 1].first, days[i][j - 1].second - dist }; } else{ days[i][j] = { days[i][j - 1].first + 1, L - dist }; } } } vector<long long> a(Q), b(Q); for (long long i = 0; i < Q; ++i){ cin >> a[i] >> b[i]; } for (long long i = 0; i < Q; ++i){ if (a[i] <= b[i]){ cout << days[a[i]][b[i]].first << endl; } else{ cout << days[b[i]][a[i]].first << endl; } } cin >> N; return 0; }
a.cc: In function 'int main()': a.cc:4:9: error: 'vector' was not declared in this scope 4 | vector<long long> loc(1); | ^~~~~~ a.cc:4:16: error: expected primary-expression before 'long' 4 | vector<long long> loc(1); | ^~~~ a.cc:5:9: error: 'cin' was not declared in this scope 5 | cin >> N; | ^~~ a.cc:9:17: error: 'loc' was not declared in this scope 9 | loc.push_back(t); | ^~~ a.cc:12:23: error: 'pair' was not declared in this scope 12 | vector<vector<pair<long long, long long>>> days(N + 1, vector<pair<long long, long long>>(N + 1, { 0, 0 })); | ^~~~ a.cc:12:28: error: expected primary-expression before 'long' 12 | vector<vector<pair<long long, long long>>> days(N + 1, vector<pair<long long, long long>>(N + 1, { 0, 0 })); | ^~~~ a.cc:12:114: error: expected primary-expression before ')' token 12 | vector<vector<pair<long long, long long>>> days(N + 1, vector<pair<long long, long long>>(N + 1, { 0, 0 })); | ^ a.cc:15:42: error: 'loc' was not declared in this scope 15 | long long dist = loc[j] - loc[j - 1]; | ^~~ a.cc:16:29: error: 'days' was not declared in this scope 16 | if (days[i][j - 1].second>=dist){ | ^~~~ a.cc:24:16: error: expected primary-expression before 'long' 24 | vector<long long> a(Q), b(Q); | ^~~~ a.cc:26:24: error: 'a' was not declared in this scope 26 | cin >> a[i] >> b[i]; | ^ a.cc:26:32: error: 'b' was not declared in this scope 26 | cin >> a[i] >> b[i]; | ^ a.cc:29:21: error: 'a' was not declared in this scope 29 | if (a[i] <= b[i]){ | ^ a.cc:29:29: error: 'b' was not declared in this scope 29 | if (a[i] <= b[i]){ | ^ a.cc:30:25: error: 'cout' was not declared in this scope 30 | cout << days[a[i]][b[i]].first << endl; | ^~~~ a.cc:30:33: error: 'days' was not declared in this scope 30 | cout << days[a[i]][b[i]].first << endl; | ^~~~ a.cc:30:59: error: 'endl' was not declared in this scope 30 | cout << days[a[i]][b[i]].first << endl; | ^~~~ a.cc:33:25: error: 'cout' was not declared in this scope 33 | cout << days[b[i]][a[i]].first << endl; | ^~~~ a.cc:33:33: error: 'days' was not declared in this scope 33 | cout << days[b[i]][a[i]].first << endl; | ^~~~ a.cc:33:59: error: 'endl' was not declared in this scope 33 | cout << days[b[i]][a[i]].first << endl; | ^~~~
s123590000
p04017
C++
#include <iostream> #include <vector> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { int N, Q, L; vector<int> loc(1); cin >> N; int t; for (int i = 0; i < N; ++i){ cin >> t; loc.push_back(t); } cin >> L >> Q; vector<vector<pair<int, int>>> days(N + 1, vector<pair<int, int>>(N + 1, { 0, 0 })); for (int i = 1; i <= N; ++i){ for (int j = i; j <= N; ++j){ int dist = loc[j] - loc[j - 1]; if (days[i][j - 1].second>=dist){ days[i][j] = { days[i][j - 1].first, days[i][j - 1].second - dist }; } else{ days[i][j] = { days[i][j - 1].first + 1, L - dist }; } } } vector<int> a(Q), b(Q); for (int i = 0; i < Q; ++i){ cin >> a[i] >> b[i]; } for (int i = 0; i < Q; ++i){ if (a[i] <= b[i]){ cout << days[a[i]][b[i]].first << endl; } else{ cout << days[b[i]][a[i]].first << endl; } } return 0; }
a.cc:5:22: error: '_TCHAR' has not been declared 5 | int _tmain(int argc, _TCHAR* argv[]) | ^~~~~~
s103877790
p04017
C++
#include <algorithm> #include <iostream> #include <numeric> #include <string> #include <utility> #include <vector> int main() { int n, q, a, b; long long l; long long x[100000]; std::vector<std::vector<int>> next(100000, std::vector<int>(20)); std::cin >> n; for (int ni = 0; ni < n; ++ni) { std::cin >> x[ni]; } std::cin >> l >> q; for (int ni = 0; ni < n; ++ni) { int inf = 0; int sup = n; while (sup - inf > 1) { int c = (inf + sup) / 2; if (x[c] <= x[ni] + l) { inf = c; } else { sup = c; } } next[ni][0] = inf; } for (int c = 1; c < 20; ++c) { for (int ni = 0; ni < n; ++ni) { next[ni][c] = next[next[ni][c - 1]][c - 1]; } } for (int qi = 0; qi < q; ++qi) { int ans = 0; std::cin >> a >> b; if (a > b) { std::swap(a, b); } --a; --b; while (a < b) { for (int d = 19; d >= 0; --d) { if (next[a][d] <= b) { a = next[a][d] + 1; ans += 1 << d; break; } } } std::cout << ans << std::endl; } return 0; } #include <algorithm> #include <iostream> #include <numeric> #include <string> #include <utility> #include <vector> int main() { int n, q, a, b; long long l; long long x[100000]; std::vector<std::vector<int>> next(100000, std::vector<int>(20)); std::cin >> n; for (int ni = 0; ni < n; ++ni) { std::cin >> x[ni]; } std::cin >> l >> q; for (int ni = 0; ni < n; ++ni) { int inf = 0; int sup = n; while (sup - inf > 1) { int c = (inf + sup) / 2; if (x[c] <= x[ni] + l) { inf = c; } else { sup = c; } } next[ni][0] = inf; } for (int c = 1; c < 20; ++c) { for (int ni = 0; ni < n; ++ni) { next[ni][c] = next[next[ni][c - 1]][c - 1]; } } for (int qi = 0; qi < q; ++qi) { int ans = 0; std::cin >> a >> b; if (a > b) { std::swap(a, b); } --a; --b; while (a < b) { for (int d = 19; d >= 0; --d) { if (next[a][d] <= b) { a = next[a][d] + 1; ans += 1 << d; break; } } } std::cout << ans << std::endl; } return 0; } #include <algorithm> #include <iostream> #include <numeric> #include <string> #include <utility> #include <vector> int main() { int n, q, a, b; long long l; long long x[100000]; std::vector<std::vector<int>> next(100000, std::vector<int>(20)); std::cin >> n; for (int ni = 0; ni < n; ++ni) { std::cin >> x[ni]; } std::cin >> l >> q; for (int ni = 0; ni < n; ++ni) { int inf = 0; int sup = n; while (sup - inf > 1) { int c = (inf + sup) / 2; if (x[c] <= x[ni] + l) { inf = c; } else { sup = c; } } next[ni][0] = inf; } for (int c = 1; c < 20; ++c) { for (int ni = 0; ni < n; ++ni) { next[ni][c] = next[next[ni][c - 1]][c - 1]; } } for (int qi = 0; qi < q; ++qi) { int ans = 0; std::cin >> a >> b; if (a > b) { std::swap(a, b); } --a; --b; while (a < b) { for (int d = 19; d >= 0; --d) { if (next[a][d] <= b) { a = next[a][d] + 1; ans += 1 << d; break; } } } std::cout << ans << std::endl; } return 0; }
a.cc:65:5: error: redefinition of 'int main()' 65 | int main() { | ^~~~ a.cc:8:5: note: 'int main()' previously defined here 8 | int main() { | ^~~~ a.cc:122:5: error: redefinition of 'int main()' 122 | int main() { | ^~~~ a.cc:8:5: note: 'int main()' previously defined here 8 | int main() { | ^~~~
s524321037
p04018
C++
#include <iostream> #include <string> #include <unordered_map> #include <unordered_set> #include <cstring> #include <chrono> #include <vector> #include <map> #include <random> #include <set> #include <algorithm> #include <math.h> #include <cstdio> #include <stdio.h> #include <queue> #include <bitset> #include <cstdlib> #include <deque> #include <cassert> #include <stack> using namespace std; #define mp make_pair #define f first #define se second #define pb push_back #define ppb pop_back #define emb emplace_back #define ll long long #define ull unsigned long long #define cntbit(x) __builtin_popcount(x) #define endl '\n' #define uset unordered_set #define umap unordered_map #define pii pair<int, int> #define ld long double #define pll pair<long long, long long> mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template <typename T> inline T range(T l, T r) { return uniform_int_distribution<T>(l, r)(rng); } inline void setin(string s) { freopen(s.c_str(), "r", stdin); } inline void setout(string s) { freopen(s.c_str(), "w", stdout); } template <typename T> void Min(T &a, T b) { a = min(a, b); } template <typename T> void Max(T &a, T b) { a = max(a, b); } const int mod = 1e9 + 7; const int inf = 0x3f3f3f3f; const int N = 5e5 + 15; const int K = 26; int n; pii ans(inf, 0); string s; int lp[N]; int p[K][N]; int pr[N], szp; inline pii merge(pii a, pii b) { if(a.f == b.f) return mp(a.f, a.se + b.se); return min(a, b); } inline bool correct(string s) { for(int i = 1; i < s.size(); ++i) { if(s.size() % i == 0) { string t = s.substr(0, i); string nw = t; while(t.size() < s.size()) t += nw; if(t == s) return false; } } return true; } inline bool correct(int l, int r) { return correct(s.substr(l, r - l + 1)); } void rec(int i, int num, int last) { if(i == n) { if(last == n || correct(last, n - 1)) ans = merge(ans, mp(num + (last != n), 1)); } else { if(correct(last, i) && i != n - 1) rec(i + 1, num + 1, i + 1); rec(i + 1, num, last); } } inline int get(int c, int l, int r) { return p[c][r] - (l == 0 ? 0 : p[c][l-1]); } main() { lp[1] = 1; for(int i = 2; i < N; ++i) { if(!lp[i]) { lp[i] = i; pr[szp++] = i; } for(int j = 0; j < szp && pr[j] * i < N; ++j) lp[i * pr[j]] = pr[j]; } ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); // setin("input.txt"); cin >> s; n = s.size(); for(int i = 0; i < n; ++i) { for(int j = 0; j < K && i; ++j) p[j][i] = p[j][i-1]; p[s[i] - 'a'][i]++; } ans = merge(n, 1); if(n <= 4) rec(0, 0, 0); else if(correct(s)) ans = mp(1, 1); else { for(int i = 1; i < n; ++i) if(lp[i] == i && lp[n - i] == n - i && get(s[0] - 'a', 0, i - 1) != i && get(s[i] - 'a', i, n - 1) != n - i) ans = merge(ans, mp(2, 1)); } cout << ans.f << endl << ans.se << endl; return 0; }
a.cc:115:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 115 | main() { | ^~~~ a.cc: In function 'int main()': a.cc:134:20: error: no matching function for call to 'merge(int&, int)' 134 | ans = merge(n, 1); | ~~~~~^~~~~~ In file included from /usr/include/c++/14/algorithm:61, from a.cc:11: /usr/include/c++/14/bits/stl_algo.h:4857:5: note: candidate: 'template<class _IIter1, class _IIter2, class _OIter> _OIter std::merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter)' 4857 | merge(_InputIterator1 __first1, _InputIterator1 __last1, | ^~~~~ /usr/include/c++/14/bits/stl_algo.h:4857:5: note: candidate expects 5 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:4908:5: note: candidate: 'template<class _IIter1, class _IIter2, class _OIter, class _Compare> _OIter std::merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare)' 4908 | merge(_InputIterator1 __first1, _InputIterator1 __last1, | ^~~~~ /usr/include/c++/14/bits/stl_algo.h:4908:5: note: candidate expects 6 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:86: /usr/include/c++/14/pstl/glue_algorithm_defs.h:412:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _ForwardIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _Tp> std::merge(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _ForwardIterator2, _ForwardIterator, _Compare)' 412 | merge(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, | ^~~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:412:1: note: candidate expects 7 arguments, 2 provided /usr/include/c++/14/pstl/glue_algorithm_defs.h:417:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _ForwardIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _Tp> std::merge(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _ForwardIterator2, _ForwardIterator)' 417 | merge(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, | ^~~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:417:1: note: candidate expects 6 arguments, 2 provided a.cc:75:12: note: candidate: 'std::pair<int, int> merge(std::pair<int, int>, std::pair<int, int>)' 75 | inline pii merge(pii a, pii b) { | ^~~~~ a.cc:75:22: note: no known conversion for argument 1 from 'int' to 'std::pair<int, int>' 75 | inline pii merge(pii a, pii b) { | ^
s099032868
p04018
C++
場合分けはできた 文字列アルゴリズムに思考が行かなかったのはまずい それはそうと思いついたかはわからない
a.cc:1:1: error: '\U00005834\U00005408\U00005206\U00003051\U0000306f\U00003067\U0000304d\U0000305f' does not name a type 1 | 場合分けはできた | ^~~~~~~~~~~~~~~~
s224421592
p04018
C++
#include<iostream> #define maxn 500005 using namespace std; bool same(string s) { char base = s[0]; for (char c : s) if (c != base) return false; return true; } int f[2][maxn]; bool good[2][maxn]; void kmp(string s, int* f, bool* good) { f[0] = -1; for (int i = 1, j = -1; i < (int)s.size(); i++) { while (j != -1 && s[i] != s[j + 1]) j = f[j]; if (s[i] == s[j + 1]) j++; f[i] = j; } good[0] = true; for (int i = 1; i < (int)s.size(); i++) if (f[i] == -1 || (i + 1) % (i - f[i]) != 0) good[i] = true; } int main() { string s; cin >> s; if (same(s)) { cout << (int)s.size() << endl << 1 << endl; } else { kmp(s, f[0], good[0]); if (good[0][(int)s.size() - 1]) { cout << 1 << endl << 1 << endl; } else { reverse(s.begin(), s.end()); kmp(s, f[1], good[1]); int ans = 0; for (int i = 0; i < (int)s.size() - 1; i++) if (good[0][i] && good[1][(int)s.size() - 1 - (i + 1)]) ans++; cout << 2 << endl << ans << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:36:25: error: 'reverse' was not declared in this scope 36 | reverse(s.begin(), s.end()); | ^~~~~~~
s878098321
p04018
C++
#include <bits/stdc++.h> using namespace std; constexpr int mod = 1000000007; bool isprime(int n) { for (int i = 2; i * i <= n; i++) { if (n % i == 0) return (false); } return (true); } int main() { string W; cin >> W; int n = W.size(); vector < int > vec; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { if (isprime(i)) vec.push_back(i); if (n / i != i && i != 1 && isprime(n / i)) vec.push_back(n / i); } } for (auto &value : vec) { if (W.substr(0, n - value) == W.substr(value, n - value)) { if (value == 1) { cout << n << endl << 1 << endl; return (0); } flag = true; if (value % 2 == 0 && value == n / 2) cout << n - 1 << endl; else cout << n - 1 - (n / value - 1) << endl; return (0); } } cout << 1 << endl << 1 << endl; return ( 0 ); }
a.cc: In function 'int main()': a.cc:34:25: error: 'flag' was not declared in this scope 34 | flag = true; | ^~~~
s842131727
p04018
C++
#include <bits/stdc++.h> typedef long long int ll; typedef long double ld; #define pb push_back #define pii pair < int, int > #define F first #define S second #define int long long int #define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) #pragma GCC optimize ("Ofast") #pragma GCC optimize ("unroll-loops") using namespace std; /// khodaya komak kon /// ba z_func hatman dafe baad bezan const int MAX_N = 5e5 + 5; char a[MAX_N]; int N, pre[MAX_N], nxt[MAX_N]; bool check(int pos) { bool f1 = (!pre[pos]) || (pos % (pos - pre[pos])); bool f2 = (nxt[pos + 1] == N + 1) || (N - pos) % (N - pos - (N - nxt[pos + 1] + 1)); if (f1 && f2) return 1; else return 0; } int main () { scanf("%s", a + 1); N = strlen(a + 1); pre[1] = 0; for (int i = 2, j = 0; i <= N; i++) { while (j && a[j + 1] != a[i]) j = pre[j]; if (a[j + 1] == a[i]) ++j; pre[i] = j; } nxt[N] = N + 1; for (int i = N - 1, j = N + 1; i; i--) { while (j <= N && a[j - 1] != a[i]) j = nxt[j]; if (a[j - 1] == a[i]) --j; nxt[i] = j; } if (!pre[N] || N % (N - pre[N])) return puts("1\n1") & 0; if (pre[N] == N - 1) return printf("%d\n1\n", N) & 0; int ans = 0; for (int i = 1; i < N; i++) ans += check(i); printf("2\n%d\n", ans); return 0; }
a.cc:8:24: error: '::main' must return 'int' 8 | #define int long long int | ^~~ a.cc:25:1: note: in expansion of macro 'int' 25 | int main () { | ^~~
s477541802
p04018
C++
#include <iostream> #include <vector> #define llint unsigned long long #define H 1000000007 using namespace std; string s; llint hash[500005]; llint bekiH[500005]; vector<int> vec[500005]; llint get(llint l, llint r) { return hash[r] - hash[l-1]*bekiH[r-l+1]; } bool check2(int l, int r, int p) { return get(l, r-p) == get(l+p, r); } bool check(int l, int r) { int len = r-l+1; if(len == 1) return true; for(int i = 0; i < vec[len].size(); i++){ int d = vec[len][i]; if(d == len) continue; if(check2(l, r, d)) return false; } return true; } int main(void) { cin >> s; int n = s.size(); s = "#" + s; bekiH[0] = 1; for(int i = 1; i <= n; i++) bekiH[i] = bekiH[i-1] * H; for(int i = 1; i <= n; i++) hash[i] = hash[i-1] * H + s[i]; int cyc = n; for(int i = 1; i < n; i++){ if(n % i == 0 && check2(1, n, i)){ cyc = i; break; } } if(cyc == 1){ cout << n << endl; cout << 1 << endl; return 0; } if(cyc == n){ cout << 1 << endl; cout << 1 << endl; return 0; } for(int i = 1; i <= n; i++){ for(int j = 1; i*j <= n; j++) vec[i*j].push_back(i); } cout << 2 << endl; int ans = 0; for(int i = 2; i <= n; i++) if(check(1, i-1) && check(i, n)) ans++; cout << ans << endl; return 0; }
a.cc: In function 'long long unsigned int get(long long unsigned int, long long unsigned int)': a.cc:15:16: error: reference to 'hash' is ambiguous 15 | return hash[r] - hash[l-1]*bekiH[r-l+1]; | ^~~~ In file included from /usr/include/c++/14/string_view:50, from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, 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/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:9:7: note: 'long long unsigned int hash [500005]' 9 | llint hash[500005]; | ^~~~ a.cc:15:26: error: reference to 'hash' is ambiguous 15 | return hash[r] - hash[l-1]*bekiH[r-l+1]; | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:9:7: note: 'long long unsigned int hash [500005]' 9 | llint hash[500005]; | ^~~~ a.cc: In function 'int main()': a.cc:43:37: error: reference to 'hash' is ambiguous 43 | for(int i = 1; i <= n; i++) hash[i] = hash[i-1] * H + s[i]; | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:9:7: note: 'long long unsigned int hash [500005]' 9 | llint hash[500005]; | ^~~~ a.cc:43:47: error: reference to 'hash' is ambiguous 43 | for(int i = 1; i <= n; i++) hash[i] = hash[i-1] * H + s[i]; | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:9:7: note: 'long long unsigned int hash [500005]' 9 | llint hash[500005]; | ^~~~
s553604761
p04018
C++
#include <iostream> #include <vector> #include <string> #include <algorithm> using namespace std; // Sparse Table template<class MeetSemiLattice> struct SparseTable { const MeetSemiLattice INF = 1<<30; vector<vector<MeetSemiLattice> > dat; vector<int> height; SparseTable() { } SparseTable(const vector<int> &vec) { init(vec); } void init(const vector<int> &vec) { int n = (int)vec.size(), h = 0; while ((1<<h) < n) ++h; dat.assign(h, vector<MeetSemiLattice>(1<<h)); height.assign(n+1, 0); for (int i = 2; i <= n; i++) height[i] = height[i>>1]+1; for (int i = 0; i < n; ++i) dat[0][i] = vec[i]; for (int i = 1; i < h; ++i) for (int j = 0; j < n; ++j) dat[i][j] = min(dat[i-1][j], dat[i-1][min(j+(1<<(i-1)),n-1)]); } MeetSemiLattice get(int a, int b) { if (a >= b) return INF; return min(dat[height[b-a]][a], dat[height[b-a]][b-(1<<height[b-a])]); } }; // Suffix Array ( Manber&Myers: O(n (logn)^2) ) struct SuffixArray { string str; vector<int> sa; // sa[i] : the starting index of the i-th smallest suffix (i = 0, 1, ..., n) vector<int> lcp; // lcp[i]: the lcp of sa[i] and sa[i+1] (i = 0, 1, ..., n-1) inline int& operator [] (int i) {return sa[i];} SuffixArray(const string& str_) : str(str_) { buildSA(); calcLCP(); } void init(const string& str_) { str = str_; buildSA(); calcLCP(); } // build SA vector<int> rank_sa, tmp_rank_sa; struct CompareSA { int n, k; const vector<int> &rank; CompareSA(int n, int k, const vector<int> &rank_sa) : n(n), k(k), rank(rank_sa) {} bool operator()(int i, int j) { if (rank[i] != rank[j]) return (rank[i] < rank[j]); else { int rank_ik = (i + k <= n ? rank[i + k] : -1); int rank_jk = (j + k <= n ? rank[j + k] : -1); return (rank_ik < rank_jk); } } }; void buildSA() { int n = (int)str.size(); sa.resize(n+1), lcp.resize(n+1), rank_sa.resize(n+1), tmp_rank_sa.resize(n+1); for (int i = 0; i < n; ++i) sa[i] = i, rank_sa[i] = (int)str[i]; sa[n] = n, rank_sa[n] = -1; for (int k = 1; k <= n; k *= 2) { CompareSA csa(n, k, rank_sa); sort(sa.begin(), sa.end(), csa); tmp_rank_sa[sa[0]] = 0; for (int i = 1; i <= n; ++i) { tmp_rank_sa[sa[i]] = tmp_rank_sa[sa[i - 1]]; if (csa(sa[i - 1], sa[i])) ++tmp_rank_sa[sa[i]]; } for (int i = 0; i <= n; ++i) rank_sa[i] = tmp_rank_sa[i]; } } // build LCP vector<int> rsa; SparseTable<int> st; void calcLCP() { int n = (int)str.size(); rsa.resize(n+1); for (int i = 0; i <= n; ++i) rsa[sa[i]] = i; lcp.resize(n+1); lcp[0] = 0; int cur = 0; for (int i = 0; i < n; ++i) { int pi = sa[rsa[i] - 1]; if (cur > 0) --cur; for (; pi + cur < n && i + cur < n; ++cur) { if (str[pi + cur] != str[i + cur]) break; } lcp[rsa[i] - 1] = cur; } st.init(lcp); } int getLCP(int a, int b) { // lcp of str.sutstr(a) and str.substr(b) return st.get(min(rsa[a], rsa[b]), max(rsa[a], rsa[b])); } }; vector<long long> divisor(long long n) { vector<long long> res; for (long long i = 1LL; i*i <= n; ++i) { if (n%i == 0LL) { res.push_back(i); long long temp = n/i; if (i != temp) res.push_back(temp); } } sort(res.begin(), res.end()); return res; } int main() { string str; cin >> str; int n = (int)str.size(); vector<long long> divs = divisor(n); long long syuuki = n; for (auto d : divs) { bool ok = true; for (int j = 0; j + d < n; ++j) { if (str[j] != str[j+d]) ok = false; } if (ok) syuuki = min(syuuki, d); } if (syuuki == n) cout << 1 << endl << 1 << endl; else if (syuuki == 1) cout << n << endl << 1 << endl; else { vector<int> cannot_cut(n*2, 0); SuffixArray sa(str); for (int d = 1; d < n; ++d) { if (cannot_cut[d]) continue; for (int dd = d*2; dd < n; dd += d) { if (lcp[d] >= dd - d) cannot_cut[dd] = true; if (lcp2[d] >= dd - d) cannot_cut[n-dd] = true; } } int con = 0; for (int i = 1; i < n; ++i) if (!cannot_cut[i]) ++con; cout << 2 << endl << con << endl; } }
a.cc: In function 'int main()': a.cc:133:21: error: 'lcp' was not declared in this scope 133 | if (lcp[d] >= dd - d) cannot_cut[dd] = true; | ^~~ a.cc:134:21: error: 'lcp2' was not declared in this scope 134 | if (lcp2[d] >= dd - d) cannot_cut[n-dd] = true; | ^~~~
s690770834
p04018
C++
#include <iostream> #include <vector> #include <string> using namespace std; struct RollingHash { using ull = unsigned long long; string S_; vector<ull> hash, power; RollingHash(){} RollingHash(const string &S, const ull base = 1000000007LL) : S_(S) { int n = (int)S.size(); hash.assign(n+1, 0); power.assign(n+1, 0); for (int i = 0; i < n; ++i) { hash[i+1] = hash[i] * base + S[i]; power[i+1] = power[i] * base; } } // get hash of S[left:right] ull get(int left, int right) const { return hash[right] - hash[left] * power[right-left]; } // get lcp of S[a:] and S[b:] int getLCP(int a, int b) const { int len = min((int)S_.size() - a, (int)S_.size() - b); int low = -1, high = len + 1; while (high - low > 1) { int mid = (low + high) / 2; if (get(a, a+mid) == get(b, b+mid)) low = mid; else high = mid; } return low; } // get lcp of S[a:] and T[b:] int getLCP(const RollingHash &t, int a, int b) const { int len = min((int)S_.size()-a, (int)t.S_.size()-b); int low = -1, high = len + 1; while (high - low > 1) { int mid = (low + high) / 2; if (get(a, a+mid) == t.get(b, b+mid)) low = mid; else high = mid; } return low; } }; vector<long long> divisor(long long n) { vector<long long> res; for (long long i = 1LL; i*i <= n; ++i) { if (n%i == 0LL) { res.push_back(i); long long temp = n/i; if (i != temp) res.push_back(temp); } } sort(res.begin(), res.end()); return res; } int main() { string str; cin >> str; int n = (int)str.size(); vector<long long> divs = divisor(n); long long syuuki = n; for (auto d : divs) { bool ok = true; for (int j = 0; j + d < n; ++j) { if (str[j] != str[j+d]) ok = false; } if (ok) syuuki = min(syuuki, d); } if (syuuki == n) cout << 1 << endl << 1 << endl; else if (syuuki == 1) cout << n << endl << 1 << endl; else { vector<int> cannot_cut(n*2, 0); RollingHash rh(str); for (int d = 1; d < n; ++d) { for (int dd = d; dd < n; dd += d) { int lcp = rh.getLCP(0, dd); if (lcp < d) break; cannot_cut[dd + d] = true; } for (int dd = n-d*2; dd >= 0; dd -= d) { int lcp = rh.getLCP(dd, n-d); if (lcp < d) break; cannot_cut[dd] = true; } } int con = 0; for (int i = 1; i < n; ++i) if (!cannot_cut[i]) ++con; cout << 2 << endl << con << endl; } }
a.cc: In function 'std::vector<long long int> divisor(long long int)': a.cc:58:5: error: 'sort' was not declared in this scope; did you mean 'short'? 58 | sort(res.begin(), res.end()); | ^~~~ | short