submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s698563328
p00362
C++
#include<bits/stdc++.h> #define U [100005]={} typedef long long L;using namespace std;map<L,L> path U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c,p,r;char s U;D(L a){Z[a]=1;for(map<L,L>::iterator I=path[a].begin();I!=path[a].end();I++){L d=I->first;if(d-P[a]){P[d]=a;E[d]=E[a]+1;C[d]=I->second;D(d);Z[a]+=Z[d];!H[a]|Z[H[a]]<Z[d]?H[a]=d:0;}}}L G(L a){r=A[a]+A[P[a]]+C[a];return r%k?r:0;}L M(L i){for(r=0;i;r+=B[i],i-=i&-i);return r;}L S(L i,L x){for(x=G(x)-M(i+1)+M(i++);i<100005;B[i]+=x,i+=i&-i);}main(){for(cin>>n>>k;p<n-1;p++)cin>>a>>b>>c,path[a][b]=path[b][a]=c;D(0);for(c=p=0;p<n;p++)if(!p|H[P[p]]-p)for(a=p;!c|a;a=H[a])O[a]=c++,X[a]=p,S(O[a],H[a]);for(cin>>a;cin>>s>>a>>b;)if(*s&2){for(c=0;p=X[a],n=X[b],p-n;a=P[p])E[p]<E[n]?swap(p,n),swap(a,b),0:0,c+=M(O[a])-M(O[p])+G(p);cout<<c+abs(M(O[a])-M(O[b]))<<endl;}else A[a]+=b,S(O[a],H[a]),a?S(O[a]-1,a):0;}
a.cc:3:118: error: ISO C++ forbids declaration of 'D' with no type [-fpermissive] 3 | typedef long long L;using namespace std;map<L,L> path U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c,p,r;char s U;D(L a){Z[a]=1;for(map<L,L>::iterator I=path[a].begin();I!=path[a].end();I++){L d=I->first;if(d-P[a]){P[d]=a;E[d]=E[a]+1;C[d]=I->second;D(d);Z[a]+=Z[d];!H[a]|Z[H[a]]<Z[d]?H[a]=d:0;}}}L G(L a){r=A[a]+A[P[a]]+C[a];return r%k?r:0;}L M(L i){for(r=0;i;r+=B[i],i-=i&-i);return r;}L S(L i,L x){for(x=G(x)-M(i+1)+M(i++);i<100005;B[i]+=x,i+=i&-i);}main(){for(cin>>n>>k;p<n-1;p++)cin>>a>>b>>c,path[a][b]=path[b][a]=c;D(0);for(c=p=0;p<n;p++)if(!p|H[P[p]]-p)for(a=p;!c|a;a=H[a])O[a]=c++,X[a]=p,S(O[a],H[a]);for(cin>>a;cin>>s>>a>>b;)if(*s&2){for(c=0;p=X[a],n=X[b],p-n;a=P[p])E[p]<E[n]?swap(p,n),swap(a,b),0:0,c+=M(O[a])-M(O[p])+G(p);cout<<c+abs(M(O[a])-M(O[b]))<<endl;}else A[a]+=b,S(O[a],H[a]),a?S(O[a]-1,a):0;} | ^ a.cc: In function 'int D(L)': a.cc:3:299: warning: no return statement in function returning non-void [-Wreturn-type] 3 | typedef long long L;using namespace std;map<L,L> path U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c,p,r;char s U;D(L a){Z[a]=1;for(map<L,L>::iterator I=path[a].begin();I!=path[a].end();I++){L d=I->first;if(d-P[a]){P[d]=a;E[d]=E[a]+1;C[d]=I->second;D(d);Z[a]+=Z[d];!H[a]|Z[H[a]]<Z[d]?H[a]=d:0;}}}L G(L a){r=A[a]+A[P[a]]+C[a];return r%k?r:0;}L M(L i){for(r=0;i;r+=B[i],i-=i&-i);return r;}L S(L i,L x){for(x=G(x)-M(i+1)+M(i++);i<100005;B[i]+=x,i+=i&-i);}main(){for(cin>>n>>k;p<n-1;p++)cin>>a>>b>>c,path[a][b]=path[b][a]=c;D(0);for(c=p=0;p<n;p++)if(!p|H[P[p]]-p)for(a=p;!c|a;a=H[a])O[a]=c++,X[a]=p,S(O[a],H[a]);for(cin>>a;cin>>s>>a>>b;)if(*s&2){for(c=0;p=X[a],n=X[b],p-n;a=P[p])E[p]<E[n]?swap(p,n),swap(a,b),0:0,c+=M(O[a])-M(O[p])+G(p);cout<<c+abs(M(O[a])-M(O[b]))<<endl;}else A[a]+=b,S(O[a],H[a]),a?S(O[a]-1,a):0;} | ^ a.cc: In function 'L S(L, L)': a.cc:3:455: warning: no return statement in function returning non-void [-Wreturn-type] 3 | typedef long long L;using namespace std;map<L,L> path U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c,p,r;char s U;D(L a){Z[a]=1;for(map<L,L>::iterator I=path[a].begin();I!=path[a].end();I++){L d=I->first;if(d-P[a]){P[d]=a;E[d]=E[a]+1;C[d]=I->second;D(d);Z[a]+=Z[d];!H[a]|Z[H[a]]<Z[d]?H[a]=d:0;}}}L G(L a){r=A[a]+A[P[a]]+C[a];return r%k?r:0;}L M(L i){for(r=0;i;r+=B[i],i-=i&-i);return r;}L S(L i,L x){for(x=G(x)-M(i+1)+M(i++);i<100005;B[i]+=x,i+=i&-i);}main(){for(cin>>n>>k;p<n-1;p++)cin>>a>>b>>c,path[a][b]=path[b][a]=c;D(0);for(c=p=0;p<n;p++)if(!p|H[P[p]]-p)for(a=p;!c|a;a=H[a])O[a]=c++,X[a]=p,S(O[a],H[a]);for(cin>>a;cin>>s>>a>>b;)if(*s&2){for(c=0;p=X[a],n=X[b],p-n;a=P[p])E[p]<E[n]?swap(p,n),swap(a,b),0:0,c+=M(O[a])-M(O[p])+G(p);cout<<c+abs(M(O[a])-M(O[b]))<<endl;}else A[a]+=b,S(O[a],H[a]),a?S(O[a]-1,a):0;} | ^ a.cc: At global scope: a.cc:3:456: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 3 | typedef long long L;using namespace std;map<L,L> path U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c,p,r;char s U;D(L a){Z[a]=1;for(map<L,L>::iterator I=path[a].begin();I!=path[a].end();I++){L d=I->first;if(d-P[a]){P[d]=a;E[d]=E[a]+1;C[d]=I->second;D(d);Z[a]+=Z[d];!H[a]|Z[H[a]]<Z[d]?H[a]=d:0;}}}L G(L a){r=A[a]+A[P[a]]+C[a];return r%k?r:0;}L M(L i){for(r=0;i;r+=B[i],i-=i&-i);return r;}L S(L i,L x){for(x=G(x)-M(i+1)+M(i++);i<100005;B[i]+=x,i+=i&-i);}main(){for(cin>>n>>k;p<n-1;p++)cin>>a>>b>>c,path[a][b]=path[b][a]=c;D(0);for(c=p=0;p<n;p++)if(!p|H[P[p]]-p)for(a=p;!c|a;a=H[a])O[a]=c++,X[a]=p,S(O[a],H[a]);for(cin>>a;cin>>s>>a>>b;)if(*s&2){for(c=0;p=X[a],n=X[b],p-n;a=P[p])E[p]<E[n]?swap(p,n),swap(a,b),0:0,c+=M(O[a])-M(O[p])+G(p);cout<<c+abs(M(O[a])-M(O[b]))<<endl;}else A[a]+=b,S(O[a],H[a]),a?S(O[a]-1,a):0;} | ^~~~
s860834931
p00362
C++
#include<bits/stdc++.h> #define U [100005]={} typedef long long L;using namespace std;map<L,L> path U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c,p,r;char s U; L D(L a){Z[a]=1; for(map<L,L>::iterator I=path[a].begin();I!=path[a].end();L d=I->first,I++){ ;if(d-P[a]){P[d]=a;E[d]=E[a]+1;C[d]=I->second;D(d);Z[a]+=Z[d];!H[a]|Z[H[a]]<Z[d]?H[a]=d:0; } } } L G(L a){r=A[a]+A[P[a]]+C[a];return r%k?r:0;}L M(L i){for(r=0;i;r+=B[i],i-=i&-i);return r;}L S(L i,L x){for(x=G(x)-M(i+1)+M(i++);i<100005;B[i]+=x,i+=i&-i);}main(){for(cin>>n>>k;p<n-1;p++)cin>>a>>b>>c,path[a][b]=path[b][a]=c;D(0);for(c=p=0;p<n;p++)if(!p|H[P[p]]-p)for(a=p;!c|a;a=H[a])O[a]=c++,X[a]=p,S(O[a],H[a]);for(cin>>a;cin>>s>>a>>b;)if(*s&2){for(c=0;p=X[a],n=X[b],p-n;a=P[p])E[p]<E[n]?swap(p,n),swap(a,b),0:0,c+=M(O[a])-M(O[p])+G(p);cout<<c+abs(M(O[a])-M(O[b]))<<endl;}else A[a]+=b,S(O[a],H[a]),a?S(O[a]-1,a):0;}
a.cc: In function 'L D(L)': a.cc:5:61: error: expected primary-expression before 'd' 5 | for(map<L,L>::iterator I=path[a].begin();I!=path[a].end();L d=I->first,I++){ | ^ a.cc:5:60: error: expected ')' before 'd' 5 | for(map<L,L>::iterator I=path[a].begin();I!=path[a].end();L d=I->first,I++){ | ~ ^~ | ) a.cc:5:61: error: 'd' was not declared in this scope 5 | for(map<L,L>::iterator I=path[a].begin();I!=path[a].end();L d=I->first,I++){ | ^ a.cc:9:1: warning: no return statement in function returning non-void [-Wreturn-type] 9 | } | ^ a.cc: In function 'L S(L, L)': a.cc:11:156: warning: no return statement in function returning non-void [-Wreturn-type] 11 | L G(L a){r=A[a]+A[P[a]]+C[a];return r%k?r:0;}L M(L i){for(r=0;i;r+=B[i],i-=i&-i);return r;}L S(L i,L x){for(x=G(x)-M(i+1)+M(i++);i<100005;B[i]+=x,i+=i&-i);}main(){for(cin>>n>>k;p<n-1;p++)cin>>a>>b>>c,path[a][b]=path[b][a]=c;D(0);for(c=p=0;p<n;p++)if(!p|H[P[p]]-p)for(a=p;!c|a;a=H[a])O[a]=c++,X[a]=p,S(O[a],H[a]);for(cin>>a;cin>>s>>a>>b;)if(*s&2){for(c=0;p=X[a],n=X[b],p-n;a=P[p])E[p]<E[n]?swap(p,n),swap(a,b),0:0,c+=M(O[a])-M(O[p])+G(p);cout<<c+abs(M(O[a])-M(O[b]))<<endl;}else A[a]+=b,S(O[a],H[a]),a?S(O[a]-1,a):0;} | ^ a.cc: At global scope: a.cc:11:157: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 11 | L G(L a){r=A[a]+A[P[a]]+C[a];return r%k?r:0;}L M(L i){for(r=0;i;r+=B[i],i-=i&-i);return r;}L S(L i,L x){for(x=G(x)-M(i+1)+M(i++);i<100005;B[i]+=x,i+=i&-i);}main(){for(cin>>n>>k;p<n-1;p++)cin>>a>>b>>c,path[a][b]=path[b][a]=c;D(0);for(c=p=0;p<n;p++)if(!p|H[P[p]]-p)for(a=p;!c|a;a=H[a])O[a]=c++,X[a]=p,S(O[a],H[a]);for(cin>>a;cin>>s>>a>>b;)if(*s&2){for(c=0;p=X[a],n=X[b],p-n;a=P[p])E[p]<E[n]?swap(p,n),swap(a,b),0:0,c+=M(O[a])-M(O[p])+G(p);cout<<c+abs(M(O[a])-M(O[b]))<<endl;}else A[a]+=b,S(O[a],H[a]),a?S(O[a]-1,a):0;} | ^~~~
s442806243
p00362
C++
#include<bits/stdc++.h> #define U [100005]={} typedef long long L;using namespace std;map<L,L> path U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c,p,r;char s U; L D(L a){Z[a]=1; for(map<L,L>::iterator I=path[a].begin(),L d;I!=path[a].end();I++){ d=I->first;if(d-P[a]){P[d]=a;E[d]=E[a]+1;C[d]=I->second;D(d);Z[a]+=Z[d];!H[a]|Z[H[a]]<Z[d]?H[a]=d:0; } } } L G(L a){r=A[a]+A[P[a]]+C[a];return r%k?r:0;}L M(L i){for(r=0;i;r+=B[i],i-=i&-i);return r;}L S(L i,L x){for(x=G(x)-M(i+1)+M(i++);i<100005;B[i]+=x,i+=i&-i);}main(){for(cin>>n>>k;p<n-1;p++)cin>>a>>b>>c,path[a][b]=path[b][a]=c;D(0);for(c=p=0;p<n;p++)if(!p|H[P[p]]-p)for(a=p;!c|a;a=H[a])O[a]=c++,X[a]=p,S(O[a],H[a]);for(cin>>a;cin>>s>>a>>b;)if(*s&2){for(c=0;p=X[a],n=X[b],p-n;a=P[p])E[p]<E[n]?swap(p,n),swap(a,b),0:0,c+=M(O[a])-M(O[p])+G(p);cout<<c+abs(M(O[a])-M(O[b]))<<endl;}else A[a]+=b,S(O[a],H[a]),a?S(O[a]-1,a):0;}
a.cc: In function 'L D(L)': a.cc:5:43: error: expected ';' before 'd' 5 | for(map<L,L>::iterator I=path[a].begin(),L d;I!=path[a].end();I++){ | ^~ | ; a.cc:5:44: error: 'd' was not declared in this scope 5 | for(map<L,L>::iterator I=path[a].begin(),L d;I!=path[a].end();I++){ | ^ a.cc:5:62: error: expected ')' before ';' token 5 | for(map<L,L>::iterator I=path[a].begin(),L d;I!=path[a].end();I++){ | ~ ^ | ) a.cc:5:63: error: 'I' was not declared in this scope 5 | for(map<L,L>::iterator I=path[a].begin(),L d;I!=path[a].end();I++){ | ^ a.cc:9:1: warning: no return statement in function returning non-void [-Wreturn-type] 9 | } | ^ a.cc: In function 'L S(L, L)': a.cc:11:156: warning: no return statement in function returning non-void [-Wreturn-type] 11 | L G(L a){r=A[a]+A[P[a]]+C[a];return r%k?r:0;}L M(L i){for(r=0;i;r+=B[i],i-=i&-i);return r;}L S(L i,L x){for(x=G(x)-M(i+1)+M(i++);i<100005;B[i]+=x,i+=i&-i);}main(){for(cin>>n>>k;p<n-1;p++)cin>>a>>b>>c,path[a][b]=path[b][a]=c;D(0);for(c=p=0;p<n;p++)if(!p|H[P[p]]-p)for(a=p;!c|a;a=H[a])O[a]=c++,X[a]=p,S(O[a],H[a]);for(cin>>a;cin>>s>>a>>b;)if(*s&2){for(c=0;p=X[a],n=X[b],p-n;a=P[p])E[p]<E[n]?swap(p,n),swap(a,b),0:0,c+=M(O[a])-M(O[p])+G(p);cout<<c+abs(M(O[a])-M(O[b]))<<endl;}else A[a]+=b,S(O[a],H[a]),a?S(O[a]-1,a):0;} | ^ a.cc: At global scope: a.cc:11:157: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 11 | L G(L a){r=A[a]+A[P[a]]+C[a];return r%k?r:0;}L M(L i){for(r=0;i;r+=B[i],i-=i&-i);return r;}L S(L i,L x){for(x=G(x)-M(i+1)+M(i++);i<100005;B[i]+=x,i+=i&-i);}main(){for(cin>>n>>k;p<n-1;p++)cin>>a>>b>>c,path[a][b]=path[b][a]=c;D(0);for(c=p=0;p<n;p++)if(!p|H[P[p]]-p)for(a=p;!c|a;a=H[a])O[a]=c++,X[a]=p,S(O[a],H[a]);for(cin>>a;cin>>s>>a>>b;)if(*s&2){for(c=0;p=X[a],n=X[b],p-n;a=P[p])E[p]<E[n]?swap(p,n),swap(a,b),0:0,c+=M(O[a])-M(O[p])+G(p);cout<<c+abs(M(O[a])-M(O[b]))<<endl;}else A[a]+=b,S(O[a],H[a]),a?S(O[a]-1,a):0;} | ^~~~
s577130035
p00362
C++
#include<bits/stdc++.h> #define U [1<<17]={} #define G(a)((c=A[a]+A[P[a]]+C[a])%k?c:0) typedef long long L;using namespace std; map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U; L D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++) d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]&&H[a]=d:0;} L M(L i){return i?B[i]+M(i^i&-i):0;} L S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1e5;i+=i&-i)B[i]+=x;} L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G(a)+K(P[a]):abs(M(O[f])-M(O[b]));} main(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c; for(D(b=0);n<*Z;n++)if(!n|H[P[a=n]]-n)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=n; for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));}
a.cc: In function 'L D(L)': a.cc:7:95: error: lvalue required as left operand of assignment 7 | d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]&&H[a]=d:0;} | ~~~~~~~~~~~~~~~~~~^~~~~~ a.cc:7:106: warning: no return statement in function returning non-void [-Wreturn-type] 7 | d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]&&H[a]=d:0;} | ^ a.cc: In function 'L S(L, L)': a.cc:9:59: warning: no return statement in function returning non-void [-Wreturn-type] 9 | L S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1e5;i+=i&-i)B[i]+=x;} | ^ a.cc: At global scope: a.cc:11:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 11 | main(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c; | ^~~~
s592863098
p00362
C++
#include<bits/stdc++.h> #define U [1<<17]={} #define G(a)((c=A[a]+A[P[a]]+C[a])%k?c:0) typedef long long L;using namespace std;ap<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U; D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;} M(L i){return i?B[i]+M(i^i&-i):0;} S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1e5;i+=i&-i)B[i]+=x;} K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G(a)+K(P[a]):abs(M(O[f])-M(O[b]));}ain(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(b=0);n<*Z;n++)if(!n|H[P[a=n]]-n)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=n;for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));}
a.cc:4:41: error: 'ap' does not name a type 4 | typedef long long L;using namespace std;ap<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U; D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;} M(L i){return i?B[i]+M(i^i&-i):0;} S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1e5;i+=i&-i)B[i]+=x;} K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G(a)+K(P[a]):abs(M(O[f])-M(O[b]));}ain(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(b=0);n<*Z;n++)if(!n|H[P[a=n]]-n)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=n;for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));} | ^~ a.cc:4:110: error: ISO C++ forbids declaration of 'D' with no type [-fpermissive] 4 | typedef long long L;using namespace std;ap<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U; D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;} M(L i){return i?B[i]+M(i^i&-i):0;} S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1e5;i+=i&-i)B[i]+=x;} K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G(a)+K(P[a]):abs(M(O[f])-M(O[b]));}ain(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(b=0);n<*Z;n++)if(!n|H[P[a=n]]-n)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=n;for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));} | ^ a.cc: In function 'int D(L)': a.cc:4:153: error: 'T' was not declared in this scope 4 | typedef long long L;using namespace std;ap<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U; D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;} M(L i){return i?B[i]+M(i^i&-i):0;} S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1e5;i+=i&-i)B[i]+=x;} K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G(a)+K(P[a]):abs(M(O[f])-M(O[b]));}ain(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(b=0);n<*Z;n++)if(!n|H[P[a=n]]-n)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=n;for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));} | ^ a.cc:4:282: warning: no return statement in function returning non-void [-Wreturn-type] 4 | typedef long long L;using namespace std;ap<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U; D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;} M(L i){return i?B[i]+M(i^i&-i):0;} S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1e5;i+=i&-i)B[i]+=x;} K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G(a)+K(P[a]):abs(M(O[f])-M(O[b]));}ain(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(b=0);n<*Z;n++)if(!n|H[P[a=n]]-n)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=n;for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));} | ^ a.cc: At global scope: a.cc:4:284: error: ISO C++ forbids declaration of 'M' with no type [-fpermissive] 4 | typedef long long L;using namespace std;ap<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U; D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;} M(L i){return i?B[i]+M(i^i&-i):0;} S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1e5;i+=i&-i)B[i]+=x;} K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G(a)+K(P[a]):abs(M(O[f])-M(O[b]));}ain(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(b=0);n<*Z;n++)if(!n|H[P[a=n]]-n)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=n;for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));} | ^ a.cc:4:319: error: ISO C++ forbids declaration of 'S' with no type [-fpermissive] 4 | typedef long long L;using namespace std;ap<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U; D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;} M(L i){return i?B[i]+M(i^i&-i):0;} S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1e5;i+=i&-i)B[i]+=x;} K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G(a)+K(P[a]):abs(M(O[f])-M(O[b]));}ain(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(b=0);n<*Z;n++)if(!n|H[P[a=n]]-n)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=n;for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));} | ^ a.cc: In function 'int S(L, L)': a.cc:4:375: warning: no return statement in function returning non-void [-Wreturn-type] 4 | typedef long long L;using namespace std;ap<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U; D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;} M(L i){return i?B[i]+M(i^i&-i):0;} S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1e5;i+=i&-i)B[i]+=x;} K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G(a)+K(P[a]):abs(M(O[f])-M(O[b]));}ain(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(b=0);n<*Z;n++)if(!n|H[P[a=n]]-n)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=n;for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));} | ^ a.cc: At global scope: a.cc:4:377: error: ISO C++ forbids declaration of 'K' with no type [-fpermissive] 4 | typedef long long L;using namespace std;ap<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U; D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;} M(L i){return i?B[i]+M(i^i&-i):0;} S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1e5;i+=i&-i)B[i]+=x;} K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G(a)+K(P[a]):abs(M(O[f])-M(O[b]));}ain(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(b=0);n<*Z;n++)if(!n|H[P[a=n]]-n)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=n;for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));} | ^ a.cc:4:484: error: ISO C++ forbids declaration of 'ain' with no type [-fpermissive] 4 | typedef long long L;using namespace std;ap<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U; D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;} M(L i){return i?B[i]+M(i^i&-i):0;} S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1e5;i+=i&-i)B[i]+=x;} K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G(a)+K(P[a]):abs(M(O[f])-M(O[b]));}ain(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(b=0);n<*Z;n++)if(!n|H[P[a=n]]-n)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=n;for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));} | ^~~ a.cc: In function 'int ain()': a.cc:4:508: error: 'T' was not declared in this scope 4 | typedef long long L;using namespace std;ap<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U; D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;} M(L i){return i?B[i]+M(i^i&-i):0;} S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1e5;i+=i&-i)B[i]+=x;} K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G(a)+K(P[a]):abs(M(O[f])-M(O[b]))
s851682370
p00362
C++
#include<bits/stdc++.h> #define U [1<<17]={} #define G(a)((c=A[a]+A[P[a]]+C[a])%k?c:0) #define F(x,z)L x(L f){return z;}L y(L typedef long long L;using namespace std; map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U; F(M,f?B[f]+M(f^f&-f):0,D) a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++) d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;} F(K,(a=X[f],n=X[b],a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G(a)+K(P[a]):abs(M(O[f])-M(O[b]))),S) x,L i){for(x=G(x)+M(i++)-M(i);i<1e5;i+=i&-i)B[i]+=x;} main(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c; for(D(b=0);n<*Z;n++)if(!n|H[P[a=n]]-n)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=n; for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));}
a.cc:7:25: error: macro "F" passed 3 arguments, but takes just 2 7 | F(M,f?B[f]+M(f^f&-f):0,D) | ^ a.cc:4:9: note: macro "F" defined here 4 | #define F(x,z)L x(L f){return z;}L y(L | ^ a.cc:10:100: error: macro "F" passed 3 arguments, but takes just 2 10 | F(K,(a=X[f],n=X[b],a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G(a)+K(P[a]):abs(M(O[f])-M(O[b]))),S) | ^ a.cc:4:9: note: macro "F" defined here 4 | #define F(x,z)L x(L f){return z;}L y(L | ^ a.cc:7:1: error: 'F' does not name a type 7 | F(M,f?B[f]+M(f^f&-f):0,D) | ^ a.cc:10:1: error: 'F' does not name a type 10 | F(K,(a=X[f],n=X[b],a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G(a)+K(P[a]):abs(M(O[f])-M(O[b]))),S) | ^ a.cc:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 12 | main(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c; | ^~~~ a.cc: In function 'int main()': a.cc:13:13: error: 'D' was not declared in this scope 13 | for(D(b=0);n<*Z;n++)if(!n|H[P[a=n]]-n)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=n; | ^ a.cc:13:57: error: 'S' was not declared in this scope 13 | for(D(b=0);n<*Z;n++)if(!n|H[P[a=n]]-n)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=n; | ^ a.cc:14:44: error: 'K' was not declared in this scope 14 | for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));} | ^ a.cc:14:65: error: 'S' was not declared in this scope 14 | for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));} | ^
s499930950
p00362
C++
#include<bits/stdc++.h> #define U [1<<17]={} #define G(a)((c=A[a]+A[P[a]]+C[a])%k?c:0) typedef long long L;using namespace std; map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U; L D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++) d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;} L M(L i){return i?B[i]+M(i^i&-i):0;} L S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1e5;i+=i&-i)B[i]+=x;} L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G(a)+K(P[a]):abs(M(O[f])-M(O[b]));} main(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c; for(D(a=b=0);n<*Z;a=H[P[++n]]-n?n:0)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=n; // n++)if(!n|H[P[a=n]]-n) for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));}
a.cc: In function 'L D(L)': a.cc:7:107: warning: no return statement in function returning non-void [-Wreturn-type] 7 | d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;} | ^ a.cc: In function 'L S(L, L)': a.cc:9:59: warning: no return statement in function returning non-void [-Wreturn-type] 9 | L S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1e5;i+=i&-i)B[i]+=x;} | ^ a.cc: At global scope: a.cc:11:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 11 | main(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c; | ^~~~ a.cc: In function 'int main()': a.cc:14:37: error: operands to '?:' have different types 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} and 'L' {aka 'long long int'} 14 | for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));} | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
s018331654
p00362
C++
#include<bits/stdc++.h> #define U [1<<17]={} #define G((c=A[a]+A[P[a]]+C[a])%k?c:0) typedef long long L;using namespace std; map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U; L D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++) d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;} L M(L i){return i?B[i]+M(i^i&-i):0;} L S(L a,L i){for(a=M(i++)+G-M(i);i<1e5;i+=i&-i)B[i]+=a;} L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G+K(P[a]):abs(M(O[f])-M(O[b]));} main(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c; for(D(a=b=0);n<*Z;a=H[P[++n]]-n?n:0)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=n; for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));}
a.cc:3:11: error: expected parameter name, found "(" 3 | #define G((c=A[a]+A[P[a]]+C[a])%k?c:0) | ^ a.cc: In function 'L D(L)': a.cc:7:107: warning: no return statement in function returning non-void [-Wreturn-type] 7 | d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;} | ^ a.cc: In function 'L S(L, L)': a.cc:9:27: error: 'G' was not declared in this scope 9 | L S(L a,L i){for(a=M(i++)+G-M(i);i<1e5;i+=i&-i)B[i]+=a;} | ^ a.cc:9:56: warning: no return statement in function returning non-void [-Wreturn-type] 9 | L S(L a,L i){for(a=M(i++)+G-M(i);i<1e5;i+=i&-i)B[i]+=a;} | ^ a.cc: In function 'L K(L)': a.cc:10:75: error: 'G' was not declared in this scope 10 | L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G+K(P[a]):abs(M(O[f])-M(O[b]));} | ^ a.cc: At global scope: a.cc:11:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 11 | main(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c; | ^~~~
s949363641
p00362
C++
#include<bits/stdc++.h> #define U [7<<15]={} #define G )+((c=A[a]+A[P[a]]+C[a])%k?c:0)-M( typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f){return f?B[f]+M(f^f&-f):0;}L S(L f,L i){for(f=M(i++G i);i<2e5;i+=i&-i)B[i]+=f;}L D(L f){L d;Z[f]=1;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,!Z[d]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,D(d),Z[f]+=Z[d],!H[f]|Z[H[f]]<Z[d]?H[f]=d:0:0;}aL K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}amain(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(a=b=0);n<*Z;a=H[P[++n]]-n?n:0)for(;!b|a;S(a=H[a],O[a]=++b))X[a]=n;for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}
a.cc: In function 'L S(L, L)': a.cc:4:197: warning: no return statement in function returning non-void [-Wreturn-type] 4 | typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f){return f?B[f]+M(f^f&-f):0;}L S(L f,L i){for(f=M(i++G i);i<2e5;i+=i&-i)B[i]+=f;}L D(L f){L d;Z[f]=1;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,!Z[d]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,D(d),Z[f]+=Z[d],!H[f]|Z[H[f]]<Z[d]?H[f]=d:0:0;}aL K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}amain(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(a=b=0);n<*Z;a=H[P[++n]]-n?n:0)for(;!b|a;S(a=H[a],O[a]=++b))X[a]=n;for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;} | ^ a.cc: In function 'L D(L)': a.cc:4:371: warning: no return statement in function returning non-void [-Wreturn-type] 4 | typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f){return f?B[f]+M(f^f&-f):0;}L S(L f,L i){for(f=M(i++G i);i<2e5;i+=i&-i)B[i]+=f;}L D(L f){L d;Z[f]=1;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,!Z[d]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,D(d),Z[f]+=Z[d],!H[f]|Z[H[f]]<Z[d]?H[f]=d:0:0;}aL K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}amain(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(a=b=0);n<*Z;a=H[P[++n]]-n?n:0)for(;!b|a;S(a=H[a],O[a]=++b))X[a]=n;for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;} | ^ a.cc: At global scope: a.cc:4:372: error: 'aL' does not name a type; did you mean 'L'? 4 | typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f){return f?B[f]+M(f^f&-f):0;}L S(L f,L i){for(f=M(i++G i);i<2e5;i+=i&-i)B[i]+=f;}L D(L f){L d;Z[f]=1;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,!Z[d]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,D(d),Z[f]+=Z[d],!H[f]|Z[H[f]]<Z[d]?H[f]=d:0:0;}aL K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}amain(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(a=b=0);n<*Z;a=H[P[++n]]-n?n:0)for(;!b|a;S(a=H[a],O[a]=++b))X[a]=n;for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;} | ^~ | L a.cc:4:475: error: ISO C++ forbids declaration of 'amain' with no type [-fpermissive] 4 | typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f){return f?B[f]+M(f^f&-f):0;}L S(L f,L i){for(f=M(i++G i);i<2e5;i+=i&-i)B[i]+=f;}L D(L f){L d;Z[f]=1;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,!Z[d]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,D(d),Z[f]+=Z[d],!H[f]|Z[H[f]]<Z[d]?H[f]=d:0:0;}aL K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}amain(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(a=b=0);n<*Z;a=H[P[++n]]-n?n:0)for(;!b|a;S(a=H[a],O[a]=++b))X[a]=n;for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;} | ^~~~~ a.cc: In function 'int amain()': a.cc:4:664: error: 'K' was not declared in this scope 4 | typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f){return f?B[f]+M(f^f&-f):0;}L S(L f,L i){for(f=M(i++G i);i<2e5;i+=i&-i)B[i]+=f;}L D(L f){L d;Z[f]=1;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,!Z[d]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,D(d),Z[f]+=Z[d],!H[f]|Z[H[f]]<Z[d]?H[f]=d:0:0;}aL K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}amain(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(a=b=0);n<*Z;a=H[P[++n]]-n?n:0)for(;!b|a;S(a=H[a],O[a]=++b))X[a]=n;for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;} | ^ a.cc:4:685: warning: no return statement in function returning non-void [-Wreturn-type] 4 | typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f){return f?B[f]+M(f^f&-f):0;}L S(L f,L i){for(f=M(i++G i);i<2e5;i+=i&-i)B[i]+=f;}L D(L f){L d;Z[f]=1;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,!Z[d]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,D(d),Z[f]+=Z[d],!H[f]|Z[H[f]]<Z[d]?H[f]=d:0:0;}aL K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}amain(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(a=b=0);n<*Z;a=H[P[++n]]-n?n:0)for(;!b|a;S(a=H[a],O[a]=++b))X[a]=n;for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;} | ^
s949901386
p00362
C++
#include<bits/stdc++.h> #define U [7<<15]={} #define G )+((c=A[a]+A[P[a]]+C[a])%k?c:0)-M( typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f){return f?B[f]+M(f^f&-f):0;}L S(L a,L i){for(a=M(i++G i);i<2e5;i+=i&-i)B[i]+=a;}L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,d&&!E[d]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,D(d),Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(a=n=0);Z[n];a=H[P[++n]]-n?n:0)for(;!O[a];S(a=H[a],O[a]=++b))X[a]=n;PRINT();for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}
a.cc: In function 'L S(L, L)': a.cc:4:197: warning: no return statement in function returning non-void [-Wreturn-type] 4 | typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f){return f?B[f]+M(f^f&-f):0;}L S(L a,L i){for(a=M(i++G i);i<2e5;i+=i&-i)B[i]+=a;}L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,d&&!E[d]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,D(d),Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(a=n=0);Z[n];a=H[P[++n]]-n?n:0)for(;!O[a];S(a=H[a],O[a]=++b))X[a]=n;PRINT();for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;} | ^ a.cc: In function 'L D(L)': a.cc:4:363: warning: no return statement in function returning non-void [-Wreturn-type] 4 | typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f){return f?B[f]+M(f^f&-f):0;}L S(L a,L i){for(a=M(i++G i);i<2e5;i+=i&-i)B[i]+=a;}L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,d&&!E[d]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,D(d),Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(a=n=0);Z[n];a=H[P[++n]]-n?n:0)for(;!O[a];S(a=H[a],O[a]=++b))X[a]=n;PRINT();for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;} | ^ a.cc: At global scope: a.cc:4:466: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 4 | typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f){return f?B[f]+M(f^f&-f):0;}L S(L a,L i){for(a=M(i++G i);i<2e5;i+=i&-i)B[i]+=a;}L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,d&&!E[d]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,D(d),Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(a=n=0);Z[n];a=H[P[++n]]-n?n:0)for(;!O[a];S(a=H[a],O[a]=++b))X[a]=n;PRINT();for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;} | ^~~~ a.cc: In function 'int main()': a.cc:4:598: error: 'PRINT' was not declared in this scope 4 | typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f){return f?B[f]+M(f^f&-f):0;}L S(L a,L i){for(a=M(i++G i);i<2e5;i+=i&-i)B[i]+=a;}L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,d&&!E[d]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,D(d),Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(a=n=0);Z[n];a=H[P[++n]]-n?n:0)for(;!O[a];S(a=H[a],O[a]=++b))X[a]=n;PRINT();for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;} | ^~~~~
s639250939
p00362
C++
#include<bits/stdc++.h> #define U [7<<15]={} #define G )+((c=A[a]+A[P[a]]+C[a])%k?c:0)-M( typedef long long L;using namespace std;map<L,L>T U;L P U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U; L M(L f){return f?B[f]+M(f^f&-f):0;} L S(L a,L i){for(a=M(i++G i);i<2e5;i+=i&-i)B[i]+=a;} L D(L f){for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++) L d=I->first,d-P[f]?P[d]=f,C[d]=I->second,D(d),Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;} L K(L f){a=X[f];n=X[b];return a-n?M(O[Z[a]>Z[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));} main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c; for(D(n=0);Z[a=H[P[n]]-n?n:0];*Z=++n)for(;!O[a];S(a=H[a],O[a]=++b))X[a]=n; for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}
a.cc: In function 'L S(L, L)': a.cc:6:52: warning: no return statement in function returning non-void [-Wreturn-type] 6 | L S(L a,L i){for(a=M(i++G i);i<2e5;i+=i&-i)B[i]+=a;} | ^ a.cc: In function 'L D(L)': a.cc:8:19: error: expected initializer before '-' token 8 | L d=I->first,d-P[f]?P[d]=f,C[d]=I->second,D(d),Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;} | ^ a.cc:8:89: warning: no return statement in function returning non-void [-Wreturn-type] 8 | L d=I->first,d-P[f]?P[d]=f,C[d]=I->second,D(d),Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;} | ^ a.cc: At global scope: a.cc:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 10 | main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c; | ^~~~
s811414866
p00362
C++
#include<bits/stdc++.h> using namespace std; using Int = long long; struct HLDecomposition { Int n,pos; struct edge{ Int to,cost; edge(){} edge(Int to,Int cost):to(to),cost(cost){} }; vector<vector<edge> > G; vector<Int> vid, head, sub, hvy, par, dep, inv, type; HLDecomposition(){} HLDecomposition(Int sz): n(sz),pos(0),G(n), vid(n,-1),head(n),sub(n,1),hvy(n,-1), par(n),dep(n),inv(n),type(n){} void add_edge(Int u, Int v,Int c) { G[u].emplace_back(v,c); G[v].emplace_back(u,c); } void build(vector<Int> rs=vector<Int>(1,0)) { Int c=0; for(Int r:rs){ dfs(r); bfs(r, c++); } } void dfs(Int rt) { using T = pair<Int,int>; stack<T> st; par[rt]=-1; dep[rt]=0; st.emplace(rt,0); while(!st.empty()){ Int v=st.top().first; Int &i=st.top().second; if(i<(Int)G[v].size()){ Int u=G[v][i].to,c=G[v][i].cost; i++; if(u==par[v]) continue; par[u]=v; dep[u]=dep[v]+c; st.emplace(u,0); }else{ st.pop(); Int res=0; for(edge e:G[v]){ Int u=e.to; if(u==par[v]) continue; sub[v]+=sub[u]; if(res<sub[u]) res=sub[u],hvy[v]=u; } } } } void bfs(Int r,Int c) { Int &k=pos; queue<Int> q({r}); while(!q.empty()){ Int h=q.front();q.pop(); for(Int i=h;i!=-1;i=hvy[i]) { type[i]=c; vid[i]=k++; inv[vid[i]]=i; head[i]=h; for(edge e:G[i]){ Int j=e.to; if(j!=par[i]&&j!=hvy[i]) q.push(j); } } } } // for_each(vertex) // [l,r] <- attention!! void for_each(Int u, Int v, const function<void(Int, Int)>& f) { while(1){ if(vid[u]>vid[v]) swap(u,v); f(max(vid[head[v]],vid[u]),vid[v]); if(head[u]!=head[v]) v=par[head[v]]; else break; } } // for_each(edge) // [l,r] <- attention!! void for_each_edge(Int u, Int v, const function<void(Int, Int)>& f) { while(1){ if(vid[u]>vid[v]) swap(u,v); if(head[u]!=head[v]){ f(vid[head[v]],vid[v]); v=par[head[v]]; } else{ if(u!=v) f(vid[u]+1,vid[v]); break; } } } Int lca(Int u,Int v){ while(1){ if(vid[u]>vid[v]) swap(u,v); if(head[u]==head[v]) return u; v=par[head[v]]; } } Int distance(Int u,Int v){ return dep[u]+dep[v]-2*dep[lca(u,v)]; } }; template <typename T,typename E> struct SegmentTree{ typedef function<T(T,T)> F; typedef function<T(T,E)> G; Int n; F f; G g; T d1; E d0; vector<T> dat; SegmentTree(){}; SegmentTree(Int n_,F f,G g,T d1, vector<T> v=vector<T>()): f(f),g(g),d1(d1){ init(n_); if(n_==(Int)v.size()) build(n_,v); } void init(Int n_){ n=1; while(n<n_) n*=2; dat.clear(); dat.resize(2*n-1,d1); } void build(Int n_, vector<T> v){ for(Int i=0;i<n_;i++) dat[i+n-1]=v[i]; for(Int i=n-2;i>=0;i--) dat[i]=f(dat[i*2+1],dat[i*2+2]); } void update(Int k,E a){ k+=n-1; dat[k]=g(dat[k],a); while(k>0){ k=(k-1)/2; dat[k]=f(dat[k*2+1],dat[k*2+2]); } } inline T query(Int a,Int b){ T vl=d1,vr=d1; for(Int l=a+n,r=b+n;l<r;l>>=1,r>>=1) { if(l&1) vl=f(vl,dat[(l++)-1]); if(r&1) vr=f(dat[(--r)-1],vr); } return f(vl,vr); } }; signed main(){ Int n,k; cin>>n>>k; HLDecomposition hld(n); for(Int i=0;i<n-1;i++){ Int a,b,c; cin>>a>>b>>c; hld.add_edge(a,b,c); } hld.build(); vector<Int> w(n,0); using T = tuple<Int, Int, Int>; auto con=[&](Int a,Int b){ return hld.par[a]==b||hld.par[b]==a; }; auto mget=[&](Int a,Int b){ if(!con(a,b)) return 0LL; Int res=w[a]+w[b]+abs(hld.dep[a]-hld.dep[b]); if(res%k) return res; return 0LL; }; auto f=[&](T a,T b){ if(a>b) swap(a,b); Int al,ar,av; tie(al,ar,av)=a; Int bl,br,bv; tie(bl,br,bv)=b; if(al<0||ar<0) return b; Int cl,cr,cv=av+bv; if(con(al,bl)){ cl=ar;cr=br; cv+=mget(al,bl); }else if(con(al,br)){ cl=ar;cr=bl; cv+=mget(al,br); }else if(con(ar,bl)){ cl=al;cr=br; cv+=mget(ar,bl); }else if(con(ar,br)){ cl=al;cr=bl; cv+=mget(ar,br); }else{ cl=cr=cv=-1; } return T(cl,cr,cv); }; SegmentTree<T,Int> seg(n, f, [&](T a,Int b){ return T(b,b,0); }, T(-1,-1,0)); for(Int i=0;i<n;i++) seg.update(i,hld.inv[i]); Int q; cin>>q; while(q--){ string op; cin>>op; if(op=="add"){ Int x,d; cin>>x>>d; w[x]+=d; seg.update(hld.vid[x],x); } if(op=="send"){ Int s,t; cin>>s>>t; vector<T> v; hld.for_each(s,t, [&](Int l,Int r){ T x=seg.query(l,r+1); for(Int i=0;i<(Int)v.size();i++){ T y=f(x,v[i]); if(~get<0>(y)){ v[i]=y; return; } } v.push_back(x); }); while((Int)v.size()>1){ T x=v.back();v.pop_back(); for(Int i=0;i<(Int)v.size();i++){ T y=f(x,v[i]); if(~get<0>(y)){ v[i]=y; break; } } } cout<<(get<2>(v.front()))<<endl; } } return 0; }
a.cc: In member function 'void HLDecomposition::dfs(Int)': a.cc:42:23: error: cannot bind non-const lvalue reference of type 'Int&' {aka 'long long int&'} to a value of type 'int' 42 | Int &i=st.top().second; | ~~~~~~~~~^~~~~~
s226238624
p00362
C++
#include<bits/stdc++.h>#define U [7<<15]={}#define G )+((c=A[a]+A[P[a]]+C[a])%k?c:0)-M(typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f){return f?B[f]+M(f^f&-f):0;}L S(L a,L i){for(a=M(i++G i);i<2e5;i+=i&-i)B[i]+=a;}L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,d-P[f]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,D(d),Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(n=D(0);Z[a=H[P[n]]-n?n:0];n++)for(;!O[a];S(a=H[a],O[a]=++b))X[a]=n;for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}
a.cc:1:24: warning: extra tokens at end of #include directive 1 | #include<bits/stdc++.h>#define U [7<<15]={}#define G )+((c=A[a]+A[P[a]]+C[a])%k?c:0)-M(typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f){return f?B[f]+M(f^f&-f):0;}L S(L a,L i){for(a=M(i++G i);i<2e5;i+=i&-i)B[i]+=a;}L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,d-P[f]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,D(d),Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(n=D(0);Z[a=H[P[n]]-n?n:0];n++)for(;!O[a];S(a=H[a],O[a]=++b))X[a]=n;for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;} | ^ /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s946004589
p00362
C++
#include<bits/stdc++.h> #define U [7<<15]={} #define G ((c=A[a]+A[P[a]]+C[a])%k?c:0)+M( typedef long long L;using namespace std;map<L,L>T U;L P U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f{return f?B[f]+M(f^f&-f):0;}L S(L i){for(c=G i++)-M(i);i<2e5;i+=i&-i)B[i]+=c;}L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,d-P[f]?P[d]=f,C[d]=I->second,D(d),n=Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}L K(L f){return Z[a=X[f]]>Z[n=X[b]]?n=b,b=f,K(n):abs(M(O[f])-(a-n?-G O[a])-K(P[a]):M(O[b])));}main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(0);Z[a=H[P[++n]]-n?n:0];)for(;!O[a];c=a,a=H[a],S(*Z=O[c]=++b))X[a]=n;)for(cin>>a;cin>>s>>a>>b;S(b=O[a]-1),a=H[a],S(b+1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}
a.cc:4:113: error: expected ')' before '{' token 4 | typedef long long L;using namespace std;map<L,L>T U;L P U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f{return f?B[f]+M(f^f&-f):0;}L S(L i){for(c=G i++)-M(i);i<2e5;i+=i&-i)B[i]+=c;}L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,d-P[f]?P[d]=f,C[d]=I->second,D(d),n=Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}L K(L f){return Z[a=X[f]]>Z[n=X[b]]?n=b,b=f,K(n):abs(M(O[f])-(a-n?-G O[a])-K(P[a]):M(O[b])));}main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(0);Z[a=H[P[++n]]-n?n:0];)for(;!O[a];c=a,a=H[a],S(*Z=O[c]=++b))X[a]=n;)for(cin>>a;cin>>s>>a>>b;S(b=O[a]-1),a=H[a],S(b+1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;} | ~ ^ | ) a.cc: In function 'L S(L)': a.cc:4:190: warning: no return statement in function returning non-void [-Wreturn-type] 4 | typedef long long L;using namespace std;map<L,L>T U;L P U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f{return f?B[f]+M(f^f&-f):0;}L S(L i){for(c=G i++)-M(i);i<2e5;i+=i&-i)B[i]+=c;}L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,d-P[f]?P[d]=f,C[d]=I->second,D(d),n=Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}L K(L f){return Z[a=X[f]]>Z[n=X[b]]?n=b,b=f,K(n):abs(M(O[f])-(a-n?-G O[a])-K(P[a]):M(O[b])));}main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(0);Z[a=H[P[++n]]-n?n:0];)for(;!O[a];c=a,a=H[a],S(*Z=O[c]=++b))X[a]=n;)for(cin>>a;cin>>s>>a>>b;S(b=O[a]-1),a=H[a],S(b+1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;} | ^ a.cc: In function 'L D(L)': a.cc:4:344: warning: no return statement in function returning non-void [-Wreturn-type] 4 | typedef long long L;using namespace std;map<L,L>T U;L P U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f{return f?B[f]+M(f^f&-f):0;}L S(L i){for(c=G i++)-M(i);i<2e5;i+=i&-i)B[i]+=c;}L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,d-P[f]?P[d]=f,C[d]=I->second,D(d),n=Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}L K(L f){return Z[a=X[f]]>Z[n=X[b]]?n=b,b=f,K(n):abs(M(O[f])-(a-n?-G O[a])-K(P[a]):M(O[b])));}main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(0);Z[a=H[P[++n]]-n?n:0];)for(;!O[a];c=a,a=H[a],S(*Z=O[c]=++b))X[a]=n;)for(cin>>a;cin>>s>>a>>b;S(b=O[a]-1),a=H[a],S(b+1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;} | ^ a.cc: At global scope: a.cc:4:439: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 4 | typedef long long L;using namespace std;map<L,L>T U;L P U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f{return f?B[f]+M(f^f&-f):0;}L S(L i){for(c=G i++)-M(i);i<2e5;i+=i&-i)B[i]+=c;}L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,d-P[f]?P[d]=f,C[d]=I->second,D(d),n=Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}L K(L f){return Z[a=X[f]]>Z[n=X[b]]?n=b,b=f,K(n):abs(M(O[f])-(a-n?-G O[a])-K(P[a]):M(O[b])));}main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(0);Z[a=H[P[++n]]-n?n:0];)for(;!O[a];c=a,a=H[a],S(*Z=O[c]=++b))X[a]=n;)for(cin>>a;cin>>s>>a>>b;S(b=O[a]-1),a=H[a],S(b+1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;} | ^~~~ a.cc: In function 'int main()': a.cc:4:573: error: expected primary-expression before ')' token 4 | typedef long long L;using namespace std;map<L,L>T U;L P U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f{return f?B[f]+M(f^f&-f):0;}L S(L i){for(c=G i++)-M(i);i<2e5;i+=i&-i)B[i]+=c;}L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,d-P[f]?P[d]=f,C[d]=I->second,D(d),n=Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}L K(L f){return Z[a=X[f]]>Z[n=X[b]]?n=b,b=f,K(n):abs(M(O[f])-(a-n?-G O[a])-K(P[a]):M(O[b])));}main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(0);Z[a=H[P[++n]]-n?n:0];)for(;!O[a];c=a,a=H[a],S(*Z=O[c]=++b))X[a]=n;)for(cin>>a;cin>>s>>a>>b;S(b=O[a]-1),a=H[a],S(b+1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;} | ^ a.cc:4:623: error: expected ';' before ')' token 4 | typedef long long L;using namespace std;map<L,L>T U;L P U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f{return f?B[f]+M(f^f&-f):0;}L S(L i){for(c=G i++)-M(i);i<2e5;i+=i&-i)B[i]+=c;}L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,d-P[f]?P[d]=f,C[d]=I->second,D(d),n=Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}L K(L f){return Z[a=X[f]]>Z[n=X[b]]?n=b,b=f,K(n):abs(M(O[f])-(a-n?-G O[a])-K(P[a]):M(O[b])));}main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(0);Z[a=H[P[++n]]-n?n:0];)for(;!O[a];c=a,a=H[a],S(*Z=O[c]=++b))X[a]=n;)for(cin>>a;cin>>s>>a>>b;S(b=O[a]-1),a=H[a],S(b+1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;} | ^ | ;
s864171813
p00362
C++
#include<bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)n;i++) #define all(c) (c).begin(),(c).end() #define pb push_back #define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0); using namespace std; namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};} template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";} template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";} void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);} typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9; const int MX = 100000; const int MX_L=17; int n, K; int parent[MX_L][MX]; int depth[MX]; vector<vector<pi>> e; void dfs(int c, int p, int d){ depth[c] = d; parent[0][c] = p; for(pi i : e[c]){ int to = i.first; if(to == p) continue; dfs(to, c, d + 1); } } inline int lca(int a, int b){ if(depth[a] > depth[b]) swap(a, b); int d = depth[b] - depth[a]; rep(i, MX_L) if(d & 1 << i) b = parent[i][b]; if(a == b) return a; for(int i = MX_L - 1; i >= 0; i--) if(parent[i][a] != parent[i][b]){ a = parent[i][a]; b = parent[i][b]; } return parent[0][a]; } vector<pi> tmpq; //pos, add ll cost_sum[MX], edge_sum[MX], added[MX]; void build(){ for(pi i : tmpq) added[i.first] += i.second; tmpq.clear(); function<void(int,int,ll,ll)> rec = [&](int c, int p, ll cs, ll es){ cost_sum[c] = cs; edge_sum[c] = es; for(pi i : e[c]) if(i.first != p){ ll ec = added[c] + added[i.first] + i.second; ll x = cs + (ec % K ? ec : 0); ll y = es + ec; rec(i.first, c, x, y); } }; rec(0, 0, 0, 0); } ll cost(int a, int b){ return cost_sum[a] - cost_sum[b]; } ll cost(int a, int b, unordered_map<int,int> &m){ ll ec = edge_sum[a] - edge_sum[b]; if(m.count(a)) ec += m[a]; if(m.count(b)) ec += m[b]; return ec % K ? ec : 0; } ll calc(int s, int t){ if(s == t) return 0; ll ans = cost_sum[s] - cost_sum[t]; unordered_map<int,int> tmpadd; for(pi i : tmpq) if(lca(s, i.first) == i.first) tmpadd[i.first] += i.second; for(pi i : tmpadd){ int prev = s, next = parent[0][i.first], diff = max(0, depth[s] - depth[i.first] - 1); rep(j, MX_L) if(diff >> j & 1) p1rev = parent[j][prev]; if(i.first != s) ans -= cost(prev, i.first) - cost(prev, i.first, tmpadd); if(i.first != t) ans -= cost(i.first, next) - cost(i.first, next, tmpadd); } return ans; } int query(int s, int t){ int m = lca(s, t); return calc(s, m) + calc(t, m); } int main(){ cin.tie(0); cin.sync_with_stdio(0); cin >> n >> K; e.resize(n); rep(i, n - 1){ int a, b, c; cin >> a >> b >> c; e[a].emplace_back(b, c); e[b].emplace_back(a, c); } dfs(0, 0, 0); rep(i, MX_L - 1) rep(j, n) parent[i + 1][j] = parent[i][parent[i][j]]; build(); int Q; cin >> Q; const int B = 500; rep(i, Q){ string s; int a, b; cin >> s >> a >> b; if(s[0] == 'a'){ tmpq.emplace_back(a, b); if(tmpq.size() == B) build(); } else cout << query(a, b) << endl; } return 0; }
a.cc: In function 'll calc(int, int)': a.cc:74:48: error: 'p1rev' was not declared in this scope; did you mean 'prev'? 74 | rep(j, MX_L) if(diff >> j & 1) p1rev = parent[j][prev]; | ^~~~~ | prev
s940111934
p00362
C++
#include<bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)n;i++) #define all(c) (c).begin(),(c).end() #define pb push_back #define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0); using namespace std; namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};} template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";} template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";} void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);} typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9; const int MX = 100000; const int MX_L=17; int n, K; int parent[MX_L][MX]; int depth[MX]; vector<vector<pi>> e; void dfs(int c, int p, int d){ depth[c] = d; parent[0][c] = p; for(pi i : e[c]){ int to = i.first; if(to == p) continue; dfs(to, c, d + 1); } } inline int lca(int a, int b){ if(depth[a] > depth[b]) swap(a, b); int d = depth[b] - depth[a]; rep(i, MX_L) if(d & 1 << i) b = parent[i][b]; if(a == b) return a; for(int i = MX_L - 1; i >= 0; i--) if(parent[i][a] != parent[i][b]){ a = parent[i][a]; b = parent[i][b]; } return parent[0][a]; } vector<pi> tmpq; //pos, add ll cost_sum[MX], edge_sum[MX], added[MX]; void build(){ for(pi i : tmpq) added[i.first] += i.second; tmpq.clear(); function<void(int,int,ll,ll)> rec = [&](int c, int p, ll cs, ll es){ cost_sum[c] = cs; edge_sum[c] = es; for(pi i : e[c]) if(i.first != p){ ll ec = added[c] + added[i.first] + i.second; ll x = cs + (ec % K ? ec : 0); ll y = es + ec; rec(i.first, c, x, y); } }; rec(0, 0, 0, 0); } ll cost(int a, int b){ return cost_sum[a] - cost_sum[b]; } ll cost(int a, int b, unordered_map<int,int> &m){ ll ec = edge_sum[a] - edge_sum[b]; if(m.count(a)) ec += m[a]; if(m.count(b)) ec += m[b]; return ec % K ? ec : 0; } ll calc(int s, int t){ if(s == t) return 0; ll ans = cost_sum[s] - cost_sum[t]; unordered_map<int,int> tmpadd; for(pi i : tmpq) if(lca(s, i.first) == i.first) tmpadd[i.first] += i.second; for(pi i : tmpadd){ int prev = s, next = parent[0][i.first], diff = max(0, depth[s] - depth[i.first] - 1); rep(j, MX_L) if(diff >> j & 1) p1rev = parent[j][prev]; if(i.first != s) ans -= cost(prev, i.first) - cost(prev, i.first, tmpadd); if(i.first != t) ans -= cost(i.first, next) - cost(i.first, next, tmpadd); } return ans; } int query(int s, int t){ int m = lca(s, t); return calc(s, m) + calc(t, m); } int main(){ cin.tie(0); cin.sync_with_stdio(0); cin >> n >> K; e.resize(n); rep(i, n - 1){ int a, b, c; cin >> a >> b >> c; e[a].emplace_back(b, c); e[b].emplace_back(a, c); } dfs(0, 0, 0); rep(i, MX_L - 1) rep(j, n) parent[i + 1][j] = parent[i][parent[i][j]]; build(); int Q; cin >> Q; const int B = 500; rep(i, Q){ string s; int a, b; cin >> s >> a >> b; if(s[0] == 'a'){ tmpq.emplace_back(a, b); if(tmpq.size() == B) build(); } else cout << query(a, b) << endl; } return 0; }
a.cc: In function 'll calc(int, int)': a.cc:74:48: error: 'p1rev' was not declared in this scope; did you mean 'prev'? 74 | rep(j, MX_L) if(diff >> j & 1) p1rev = parent[j][prev]; | ^~~~~ | prev
s177940765
p00362
C++
#include<bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)n;i++) #define all(c) (c).begin(),(c).end() #define pb push_back #define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0); using namespace std; namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};} template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";} template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";} void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);} typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9; const int MX = 100000; const int MX_L=17; int n, K; int parent[MX_L][MX]; int depth[MX]; vector<vector<pi>> e; void dfs(int c, int p, int d){ depth[c] = d; parent[0][c] = p; for(pi i : e[c]){ int to = i.first; if(to == p) continue; dfs(to, c, d + 1); } } inline int lca(int a, int b){ if(depth[a] > depth[b]) swap(a, b); int d = depth[b] - depth[a]; rep(i, MX_L) if(d & 1 << i) b = parent[i][b]; if(a == b) return a; for(int i = MX_L - 1; i >= 0; i--) if(parent[i][a] != parent[i][b]){ a = parent[i][a]; b = parent[i][b]; } return parent[0][a]; } vector<pi> tmpq; //pos, add ll cost_sum[MX], edge_sum[MX], added[MX]; void build(){ for(pi i : tmpq) added[i.first] += i.second; tmpq.clear(); function<void(int,int,ll,ll)> rec = [&](int c, int p, ll cs, ll es){ cost_sum[c] = cs; edge_sum[c] = es; for(pi i : e[c]) if(i.first != p){ ll ec = added[c] + added[i.first] + i.second; ll x = cs + (ec % K ? ec : 0); ll y = es + ec; rec(i.first, c, x, y); } }; rec(0, 0, 0, 0); } ll cost(int a, int b){ return cost_sum[a] - cost_sum[b]; } ll cost(int a, int b, unordered_map<int,int> &m){ ll ec = edge_sum[a] - edge_sum[b]; if(m.count(a)) ec += m[a]; if(m.count(b)) ec += m[b]; return ec % K ? ec : 0; } ll calc(int s, int t){ if(s == t) return 0; ll ans = cost_sum[s] - cost_sum[t]; unordered_map<int,int> tmpadd; for(pi i : tmpq) if(lca(s, i.first) == i.first) tmpadd[i.first] += i.second; for(pi i : tmpadd){ int prev = s, next = parent[0][i.first], diff = max(0, depth[s] - depth[i.first] - 1); rep(j, MX_L) if(diff >> j & 1) p1rev = parent[j][prev]; if(i.first != s) ans -= cost(prev, i.first) - cost(prev, i.first, tmpadd); if(i.first != t) ans -= cost(i.first, next) - cost(i.first, next, tmpadd); } return ans; } int query(int s, int t){ int m = lca(s, t); return calc(s, m) + calc(t, m); } int main(){ cin.tie(0); cin.sync_with_stdio(0); cin >> n >> K; e.resize(n); rep(i, n - 1){ int a, b, c; cin >> a >> b >> c; e[a].emplace_back(b, c); e[b].emplace_back(a, c); } dfs(0, 0, 0); rep(i, MX_L - 1) rep(j, n) parent[i + 1][j] = parent[i][parent[i][j]]; build(); int Q; cin >> Q; const int B = 500; rep(i, Q){ string s; int a, b; cin >> s >> a >> b; if(s[0] == 'a'){ tmpq.emplace_back(a, b); if(tmpq.size() == B) build(); } else cout << query(a, b) << endl; } return 0; }
a.cc: In function 'll calc(int, int)': a.cc:74:48: error: 'p1rev' was not declared in this scope; did you mean 'prev'? 74 | rep(j, MX_L) if(diff >> j & 1) p1rev = parent[j][prev]; | ^~~~~ | prev
s015566018
p00362
C++
#include<bits/stdc++.h> using namespace std; using int64 = long long; const int INF = 1 << 30; struct edge { int to; int64 cost; pair< int, int > to_adjust, curr_adjust; }; int N, K, Q; char S[500][10]; int A[500], B[500]; vector< vector< edge > > g; int64 weight[100000]; struct TreeContraction { vector< int > marker, order, parent; edge NONE; TreeContraction(int n) { g.resize(n); destroy(); NONE = (edge) {-1}; } void destroy() { marker.assign(g.size(), 0); } void add_edge(int idx, const edge &e) { g[idx].emplace_back(e); } void build() { function< void(int, int) > dfs = [&](int idx, int par) { for(auto &e : g[idx]) { if(e.to == par) continue; dfs(e.to, idx); } parent[idx] = par; order.emplace_back(idx); }; parent.resize(g.size()); dfs(0, -1); order.pop_back(); } inline void mark(int x) { marker[x] = 2; } void contract(vector< vector< edge > > &gg) { for(int i : order) { if(marker[i] >= 1) ++marker[parent[i]]; } gg.assign(g.size(), vector< edge >()); inline function< edge(int, int) > contraction = [&](int idx, int par) { vector< pair< edge, edge > > reach; for(auto &e : g[idx]) { if(e.to == par) continue; auto ret = contraction(e.to, idx); if(~ret.to) { reach.emplace_back(ret, e); reach.back().first.cost += e.cost; if(reach.back().first.to_adjust.first == -1) { reach.back().first.to_adjust = {idx, e.cost}; } else if(marker[idx] <= 1) { // to-to_adjust * - -!idx auto sum = e.cost + weight[e.to] + weight[idx]; if(sum % K == 0) reach.back().first.cost -= sum; // えーわからない } } } if(marker[idx] >= 2) { for(auto &e : reach) { gg[idx].emplace_back((edge) {e.first.to, e.first.cost, e.first.to_adjust, make_pair(e.second.to, e.second.cost)}); gg[e.first.to].emplace_back((edge) {idx, e.first.cost, make_pair(e.second.to, e.second.cost), e.first.to_adjust}); } return ((edge) {idx, 0, make_pair(-1, -1), make_pair(-1, -1)}); } else if(reach.empty()) { return (NONE); } else if(reach.size() == 1) { reach[0].first.cost += weight[idx]; reach[0].first.cost += weight[idx]; return (reach[0].first); } else { assert(false); } }; contraction(0, -1); } }; int main() { scanf("%d %d", &N, &K); TreeContraction tree(N); for(int i = 1; i < N; i++) { int a, b, c; scanf("%d %d %d", &a, &b, &c); tree.add_edge(a, (edge) {b, c}); tree.add_edge(b, (edge) {a, c}); } tree.build(); scanf("%d", &Q); int64 cost; vector< vector< edge > > gg; function< bool(int, int, int) > dfs2 = [&](int s, int t, int par) { if(s == t) { cost += weight[t]; cost += weight[t]; return (true); } for(auto &e : gg[s]) { if(e.to == par) continue; if(dfs2(e.to, t, s)) { auto sum = weight[s] + weight[e.curr_adjust.first] + e.curr_adjust.second; if(sum % K == 0) cost -= sum; if(e.to_adjust.first != s) { sum = weight[e.to] + weight[e.to_adjust.first] + e.to_adjust.second; if(sum % K == 0) cost -= sum; } cost += e.cost; cost += weight[s]; cost += weight[s]; return (true); } } return (false); }; for(int i = 0; i < Q; i += 375) { int l = i, r = min(i + 375, Q); tree.destroy(); for(int j = 0; j < r - l; j++) { scanf(" %s %d %d", S[j], &A[j], &B[j]); if(S[j][0] == 'a') tree.mark(A[j]); else tree.mark(A[j]), tree.mark(B[j]); } tree.contract(gg); for(int j = 0; j < r - l; j++) { if(S[j][0] == 'a') { weight[A[j]] += B[j]; } else { cost = 0; dfs2(B[j], A[j], -1); printf("%lld\n", cost - weight[A[j]] - weight[B[j]]); } } } }
a.cc: In member function 'void TreeContraction::contract(std::vector<std::vector<edge> >&)': a.cc:71:5: error: 'inline' specifier invalid for variable 'contraction' declared at block scope 71 | inline function< edge(int, int) > contraction = [&](int idx, int par) | ^~~~~~
s788616259
p00363
Java
import java.util.Scanner; /** * Flag */ public class P0368 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int W, H; char c; W = sc.nextInt(); H = sc.nextInt(); c = sc.next().charAt(0); for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { if ((i == 0 || i == H - 1) && (j == 0 || j == W - 1)) { System.out.print('+'); } else if (i == 0 || i == H - 1) { System.out.print('-'); } else if (j == 0 || j == W - 1) { System.out.print('|'); } else if (i == H / 2 && j == W / 2) { System.out.print(c); } else { System.out.print('.'); } } System.out.println(); } } }
Main.java:6: error: class P0368 is public, should be declared in a file named P0368.java public class P0368 { ^ 1 error
s747563658
p00363
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n, q,b,c,d,e; int a[1001] = { }; while(1){ cin >> n >> q; if(n==0 && q==0)break; for(int i=0;i<1001;i++){ a[i] = 0; } for(int j=0;j<n;j++){ cin >> c; for(int i=0;i<c;i++){ cin >> d; a[d]++; } } e=-1; for(int i=1;i<1001;i++){ if(a[i] > e) e = i; } if (a[e] >= b) cout << e << endl; else cout << 0 << endl; } } }
a.cc:46:1: error: expected declaration before '}' token 46 | } | ^
s869898601
p00366
C++
#include <stdio.h> #include <set> #include <algorithm> using namespace std; const int N=1e5+10; int main(){ int n,a[N]; long long int ans=0; set<int> s; scanf("%d",&n); for(int i=0;i<n;i++)scanf("%d",&a[i]); sort(a,a+n); for(int i=1;i<=a[n-1];i++)if(a[n-1]%i==0)s.insert(i); for(int i=0;i<n;i++)ans+=s.lower_bound(a[i])-a[i]; printf("%lld\n",ans); }
a.cc: In function 'int main()': a.cc:14:49: error: no match for 'operator-' (operand types are 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} and 'int') 14 | for(int i=0;i<n;i++)ans+=s.lower_bound(a[i])-a[i]; | ~~~~~~~~~~~~~~~~~~~^~~~~ | | | | | int | std::set<int>::iterator {aka std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator} In file included from /usr/include/c++/14/bits/stl_algobase.h:67, from /usr/include/c++/14/bits/stl_tree.h:63, from /usr/include/c++/14/set:62, from a.cc:2: /usr/include/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 618 | operator-(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:618:5: note: template argument deduction/substitution failed: a.cc:14:53: note: 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::reverse_iterator<_Iterator>' 14 | for(int i=0;i<n;i++)ans+=s.lower_bound(a[i])-a[i]; | ^ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1790 | operator-(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: template argument deduction/substitution failed: a.cc:14:53: note: 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::move_iterator<_IteratorL>' 14 | for(int i=0;i<n;i++)ans+=s.lower_bound(a[i])-a[i]; | ^
s263196071
p00367
C++
5 1 0 2 0 3 30 4 30 6 0 7 0 2 30 3 0 4 0 5 0 5 30 6 30 1 30 2 30 4 30 5 0 6 30 7 0 2 30 3 0 5 0 6 0 6 30 7 0 1 0 2 0 3 0 3 30 4 0 5 0
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 5 | ^
s818154866
p00370
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define FOR(i, a, b) for(int i=a;i<b;i++) #define REP(i, n) FOR(i, 0, n) #define LAR(a, b) ((a)=max((a),(b))) #define SML(a, b) ((a)=min((a),(b))) typedef vector<int> vi; #define PB push_back #define MP make_pair ld dst(ld x1, ld y1, ld x2, ld y2){ x1-=x2; y1-=y2; return sqrt(x1*x1+y1*y1); } int sgn(ld a){ if(a>0) return 1; else if(a<0) return -1; else return 0; } int linsgn(ld a, ld b, ld c, ld d, ld x, ld y){ return sgn((d-b)*x-(c-a)*y-a*d+b*c); } bool cross(ld x1, ld y1, ld x2, ld y2, ld x3, ld y3, ld x4, ld y4){ return linsgn(x1,y1,x2,y2,x3,y3)*linsgn(x1,y1,x2,y2,x4,y4)<=0 && linsgn(x3,y3,x4,y4,x1,y1)*linsgn(x3,y3,x4,y4,x2,y2)<=0; } void tim(ld &a, ld &b, ld c, ld d){ ld e=a, f=b; a=c*e-d*f; b=c*f+d*e; } void flp(ld &p, ld &q, ld a, ld b, ld x, ld y){ p-=a; x-=a; q-=b; y-=b; ld r=dst(0,0,x,y); tim(x, y, x, y); q*=-1; tim(p, q, x, y); p/=r*r; q/=r*r; p+=a; q+=b; } void cpt(ld &p, ld &q, ld x1, ld y1, ld x2, ld y2, ld x3, ld y3, ld x4, ld y4){ ld a=y2-y1, b=x2-x1, c=x1*y2-x2*y1, d=y4-y3, e=x4-x3, f=x3*y4-x4*y3; p=(b*f-c*e)/(b*d-a*e); q=-(a*f-c*d)/(a*e-b*d); } struct edge{ int to; ld cost; }; #define N 240 int n; ld x[N], y[N]; ld s[N], t[N]; vector<edge> e[N]; void add_edge(int p, int q, ld a, ld b, ld c, ld d){ // printf("%d->%d: (%Lf, %Lf)-(%Lf, %Lf)\n", p, q, a, b, c, d); ld f=dst(a,b,c,d); e[p].PB(edge{q, f}); e[q].PB(edge{p, f}); } typedef pair<ld, int> pld; bool used[N]; priority_queue<pld, vector<pld>, greater<pld>> que; ld cst[N]; int main(){ REP(i, 2) scanf("%Lf%Lf", s+i, t+i); scanf("%d", &n); REP(i, n) scanf("%Lf%Lf", x+i, y+i); REP(i, n){ add_edge(i, (i+1)%n, x[i], y[i], x[(i+1)%n], y[(i+1)%n]); } REP(i, n){ REP(j, 2){ FOR(k, i+1, i+n-1){ if(cross(s[j],t[j],x[i],y[i],x[k%n],y[k%n],x[(k+1)%n],y[(k+1)%n])) goto nxt; } add_edge(n+j, i, s[j],t[j],x[i],y[i]); nxt:; } } REP(i, n){ // printf("i=%d\n", i); ld p=s[1], q=t[1]; flp(p, q, x[i], y[i], x[(i+1)%n], y[(i+1)%n]); // printf("(%Lf, %Lf)\n", p, q); if(!cross(s[0],t[0],p,q,x[i], y[i], x[(i+1)%n], y[(i+1)%n])) continue; ld u, v; cpt(u, v, s[0], t[0], p, q, x[i], y[i], x[(i+1)%n], y[(i+1)%n]); REP(j, 2){ FOR(k, i+1, i+n-1){ if(cross(s[j],t[j],u,v,x[k%n],y[k%n],x[(k+1)%n],y[(k+1)%n])) goto fal; } } REP(j, 2) add_edge(n+j, n+2+i, s[j], t[j], u, v); fal:; } fill(cst, cst+N, 1e18); fill(used, used+N, false); cst[n]=0; que.push(MP(0, n)); while(!used[n+1]){ pld tp=que.top(); que.pop(); int nw=tp.second; if(used[nw]) continue; used[nw]=true; REP(i, e[nw]){ edge &ed=e[nw][i]; ld ncst=cst[nw]+ed.cost; int dst=ed.to; if(cst[dst]>ncst){ cst[dst]=ncst; que.push(MP(ncst, dst)); } } } printf("%Lf\n", cst[n+1]); }
a.cc: In function 'int main()': a.cc:5:35: error: no match for 'operator<' (operand types are 'int' and 'std::vector<edge>') 5 | #define FOR(i, a, b) for(int i=a;i<b;i++) | ^ a.cc:6:19: note: in expansion of macro 'FOR' 6 | #define REP(i, n) FOR(i, 0, n) | ^~~ a.cc:117:17: note: in expansion of macro 'REP' 117 | REP(i, e[nw]){ | ^~~ In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:1: /usr/include/c++/14/bits/regex.h:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1143 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1143:5: note: template argument deduction/substitution failed: a.cc:117:28: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int' 117 | REP(i, e[nw]){ | ^ a.cc:5:36: note: in definition of macro 'FOR' 5 | #define FOR(i, a, b) for(int i=a;i<b;i++) | ^ a.cc:117:17: note: in expansion of macro 'REP' 117 | REP(i, e[nw]){ | ^~~ /usr/include/c++/14/bits/regex.h:1224:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1224 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: template argument deduction/substitution failed: a.cc:117:28: note: mismatched types 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' and 'int' 117 | REP(i, e[nw]){ | ^ a.cc:5:36: note: in definition of macro 'FOR' 5 | #define FOR(i, a, b) for(int i=a;i<b;i++) | ^ a.cc:117:17: note: in expansion of macro 'REP' 117 | REP(i, e[nw]){ | ^~~ /usr/include/c++/14/bits/regex.h:1317:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1317 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: template argument deduction/substitution failed: a.cc:117:28: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int' 117 | REP(i, e[nw]){ | ^ a.cc:5:36: note: in definition of macro 'FOR' 5 | #define FOR(i, a, b) for(int i=a;i<b;i++) | ^ a.cc:117:17: note: in expansion of macro 'REP' 117 | REP(i, e[nw]){ | ^~~ /usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1391 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: template argument deduction/substitution failed: a.cc:117:28: note: 'std::vector<edge>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 117 | REP(i, e[nw]){ | ^ a.cc:5:36: note: in definition of macro 'FOR' 5 | #define FOR(i, a, b) for(int i=a;i<b;i++) | ^ a.cc:117:17: note: in expansion of macro 'REP' 117 | REP(i, e[nw]){ | ^~~ /usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1485 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: template argument deduction/substitution failed: a.cc:117:28: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int' 117 | REP(i, e[nw]){ | ^ a.cc:5:36: note: in definition of macro 'FOR' 5 | #define FOR(i, a, b) for(int i=a;i<b;i++) | ^ a.cc:117:17: note: in expansion of macro 'REP' 117 | REP(i, e[nw]){ | ^~~ /usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1560 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: template argument deduction/substitution failed: a.cc:117:28: note: 'std::vector<edge>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 117 | REP(i, e[nw]){ | ^ a.cc:5:36: note: in definition of macro 'FOR' 5 | #define FOR(i, a, b) for(int i=a;i<b;i++) | ^ a.cc:117:17: note: in expansion of macro 'REP' 117 | REP(i, e[nw]){ | ^~~ /usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1660 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: template argument deduction/substitution failed: a.cc:117:28: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int' 117 | REP(i, e[nw]){ | ^ a.cc:5:36: note: in definition of macro 'FOR' 5 | #define FOR(i, a, b) for(int i=a;i<b;i++) | ^ a.cc:117:17: note: in expansion of macro 'REP' 117 | REP(i, e[nw]){ | ^~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: a.cc:117:28: note: mismatched types 'const std::pair<_T1, _T2>' and 'int' 117 | REP(i, e[nw]){ | ^ a.cc:5:36: note: in definition of macro 'FOR' 5 | #define FOR(i, a, b) for(int i=a;i<b;i++) | ^ a.cc:117:17: note: in expansion of macro 'REP' 117 | REP(i, e[nw]){ | ^~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: a.cc:117:28: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' 117 | REP(i, e[nw]){ | ^ a.cc:5:36: note: in definition of macro 'FOR' 5 | #define FOR(i, a, b) for(int i=a;i<b;i++) | ^ a.cc:117:17: note: in expansion of macro 'REP' 117 | REP(i, e[nw]){ | ^~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: a.cc:117:28: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' 117 | REP(i, e[nw]){ | ^ a.cc:5:36: note: in definition of macro 'FOR' 5 | #define FOR(i, a, b) for(int i=a;i<b;i++) | ^ a.cc:117:17: note: in expansion of macro 'REP' 117 | REP(i, e[nw]){ | ^~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: a.cc:117:28: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'int' 117 | REP(i, e[nw]){ | ^ a.cc:5:36: note: in definition of macro 'FOR' 5 | #define FOR(i, a, b) for(int i=a;i<b;i++) | ^ a.cc:117:17: note: in expansion of macro 'REP' 117 | REP(i, e[nw]){ | ^~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: a.cc:117:28: note: misma
s627840304
p00372
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define FOR(i, a, b) for(int i=a;i<b;i++) #define REP(i, n) FOR(i, 0, n) #define LAR(a, b) ((a)=max((a),(b))) #define SML(a, b) ((a)=min((a),(b))) typedef vector<int> vi; #define PB push_back #define MP make_pair #define YES() printf("yes\n"),exit(0); #define NO() printf("no\n"),exit(0); #define N 112345 int n, m; int d[N]; vi path[N]; int g[N]; int cnt=0; bool vis[N]; void dfs(int a){ if(cnt++>=n*10){ //while(1) cnt++; printf("%d(%d)\n", cnt, a); } REP(j, path[a].size()){ int b=path[a][j]; if(d[b]==a) continue; if(~d[b]){ int c=b; while(g[c]!=g[a]){ g[c]=g[a]; c=d[c]; } }else{ if(g[a]!=g[b]){ d[a]=b; dfs(b); d[a]=-1; } } } } vi stick[N]; int siz[N]; int memo[N][2]; int DP(int,int,bool); int dp(int a, int p, bool av){ if(~memo[a][av]) return memo[a][av]; else return memo[a][av]=DP(a,p,av); } int DP(int a, int p, bool av){ int x=0, y=INT_MIN; REP(i, stick[a].size()){ int b=stick[a][i]; if(b==p) continue; x+=dp(b, a, true); } if(av){ y=siz[a]; REP(i, stick[a].size()){ int b=stick[a][i]; if(b==p) continue; y+=dp(b, a, false); } } // printf("dp(%d, %d)=max(%d, %d)\n", a, av, x, y); return max(x, y); } int main(){ scanf("%d%d", &n, &m); REP(i, m){ int s, t; scanf("%d%d", &s, &t); path[s].PB(t); path[t].PB(s); } fill(d, d+N, -1); // fill(vis, vis+N, false); REP(i, N) g[i]=i; dfs(0); printf(6); return 0; // REP(i, n) printf("%2d ", i); printf("\n"); // REP(i, n) printf("%2d ",g[i]);printf("\n"); int r=-1; REP(i, n){ REP(j, path[i].size()){ int p=g[i], q=g[path[i][j]]; if(i<path[i][j] && p!=q){ stick[p].PB(q); stick[q].PB(p); // printf("%d-%d\n", p, q); } r=p; } } fill(siz, siz+N, 0); REP(i, n) siz[g[i]]++; // REP(i, n) if(siz[i]) printf("siz[%d]=%d\n", i, siz[i]); REP(i, n) memo[i][0]=memo[i][1]=-1; printf("%d\n", dp(r, -1, true)); }
a.cc: In function 'int main()': a.cc:85:16: error: invalid conversion from 'int' to 'const char*' [-fpermissive] 85 | printf(6); | ^ | | | int In file included from /usr/include/c++/14/cstdio:42, from /usr/include/c++/14/ext/string_conversions.h:45, from /usr/include/c++/14/bits/basic_string.h:4154, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:1: /usr/include/stdio.h:363:43: note: initializing argument 1 of 'int printf(const char*, ...)' 363 | extern int printf (const char *__restrict __format, ...); | ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
s942634799
p00372
C++
#include <bits/stdc++.h> using namespace std; #define INF_LL (ll)1e18 #define INF (int)1e9 #define REP(i, n) for(int i = 0;i < (n);i++) #define FOR(i, a, b) for(int i = (a);i < (b);i++) #define all(x) x.begin(),x.end() #define fs first #define sc second using ll = long long; using PII = pair<int, int>; using PLL = pair<ll, ll>; const double eps = 1e-10; template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;} template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;} const int DIRECTED = 0; const int UNDIRECTED = 1; template<int isUNDIRECTED=0> class Graph{ protected: struct Edge{ int u, v, id; // from, to, 何番目の辺か ll c; // cost Edge(int u, int v, ll c=0, int id=0):u(u), v(v), c(c), id(id){} }; int V, E; // 頂点数、辺数 vector<vector<Edge>> G; vector<Edge> Es; public: Graph(){} Graph(int V):V(V){G.resize(V);} Graph(const Graph<isUNDIRECTED>& g):V(g.V), E(g.E), G(g.G), Es(g.Es){} void add_edge(int u, int v, ll c=0, int id=0){ G[u].emplace_back(u, v, c, id); if(isUNDIRECTED) G[v].emplace_back(v, u, c, id); Es.emplace_back(u, v, c, id); E++; } const vector<Edge>& operator[](int k){ return G[k]; } unsigned long long size(){ return V; } }; template<int isUNDIRECTED> class Lowlink : public Graph<isUNDIRECTED>{ vector<int> ord, low; vector<int> articulation; vector<pair<int, int>> bridge; public: Lowlink(){} Lowlink(int V):Graph<isUNDIRECTED>(V){} Lowlink(const Graph<isUNDIRECTED>& g):Graph<isUNDIRECTED>(g){} void build(){ ord.resize(this->V, -1); low.resize(this->V, -1); int k = 0; function<void(int, int)> dfs = [&, this](int v, int p){ ord[v] = k++; low[v] = ord[v]; bool isArt = 0; // 関節点か int cnt = 0; for(auto e : this->G[v]){ if(e.v == p) continue; if(ord[e.v] == -1){ cnt++; dfs(e.v, v); low[v] = min(low[v], low[e.v]); if(ord[v] < low[e.v]) bridge.emplace_back(e.u, e.v); if(~p && ord[v] <= low[e.v]) isArt = 1; }else{ low[v] = min(low[v], ord[e.v]); } } if(p==-1 && cnt > 1) isArt = 1; if(isArt) articulation.push_back(v); }; for(int i = 0;i < this->V;i++) if(ord[i] == -1) dfs(i, -1); } const vector<pair<int, int>>& getBridge(){ return bridge; } const vector<int>& getArticulation(){ return articulation; } bool isBridge(int u, int v) const{ if(ord[u] > ord[v]) swap(u, v); return ord[u] < low[v]; } }; template<int isUNDIRECTED> class BECC{ private: Lowlink<isUNDIRECTED> orgG; Graph<isUNDIRECTED> G; vector<int> belongs; vector<vector<int>> comps; public: BECC(){} BECC(const Graph<isUNDIRECTED>& g):orgG(g){ orgG.build(); belongs.resize(orgG.size(), -1); } void build(){ vector<bool> used(orgG.size(), 0); int k = 0; function<void(int, int)> dfs = [&](int v, int p){ belongs[v] = k; if(p == -1) comps.push_back(vector<int>()); comps[k].push_back(v); for(auto e : orgG[v]){ if(e.v == p) continue; if(orgG.isBridge(e.u, e.v)) continue; if(belongs[e.v] >= 0) continue; dfs(e.v, v); } }; for(int i = 0;i < orgG.size();i++){ if(belongs[i] >= 0) continue; dfs(i, -1); k++; } G = Graph<isUNDIRECTED>(k); for(auto e : orgG.getBridge()){ G.add_edge(belongs[e.first], belongs[e.second]); } } int belong(int v){ return belongs[v]; } int size(int v){ return comps[v].size(); } const Graph<isUNDIRECTED>& getGraph(){ return G; } }; int N, M; Graph<UNDIRECTED> orgG; Graph<UNDIRECTED> tree; int main(void){ cin >> N >> M; orgG = Graph<UNDIRECTED>(N); REP(i, M){ int s, t; cin >> s >> t; orgG.add_edge(s, t); } BECC<UNDIRECTED> becc(orgG); becc.build(); tree = becc.getGraph(); vector<vector<int>> dp(tree.size(), vector<int>(2, 0)); function<void(int, int)> dfs = [&](int v, int p){ int sum[2] = {}; for(auto e : tree[v]){ if(e.v == p) continue; dfs(e.v, v); sum[0] += max(dp[e.v][0], dp[e.v][1]); sum[1] += dp[e.v][0]; } dp[v][0] = sum[0]; dp[v][1] = sum[1]+becc.size(v); }; int res = 0; REP(i, tree.size()){ if(dp[i] == 0) dfs(i, -1); } cout << max(dp[0][0], dp[0][1]) << endl; }
a.cc: In function 'int main()': a.cc:198:26: error: no match for 'operator==' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} and 'int') 198 | if(dp[i] == 0) In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:1: /usr/include/c++/14/bits/regex.h:1103:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1103 | operator==(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1103:5: note: template argument deduction/substitution failed: a.cc:198:29: note: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 198 | if(dp[i] == 0) | ^ /usr/include/c++/14/bits/regex.h:1199:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1199 | operator==(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1199:5: note: template argument deduction/substitution failed: a.cc:198:29: note: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 198 | if(dp[i] == 0) | ^ /usr/include/c++/14/bits/regex.h:1274:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1274 | operator==(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1274:5: note: template argument deduction/substitution failed: a.cc:198:29: note: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 198 | if(dp[i] == 0) | ^ /usr/include/c++/14/bits/regex.h:1366:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1366 | operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1366:5: note: template argument deduction/substitution failed: a.cc:198:29: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int' 198 | if(dp[i] == 0) | ^ /usr/include/c++/14/bits/regex.h:1441:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1441 | operator==(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1441:5: note: template argument deduction/substitution failed: a.cc:198:29: note: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 198 | if(dp[i] == 0) | ^ /usr/include/c++/14/bits/regex.h:1534:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1534 | operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1534:5: note: template argument deduction/substitution failed: a.cc:198:29: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int' 198 | if(dp[i] == 0) | ^ /usr/include/c++/14/bits/regex.h:1613:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1613 | operator==(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1613:5: note: template argument deduction/substitution failed: a.cc:198:29: note: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 198 | if(dp[i] == 0) | ^ /usr/include/c++/14/bits/regex.h:2186:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator==(const match_results<_BiIter, _Alloc>&, const match_results<_BiIter, _Alloc>&)' 2186 | operator==(const match_results<_Bi_iter, _Alloc>& __m1, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:2186:5: note: template argument deduction/substitution failed: a.cc:198:29: note: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>' 198 | if(dp[i] == 0) | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed: a.cc:198:29: note: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} is not derived from 'const std::pair<_T1, _T2>' 198 | if(dp[i] == 0) | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 441 | operator==(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed: a.cc:198:29: note: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} is not derived from 'const std::reverse_iterator<_Iterator>' 198 | if(dp[i] == 0) | ^ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 486 | operator==(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed: a.cc:198:29: note: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} is not derived from 'const std::reverse_iterator<_Iterator>' 198 | if(dp[i] == 0) | ^ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1667 | operator==(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed: a.cc:198:29: note: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} is not derived from 'const std::move_iterator<_IteratorL>' 198 | if(dp[i] == 0) | ^ /usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1737 | operator==(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed: a.cc:198:29: note: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} is not derived from 'const std::move_iterator<_IteratorL>' 198 | if(dp[i] == 0) | ^ In file included from /usr/include/c++/14/bits/char_traits.h:42, from /usr/include/c++/14/string:42, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)' 192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed: a.cc:198:29: note: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} is not derived from 'const std::fpos<_StateT>' 198 | if(dp[i] == 0) | ^ In file included from /usr/include/c++/14/string:43: /usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const
s313028929
p00374
C++
d
a.cc:1:1: error: 'd' does not name a type 1 | d | ^
s945769916
p00374
C++
#include<bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)n;i++) #define all(c) (c).begin(),(c).end() #define pb push_back #define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0); using namespace std; namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};} template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";} template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";} void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);} typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9; int main(){ cin.tie(0); cin.sync_with_stdio(0); int n, m, X, Y; cin >> n >> m >> X >> Y; vi v(n + m); rep(i, n + m) cin >> v[i]; ll ans = 0; set<int> lens; map<int,int> cnt; map<pi,int> cnt2; set<tuple<int,int,int>> vis; rep(i, n){ if(i < m){ int a = v[i] - v[i + n], b = v[i + n]; lens.insert(a); lens.insert(b); ++cnt2[pi(min(a, b), max(a, b))]; } else{ ++cnt[v[i]]; lens.insert(v[i]); } } if(X == 0){ //assert(0); vector<pi> vs; for(auto i : cnt) if(i.second >= 4) vs.emplace_back(i.first, i.second); rep(i, vs.size()){ if(vs[i].second >= 12) ans++; if(vs[i].second >= 8) ans += (int)vs.size() - i - 1; for(int j = i + 1; j < vs.size(); j++){ if(vs[j].second >= 8) ans++; ans += (int)vs.size() - j - 1; } } cout << ans << endl; return 0; } //rep(i, m) for(int j : lens) for(int ii : lens) for(int jj : lens) for(int kk : lens){ //vi l = {v[i] - v[i + n], v[i + n], j}; vi l = {ii, jj, kk}; sort(all(l)); if(vis.count(tie(l[0], l[1], l[2]))) continue; vis.emplace(l[0], l[1], l[2]); if(l[0] == l[1] && l[1] == l[2]){ int x = min(X, cnt2.count(pi(l[0], l[1])) ? cnt2[pi(l[0], l[1])] : 0); int y = cnt.count(l[0]) ? cnt[l[0]] : 0; if(x == X && 2 * x + y >= 12) ans++; } else if(l[0] == l[1]){ int x0 = min(X, cnt2.count(pi(l[0], l[1])) ? cnt2[pi(l[0], l[1])] : 0); int x1 = min(X, cnt2.count(pi(l[0], l[2])) ? cnt2[pi(l[0], l[2])] : 0); bool ok = 0; rep(i, x0+1){ if(X - i > x1) continue; if(a > 8 || c > 4) continue; int a = 2 * i + X - i, c = X - i; if(a + (cnt.count(l[0]) ? cnt[l[0]] : 0) >= 8 && c + (cnt.count(l[2]) ? cnt[l[2]] : 0) >= 4){ ok = 1; break; } } if(ok) ans++; } else if(l[1] == l[2]){ int x0 = min(X, cnt2.count(pi(l[0], l[1])) ? cnt2[pi(l[0], l[1])] : 0); int x1 = min(X, cnt2.count(pi(l[1], l[2])) ? cnt2[pi(l[1], l[2])] : 0); bool ok = 0; rep(i, x0+1){ if(X - i > x1) continue; int a = i, c = i + 2*(X - i); if(a > 4 || c > 8) continue; if(a + (cnt.count(l[0]) ? cnt[l[0]] : 0) >= 4 && c + (cnt.count(l[2]) ? cnt[l[2]] : 0) >= 8){ ok = 1; break; } } if(ok) ans++; } else{ int x0 = min(X, cnt2.count(pi(l[0], l[1])) ? cnt2[pi(l[0], l[1])] : 0); int x1 = min(X, cnt2.count(pi(l[1], l[2])) ? cnt2[pi(l[1], l[2])] : 0); int x2 = min(X, cnt2.count(pi(l[0], l[2])) ? cnt2[pi(l[0], l[2])] : 0); bool ok = 0; rep(i, x0+1) rep(j, x1+1){ if(X - i - j > x2) continue; int a = i + (X - i - j), b = i + j, c = j + (X - i - j); if(a > 4 || b > 4 || c > 4) continue; if(a + (cnt.count(l[0]) ? cnt[l[0]] : 0) >= 4 && b + (cnt.count(l[1]) ? cnt[l[1]] : 0) >= 4 && c + (cnt.count(l[2]) ? cnt[l[2]] : 0) >= 4){ ok = 1; break; } } if(ok) ans++; } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:75:36: error: 'a' was not declared in this scope 75 | if(a > 8 || c > 4) continue; | ^ a.cc:75:45: error: 'c' was not declared in this scope 75 | if(a > 8 || c > 4) continue; | ^
s415005338
p00374
C++
#include<bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)n;i++) #define all(c) (c).begin(),(c).end() #define pb push_back #define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0); using namespace std; namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};} template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";} template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";} void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);} typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9; int main(){ cin.tie(0); cin.sync_with_stdio(0); int n, m, X, Y; cin >> n >> m >> X >> Y; vi v(n + m); rep(i, n + m) cin >> v[i]; ll ans = 0; set<int> lens; map<int,int> cnt; map<pi,int> cnt2; set<tuple<int,int,int>> vis; rep(i, n){ if(i < m){ int a = v[i] - v[i + n], b = v[i + n]; lens.insert(a); lens.insert(b); ++cnt2[pi(min(a, b), max(a, b))]; } else{ ++cnt[v[i]]; lens.insert(v[i]); } } if(X == 0){ //assert(0); vector<pi> vs; for(auto i : cnt) if(i.second >= 4) vs.emplace_back(i.first, i.second); rep(i, vs.size()){ if(vs[i].second >= 12) ans++; if(vs[i].second >= 8) ans += (int)vs.size() - i - 1; for(int j = i + 1; j < vs.size(); j++){ if(vs[j].second >= 8) ans++; ans += (int)vs.size() - j - 1; } } cout << ans << endl; return 0; } rep(i, m) for(int j : lens) //for(int ii : lens) for(int jj : lens) for(int kk : lens){ vi l = {v[i] - v[i + n], v[i + n], j}; //vi l = {ii, jj, kk}; sort(all(l)); if(vis.count(tie(l[0], l[1], l[2]))) continue; vis.emplace(l[0], l[1], l[2]); if(l[0] == l[1] && l[1] == l[2]){ int x = min(X, cnt2.count(pi(l[0], l[1])) ? cnt2[pi(l[0], l[1])] : 0); int y = cnt.count(l[0]) ? cnt[l[0]] : 0; if(x == X && 2 * x + y >= 12) ans++; } else if(l[0] == l[1]){ int x0 = min(X, cnt2.count(pi(l[0], l[1])) ? cnt2[pi(l[0], l[1])] : 0); int x1 = min(X, cnt2.count(pi(l[0], l[2])) ? cnt2[pi(l[0], l[2])] : 0); bool ok = 0; rep(i, x0+1){ if(X - i > x1) continue; int a = 2 * i + X - i, c = X - i; if(a > 8 || c > 4) continue; if(a + (cnt.count(l[0]) ? cnt[l[0]] : 0) >= 8 && c + (cnt.count(l[2]) ? cnt[l[2]] : 0) >= 4){ ok = 1; break; } } if(ok) ans++; } else if(l[1] == l[2]){ int x0 = min(X, cnt2.count(pi(l[0], l[1])) ? cnt2[pi(l[0], l[1])] : 0); int x1 = min(X, cnt2.count(pi(l[1], l[2])) ? cnt2[pi(l[1], l[2])] : 0); bool ok = 0; rep(i, x0+1){ if(X - i > x1) continue; int a = i, c = i + 2*(X - i); if(a > 4 || c > 8) continue; if(a + (cnt.count(l[0]) ? cnt[l[0]] : 0) >= 4 && c + (cnt.count(l[2]) ? cnt[l[2]] : 0) >= 8){ ok = 1; break; } } if(ok) ans++; } else{ int x0 = min(X, cnt2.count(pi(l[0], l[1])) ? cnt2[pi(l[0], l[1])] : 0); int x1 = min(X, cnt2.count(pi(l[1], l[2])) ? cnt2[pi(l[1], l[2])] : 0); int x2 = min(X, cnt2.count(pi(l[0], l[2])) ? cnt2[pi(l[0], l[2])] : 0); bool ok = 0; rep(i, x0+1) rep(j, x1+1){ if(X - i - j > x2 || i + j > X) continue; int a = i + (X - i - j), b = i + j, c = j + (X - i - j); if(a > 4 || b > 4 || c > 4) continue; if(a + (cnt.count(l[0]) ? cnt[l[0]] : 0) >= 4 && b + (cnt.count(l[1]) ? cnt[l[1]] : 0) >= 4 && c + (cnt.count(l[2]) ? cnt[l[2]] : 0) >= 4){ ok = 1; break; } } if(ok) ans++; } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:59:26: error: 'l' was not declared in this scope 59 | sort(all(l)); | ^ a.cc:3:17: note: in definition of macro 'all' 3 | #define all(c) (c).begin(),(c).end() | ^ a.cc:61:54: error: continue statement not within a loop 61 | if(vis.count(tie(l[0], l[1], l[2]))) continue; | ^~~~~~~~ a.cc: At global scope: a.cc:120:9: error: 'cout' does not name a type 120 | cout << ans << endl; | ^~~~ a.cc:121:9: error: expected unqualified-id before 'return' 121 | return 0; | ^~~~~~ a.cc:122:1: error: expected declaration before '}' token 122 | } | ^
s418938304
p00375
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.UncheckedIOException; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { SC sc=new SC(System.in); int a=sc.nextInt(); pl((a-30)/2) } static class SC { private BufferedReader reader = null; private StringTokenizer tokenizer = null; public SC(InputStream in) { reader = new BufferedReader(new InputStreamReader(in)); } public String next() { if (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new UncheckedIOException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String nextLine() { try { return reader.readLine(); } catch (IOException e) { throw new UncheckedIOException(e); } } } public static void pl(Object o) { System.out.println(o); } public static void pl() { System.out.println(); } public static void p(Object o) { System.out.print(o); } }
Main.java:12: error: ';' expected pl((a-30)/2) ^ 1 error
s726092356
p00375
C++
// Celcius and Fahrenheit 2018/12/28 #include <iostream> using namespace std; int main() { int F, C; cin >> F; cout << (F - 30) / 2 << '\n'; return 0; } ~
a.cc:13:2: error: expected class-name at end of input 13 | ~ | ^
s326849729
p00375
C++
#include <stdio.h> #include <iostream> #include <string> using namespace std; int main(){ int F; cin >> F; cout << (F - 30) / 2 }
a.cc: In function 'int main()': a.cc:10:29: error: expected ';' before '}' token 10 | cout << (F - 30) / 2 | ^ | ; 11 | } | ~
s517935824
p00376
C++
#include <iostream> using namespace std; int main(){ int a , b , c ; cin >> a >> b ; c = a – b ; if (c < 0 ) cout << c * -1 <<endl ; cout << c << endl ; return 0; }
a.cc:7:15: error: extended character – is not valid in an identifier 7 | c = a – b ; | ^ a.cc: In function 'int main()': a.cc:7:14: error: expected ';' before '\U00002013' 7 | c = a – b ; | ^~ | ;
s427284857
p00376
C++
#include <iostream> using namespace std; int main(){ int a , b , c ; cin >> a >> b ; c = a – b ; if (c < 0 ) cout << c * -1 <<endl ; cout << c << endl ; return 0; }
a.cc:7:7: error: extended character – is not valid in an identifier 7 | c = a – b ; | ^ a.cc: In function 'int main()': a.cc:7:6: error: expected ';' before '\U00002013' 7 | c = a – b ; | ^~ | ;
s222791156
p00376
C++
#include <iostream> using namespace std; int main(){ int a , b , c ; cin >> a >> b ; c = a – b ; if (c < 0 ) cout << c * -1 <<endl ; cout << c << endl ; return 0; }
a.cc:7:7: error: extended character – is not valid in an identifier 7 | c = a – b ; | ^ a.cc: In function 'int main()': a.cc:7:6: error: expected ';' before '\U00002013' 7 | c = a – b ; | ^~ | ;
s716595053
p00376
C++
#include <iostream> using namespace std; int main(){ int a , b , c ; cin >> a >> b ; c = a – b ; if (c < 0 ) cout << c * -1 <<endl ; cout << c << endl ; return 0; }
a.cc:7:7: error: extended character – is not valid in an identifier 7 | c = a – b ; | ^ a.cc: In function 'int main()': a.cc:7:6: error: expected ';' before '\U00002013' 7 | c = a – b ; | ^~ | ;
s649886919
p00376
C++
#include <iostream> using namespace std; int main(){ int x1 , x2 ; cin >> x1 >> x2 ; if (a < b ) cout << b - a <<endl ; cout << a - b << endl ; return 0; }
a.cc: In function 'int main()': a.cc:7:13: error: 'a' was not declared in this scope 7 | if (a < b ) cout << b - a <<endl ; | ^ a.cc:7:17: error: 'b' was not declared in this scope 7 | if (a < b ) cout << b - a <<endl ; | ^ a.cc:8:17: error: 'a' was not declared in this scope 8 | cout << a - b << endl ; | ^ a.cc:8:21: error: 'b' was not declared in this scope 8 | cout << a - b << endl ; | ^
s333699780
p00376
C++
#include <iostream> using namespace std; int main(){ int x1 , x2 ; cin >> x1 >> x2 ; if (x1 < x2 ) cout << x2 – x1 <<endl ; cout << x1 – x2 << endl ; return 0; }
a.cc:7:34: error: extended character – is not valid in an identifier 7 | if (x1 < x2 ) cout << x2 – x1 <<endl ; | ^ a.cc:8:20: error: extended character – is not valid in an identifier 8 | cout << x1 – x2 << endl ; | ^ a.cc: In function 'int main()': a.cc:7:33: error: expected ';' before '\U00002013' 7 | if (x1 < x2 ) cout << x2 – x1 <<endl ; | ^~ | ; a.cc:8:19: error: expected ';' before '\U00002013' 8 | cout << x1 – x2 << endl ; | ^~ | ;
s080813775
p00376
C++
#include <iostream> using namespace std; int main(){ int x1 , x2 ; cin >> x1 >> x2 ; if (x1 < x2 ) cout << x2 – x1 <<endl ; cout << x1 – x2 << endl ; return 0; }
a.cc:8:34: error: extended character – is not valid in an identifier 8 | if (x1 < x2 ) cout << x2 – x1 <<endl ; | ^ a.cc:9:20: error: extended character – is not valid in an identifier 9 | cout << x1 – x2 << endl ; | ^ a.cc: In function 'int main()': a.cc:8:33: error: expected ';' before '\U00002013' 8 | if (x1 < x2 ) cout << x2 – x1 <<endl ; | ^~ | ; a.cc:9:19: error: expected ';' before '\U00002013' 9 | cout << x1 – x2 << endl ; | ^~ | ;
s294434228
p00376
C++
#include <iostream> using namespace std; int main(){ int x1 , x2 ; cin >> x1 >> x2 ; if (x1 < x2 ) cout << x2 – x1 <<endl ; cout << x1 – x2 << endl ; return 0; }
a.cc:8:34: error: extended character – is not valid in an identifier 8 | if (x1 < x2 ) cout << x2 – x1 <<endl ; | ^ a.cc:9:20: error: extended character – is not valid in an identifier 9 | cout << x1 – x2 << endl ; | ^ a.cc: In function 'int main()': a.cc:8:33: error: expected ';' before '\U00002013' 8 | if (x1 < x2 ) cout << x2 – x1 <<endl ; | ^~ | ; a.cc:9:19: error: expected ';' before '\U00002013' 9 | cout << x1 – x2 << endl ; | ^~ | ;
s395733311
p00376
C++
#include <iostream> using namespace std; int main(){ int x1 , x2 ; cin >> x1 >> x2 ; if ( x1 < x2 ) cout << x2 – x1 <<endl ; else cout << x1 – x2 << endl ; return 0; }
a.cc:8:27: error: extended character – is not valid in an identifier 8 | if ( x1 < x2 ) cout << x2 – x1 <<endl ; | ^ a.cc:10:12: error: extended character – is not valid in an identifier 10 | cout << x1 – x2 << endl ; | ^ a.cc: In function 'int main()': a.cc:8:26: error: expected ';' before '\U00002013' 8 | if ( x1 < x2 ) cout << x2 – x1 <<endl ; | ^~ | ; a.cc:10:11: error: expected ';' before '\U00002013' 10 | cout << x1 – x2 << endl ; | ^~ | ;
s112165886
p00376
C++
#include <iostream> using namespace std; int main(){ int x1 , x2 ; cin >> x1 >> x2 ; if ( x1 < x2 ) cout << x2 – x1 <<endl ; else cout << x1 – x2 << endl ; return 0; }
a.cc:8:27: error: extended character – is not valid in an identifier 8 | if ( x1 < x2 ) cout << x2 – x1 <<endl ; | ^ a.cc:10:12: error: extended character – is not valid in an identifier 10 | cout << x1 – x2 << endl ; | ^ a.cc: In function 'int main()': a.cc:8:26: error: expected ';' before '\U00002013' 8 | if ( x1 < x2 ) cout << x2 – x1 <<endl ; | ^~ | ; a.cc:10:11: error: expected ';' before '\U00002013' 10 | cout << x1 – x2 << endl ; | ^~ | ;
s616931755
p00376
C++
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s508694772
p00376
C++
#include <iostream> using namespace std; int main(){ int x1,x2; cin>>x1>>x2; if (x1>x2) cost<<x2-x1<<endl; elsecost<<x1-x2<<endl; }
a.cc: In function 'int main()': a.cc:6:12: error: 'cost' was not declared in this scope; did you mean 'const'? 6 | if (x1>x2) cost<<x2-x1<<endl; | ^~~~ | const a.cc:7:1: error: 'elsecost' was not declared in this scope 7 | elsecost<<x1-x2<<endl; | ^~~~~~~~
s360653965
p00376
C++
#include <iostream> using namespace std; int main(){ int x,y; cin>>a>>b; if a > b; cout<<(a-b)<<; else cout<<(b-a)<< endl; return 0; }
a.cc: In function 'int main()': a.cc:6:6: error: 'a' was not declared in this scope 6 | cin>>a>>b; | ^ a.cc:6:9: error: 'b' was not declared in this scope 6 | cin>>a>>b; | ^ a.cc:7:4: error: expected '(' before 'a' 7 | if a > b; | ^ | ( a.cc:8:14: error: expected primary-expression before ';' token 8 | cout<<(a-b)<<; | ^ a.cc:9:1: error: 'else' without a previous 'if' 9 | else cout<<(b-a)<< endl; | ^~~~
s359764042
p00376
C++
#include <iostream> using namespace std; int main(){ int x,y; cin>>a>>b; if(a > b) cout<<(a-b)<<endl; else cout<<(b-a)<< endl; return 0; }
a.cc: In function 'int main()': a.cc:6:6: error: 'a' was not declared in this scope 6 | cin>>a>>b; | ^ a.cc:6:9: error: 'b' was not declared in this scope 6 | cin>>a>>b; | ^
s189324786
p00376
C++
#include <iostream> using namespace std; int main(){ int x,y; cin>>a>>b; if(a>b) cout<<(a-b)<<endl; else cout<<(b-a)<< endl; return 0; }
a.cc: In function 'int main()': a.cc:6:6: error: 'a' was not declared in this scope 6 | cin>>a>>b; | ^ a.cc:6:9: error: 'b' was not declared in this scope 6 | cin>>a>>b; | ^
s633778121
p00376
C++
#include <iostream> using namespace std; int main(){ int x,y; cin>>a>>b; if(a>b) cout<<(a-b)<<endl; else cout<<(b-a)<< endl; return 0; }
a.cc: In function 'int main()': a.cc:6:6: error: 'a' was not declared in this scope 6 | cin>>a>>b; | ^ a.cc:6:9: error: 'b' was not declared in this scope 6 | cin>>a>>b; | ^
s050208873
p00376
C++
#include <iostream> using namespace std; int main(){ int x,y; cin> x>>y; if(x>y) cout<<(x-y)<<endl; else cout<<(x-b)<< endl; return 0; }
a.cc: In function 'int main()': a.cc:6:4: error: no match for 'operator>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'int') 6 | cin> x>>y; | ~~~^ ~~~~ | | | | | int | std::istream {aka std::basic_istream<char>} a.cc:6:4: note: candidate: 'operator>(int, int)' (built-in) 6 | cin> x>>y; | ~~~^~~~~~ a.cc:6:4: note: no known conversion for argument 1 from 'std::istream' {aka 'std::basic_istream<char>'} to 'int' In file included from /usr/include/c++/14/string:48, 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.h:462:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 462 | operator>(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:462:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 6 | cin> x>>y; | ^ /usr/include/c++/14/bits/stl_iterator.h:507:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 507 | operator>(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:507:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 6 | cin> x>>y; | ^ /usr/include/c++/14/bits/stl_iterator.h:1714:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1714 | operator>(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1714:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 6 | cin> x>>y; | ^ /usr/include/c++/14/bits/stl_iterator.h:1774:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1774 | operator>(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1774:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 6 | cin> x>>y; | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51: /usr/include/c++/14/bits/stl_pair.h:1058:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator>(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1058 | operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1058:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::pair<_T1, _T2>' 6 | cin> x>>y; | ^ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:695:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 695 | operator> (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:695:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 6 | cin> x>>y; | ^ /usr/include/c++/14/string_view:702:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 702 | operator> (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:702:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 6 | cin> x>>y; | ^ /usr/include/c++/14/string_view:710:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 710 | operator> (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:710:5: note: template argument deduction/substitution failed: a.cc:6:9: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int' 6 | cin> x>>y; | ^ /usr/include/c++/14/bits/basic_string.h:3915:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3915 | operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3915:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 6 | cin> x>>y; | ^ /usr/include/c++/14/bits/basic_string.h:3929:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3929 | operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3929:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 6 | cin> x>>y; | ^ /usr/include/c++/14/bits/basic_string.h:3942:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3942 | operator>(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3942:5: note: template argument deduction/substitution failed: a.cc:6:9: note: mismatched types 'const _CharT*' and 'std::basic_istream<char>' 6 | cin> x>>y; | ^ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68: /usr/include/c++/14/tuple:2619:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator>(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)' 2619 | operator>(const tuple<_TElements...>& __t, | ^~~~~~~~ /usr/include/c++/14/tuple:2619:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::tuple<_UTypes ...>' 6 | cin> x>>y; | ^ a.cc:10:10: error: 'b' was not declared in this scope 10 | cout<<(x-b)<< endl; | ^
s145911340
p00376
C++
#include <iostream> using namespace std; int main(){ int x,y; cin> x>>y; if(x>y) cout<<(x-y)<<endl; else cout<<(x-y)<< endl; return 0; }
a.cc: In function 'int main()': a.cc:6:4: error: no match for 'operator>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'int') 6 | cin> x>>y; | ~~~^ ~~~~ | | | | | int | std::istream {aka std::basic_istream<char>} a.cc:6:4: note: candidate: 'operator>(int, int)' (built-in) 6 | cin> x>>y; | ~~~^~~~~~ a.cc:6:4: note: no known conversion for argument 1 from 'std::istream' {aka 'std::basic_istream<char>'} to 'int' In file included from /usr/include/c++/14/string:48, 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.h:462:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 462 | operator>(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:462:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 6 | cin> x>>y; | ^ /usr/include/c++/14/bits/stl_iterator.h:507:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 507 | operator>(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:507:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 6 | cin> x>>y; | ^ /usr/include/c++/14/bits/stl_iterator.h:1714:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1714 | operator>(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1714:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 6 | cin> x>>y; | ^ /usr/include/c++/14/bits/stl_iterator.h:1774:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1774 | operator>(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1774:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 6 | cin> x>>y; | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51: /usr/include/c++/14/bits/stl_pair.h:1058:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator>(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1058 | operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1058:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::pair<_T1, _T2>' 6 | cin> x>>y; | ^ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:695:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 695 | operator> (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:695:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 6 | cin> x>>y; | ^ /usr/include/c++/14/string_view:702:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 702 | operator> (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:702:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 6 | cin> x>>y; | ^ /usr/include/c++/14/string_view:710:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 710 | operator> (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:710:5: note: template argument deduction/substitution failed: a.cc:6:9: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int' 6 | cin> x>>y; | ^ /usr/include/c++/14/bits/basic_string.h:3915:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3915 | operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3915:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 6 | cin> x>>y; | ^ /usr/include/c++/14/bits/basic_string.h:3929:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3929 | operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3929:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 6 | cin> x>>y; | ^ /usr/include/c++/14/bits/basic_string.h:3942:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3942 | operator>(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3942:5: note: template argument deduction/substitution failed: a.cc:6:9: note: mismatched types 'const _CharT*' and 'std::basic_istream<char>' 6 | cin> x>>y; | ^ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68: /usr/include/c++/14/tuple:2619:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator>(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)' 2619 | operator>(const tuple<_TElements...>& __t, | ^~~~~~~~ /usr/include/c++/14/tuple:2619:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::tuple<_UTypes ...>' 6 | cin> x>>y; | ^
s073311888
p00376
C++
#include <iostream> using namespace std; int main(){ int x,y; cin> x>>y; if(x>y) cout<<(x-y)<<endl; else cout<<(y-x)<< endl; return 0; }
a.cc: In function 'int main()': a.cc:6:4: error: no match for 'operator>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'int') 6 | cin> x>>y; | ~~~^ ~~~~ | | | | | int | std::istream {aka std::basic_istream<char>} a.cc:6:4: note: candidate: 'operator>(int, int)' (built-in) 6 | cin> x>>y; | ~~~^~~~~~ a.cc:6:4: note: no known conversion for argument 1 from 'std::istream' {aka 'std::basic_istream<char>'} to 'int' In file included from /usr/include/c++/14/string:48, 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.h:462:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 462 | operator>(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:462:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 6 | cin> x>>y; | ^ /usr/include/c++/14/bits/stl_iterator.h:507:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 507 | operator>(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:507:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 6 | cin> x>>y; | ^ /usr/include/c++/14/bits/stl_iterator.h:1714:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1714 | operator>(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1714:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 6 | cin> x>>y; | ^ /usr/include/c++/14/bits/stl_iterator.h:1774:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1774 | operator>(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1774:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 6 | cin> x>>y; | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51: /usr/include/c++/14/bits/stl_pair.h:1058:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator>(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1058 | operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1058:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::pair<_T1, _T2>' 6 | cin> x>>y; | ^ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:695:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 695 | operator> (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:695:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 6 | cin> x>>y; | ^ /usr/include/c++/14/string_view:702:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 702 | operator> (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:702:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 6 | cin> x>>y; | ^ /usr/include/c++/14/string_view:710:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 710 | operator> (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:710:5: note: template argument deduction/substitution failed: a.cc:6:9: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int' 6 | cin> x>>y; | ^ /usr/include/c++/14/bits/basic_string.h:3915:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3915 | operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3915:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 6 | cin> x>>y; | ^ /usr/include/c++/14/bits/basic_string.h:3929:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3929 | operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3929:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 6 | cin> x>>y; | ^ /usr/include/c++/14/bits/basic_string.h:3942:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3942 | operator>(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3942:5: note: template argument deduction/substitution failed: a.cc:6:9: note: mismatched types 'const _CharT*' and 'std::basic_istream<char>' 6 | cin> x>>y; | ^ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68: /usr/include/c++/14/tuple:2619:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator>(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)' 2619 | operator>(const tuple<_TElements...>& __t, | ^~~~~~~~ /usr/include/c++/14/tuple:2619:5: note: template argument deduction/substitution failed: a.cc:6:9: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::tuple<_UTypes ...>' 6 | cin> x>>y; | ^
s787694977
p00377
C++
#include<iostream> using namespace std; int main(){ int N,C,p[200]; cin>>N>>C; inbt sum=0; for(int i=0;i<C;i++){ cin>>p[i]; sum+=p[i]; } cout<<sum/(N+1)+(sum%(N;1)!=0)<<endl; return 0; }
a.cc: In function 'int main()': a.cc:7:5: error: 'inbt' was not declared in this scope; did you mean 'int'? 7 | inbt sum=0; | ^~~~ | int a.cc:10:9: error: 'sum' was not declared in this scope 10 | sum+=p[i]; | ^~~ a.cc:13:11: error: 'sum' was not declared in this scope 13 | cout<<sum/(N+1)+(sum%(N;1)!=0)<<endl; | ^~~ a.cc:13:28: error: expected ')' before ';' token 13 | cout<<sum/(N+1)+(sum%(N;1)!=0)<<endl; | ~ ^ | ) a.cc:13:28: error: expected ')' before ';' token 13 | cout<<sum/(N+1)+(sum%(N;1)!=0)<<endl; | ~ ^ | ) a.cc:13:30: error: expected ';' before ')' token 13 | cout<<sum/(N+1)+(sum%(N;1)!=0)<<endl; | ^ | ;
s500834432
p00378
C++
#include <iostream> #include <cstdio> #include <algorithm> using namespace std; int main (){ int a,b,x,az,bz,abh; cin>>a>>b>>x; //////////////////az////////////////// if (x<a){ az=a; } else { az=x/1000*a; if (x%1000!=0){ az+=a; } } //////////////////bz////////////////// if (x<b){ bz=b; } else { bz=x/500*b; if (x%500!=0){ bz+=b; } } /////////////////abh////////////////// if (b*2<a){ } else { }
a.cc: In function 'int main()': a.cc:34:10: error: expected '}' at end of input 34 | } | ^ a.cc:5:12: note: to match this '{' 5 | int main (){ | ^
s213063943
p00378
C++
include <iostream> #include <cstdio> #include <algorithm> using namespace std; int main (){ int a,b,x,az,bz,abh=0; cin>>a>>b>>x; //////////////////az////////////////// if (x<a){ az=a; } else { az=x/1000*a; if (x%1000!=0){ az+=a; } } //////////////////bz////////////////// if (x<b){ bz=b; } else { bz=x/500*b; if (x%500!=0){ bz+=b; } } /////////////////abh////////////////// if (b*2<a){ abh+=x/500*b; if (x%500!=0){ abh+=min(a,b); } } else { //b*2>a abh+=x/1000*a; if (x%1000!=0){ if (x%1000<=500){ abh+=min(a,b); } else { abh+=min(a,b*2); } } } int ans=min(abh,min(az,bz)); cout<<ans<<endl; return 0; }
a.cc:1:1: error: 'include' does not name a type 1 | include <iostream> | ^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/algorithm:60, from a.cc:3: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std' 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std' 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ In file included from /usr/include/stdio.h:34, from /usr/include/c++/14/cstdio:42, from a.cc:2: /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared 2086 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope 2087 | struct remove_extent<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid 2087 | struct remove_extent<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared 2099 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope 2100 | struct remove_all_extents<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid 2100 | struct remove_all_extents<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared 2171 | template<std::size_t _Len> | ^~~ /usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope 2176 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^~~~ /usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^ /usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope 2202 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope 2203 | struct __attribute__((__aligned__((_Align)))) { } __align; | ^~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:65: /usr/include/c++/14/bits/stl_iterator_base_types.h:125:67: error: 'ptrdiff_t' does not name a type 125 | template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t, | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_types.h:1:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' +++ |+#include <cstddef> 1 | // Types used in iterator implementation -*- C++ -*- /usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: error: 'ptrdiff_t' does not name a type 214 | typedef ptrdiff_t difference_type; | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: error: 'ptrdiff_t' does not name a type 225 | typedef ptrdiff_t difference_type; | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' In file included from /usr/include/c++/14/bits/stl_algobase.h:66: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:112:5: error: 'ptrdiff_t' does not name a type 112 | ptrdiff_t | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:66:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 65 | #include <debug/assertions.h> +++ |+#include <cstddef> 66 | #include <bits/stl_iterator_base_types.h> /usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: error: 'ptrdiff_t' does not name a type 118 | ptrdiff_t | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' In file included from /usr/include/c++/14/bits/stl_iterator.h:67, from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/ptr_traits.h:156:47: error: 'ptrdiff_t' was not declared in this scope 1
s037052215
p00379
C++
#include<iostream> #include<cmath> using namespace std; int main(){ int a, n, m; int ans = 0; cin >> a >> n >> m; int kai = powl(a,n)+1; for( kai; kai <= m; kai++) { int sum = 0; while(kai>0){ sum = kai % 10; kai /10; if(kai - powl(a,n) == sum * (sum + 2*a)) ans++; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:28:2: error: expected '}' at end of input 28 | } | ^ a.cc:5:11: note: to match this '{' 5 | int main(){ | ^
s353658121
p00380
C++
#include<bits/c++std.h> using namespace std; int main(void) { int a[300001],A[300001]; int n,q; int x,y; int cnt=0; cin>>n; for(int i=0;i<n;i++){ cin>>a[i]; A[i]=a[i]; } sort(a,a+n); for(int i=0;i<n;i++){ if(a[i]==A[i]){ cnt++; } } if(cnt==n){ cout<<0<<endl; return 0; } cin>>q; for(int i=0;i<q;i++){ cin>>x>>y; x--;y--; if(a[x]==A[x]){ cnt--; } if(a[y]==a[y]){ cnt--; } swap(A[x],A[y]); if(a[x]==A[x]){ cnt++; } if(a[y]==A[y]){ cnt++; } if(cnt==n){ cout<<i+1<<endl; return 0; } } cout<<-1<<endl; return 0; }
a.cc:1:9: fatal error: bits/c++std.h: No such file or directory 1 | #include<bits/c++std.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s065969408
p00382
C++
#include<iostream> #include<set> #include<algorithm> //#include<numeric> using namespace std; int main(){ int N; cin >> N; multiset<int>max; for(int i=1; i<=N; i++) { int M; cin >> M; for(int j=1; j<=M; j++) { int c; cin >> c; max.insert(c); if(max.size() > i) max.erase(max.begin()); } } //cout << accumulate(max.cbegin(), max.cend(), 0) << endl; unsigned long long ans = 0; for(auto it=max.begin(); it<max.end(); it++) ans += it; cout << ans << endl; }
a.cc: In function 'int main()': a.cc:23:30: error: no match for 'operator<' (operand types are 'std::_Rb_tree_const_iterator<int>' and 'std::multiset<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'}) 23 | for(auto it=max.begin(); it<max.end(); it++) ans += it; | ~~^~~~~~~~~~ | | | | | _Rb_tree_const_iterator<[...]> | _Rb_tree_const_iterator<[...]> In file included from /usr/include/c++/14/string:48, 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.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: a.cc:23:39: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'const std::reverse_iterator<_Iterator>' 23 | for(auto it=max.begin(); it<max.end(); it++) ans += it; | ^ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: a.cc:23:39: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'const std::reverse_iterator<_Iterator>' 23 | for(auto it=max.begin(); it<max.end(); it++) ans += it; | ^ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: a.cc:23:39: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'const std::move_iterator<_IteratorL>' 23 | for(auto it=max.begin(); it<max.end(); it++) ans += it; | ^ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: a.cc:23:39: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'const std::move_iterator<_IteratorL>' 23 | for(auto it=max.begin(); it<max.end(); it++) ans += it; | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: a.cc:23:39: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'const std::pair<_T1, _T2>' 23 | for(auto it=max.begin(); it<max.end(); it++) ans += it; | ^ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 673 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed: a.cc:23:39: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 23 | for(auto it=max.begin(); it<max.end(); it++) ans += it; | ^ /usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 680 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed: a.cc:23:39: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 23 | for(auto it=max.begin(); it<max.end(); it++) ans += it; | ^ /usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed: a.cc:23:39: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 23 | for(auto it=max.begin(); it<max.end(); it++) ans += it; | ^ /usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed: a.cc:23:39: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 23 | for(auto it=max.begin(); it<max.end(); it++) ans += it; | ^ /usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3888 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3888:5: note: template argument deduction/substitution failed: a.cc:23:39: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 23 | for(auto it=max.begin(); it<max.end(); it++) ans += it; | ^ /usr/include/c++/14/bits/basic_string.h:3901:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3901 | operator<(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3901:5: note: template argument deduction/substitution failed: a.cc:23:39: note: mismatched types 'const _CharT*' and 'std::_Rb_tree_const_iterator<int>' 23 | for(auto it=max.begin(); it<max.end(); it++) ans += it; | ^ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68: /usr/include/c++/14/tuple:2600:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator<(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)' 2600 | operator<(const tuple<_TElements...>& __t, | ^~~~~~~~ /usr/include/c++/14/tuple:2600:5: note: template argument deduction/substitution failed: a.cc:23:39: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'const std::tuple<_UTypes ...>' 23 | for(auto it=max.begin(); it<max.end(); it++) ans += it; | ^ In file included from /usr/include/c++/14/set:63, from a.cc:2: /usr/include/c++/14/bits/stl_set.h:1025:5: note: candidate: 'template<class _Key, class _Compare, class _Alloc> bool std::operator<(const set<_Key, _Compare, _Allocator>&, const set<_Key, _Compare, _Allocator>&)' 1025 | operator<(const set<_Key, _Compare, _Alloc>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_set.h:1025:5: note: template argument deduction/substitution failed: a.cc:23:39: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'const std::set<_Key, _Compare, _Allocator>' 23 | for(auto it=max.begin(); it<max.end(); it++) ans += it; | ^ In file included from /usr/include/c++/14/set:64: /usr/include/c++/14/bits/stl_multiset.h:1011:5: note: candidate: 'template<class _Key, class _Compare, class _Alloc> bool std::operator<(const multiset<_Key, _Compare, _Allocator>&, const multiset<_Key, _Compare, _Allocator>&)' 1011 | operator<(const multiset<_Key, _Compare, _Alloc>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_multiset.h:1011:5: note: template argument deduction/substitution failed: a.cc:23:39: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'const std::multiset<_Key, _Compare, _Allocator>' 23 | for(auto it=max.begin(); it<max.end(); it++) ans += it; | ^ In file incl
s035690213
p00385
C
#include <stdio.h> typedef struct { long long rotate; int flip; } Query; long long k, n, q; tree[(1 << 20) * 2 + 5]; void init(void) { long long _n = n; long long i; while (_n < n) { _n *= 2; } n = 2; for (long long i = 0; i <= n * 2; i++) { tree[i] = (Query){0, 0}; } return; } Query merge(Query a, Query b) { Query x; x.flip = (a.flip + b.flip) % 2; if (a.flip) x.rotate = a.rotate + b.rotate; else x.rotate = a.rotate - b.rotate; return Query; } void update(Query a, long long k) { k += (n - 1); tree[k] = a; while (k > 0) { k = (k + 1) / 2; tree[k] = merge(tree[k * 2 + 1], tree[k * 2 + 2]); } return; } Query sum(void) { return tree[0]; } int main() { long long a; scanf("%lld %lld %lld", &k, &n, &q); for (long long i = 0; i < n; i++) { Query x = (Query){0, 0}; scanf("%lld", &a); if (a == 0) x.flip = 1; x.rotate = a; update(x, i); } for (long long i = 0; i < q; i++) { long long l, r; scanf("%lld %lld", &l, &r); Query left = tree[l + (n - 1)]; Qeury right = tree[r + (n - 1)]; update(left, r); update(right, l); Query total = sum(); total.rotate = (k - total.rotate) % k; long long num = 1 + total.rotate; if (total.flip) { if (num == 1) { num = -1; } else { num = num - (k + 2); } } printf("%lld\n", num); } return 0; }
main.c:10:1: warning: data definition has no type or storage class 10 | tree[(1 << 20) * 2 + 5]; | ^~~~ main.c:10:1: error: type defaults to 'int' in declaration of 'tree' [-Wimplicit-int] main.c: In function 'init': main.c:22:19: error: incompatible types when assigning to type 'int' from type 'Query' 22 | tree[i] = (Query){0, 0}; | ^ main.c: In function 'merge': main.c:36:12: error: expected expression before 'Query' 36 | return Query; | ^~~~~ main.c: In function 'update': main.c:43:15: error: incompatible types when assigning to type 'int' from type 'Query' 43 | tree[k] = a; | ^ main.c:47:29: error: incompatible type for argument 1 of 'merge' 47 | tree[k] = merge(tree[k * 2 + 1], tree[k * 2 + 2]); | ~~~~^~~~~~~~~~~ | | | int main.c:27:19: note: expected 'Query' but argument is of type 'int' 27 | Query merge(Query a, Query b) | ~~~~~~^ main.c:47:46: error: incompatible type for argument 2 of 'merge' 47 | tree[k] = merge(tree[k * 2 + 1], tree[k * 2 + 2]); | ~~~~^~~~~~~~~~~ | | | int main.c:27:28: note: expected 'Query' but argument is of type 'int' 27 | Query merge(Query a, Query b) | ~~~~~~^ main.c: In function 'sum': main.c:55:16: error: incompatible types when returning type 'int' but 'Query' was expected 55 | return tree[0]; | ~~~~^~~ main.c: In function 'main': main.c:78:22: error: invalid initializer 78 | Query left = tree[l + (n - 1)]; | ^~~~ main.c:79:9: error: unknown type name 'Qeury'; did you mean 'Query'? 79 | Qeury right = tree[r + (n - 1)]; | ^~~~~ | Query main.c:82:16: error: incompatible type for argument 1 of 'update' 82 | update(right, l); | ^~~~~ | | | int main.c:39:19: note: expected 'Query' but argument is of type 'int' 39 | void update(Query a, long long k) | ~~~~~~^
s422890993
p00385
C
#include <stdio.h> typedef struct { long long rotate; int flip; } Query; long long k, n, q; Query tree[(1 << 20) * 2 + 5]; void init(void) { long long _n = n; long long i; while (_n < n) { _n *= 2; } n = 2; for (long long i = 0; i <= n * 2; i++) { tree[i] = (Query){0, 0}; } return; } Query merge(Query a, Query b) { Query x; x.flip = (a.flip + b.flip) % 2; if (a.flip) x.rotate = a.rotate + b.rotate; else x.rotate = a.rotate - b.rotate; return Query; } void update(Query a, long long k) { k += (n - 1); tree[k] = a; while (k > 0) { k = (k + 1) / 2; tree[k] = merge(tree[k * 2 + 1], tree[k * 2 + 2]); } return; } Query sum(void) { return tree[0]; } int main() { long long a; scanf("%lld %lld %lld", &k, &n, &q); for (long long i = 0; i < n; i++) { Query x = (Query){0, 0}; scanf("%lld", &a); if (a == 0) x.flip = 1; x.rotate = a; update(x, i); } for (long long i = 0; i < q; i++) { long long l, r; scanf("%lld %lld", &l, &r); Query left = tree[l + (n - 1)]; Qeury right = tree[r + (n - 1)]; update(left, r); update(right, l); Query total = sum(); total.rotate = (k - total.rotate) % k; long long num = 1 + total.rotate; if (total.flip) { if (num == 1) { num = -1; } else { num = num - (k + 2); } } printf("%lld\n", num); } return 0; }
main.c: In function 'merge': main.c:36:12: error: expected expression before 'Query' 36 | return Query; | ^~~~~ main.c: In function 'main': main.c:79:9: error: unknown type name 'Qeury'; did you mean 'Query'? 79 | Qeury right = tree[r + (n - 1)]; | ^~~~~ | Query main.c:79:23: error: incompatible types when initializing type 'int' using type 'Query' 79 | Qeury right = tree[r + (n - 1)]; | ^~~~ main.c:82:16: error: incompatible type for argument 1 of 'update' 82 | update(right, l); | ^~~~~ | | | int main.c:39:19: note: expected 'Query' but argument is of type 'int' 39 | void update(Query a, long long k) | ~~~~~~^
s066993044
p00385
C
#include <stdio.h> typedef struct { long long rotate; int flip; } Query; long long k, n, q; Query tree[(1 << 20) * 2 + 5]; void init(void) { long long _n = n; long long i; while (_n < n) { _n *= 2; } n = 2; for (long long i = 0; i <= n * 2; i++) { tree[i] = (Query){0, 0}; } return; } Query merge(Query a, Query b) { Query x; x.flip = (a.flip + b.flip) % 2; if (a.flip) x.rotate = a.rotate + b.rotate; else x.rotate = a.rotate - b.rotate; return x; } void update(Query a, long long k) { k += (n - 1); tree[k] = a; while (k > 0) { k = (k + 1) / 2; tree[k] = merge(tree[k * 2 + 1], tree[k * 2 + 2]); } return; } Query sum(void) { return tree[0]; } int main() { long long a; scanf("%lld %lld %lld", &k, &n, &q); for (long long i = 0; i < n; i++) { Query x = (Query){0, 0}; scanf("%lld", &a); if (a == 0) x.flip = 1; x.rotate = a; update(x, i); } for (long long i = 0; i < q; i++) { long long l, r; scanf("%lld %lld", &l, &r); Query left = tree[l + (n - 1)]; Qeury right = tree[r + (n - 1)]; update(left, r); update(right, l); Query total = sum(); total.rotate = (k - total.rotate) % k; long long num = 1 + total.rotate; if (total.flip) { if (num == 1) { num = -1; } else { num = num - (k + 2); } } printf("%lld\n", num); } return 0; }
main.c: In function 'main': main.c:79:9: error: unknown type name 'Qeury'; did you mean 'Query'? 79 | Qeury right = tree[r + (n - 1)]; | ^~~~~ | Query main.c:79:23: error: incompatible types when initializing type 'int' using type 'Query' 79 | Qeury right = tree[r + (n - 1)]; | ^~~~ main.c:82:16: error: incompatible type for argument 1 of 'update' 82 | update(right, l); | ^~~~~ | | | int main.c:39:19: note: expected 'Query' but argument is of type 'int' 39 | void update(Query a, long long k) | ~~~~~~^
s384444299
p00387
Java
public class Main{ public static void main(String[] args){ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder createString = new StringBuilder(); String line = br.readLine(); String[] numbers = line.split(" "); int A = Integer.valueOf(numbers[0]); int B = Integer.valueOf(numbers[1]); int num = Math.floorDiv(B,A) + 1; System.out.print(num); } }
Main.java:5: error: cannot find symbol BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class BufferedReader location: class Main Main.java:5: error: cannot find symbol BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class BufferedReader location: class Main Main.java:5: error: cannot find symbol BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class InputStreamReader location: class Main 3 errors
s906605306
p00387
Java
import java.io.*; public class Main{ public static void main(String[] args){ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder createString = new StringBuilder(); String line = br.readLine(); String[] numbers = line.split(" "); int A = Integer.valueOf(numbers[0]); int B = Integer.valueOf(numbers[1]); int num = Math.floorDiv(B,A) + 1; System.out.print(num); } }
Main.java:8: error: unreported exception IOException; must be caught or declared to be thrown String line = br.readLine(); ^ 1 error
s167271719
p00388
C++
#include<cassert> using namespace std; int main() { int H, A, B; cin >> H >> A >> B; int cnt = 0; for ( int i = A; i <= B; i++ ){ cnt += (H % i == 0 ); } cout << cnt << endl; }
a.cc: In function 'int main()': a.cc:5:16: error: 'cin' was not declared in this scope 5 | int H, A, B; cin >> H >> A >> B; | ^~~ a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 1 | #include<cassert> +++ |+#include <iostream> 2 | using namespace std; a.cc:12:3: error: 'cout' was not declared in this scope 12 | cout << cnt << endl; | ^~~~ a.cc:12:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:12:18: error: 'endl' was not declared in this scope 12 | cout << cnt << endl; | ^~~~ a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 1 | #include<cassert> +++ |+#include <ostream> 2 | using namespace std;
s608731236
p00390
C++
#include <bits/stdc++.h> using namespace std; bool fin; int main(){ int n,ans; cin>>n; vector<pair<int,int> >v(n); for(int i=0;i<n;++i){cin>>v[i].first;} for(int i=0;i<n;++i){cin>>v[i].second;} sort(v.begin(),v.end()); if(v[0].first==1){ cout<<0<<endl; return 0; } ans=v[0].second; for(int i=0;i<n;++i){ if(v[i].first==1){ ans+=v[i].second; fin=1; break; } } if(fi){cout<<ans<<endl;} else{cout<<0<<endl;} }
a.cc: In function 'int main()': a.cc:24:6: error: 'fi' was not declared in this scope; did you mean 'fin'? 24 | if(fi){cout<<ans<<endl;} | ^~ | fin
s280957622
p00423
Java
public class CardSum { public static void main(String[] args) { // 自分の得意な言語で // Let's チャレンジ!! Scanner sc = new Scanner(System.in); while(true) { // 配られるカードの枚数取得 int loopCnt = Integer.parseInt(sc.nextLine()); if(loopCnt==0)break; // プレイヤーAの得点 int sumA=0; // プレイヤーBの得点 int sumB=0; // 枚数分ループ for(int cnt=1;cnt<=loopCnt;cnt++) { // カード取得 List<String> listString = Arrays.asList(sc.nextLine().split(" ")); List<Integer> list = new ArrayList<>(); for (String num : listString) { list.add(Integer.parseInt(num)); } // カード比較 if (list.get(0) == list.get(1)) { // 同値の場合 sumA += list.get(0); sumB += list.get(1); } else if (list.get(0) > list.get(1)) { // Aが大きい場合 sumA += list.get(0) + list.get(1); } else { // Bが大きい場合 sumB += list.get(0) + list.get(1); } } System.out.println(sumA+" "+sumB); } } }
Main.java:1: error: class CardSum is public, should be declared in a file named CardSum.java public class CardSum { ^ Main.java:6: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class CardSum Main.java:6: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class CardSum Main.java:19: error: cannot find symbol List<String> listString = Arrays.asList(sc.nextLine().split(" ")); ^ symbol: class List location: class CardSum Main.java:19: error: cannot find symbol List<String> listString = Arrays.asList(sc.nextLine().split(" ")); ^ symbol: variable Arrays location: class CardSum Main.java:20: error: cannot find symbol List<Integer> list = new ArrayList<>(); ^ symbol: class List location: class CardSum Main.java:20: error: cannot find symbol List<Integer> list = new ArrayList<>(); ^ symbol: class ArrayList location: class CardSum 7 errors
s111669497
p00423
Java
package sample; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; public class CardSum { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(true) { // 配られるカードの枚数取得 int loopCnt = Integer.parseInt(sc.nextLine()); if(loopCnt==0)break; // プレイヤーAの得点 int sumA=0; // プレイヤーBの得点 int sumB=0; // 枚数分ループ for(int cnt=1;cnt<=loopCnt;cnt++) { // カード取得 List<String> listString = Arrays.asList(sc.nextLine().split(" ")); List<Integer> list = new ArrayList<>(); for (String num : listString) { list.add(Integer.parseInt(num)); } // カード比較 if (list.get(0) == list.get(1)) { // 同値の場合 sumA += list.get(0); sumB += list.get(1); } else if (list.get(0) > list.get(1)) { // Aが大きい場合 sumA += list.get(0) + list.get(1); } else { // Bが大きい場合 sumB += list.get(0) + list.get(1); } } System.out.println(sumA+" "+sumB); } } }
Main.java:8: error: class CardSum is public, should be declared in a file named CardSum.java public class CardSum { ^ 1 error
s115615396
p00423
Java
package sample; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; public class CardSum { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(true) { // 配られるカードの枚数取得 int loopCnt = Integer.parseInt(sc.nextLine()); if(loopCnt==0)break; // プレイヤーAの得点 int sumA=0; // プレイヤーBの得点 int sumB=0; // 枚数分ループ for(int cnt=1;cnt<=loopCnt;cnt++) { // カード取得 List<String> listString = Arrays.asList(sc.nextLine().split(" ")); List<Integer> list = new ArrayList<>(); for (String num : listString) { list.add(Integer.parseInt(num)); } // カード比較 if (list.get(0) == list.get(1)) { // 同値の場合 sumA += list.get(0); sumB += list.get(1); } else if (list.get(0) > list.get(1)) { // Aが大きい場合 sumA += list.get(0) + list.get(1); } else { // Bが大きい場合 sumB += list.get(0) + list.get(1); } } System.out.println(sumA+" "+sumB); } } }
Main.java:8: error: class CardSum is public, should be declared in a file named CardSum.java public class CardSum { ^ 1 error
s574474495
p00423
Java
public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(true) { // 配られるカードの枚数取得 int loopCnt = Integer.parseInt(sc.nextLine()); if(loopCnt==0)break; // プレイヤーAの得点 int sumA=0; // プレイヤーBの得点 int sumB=0; // 枚数分ループ for(int cnt=1;cnt<=loopCnt;cnt++) { // カード取得 List<String> listString = Arrays.asList(sc.nextLine().split(" ")); List<Integer> list = new ArrayList<>(); for (String num : listString) { list.add(Integer.parseInt(num)); } // カード比較 if (list.get(0) == list.get(1)) { // 同値の場合 sumA += list.get(0); sumB += list.get(1); } else if (list.get(0) > list.get(1)) { // Aが大きい場合 sumA += list.get(0) + list.get(1); } else { // Bが大きい場合 sumB += list.get(0) + list.get(1); } } System.out.println(sumA+" "+sumB); } }
Main.java:1: error: unnamed classes are a preview feature and are disabled by default. public static void main(String[] args) { ^ (use --enable-preview to enable unnamed classes) 1 error
s462197815
p00423
Java
import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; public class CardSum { public static void main(String[] args) { // 自分の得意な言語で // Let's チャレンジ!! Scanner sc = new Scanner(System.in); while(true) { // 配られるカードの枚数取得 int loopCnt = Integer.parseInt(sc.nextLine()); if(loopCnt==0)break; // プレイヤーAの得点 int sumA=0; // プレイヤーBの得点 int sumB=0; // 枚数分ループ for(int cnt=1;cnt<=loopCnt;cnt++) { // カード取得 List<String> listString = Arrays.asList(sc.nextLine().split(" ")); List<Integer> list = new ArrayList<>(); for (String num : listString) { list.add(Integer.parseInt(num)); } // カード比較 if (list.get(0) == list.get(1)) { // 同値の場合 sumA += list.get(0); sumB += list.get(1); } else if (list.get(0) > list.get(1)) { // Aが大きい場合 sumA += list.get(0) + list.get(1); } else { // Bが大きい場合 sumB += list.get(0) + list.get(1); } } System.out.println(sumA+" "+sumB); } } }
Main.java:6: error: class CardSum is public, should be declared in a file named CardSum.java public class CardSum { ^ 1 error
s843406858
p00423
Java
import java.util.ArrayList; import java.util.Scanner; public class q0500 { public static void main (String[] args){ Scanner s = new Scanner(System.in); ArrayList<Integer> a = new ArrayList<>(); ArrayList<Integer> b = new ArrayList<>(); int n = s.nextInt(); while(n != 0){ int x[] = new int[n]; int y[] = new int[n]; int x1 = 0; int y1 = 0; for(int i = 0; i < n; i++){ x[i] = s.nextInt(); y[i] = s.nextInt(); if(x[i] > y[i]){ x1 += x[i] + y[i]; } else if( x[i] < y[i]){ y1 += x[i] + y[i]; } else{ x1 += x[i]; y1 += y[i]; } } a.add(x1); b.add(y1); n = s.nextInt(); } for (int i = 0 ;i < a.size() ; i++){ System.out.println(a.get(i) + " " + b.get(i)); } } }
Main.java:4: error: class q0500 is public, should be declared in a file named q0500.java public class q0500 { ^ 1 error
s306491492
p00423
Java
import java.util.ArrayList; import java.util.Scanner; public class q0500 { public static void main (String[] args){ Scanner s = new Scanner(System.in); ArrayList<Integer> a = new ArrayList<Integer>(); ArrayList<Integer> b = new ArrayList<Integer>(); int n = s.nextInt(); while(n != 0){ int x[] = new int[n]; int y[] = new int[n]; int x1 = 0; int y1 = 0; for(int i = 0; i < n; i++){ x[i] = s.nextInt(); y[i] = s.nextInt(); if(x[i] > y[i]){ x1 += x[i] + y[i]; } else if( x[i] < y[i]){ y1 += x[i] + y[i]; } else{ x1 += x[i]; y1 += y[i]; } } a.add(x1); b.add(y1); n = s.nextInt(); } for (int i = 0 ;i < a.size() ; i++){ System.out.println(a.get(i) + " " + b.get(i)); } } }
Main.java:4: error: class q0500 is public, should be declared in a file named q0500.java public class q0500 { ^ 1 error
s018369758
p00423
Java
/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class Ideone { public static void main (String[] args) throws java.lang.Exception { int n = System.in.read(); int as = 0; int bs = 0; for (int i=0; i<n ;i++){ String tmp = System.in.read(); String[] buf = tmp.split(" "); int a = Integer.parseInt(buf[0]); int b = Integer.parseInt(buf[1]); if ( a > b ){ as += a + b; }else if (a < b){ bs += a + b; }else{ as += a; bs += b; } } System.out.println(as + " " + bs); } }
Main.java:17: error: incompatible types: int cannot be converted to String String tmp = System.in.read(); ^ 1 error
s225037988
p00423
Java
import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Deque; import java.util.HashMap; import java.util.InputMismatchException; import java.util.Map; import java.util.PriorityQueue??? import java.util.Scanner; import java.math.BigInteger; public class Main{ static final InputStream in=System.in; static final PrintWriter out=new PrintWriter(System.out); static final int INF=Integer.MAX_VALUE/2; static final long LINF=Long.MAX_VALUE/2; public static void main(String[] args) throws IOException{ Scanner ir=new Scanner(in); while(sc.hasNextInt()){ int N=ir.nextInt(); int acnt,bcnt; acnt=bcnt=0; while(N-->0){ int a=ir.nextInt(); int b=ir.nextInt(); if(a>b) acnt+=(a+b); else if(a==b){ acnt+=a; bcnt+=b; } else bcnt+=(a+b); } out.println(acnt+" "+bcnt); } out.flush(); } static class InputReader { private InputStream in; private byte[] buffer=new byte[1024]; private int curbuf; private int lenbuf; public InputReader(InputStream in) {this.in=in;} public int readByte() { if(lenbuf==-1) throw new InputMismatchException(); if(curbuf>=lenbuf){ curbuf= 0; try{ lenbuf=in.read(buffer); } catch (IOException e) { throw new InputMismatchException(); } if(lenbuf<=0) return -1; } return buffer[curbuf++]; } public boolean isSpaceChar(int c){return !(c>=33&&c<=126);} private int skip() {int b; while((b = readByte())!=-1&&isSpaceChar(b)); return b;} public String next() { int b=skip(); StringBuilder sb=new StringBuilder(); while(!isSpaceChar(b)){ sb.appendCodePoint(b); b=readByte(); } return sb.toString(); } public int nextInt() { int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } int res=0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public long nextLong() { int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } long res = 0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public int[] toIntArray(int n){ int[] a=new int[n]; for(int i=0;i<n;i++) a[i]=nextInt(); return a; } } }
Main.java:13: error: ';' expected import java.util.PriorityQueue??? ^ 1 error
s626875907
p00423
Java
import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Deque; import java.util.HashMap; import java.util.InputMismatchException; import java.util.Map; import java.util.PriorityQueue; import java.util.Scanner; import java.math.BigInteger; public class Main{ static final InputStream in=System.in; static final PrintWriter out=new PrintWriter(System.out); static final int INF=Integer.MAX_VALUE/2; static final long LINF=Long.MAX_VALUE/2; public static void main(String[] args) throws IOException{ Scanner ir=new Scanner(in); while(sc.hasNextInt()){ int N=ir.nextInt(); int acnt,bcnt; acnt=bcnt=0; while(N-->0){ int a=ir.nextInt(); int b=ir.nextInt(); if(a>b) acnt+=(a+b); else if(a==b){ acnt+=a; bcnt+=b; } else bcnt+=(a+b); } out.println(acnt+" "+bcnt); } out.flush(); } static class InputReader { private InputStream in; private byte[] buffer=new byte[1024]; private int curbuf; private int lenbuf; public InputReader(InputStream in) {this.in=in;} public int readByte() { if(lenbuf==-1) throw new InputMismatchException(); if(curbuf>=lenbuf){ curbuf= 0; try{ lenbuf=in.read(buffer); } catch (IOException e) { throw new InputMismatchException(); } if(lenbuf<=0) return -1; } return buffer[curbuf++]; } public boolean isSpaceChar(int c){return !(c>=33&&c<=126);} private int skip() {int b; while((b = readByte())!=-1&&isSpaceChar(b)); return b;} public String next() { int b=skip(); StringBuilder sb=new StringBuilder(); while(!isSpaceChar(b)){ sb.appendCodePoint(b); b=readByte(); } return sb.toString(); } public int nextInt() { int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } int res=0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public long nextLong() { int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } long res = 0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public int[] toIntArray(int n){ int[] a=new int[n]; for(int i=0;i<n;i++) a[i]=nextInt(); return a; } } }
Main.java:26: error: cannot find symbol while(sc.hasNextInt()){ ^ symbol: variable sc location: class Main 1 error
s481866636
p00423
Java
package aizuonlinejava; public class Practice { void practice(int n){ int a = 0,b = 0,aa,bb,i; if(n != 0){ return; } for(i = 0; i < n; i++){ if( a > b){ aa = a + b; } else if (a < b){ bb = a + b; } else{ aa = a; bb = b; } } } }
Main.java:3: error: class Practice is public, should be declared in a file named Practice.java public class Practice { ^ 1 error
s906552322
p00423
Java
import java.io.InputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatchException; import java.util.NoSuchElementException; import java.math.BigInteger; public class Main{ static PrintWriter out; static InputReader ir; static void solve(){ for(;;){ int n=ir.nextInt(); if(n==0) break; int acnt=0,bcnt=0; while(n-->0){ int a=ir.nextInt(); int b=ir.nextInt(); if(a>b) acnt+=a+b; else if(a==b){ acnt+=a; bcnt+=b; } else bcnt+=a+b; } out.println(acnt+" "+bcnt); } } } public static void main(String[] args) throws Exception{ ir=new InputReader(System.in); out=new PrintWriter(System.out); solve(); out.flush(); } static class InputReader { private InputStream in; private byte[] buffer=new byte[1024]; private int curbuf; private int lenbuf; public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;} public boolean hasNextByte() { if(curbuf>=lenbuf){ curbuf= 0; try{ lenbuf=in.read(buffer); }catch(IOException e) { throw new InputMismatchException(); } if(lenbuf<=0) return false; } return true; } private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;} private boolean isSpaceChar(int c){return !(c>=33&&c<=126);} private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;} public boolean hasNext(){skip(); return hasNextByte();} public int nextInt() { if(!hasNext()) throw new NoSuchElementException(); int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } int res=0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } }
Main.java:36: error: unnamed classes are a preview feature and are disabled by default. public static void main(String[] args) throws Exception{ ^ (use --enable-preview to enable unnamed classes) 1 error
s093627086
p00423
Java
import java.io.InputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatchException; import java.util.NoSuchElementException; import java.math.BigInteger; public class Main{ static PrintWriter out; static InputReader ir; static void solve(){ for(;;){ int n=ir.nextInt(); if(n==0) break; int acnt=0,bcnt=0; while(n-->0){ int a=ir.nextInt(); int b=ir.nextInt(); if(a>b) acnt+=a+b; else if(a==b){ acnt+=a; bcnt+=b; } else bcnt+=a+b; } out.println(acnt+" "+bcnt); } } } public static void main(String[] args) throws Exception{ ir=new InputReader(System.in); out=new PrintWriter(System.out); solve(); out.flush(); } static class InputReader { private InputStream in; private byte[] buffer=new byte[1024]; private int curbuf; private int lenbuf; public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;} public boolean hasNextByte() { if(curbuf>=lenbuf){ curbuf= 0; try{ lenbuf=in.read(buffer); }catch(IOException e) { throw new InputMismatchException(); } if(lenbuf<=0) return false; } return true; } private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;} private boolean isSpaceChar(int c){return !(c>=33&&c<=126);} private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;} public boolean hasNext(){skip(); return hasNextByte();} public int nextInt() { if(!hasNext()) throw new NoSuchElementException(); int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } int res=0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } } }
Main.java:36: error: unnamed classes are a preview feature and are disabled by default. public static void main(String[] args) throws Exception{ ^ (use --enable-preview to enable unnamed classes) Main.java:90: error: class, interface, enum, or record expected } ^ 2 errors
s852779165
p00423
Java
public class Main{ public static void main(String[] args) throws Exception{ BufferedReader bf =new BufferedReader( new InputStreamReader(System.in)); int n = Integer.parseInt(bf.readLine()); System.out.println(n); while(n != 0) { Score s = new Score(); for (int i = 0; i < n; i++){ String new_line = bf.readLine(); String[] data = new_line.split(" "); int a = Integer.parseInt(data[0]); int b = Integer.parseInt(data[1]); s.openCard(a,b); //System.out.println("a = " + a + " b = " + b); } s.print(); n = Integer.parseInt(bf.readLine()); } //System.out.print("finish"); } } class Score{ int A=0 ,B =0; public Score(){ } public void openCard(int a, int b){ if(a>b){ A += (a+b); return; } if(b > a){ B += (a+b); return; } A += a; B += b; } public void print(){ System.out.print(A+" "+B); } }
Main.java:4: error: cannot find symbol BufferedReader bf =new BufferedReader( new InputStreamReader(System.in)); ^ symbol: class BufferedReader location: class Main Main.java:4: error: cannot find symbol BufferedReader bf =new BufferedReader( new InputStreamReader(System.in)); ^ symbol: class BufferedReader location: class Main Main.java:4: error: cannot find symbol BufferedReader bf =new BufferedReader( new InputStreamReader(System.in)); ^ symbol: class InputStreamReader location: class Main 3 errors
s749721548
p00423
Java
class Main{ static Scanner s = new Scanner(System.in); public static void main(String[] args){ int sca=0,scb=0,a,b,x; while((x=Integer.parseInt(s.next()))!=0) { sca=0;scb=0;a=0;b=0; for(int i=x;i>0;--i) { a=Integer.parseInt(s.next()); b=Integer.parseInt(s.next()); if(a>b) { sca+=a+b; }else if(a<b) { scb+=a+b; }else { sca+=a; scb+=b; } } System.out.printf("%d %d\n",sca,scb); } } }
Main.java:2: error: cannot find symbol static Scanner s = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:2: error: cannot find symbol static Scanner s = new Scanner(System.in); ^ symbol: class Scanner location: class Main 2 errors
s087669166
p00423
Java
import java.io.*; public class Main0500{ static int Ap = 0; static int Bp = 0; public static void main(String[] args){ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try{ while(true){ int a = Integer.parseInt(br.readLine()); if(a == 0) break; Ap = Bp = 0; for(int i = 0; i < a; i++){ String[] tmp = br.readLine().split(" " , 2); int[] points = new int[2]; points[0] = Integer.parseInt(tmp[0]); points[1] = Integer.parseInt(tmp[1]); judgement(points); } System.out.println(Ap + " " + Bp); } }catch(IOException e){ e.printStackTrace(); } } public static void judgement (int[] p){ if(p[0] > p[1]){ Ap += (p[0]+p[1]); }else if(p[0] < p[1]){ Bp += (p[0]+p[1]); }else if(p[0] == p[1]){ Ap += p[0]; Bp += p[1]; } } }
Main.java:3: error: class Main0500 is public, should be declared in a file named Main0500.java public class Main0500{ ^ 1 error
s665448333
p00423
Java
import java.io.*; public class main{ public static void main(String[] args){ BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); try{ while(true){ int n = Integer.parseInt(bf.readLine()); if(n == 0){ break; } Shobu(n); } }catch(IOException e){ System.out.println(e); } } private static void Shobu(int n){ BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); try{ int[] a = new int[n]; int[] b = new int[n]; for(int i = 0; i < n; i++){ String line = bf.readLine(); String[] strAry = line.split(" "); a[i] = Integer.parseInt(strAry[0]); b[i] = Integer.parseInt(strAry[1]); } int a_gou = 0; int b_gou = 0; for(int i = 0; i < n; i++){ if(a[i] > b[i]){ a_gou += Katimake(a[i], b[i]); }else if(a[i] < b[i]){ b_gou += Katimake(a[i], b[i]); }else{ a_gou += Katimake(a[i], b[i]); b_gou += Katimake(a[i], b[i]); } } System.out.println(a_gou + " " + b_gou); }catch(IOException e){ System.out.println(e); } } public static int Katimake(int x, int y){ if(x == y){ return x; }else{ return (x + y); } } }
Main.java:3: error: class main is public, should be declared in a file named main.java public class main{ ^ 1 error
s888158862
p00423
Java
package jp.co.practice.volume5; import java.util.Scanner; public class Question0500 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int times = Integer.parseInt(sc.nextLine()); while (0 < times) { compare(sc, times); times = Integer.parseInt(sc.nextLine()); } } private static void compare(Scanner sc, int times) { int a_total = 0, b_total = 0; int counter = 1; while (counter <= times) { String[] line = sc.nextLine().split(" "); int a = Integer.parseInt(line[0]); int b = Integer.parseInt(line[1]); if (a > b) { a_total += a + b; } if (a < b) { b_total += a + b; } if (a == b) { a_total += a; b_total += b; } counter++; } System.out.println(a_total + " " + b_total); } }
Main.java:5: error: class Question0500 is public, should be declared in a file named Question0500.java public class Question0500 { ^ 1 error
s004534858
p00423
Java
import java.util.Scanner; public class Question0500 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int times = Integer.parseInt(sc.nextLine()); while (0 < times) { compare(sc, times); times = Integer.parseInt(sc.nextLine()); } } private static void compare(Scanner sc, int times) { int a_total = 0, b_total = 0; int counter = 1; while (counter <= times) { String[] line = sc.nextLine().split(" "); int a = Integer.parseInt(line[0]); int b = Integer.parseInt(line[1]); if (a > b) { a_total += a + b; } if (a < b) { b_total += a + b; } if (a == b) { a_total += a; b_total += b; } counter++; } System.out.println(a_total + " " + b_total); } }
Main.java:3: error: class Question0500 is public, should be declared in a file named Question0500.java public class Question0500 { ^ 1 error
s453769538
p00423
Java
import java.util.Scanner; class Main{ public static void main(String[] a){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int ua = 0; int ub = 0; for(i=0; i<n; i++) { int va = sc.nextInt(); int vb = sc.nextInt(); if (va > vb) { ua += va+vb; } else if (vb > va) { ub += va + vb; } else { ua += va; ub += vb; } } System.out.println(ua + " " + ub); } }
Main.java:10: error: cannot find symbol for(i=0; i<n; i++) { ^ symbol: variable i location: class Main Main.java:10: error: cannot find symbol for(i=0; i<n; i++) { ^ symbol: variable i location: class Main Main.java:10: error: cannot find symbol for(i=0; i<n; i++) { ^ symbol: variable i location: class Main 3 errors
s826566359
p00423
Java
import java.util.Scanner; class Main{ public static void main(String[] a){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); if (n != 0) { int ua = 0; int ub = 0; for(int i=0; i<n; i++) { int va = sc.nextInt(); int vb = sc.nextInt(); if (va > vb) { ua += va+vb; } else if (vb > va) { ub += va + vb; } else { ua += va; ub += vb; } } } System.out.println(ua + " " + ub); } }
Main.java:24: error: cannot find symbol System.out.println(ua + " " + ub); ^ symbol: variable ua location: class Main Main.java:24: error: cannot find symbol System.out.println(ua + " " + ub); ^ symbol: variable ub location: class Main 2 errors
s167311533
p00423
Java
import java.util.Scanner; class Main{ public static void main(String[] a){ Scanner sc = new Scanner(System.in); while(0) { int n = sc.nextInt(); if(n == 0) { break; } else if (n != 0) { int ua = 0; int ub = 0; for(int i=0; i<n; i++) { int va = sc.nextInt(); int vb = sc.nextInt(); if (va > vb) { ua += va+vb; } else if (vb > va) { ub += va + vb; } else if (vb == va) { ua += va; ub += vb; } } System.out.println(ua + " " + ub); } } } }
Main.java:7: error: incompatible types: int cannot be converted to boolean while(0) { ^ 1 error
s549414710
p00423
Java
import java.util.Scanner; class Main{ public static void main(String[] a){ Scanner sc = new Scanner(System.in); while(0) { int n = sc.nextInt(); if(n == 0) { break; } else if (n != 0) { int ua = 0; int ub = 0; for(int i=0; i<n; i++) { int va = sc.nextInt(); int vb = sc.nextInt(); if (va > vb) { ua += va+vb; } else if (vb > va) { ub += va + vb; } else { ua += va; ub += vb; } } System.out.println(ua + " " + ub); } } } }
Main.java:7: error: incompatible types: int cannot be converted to boolean while(0) { ^ 1 error
s028004590
p00423
Java
public class problem1 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); while(true){ int in = scan.nextInt(); if(in == 0) return; int aSum = 0; int bSum = 0; for(int i = 0; i < in; i++){ int a = scan.nextInt(); int b = scan.nextInt(); if(a > b){ aSum += a+b; }else if(a < b){ bSum += a+b; }else{ aSum += a; bSum += b; } } System.out.println(aSum +" "+ bSum); } } }
Main.java:1: error: class problem1 is public, should be declared in a file named problem1.java public class problem1 { ^ Main.java:4: error: cannot find symbol Scanner scan = new Scanner(System.in); ^ symbol: class Scanner location: class problem1 Main.java:4: error: cannot find symbol Scanner scan = new Scanner(System.in); ^ symbol: class Scanner location: class problem1 3 errors
s567158576
p00423
Java
public class pro500 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); while (true) { int cnt = in.nextInt(); if(cnt==0)break; int i = 0; int[] str = new int[cnt * 2]; while (i < cnt * 2) { str[i] = in.nextInt(); i++; } int p1=0,p2=0; for(int j=0;j<cnt*2;j+=2){ if(str[j]>str[j+1])p1+=(str[j]+str[j+1]); else if(str[j]<str[j+1])p2+=(str[j]+str[j+1]); else{ p1+=str[j]; p2+=str[j+1]; } } System.out.println(p1+" "+p2); } } }
Main.java:1: error: class pro500 is public, should be declared in a file named pro500.java public class pro500 { ^ Main.java:9: error: cannot find symbol Scanner in = new Scanner(System.in); ^ symbol: class Scanner location: class pro500 Main.java:9: error: cannot find symbol Scanner in = new Scanner(System.in); ^ symbol: class Scanner location: class pro500 3 errors
s934933925
p00423
Java
import java.util.Scanner; public class pro500 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); while (true) { int cnt = in.nextInt(); if(cnt==0)break; int i = 0; int[] str = new int[cnt * 2]; while (i < cnt * 2) { str[i] = in.nextInt(); i++; } int p1=0,p2=0; for(int j=0;j<cnt*2;j+=2){ if(str[j]>str[j+1])p1+=(str[j]+str[j+1]); else if(str[j]<str[j+1])p2+=(str[j]+str[j+1]); else{ p1+=str[j]; p2+=str[j+1]; } } System.out.println(p1+" "+p2); } } }
Main.java:3: error: class pro500 is public, should be declared in a file named pro500.java public class pro500 { ^ 1 error
s430269764
p00423
Java
import java.util.Scanner; public class main { main(){ Scanner in= new Scanner(System.in); int a=0,b=0,temp1,temp2; for(int i=0;i<in.nextInt();i++){ temp1=in.nextInt(); temp2=in.nextInt(); if(temp1>temp2){ a+=temp1+temp2; } else if(temp1==temp2){ a+=temp1;b=a+=temp2; } else{ b+=temp1+temp2; } } System.out.printf("%d %d\n",a,b); } }
Main.java:3: error: class main is public, should be declared in a file named main.java public class main { ^ 1 error
s966252956
p00423
Java
import java.util.Scanner; public class main { public static void main(){ Scanner in= new Scanner(System.in); int a=0,b=0,temp1,temp2; for(int i=0;i<in.nextInt();i++){ temp1=in.nextInt(); temp2=in.nextInt(); if(temp1>temp2){ a+=temp1+temp2; } else if(temp1==temp2){ a+=temp1;b=a+=temp2; } else{ b+=temp1+temp2; } } System.out.printf("%d %d\n",a,b); } }
Main.java:3: error: class main is public, should be declared in a file named main.java public class main { ^ 1 error
s035647257
p00423
Java
public class Main { public static void main(String[] args){ Scanner in= new Scanner(System.in); int a=0,b=0,temp1,temp2,j; j=in.nextInt(); while(j!=0){ for(int i=0;i<in.nextInt();i++){ temp1=in.nextInt(); temp2=in.nextInt(); if(temp1>temp2){ a+=temp1+temp2; } else if(temp1==temp2){ a+=temp1;b=a+=temp2; } else{ b+=temp1+temp2; } } System.out.printf("%d %d\n",a,b); j=in.nextInt(); } } }
Main.java:3: error: cannot find symbol Scanner in= new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:3: error: cannot find symbol Scanner in= new Scanner(System.in); ^ symbol: class Scanner location: class Main 2 errors
s269050688
p00423
Java
import java.util.ArrayList; import java.util.Scanner; import java.util.Stack; public class Test { public static void main(String args[]) { Scanner scanner = new Scanner(System.in); int n; while((n=scanner.nextInt())>0){ int a=0,b=0; for(int i=0;i<n;i++){ int aa=scanner.nextInt(),bb=scanner.nextInt(); if(aa>bb)a+=aa+bb; else if(aa<bb)b+=aa+bb; else {a+=aa;b+=bb;} } System.out.println(a + " "+b); } } }
Main.java:5: error: class Test is public, should be declared in a file named Test.java public class Test { ^ 1 error
s279693728
p00423
Java
import java.util.Scanner; public class Exp { public static void main(String[] args) { int size; int A = 0; int B = 0; int i = 0; Scanner scan = new Scanner(System.in); while(true){ while(true){ if(scan.hasNext() == true){ size = scan.nextInt(); break; } } int[] arr = new int[size * 2]; while(i < 2 * size){ if(scan.hasNext() == true){ arr[i] = scan.nextInt(); i++; } } i = 0; while(i < 2 * size){ if(arr[i] < arr[i + 1]){ B += (arr[i] + arr[i + 1]); } else if(arr[i] > arr[i + 1]){ A += (arr[i] + arr[i + 1]); } else{ A += arr[i]; B += arr[i]; } i += 2; }; System.out.println(A + " " + B); } } }
Main.java:3: error: class Exp is public, should be declared in a file named Exp.java public class Exp { ^ 1 error
s762832928
p00423
Java
import java.util.Scanner; public class Exp { public static void main(String[] args) { int size = 1; int A = 0; int B = 0; int i = 0; int[] arr; Scanner scan = new Scanner(System.in); while(size != 0){ while(true){ if(scan.hasNext() == true){ A = 0; B = 0; size = scan.nextInt(); break; } } arr = new int[size * 2]; i = 0; while(i < 2 * size){ if(scan.hasNext() == true){ arr[i] = scan.nextInt(); i++; } } i = 0; while(i < 2 * size){ if(arr[i] < arr[i + 1]){ B += (arr[i] + arr[i + 1]); } else if(arr[i] > arr[i + 1]){ A += (arr[i] + arr[i + 1]); } else{ A += arr[i]; B += arr[i]; } i += 2; } System.out.println(A + " " + B); } } }
Main.java:3: error: class Exp is public, should be declared in a file named Exp.java public class Exp { ^ 1 error
s524202486
p00423
Java
import java.util.Scanner; public class Game { private int a = 0; private int b = 0; void play(int _a, int _b) { if (_a < _b) { b += _a + _b; } else if (_a > _b) { a += _a + _b; } else { a += _a; b += _b; } } void printPoint() { System.out.println(a + " " + b); } } public class Main { public static void main(String[] args) { Scanner stdin = new Scanner(System.in); int data, a, b; data = a = b = 0; while (true) { Game game = new Game(); try { data = stdin.nextInt(); } catch (Exception e) { e.printStackTrace(); data = 0; } if (data == 0) break; for (int i = 0; i < data; ++i) { try { a = stdin.nextInt(); b = stdin.nextInt(); } catch (Exception e) { e.printStackTrace(); } game.play(a, b); } game.printPoint(); } stdin.close(); } }
Main.java:3: error: class Game is public, should be declared in a file named Game.java public class Game { ^ 1 error
s036015752
p00423
Java
import java.util.ArrayList; import java.util.Iterator; import java.util.Scanner; public class Main { /** * @param args */ public static void main(String[] args) { // TODO ティツ?ェテ・ツ仰陛ァツ板淌ヲツ按静」ツ?陛」ツつ古」ツ?淌」ツδ。テ」ツつステ」ツδε」ツδ嘉」ツδサテ」ツつケテ」ツつソテ」ツδ? Scanner sc = new Scanner(System.in); while (sc.hasNextLine() && sc.nextInt() > 0) { int n = sc.nextInt(); ArrayList<Game> games = new ArrayList<Game>(n); for (int i = 0; i < n; i++) { games.add((new Game(sc.nextInt(), sc.nextInt()))); } int point_a = 0; int point_b = 0; Iterator<Game> it = games.iterator(); while (it.hasNext()) { Game now = it.next(); if (now.winner() == Winner.A) point_a += now.sum(); else if (now.winner() == Winner.B) point_b += now.sum(); else { point_a += now.a; point_b += now.b; } } System.out.println(point_a + " " + point_b); } } } class Game{ int a; int b; public Winner winner() { if(a > b) return Winner.A; else if(a == b) return Winner.draw; else return Winner.B; } public int sum() { return a + b; } public Game(int a, int b) { this.a = a; this.b = b; } }
Main.java:53: error: cannot find symbol public Winner winner() { ^ symbol: class Winner location: class Game Main.java:30: error: cannot find symbol if (now.winner() == Winner.A) ^ symbol: variable Winner location: class Main Main.java:32: error: cannot find symbol else if (now.winner() == Winner.B) ^ symbol: variable Winner location: class Main Main.java:54: error: cannot find symbol if(a > b) return Winner.A; ^ symbol: variable Winner location: class Game Main.java:55: error: cannot find symbol else if(a == b) return Winner.draw; ^ symbol: variable Winner location: class Game Main.java:56: error: cannot find symbol else return Winner.B; ^ symbol: variable Winner location: class Game 6 errors
s204241812
p00423
Java
import java.util.Scanner; class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); while( (num = sc.nextInt()) != 0 ){ int aCnt = 0; int bCnt = 0; for(int cnt = 0;cnt < num;cnt++){ int a = sc.nextInt(); int b = sc.nextInt(); if( a < b ){ bCnt += a + b; }else if( a > b ){ aCnt += a + b; }else{ aCnt += a; bCnt += b; } } System.out.printf("%d %d\n",aCnt,bCnt); } } }
Main.java:7: error: cannot find symbol while( (num = sc.nextInt()) != 0 ){ ^ symbol: variable num location: class Main Main.java:10: error: cannot find symbol for(int cnt = 0;cnt < num;cnt++){ ^ symbol: variable num location: class Main 2 errors
s931013063
p00423
Java
import java.util.Scanner; public class CardGame { public static void main(String[] args) { Scanner in = new Scanner(System.in); int cardNum = Integer.parseInt(in.nextLine()); int[] aCard = new int[cardNum]; int[] bCard = new int[cardNum]; for(int i=0; i<cardNum; i++){ String[] pCard = in.nextLine().split(" "); aCard[i] = Integer.parseInt(pCard[0]); bCard[i] = Integer.parseInt(pCard[1]); //System.out.println(aCard[i] + " " + bCard[i]); } match(cardNum,aCard,bCard); } public static void match(int n, int[] a, int[] b){ int aScore=0; int bScore=0; for(int i = 0; i < n; i++){ if(a[i] > b[i]){ aScore = aScore + a[i] + b[i]; }else if(a[i] == b[i]){ aScore = aScore + a[i]; bScore = bScore + b[i]; }else{ bScore = bScore + a[i] + b[i]; } } System.out.println(aScore + " " + bScore); } }
Main.java:3: error: class CardGame is public, should be declared in a file named CardGame.java public class CardGame { ^ 1 error
s029367360
p00423
Java
import java.util.ArrayList; import java.util.Scanner; public class CardGame { public static void main(String[] args) { Scanner in = new Scanner(System.in); ArrayList<String> result = new ArrayList<String>(); while(true){ int cardNum = Integer.parseInt(in.nextLine()); int[] aCard = new int[cardNum]; int[] bCard = new int[cardNum]; if(cardNum == 0){ resultToString(result); in.close(); break; } for(int i=0; i<cardNum; i++){ String[] pCard = in.nextLine().split(" "); aCard[i] = Integer.parseInt(pCard[0]); bCard[i] = Integer.parseInt(pCard[1]); //System.out.println(aCard[i] + " " + bCard[i]); } result.add(match(cardNum,aCard,bCard)); } } public static String match(int n, int[] a, int[] b){ int aScore=0; int bScore=0; for(int i = 0; i < n; i++){ if(a[i] > b[i]){ aScore = aScore + a[i] + b[i]; }else if(a[i] == b[i]){ aScore = aScore + a[i]; bScore = bScore + b[i]; }else{ bScore = bScore + a[i] + b[i]; } } return aScore + " " + bScore; } public static void resultToString(ArrayList<String> result){ for(int i=0; i<result.size(); i++){ System.out.println(result.get(i)); } } }
Main.java:4: error: class CardGame is public, should be declared in a file named CardGame.java public class CardGame { ^ 1 error