submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s285777500
p00543
Java
#include<iostream> using namespace std;int main(){int a[100];int b,c;cin>>b>>c;for (int d = 0; d < b; d++) cin>>a[d];for(int k=2;k<=c;k++)for(int g=0;g<b-1;g++)if(a[g]% k>a[g+1] % k)swap(a[g],a[g + 1]);for(int s=0;s<b;s++)cout<<a[s]<<endl;}
Main.java:1: error: illegal character: '#' #include<iostream> ^ Main.java:1: error: class, interface, enum, or record expected #include<iostream> ^ Main.java:2: error: not a statement using namespace std;int main(){int a[100];int b,c;cin>>b>>c;for (int d = 0; d < b; d++) cin>>a[d];for(int k=2;k<=c;k++)for(int g=0;g<b-1;g++)if(a[g]% k>a[g+1] % k)swap(a[g],a[g + 1]);for(int s=0;s<b;s++)cout<<a[s]<<endl;} ^ Main.java:2: error: not a statement using namespace std;int main(){int a[100];int b,c;cin>>b>>c;for (int d = 0; d < b; d++) cin>>a[d];for(int k=2;k<=c;k++)for(int g=0;g<b-1;g++)if(a[g]% k>a[g+1] % k)swap(a[g],a[g + 1]);for(int s=0;s<b;s++)cout<<a[s]<<endl;} ^ Main.java:2: error: not a statement using namespace std;int main(){int a[100];int b,c;cin>>b>>c;for (int d = 0; d < b; d++) cin>>a[d];for(int k=2;k<=c;k++)for(int g=0;g<b-1;g++)if(a[g]% k>a[g+1] % k)swap(a[g],a[g + 1]);for(int s=0;s<b;s++)cout<<a[s]<<endl;} ^ Main.java:2: error: unnamed classes are a preview feature and are disabled by default. using namespace std;int main(){int a[100];int b,c;cin>>b>>c;for (int d = 0; d < b; d++) cin>>a[d];for(int k=2;k<=c;k++)for(int g=0;g<b-1;g++)if(a[g]% k>a[g+1] % k)swap(a[g],a[g + 1]);for(int s=0;s<b;s++)cout<<a[s]<<endl;} ^ (use --enable-preview to enable unnamed classes) Main.java:2: error: ']' expected using namespace std;int main(){int a[100];int b,c;cin>>b>>c;for (int d = 0; d < b; d++) cin>>a[d];for(int k=2;k<=c;k++)for(int g=0;g<b-1;g++)if(a[g]% k>a[g+1] % k)swap(a[g],a[g + 1]);for(int s=0;s<b;s++)cout<<a[s]<<endl;} ^ 7 errors
s993622545
p00543
C
#include<cstdio> #include<algorithm> using namespace std; int main(void) { int a[101],k,i,j,m,n,x1,x2; scanf("%d %d",&n,&m); // printf("n=%d n=%d\n",n,m); for(i=1;i<=n;i++) scanf("%d",&a[i]); // printf("aaa\n"); for(i=1;i<=m;i++) { for(j=1;j<n;j++){ x1=a[j]%i; x2=a[j+1]%i; if(x2<x1) swap(a[j],a[j+1]); } } for(i=1;i<=n;i++) printf("%d\n",a[i]); return 0; }
main.c:1:9: fatal error: cstdio: No such file or directory 1 | #include<cstdio> | ^~~~~~~~ compilation terminated.
s628812395
p00543
C
#include<cstdio> #include<algorithm> using namespace std; int main(void) { int a[101],k,i,j,m,n,x1,x2; scanf("%d %d",&n,&m); for(i=1;i<=n;i++) scanf("%d",&a[i]); for(i=1;i<=m;i++) { for(j=1;j<n;j++){ x1=a[j]%i; x2=a[j+1]%i; if(x2<x1) swap(a[j],a[j+1]); } } for(i=1;i<=n;i++) printf("%d\n",a[i]); return 0; }
main.c:1:9: fatal error: cstdio: No such file or directory 1 | #include<cstdio> | ^~~~~~~~ compilation terminated.
s815245828
p00543
C
#include<stdio.h> int main(){ int n,m,k,i,j,a[101],te; while(1){ scanf("%d,&n); if(n==0){ break; } scanf("%d,&m); for(j=1;j<n;j++){ scanf("%d",&a[j]); } i=1; for(j=1;j<=m;){ if(i<n&&1<i){ if(a[j]%j>a[j+1]%j){ te=a[j]; a[j]=a[j+1]; a[j+1]=te; i++; } else{ i++; } if(i==n){ j++; } } for(j=1;j<=n;j++){ printf("%d",a[j]); } } return 0; }
main.c: In function 'main': main.c:5:15: warning: missing terminating " character 5 | scanf("%d,&n); | ^ main.c:5:15: error: missing terminating " character 5 | scanf("%d,&n); | ^~~~~~~~ main.c:6:9: error: expected expression before 'if' 6 | if(n==0){ | ^~ main.c:9:15: warning: missing terminating " character 9 | scanf("%d,&m); | ^ main.c:9:15: error: missing terminating " character 9 | scanf("%d,&m); | ^~~~~~~~ main.c:34:1: error: expected declaration or statement at end of input 34 | } | ^ main.c:34:1: error: expected declaration or statement at end of input
s778505712
p00543
C
#include<stdio.h> int main(){ int n,m,k,i,j,a[101],te; while(1){ scanf("%d",&n); if(n==0){ break; } scanf("%d",&m); for(j=1;j<n;j++){ scanf("%d",&a[j]); } i=1; for(j=1;j<=m;){ if(i<n&&1<i){ if(a[j]%j>a[j+1]%j){ te=a[j]; a[j]=a[j+1]; a[j+1]=te; i++; } else{ i++; } if(i==n){ j++; } } for(j=1;j<=n;j++){ printf("%d",a[j]); } } return 0; }
main.c: In function 'main': main.c:34:1: error: expected declaration or statement at end of input 34 | } | ^
s243913476
p00543
C
#include<stdio.h> int main(){ int n,m,k,i,j,a[101],te; scanf("%d",&n); scanf("%d",&m); for(j=1;j<n;j++){ scanf("%d",&a[j]); } i=1; for(j=1;j<=m;){ if(i<n&&1<i){ if(a[i]%j>a[i+1]%j){ te=a[i]; a[i]=a[i+1]; a[i+1]=te; i++; } else{ i++; } if(i==n){ j++; } } for(j=1;j<=n;j++){ printf("%d",a[j]); } return 0; }
main.c: In function 'main': main.c:29:1: error: expected declaration or statement at end of input 29 | } | ^
s003108466
p00543
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
s457029400
p00543
C++
#include<iostream> using namespace std; int n,m,a[1000]; int main(){ cin>>n>>m; for(int i=0;i<n;i++){cin>>a[i];} for(int i=1;i<n;i++){ if(a[i]%k>a[i+1]%k){swap(a[i],a[i+1]);} } for(int i=0;i<n;i++)cout<<a[i]<<endl; return 0; }
a.cc: In function 'int main()': a.cc:8:25: error: 'k' was not declared in this scope 8 | if(a[i]%k>a[i+1]%k){swap(a[i],a[i+1]);} | ^
s538411622
p00543
C++
#include<iostream> #include<algorithm> #include<string> using namespace std; int main() { int a = 0, b = 0; int c[100]; cin >> a >> b; for (int i = 0; i < a; i++) { cin >> c[i]; } for (int i = 1; i <= b; i++) { for (int j = 0; j < (a - 1); j++) { if ((c[j] % i)>(c[j + 1] % i)) { int k = c[j]; c[j] = c[j + 1]; c[j + 1] = k; } } } for (int i = 0; i < a; i++) { cout << c[i] << endl; } gereturn 0; }
a.cc: In function 'int main()': a.cc:31:9: error: 'gereturn' was not declared in this scope 31 | gereturn 0; | ^~~~~~~~
s210000019
p00543
C++
#include<iostream> #include<algorithm> using namespace std; int main() { int n;//JOI?????????????????° int m;//?????????????????° int person[101] = { 0 };//??????????????? int baton[101] = { 0 }; cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> person[i]; } //cout << "ruio"; for (int k = 1; k <= m; k++) { int i = 1; //cout << "ruio"; while (i != n) { if (1 <= i&&i <= n - 1) { if (person[i] % k > person[i + 1] % k) { // cout << "ruio"; swap(person[i], person[i + 1]); i = i + 1; } else { i = i + 1; } } } for (int i = 1; i <= n; i++) { cout << person[i] << endl; } }
a.cc: In function 'int main()': a.cc:32:2: error: expected '}' at end of input 32 | } | ^ a.cc:4:12: note: to match this '{' 4 | int main() { | ^
s514040728
p00543
C++
#include <bits/stdc++.h> #include<algorithm> using namespace std; int main(){ int N,M; cin >>N>>M; int A[N]; for(int i=0;int<N;++i){ cin >>A[i]; } for(int k=1;k<M+1;++k){ for(int a=0,a<N+1,++a){ if(1<=a&&a<N){ if(A[a]%k>A[a+1]%k){ temp = A[a] A[a]=A[a+1] A[a+1]=temp } else{ } } else{ break; } } } for(int w=0;w<N;++w){ cout <<A[w]<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:9:17: error: 'int' is not a template 9 | for(int i=0;int<N;++i){ | ^~~ a.cc:9:17: error: expected primary-expression before 'int' a.cc:9:17: error: expected ';' before 'int' 9 | for(int i=0;int<N;++i){ | ^~~ | ; a.cc:9:17: error: expected primary-expression before 'int' 9 | for(int i=0;int<N;++i){ | ^~~ a.cc:9:17: error: expected ')' before 'int' 9 | for(int i=0;int<N;++i){ | ~ ^~~ | ) a.cc:9:17: error: declaration does not declare anything [-fpermissive] 9 | for(int i=0;int<N;++i){ | ^~~ a.cc:9:25: error: 'i' was not declared in this scope 9 | for(int i=0;int<N;++i){ | ^ a.cc:14:18: error: expected ';' before '<' token 14 | for(int a=0,a<N+1,++a){ | ^ | ; a.cc:14:18: error: expected primary-expression before '<' token a.cc:14:26: error: expected ';' before ')' token 14 | for(int a=0,a<N+1,++a){ | ^ | ; a.cc:17:13: error: 'temp' was not declared in this scope; did you mean 'tm'? 17 | temp = A[a] | ^~~~ | tm
s049316983
p00543
C++
#include <bits/stdc++.h> #include<algorithm> using namespace std; int main(){ int N,M; cin >>N>>M; int A[N]; for(int i=0;int<N;++i){ cin >>A[i]; } for(int k=1;k<M+1;++k){ for(int a=0,a<N+1,++a){ if(1<=a&&a<N){ if(A[a]%k>A[a+1]%k){ temp = A[a]; A[a]=A[a+1]; A[a+1]=temp; } else{ } } else{ break; } } } for(int w=0;w<N;++w){ cout <<A[w]<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:9:17: error: 'int' is not a template 9 | for(int i=0;int<N;++i){ | ^~~ a.cc:9:17: error: expected primary-expression before 'int' a.cc:9:17: error: expected ';' before 'int' 9 | for(int i=0;int<N;++i){ | ^~~ | ; a.cc:9:17: error: expected primary-expression before 'int' 9 | for(int i=0;int<N;++i){ | ^~~ a.cc:9:17: error: expected ')' before 'int' 9 | for(int i=0;int<N;++i){ | ~ ^~~ | ) a.cc:9:17: error: declaration does not declare anything [-fpermissive] 9 | for(int i=0;int<N;++i){ | ^~~ a.cc:9:25: error: 'i' was not declared in this scope 9 | for(int i=0;int<N;++i){ | ^ a.cc:14:18: error: expected ';' before '<' token 14 | for(int a=0,a<N+1,++a){ | ^ | ; a.cc:14:18: error: expected primary-expression before '<' token a.cc:14:26: error: expected ';' before ')' token 14 | for(int a=0,a<N+1,++a){ | ^ | ; a.cc:17:13: error: 'temp' was not declared in this scope; did you mean 'tm'? 17 | temp = A[a]; | ^~~~ | tm
s361118556
p00543
C++
#include <bits/stdc++.h> #include<algorithm> using namespace std; int main(){ int N,M; cin >>N>>M; int A[N]; for(int i=0;int<N;++i){ cin >>A[i]; } for(int k=1;k<M+1;++k){ for(int a=0,a<N+1,++a){ if(1<=a&&a<N){ if(A[a]%k>A[a+1]%k){ int temp = A[a]; A[a]=A[a+1]; A[a+1]=temp; } else{ } } else{ break; } } } for(int w=0;w<N;++w){ cout <<A[w]<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:9:17: error: 'int' is not a template 9 | for(int i=0;int<N;++i){ | ^~~ a.cc:9:17: error: expected primary-expression before 'int' a.cc:9:17: error: expected ';' before 'int' 9 | for(int i=0;int<N;++i){ | ^~~ | ; a.cc:9:17: error: expected primary-expression before 'int' 9 | for(int i=0;int<N;++i){ | ^~~ a.cc:9:17: error: expected ')' before 'int' 9 | for(int i=0;int<N;++i){ | ~ ^~~ | ) a.cc:9:17: error: declaration does not declare anything [-fpermissive] 9 | for(int i=0;int<N;++i){ | ^~~ a.cc:9:25: error: 'i' was not declared in this scope 9 | for(int i=0;int<N;++i){ | ^ a.cc:14:18: error: expected ';' before '<' token 14 | for(int a=0,a<N+1,++a){ | ^ | ; a.cc:14:18: error: expected primary-expression before '<' token a.cc:14:26: error: expected ';' before ')' token 14 | for(int a=0,a<N+1,++a){ | ^ | ;
s322840461
p00543
C++
#include <bits/stdc++.h> #include<algorithm> using namespace std; int main(){ int N,M; cin >>N>>M; int A[N]; for(int i=0;int<N;++i){ cin >>A[i]; } for(int k=1;k<M+1;++k){ for(int a=0;a<N+1;++a){ if(1<=a&&a<N){ if(A[a]%k>A[a+1]%k){ int temp = A[a]; A[a]=A[a+1]; A[a+1]=temp; } else{ } } else{ break; } } } for(int w=0;w<N;++w){ cout <<A[w]<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:9:17: error: 'int' is not a template 9 | for(int i=0;int<N;++i){ | ^~~ a.cc:9:17: error: expected primary-expression before 'int' a.cc:9:17: error: expected ';' before 'int' 9 | for(int i=0;int<N;++i){ | ^~~ | ; a.cc:9:17: error: expected primary-expression before 'int' 9 | for(int i=0;int<N;++i){ | ^~~ a.cc:9:17: error: expected ')' before 'int' 9 | for(int i=0;int<N;++i){ | ~ ^~~ | ) a.cc:9:17: error: declaration does not declare anything [-fpermissive] 9 | for(int i=0;int<N;++i){ | ^~~ a.cc:9:25: error: 'i' was not declared in this scope 9 | for(int i=0;int<N;++i){ | ^
s102154063
p00543
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n,m,a[n]; cin>>n>>m; for(int i=0;i<n;i++){ cin>>a[i]; } for(int k=1;i<m+1;k++){ for(int i=0;i<n-2;i++){ if(a[i]%k<a[i+1]%k){ swap(a[i],a[1+i]) } } } for(int i=0;i<n;i++){ cout<<a[i]<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:9:17: error: 'i' was not declared in this scope 9 | for(int k=1;i<m+1;k++){ | ^ a.cc:12:30: error: expected ';' before '}' token 12 | swap(a[i],a[1+i]) | ^ | ; 13 | } | ~
s494532659
p00543
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n,m,a[n]; cin>>n>>m; for(int i=0;i<n;i++){ cin>>a[i]; } for(int k=1;k<m+1;k++){ for(int i=0;i<n-2;i++){ if(a[i]%k<a[i+1]%k){ swap(a[i],a[1+i]) } } } for(int i=0;i<n;i++){ cout<<a[i]<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:12:33: error: expected ';' before '}' token 12 | swap(a[i],a[1+i]) | ^ | ; 13 | } | ~
s504599504
p00543
C++
#include<stdio.h> int main(void) { int n,m,x,i,k,a[100]; scanf("%d %d",&n,&m); for(i=0;i<n;i++) scanf("%d",&a[i]); for(k=1;k<=m;k++){ for(i=0;i<n-1;i++){ if(a[i]%k>a[i+1]%k) swap(a[i],a[i+1]); } } for(i=0;i<n;i++) printf("%d\n",a[i]); return 0; }
a.cc: In function 'int main()': a.cc:9:45: error: 'swap' was not declared in this scope 9 | if(a[i]%k>a[i+1]%k) swap(a[i],a[i+1]); | ^~~~
s797285788
p00543
C++
#include<stdio.h> #include<algorithm> using namespace str; int main(void) { int n,m,x,i,k,a[100]; scanf("%d %d",&n,&m); for(i=0;i<n;i++) scanf("%d",&a[i]); for(k=1;k<=m;k++){ for(i=0;i<n-1;i++){ if(a[i]%k>a[i+1]%k) swap(a[i],a[i+1]); } } for(i=0;i<n;i++) printf("%d\n",a[i]); return 0; }
a.cc:3:17: error: 'str' is not a namespace-name 3 | using namespace str; | ^~~ a.cc: In function 'int main()': a.cc:11:45: error: 'swap' was not declared in this scope 11 | if(a[i]%k>a[i+1]%k) swap(a[i],a[i+1]); | ^~~~ a.cc:11:45: note: suggested alternatives: In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from a.cc:2: /usr/include/c++/14/bits/stl_pair.h:1106:5: note: 'std::swap' 1106 | swap(pair<_T1, _T2>&, pair<_T1, _T2>&) = delete; | ^~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:61: /usr/include/c++/14/bits/move.h:226:5: note: 'std::swap' 226 | swap(_Tp& __a, _Tp& __b) | ^~~~ /usr/include/c++/14/bits/move.h:226:5: note: 'std::swap'
s186336001
p00543
C++
#include<iostream> using namespace std; int s, b, Ns, Nb, z; int a[101], r[101]; int main(){ cin >> Ns >> Nb; for(s=1; s<=Ns; s++){cin>>a[s];} for(b=1; b<=Nb; b++){ for(s=1; s<=Ns; s++){r[s] = a[s]%b;} for(s=1; s<=Ns-1; s++){if(r[s] > r[s+1]){ swap(a[s], a[s+1); swap(r[s], r[s+1]); } } } for(s=1; s<=Ns; s++){ cout << a[s] << endl; } } void swap(int x, int y){ z = x; x = y; y = z; }
a.cc: In function 'int main()': a.cc:11:51: error: expected ']' before ')' token 11 | swap(a[s], a[s+1); | ^ | ]
s762778269
p00543
C++
#include<iostream> using namespace std; int s, b, Ns, Nb, z; int a[101], r[101]; int main(){ cin >> Ns >> Nb; for(s=1; s<=Ns; s++){cin>>a[s];} for(b=1; b<=Nb; b++){ for(s=1; s<=Ns; s++){ r[s] = a[s]%b; } for(s=1; s<=Ns-1; s++){ if(r[s] > r[s+1]){ swap(a[s], a[s+1); swap(r[s], r[s+1]); } } } for(s=1; s<=Ns; s++){ cout << a[s] << endl; } } void swap(int x, int y){ z = x; x = y; y = z; }
a.cc: In function 'int main()': a.cc:14:33: error: expected ']' before ')' token 14 | swap(a[s], a[s+1); | ^ | ]
s387820381
p00543
C++
#include<iostream> using namespace std; int s, b, Ns, Nb, z; int z[101], r[101]; int main(){ cin >> Ns >> Nb; for(s=1; s<=Ns; s++){cin>>z[s];} for(b=1; b<=Nb; b++){ for(s=1; s<=Ns; s++){ r[s] = z[s]%b; } for(s=1; s<=Ns-1; s++){ if(r[s] > r[s+1]){ swap(z[s], z[s+1); swap(r[s], r[s+1]); } } } for(s=1; s<=Ns; s++){ cout << a[s] << endl; } } void swap(int x, int y){ z = x; x = y; y = z; }
a.cc:4:5: error: conflicting declaration 'int z [101]' 4 | int z[101], r[101]; | ^ a.cc:3:19: note: previous declaration as 'int z' 3 | int s, b, Ns, Nb, z; | ^ a.cc: In function 'int main()': a.cc:7:32: error: invalid types 'int[int]' for array subscript 7 | for(s=1; s<=Ns; s++){cin>>z[s];} | ^ a.cc:10:21: error: invalid types 'int[int]' for array subscript 10 | r[s] = z[s]%b; | ^ a.cc:14:23: error: invalid types 'int[int]' for array subscript 14 | swap(z[s], z[s+1); | ^ a.cc:14:33: error: expected ']' before ')' token 14 | swap(z[s], z[s+1); | ^ | ] a.cc:14:29: error: invalid types 'int[int]' for array subscript 14 | swap(z[s], z[s+1); | ^ a.cc:20:17: error: 'a' was not declared in this scope 20 | cout << a[s] << endl; | ^
s535489378
p00543
C++
#include<iostream> using namespace std; int s, b, Ns, Nb, w; int z[101], r[101]; int main(){ cin >> Ns >> Nb; for(s=1; s<=Ns; s++){cin>>z[s];} for(b=1; b<=Nb; b++){ for(s=1; s<=Ns; s++){ r[s] = z[s]%b; } for(s=1; s<=Ns-1; s++){ if(r[s] > r[s+1]){ swap(z[s], z[s+1); swap(r[s], r[s+1]); } } } for(s=1; s<=Ns; s++){ cout << a[s] << endl; } } void swap(int x, int y){ w = x; x = y; y = w; }
a.cc: In function 'int main()': a.cc:14:33: error: expected ']' before ')' token 14 | swap(z[s], z[s+1); | ^ | ] a.cc:20:17: error: 'a' was not declared in this scope 20 | cout << a[s] << endl; | ^
s114440241
p00543
C++
#include<iostream> using namespace std; int s, b, Ns, Nb; int z[101], r[101]; int main(){ cin >> Ns >> Nb; for(s=1; s<=Ns; s++){cin>>z[s];} for(b=1; b<=Nb; b++){ for(s=1; s<=Ns; s++){ r[s] = z[s]%b; } for(s=1; s<=Ns-1; s++){ if(r[s] > r[s+1]){ swap(z[s], z[s+1); swap(r[s], r[s+1]); } } } for(s=1; s<=Ns; s++){ cout << a[s] << endl; } } void swap(int x, int y){ int z; w = x; x = y; y = w; }
a.cc: In function 'int main()': a.cc:14:33: error: expected ']' before ')' token 14 | swap(z[s], z[s+1); | ^ | ] a.cc:20:17: error: 'a' was not declared in this scope 20 | cout << a[s] << endl; | ^ a.cc: In function 'void swap(int, int)': a.cc:25:6: error: 'w' was not declared in this scope 25 | w = x; | ^
s149396666
p00543
C++
#include<iostream> using namespace std; int s, b, Ns, Nb; int z[101], r[101]; int main(){ cin >> Ns >> Nb; for(s=1; s<=Ns; s++){cin>>z[s];} for(b=1; b<=Nb; b++){ for(s=1; s<=Ns; s++){ r[s] = z[s]%b; } for(s=1; s<=Ns-1; s++){ if(r[s] > r[s+1]){ swap(z[s], z[s+1); swap(r[s], r[s+1]); } } } for(s=1; s<=Ns; s++){ cout << a[s] << endl; } } void swap(int x, int y){ int w; w = x; x = y; y = w; }
a.cc: In function 'int main()': a.cc:14:33: error: expected ']' before ')' token 14 | swap(z[s], z[s+1); | ^ | ] a.cc:20:17: error: 'a' was not declared in this scope 20 | cout << a[s] << endl; | ^
s934989996
p00543
C++
#include<iostream> using namespace std; int s, b, nS, nB; int z[101], r[101]; int main(){ cin >> nS >> nB; for(s=1; s<=nS; s++){cin>>z[s];} for(b=1; b<=nB; b++){ for(s=1; s<=nS; s++){ r[s] = z[s]%b; } for(s=1; s<=Ns-1; s++){ if(r[s] > r[s+1]){ swap(z[s], z[s+1); swap(r[s], r[s+1]); } } } for(s=1; s<=nS; s++){ cout << a[s] << endl; } } void swap(int x, int y){ int w; w = x; x = y; y = w; }
a.cc: In function 'int main()': a.cc:12:21: error: 'Ns' was not declared in this scope; did you mean 's'? 12 | for(s=1; s<=Ns-1; s++){ | ^~ | s a.cc:14:33: error: expected ']' before ')' token 14 | swap(z[s], z[s+1); | ^ | ] a.cc:20:17: error: 'a' was not declared in this scope 20 | cout << a[s] << endl; | ^
s243705772
p00543
C++
#include<iostream> using namespace std; int s, b, nS, nB; int z[101], r[101]; int main(){ cin >> nS >> nB; for(s=1; s<=nS; s++){cin>>z[s];} for(b=1; b<=nB; b++){ for(s=1; s<=nS; s++){ r[s] = z[s]%b; } for(s=1; s<=nS-1; s++){ if(r[s] > r[s+1]){ swap(z[s], z[s+1); swap(r[s], r[s+1]); } } } for(s=1; s<=nS; s++){ cout << a[s] << endl; } } void swap(int x, int y){ int w; w = x; x = y; y = w; }
a.cc: In function 'int main()': a.cc:14:33: error: expected ']' before ')' token 14 | swap(z[s], z[s+1); | ^ | ] a.cc:20:17: error: 'a' was not declared in this scope 20 | cout << a[s] << endl; | ^
s312170864
p00543
C++
#include<iostream> using namespace std; int s, b, nS, nB; int z[101], r[101]; int main(){ cin >> nS >> nB; for(s=1; s<=nS; s++){cin>>z[s];} for(b=1; b<=nB; b++){ for(s=1; s<=nS; s++){ r[s] = z[s]%b; } for(s=1; s<=nS-1; s++){ if(r[s] > r[s+1]){ swap(z[s], z[s+1]); swap(r[s], r[s+1]); } } } for(s=1; s<=nS; s++){ cout << a[s] << endl; } } void swap(int x, int y){ int w; w = x; x = y; y = w; }
a.cc: In function 'int main()': a.cc:20:17: error: 'a' was not declared in this scope 20 | cout << a[s] << endl; | ^
s847228577
p00543
C++
#include<iostream> using namespace std; int s, b, nS, nB; int z[101], r[101]; int main(){ cin >> nS >> nB; for(s=1; s<=nS; s++){cin>>z[s];} for(b=1; b<=nB; b++){ for(s=1; s<=nS; s++){ r[s] = z[s]%b; } for(s=1; s<=nS-1; s++){ if(r[s] > r[s+1]){ swap(z[s], z[s+1]); swap(r[s], r[s+1]); } } } for(s=1; s<=nS; s++){ cout << a[s] << endl; } } void swap(int x, int y){ int w; w = x; x = y; y = w; }
a.cc: In function 'int main()': a.cc:20:17: error: 'a' was not declared in this scope 20 | cout << a[s] << endl; | ^
s173839829
p00543
C++
#include<iostream> using namespace std; int s, b, Ns, nB; int a[101], r[101]; int main(){ cin >> nS >> nB; for(s=1; s<=Ns; s++){cin>>a[s];} for(b=1; b<=nB; b++){ for(s=1; s<=Ns; s++){ r[s] = a[s]%b; } for(s=1; s<=Ns-1; s++){ if(r[s] > r[s+1]){ swap(a[s], a[s+1]); swap(r[s], r[s+1]); } } } for(s=1; s<=Ns; s++){ cout << a[s] << endl; } } void swap(int x, int y){ int w; w = x; x = y; y = w; }
a.cc: In function 'int main()': a.cc:6:12: error: 'nS' was not declared in this scope; did you mean 'nB'? 6 | cin >> nS >> nB; | ^~ | nB
s325196844
p00543
C++
#include <stdio.h> #define rep(i, n) for(int i = 0; i < n; ++i) int main(void) { int n, m; scanf("%d%d", &n, &n); int a[n]; rep(i, n) scanf("%d", &a[i]); rep(i, m) rep(j, n - 1) if(a[j] % i < a[j + 1] % i) int t = a[j], a[j] = a[j + 1], a[j + 1] - t; rep(i, n) printf("%d\n", a[i]); return 0; }
a.cc: In function 'int main()': a.cc:11:63: error: array must be initialized with a brace-enclosed initializer 11 | if(a[j] % i < a[j + 1] % i) int t = a[j], a[j] = a[j + 1], a[j + 1] - t; | ~~~~~~~^ a.cc:11:75: error: expected initializer before '-' token 11 | if(a[j] % i < a[j + 1] % i) int t = a[j], a[j] = a[j + 1], a[j + 1] - t; | ^
s313931389
p00543
C++
#include<iostream> int main() { std::cout << "Hello World" << std::endl; return 0; } #include<iostream> int main() { std::cout << "Hello World" << std::endl; return 0; }
a.cc:8:5: error: redefinition of 'int main()' 8 | int main() { | ^~~~ a.cc:2:5: note: 'int main()' previously defined here 2 | int main() { | ^~~~
s018068924
p00544
C
#include <stdio.h> #include <algorithm> using namespace std; int n; int m; int cc; int ans=9999; char c[50][50]; int main(){ scanf("%d%d",&n,m); for(int i=0;i<n;i++){ scanf("%s",&c[i]); } for(int j=0;j<=n-2;j++){ if(j==0){break;} for(int i=0;i<=n-j-1;i++){ for(int k=0;k<j;k++){ for(int l=0;l<m;l++){ if(c[k][l]=='B'||c[k][l]=='R'){ cc++; } } } for(int k=0;k<i;k++){ if(k<j){break;} for(int l=0;l<m;l++){ if(c[k][l]=='W'||c[k][l]=='R'){ cc++; } } } for(int k=0;k<n-j-i;k++){ if(k<i){break;} for(int l=0;l<m;l++){ if(c[k][l]=='W'||c[k][l]=='B'){ cc++; } } } if(cc<ans){ ans=cc; } cc=0; } } printf("%d\n",ans); }
main.c:2:10: fatal error: algorithm: No such file or directory 2 | #include <algorithm> | ^~~~~~~~~~~ compilation terminated.
s201050093
p00544
C
#include<iostream> using namespace std; int i, j, l; char a[50][51]; int x[125000], min = 150000; int n, m, k, cntW, cntB, cntR, cnt = 0; #define I for(i=0;i<n;i++) #define Wp cntW++ #define Bp cntB++ #define Rp cntR++ int main(void) { cin >> n >> m; I{ x[i] = 0; } I{ cin >> a[i]; } for (i = 0; i<n - 2; i++) { for (j = i + 1; j<n - 1; j++) { for (k = 0; k <= i; k++) { cntW = 0; for (l = 0; l<m; l++) { if (a[k][l] == 'W')Wp; } x[cnt] += m - cntW; } for (k = i + 1; k <= j; k++) { cntB = 0; for (l = 0; l<m; l++) { if (a[k][l] == 'B')Bp; } x[cnt] += m - cntB; } for (k = j + 1; k<n; k++) { cntR = 0; for (l = 0; l<m; l++) { if (a[k][l] == 'R')Rp; } x[cnt] += m - cntR; } cnt++; } } for (i = 0; i<cnt; i++) { if (min>x[i]) { min = x[i]; } } cout << min << endl; return 0; }
main.c:1:9: fatal error: iostream: No such file or directory 1 | #include<iostream> | ^~~~~~~~~~ compilation terminated.
s490944896
p00544
C
#include<iostream> using namespace std; int i, j, l; char a[50][51]; int x[125000], min = 150000; int n, m, k, cntW, cntB, cntR, cnt = 0; #define I for(i=0;i<n;i++) #define Wp cntW++ #define Bp cntB++ #define Rp cntR++ int main(void) { cin >> n >> m; I{ x[i] = 0; } I{ cin >> a[i]; } for (i = 0; i<n - 2; i++) { for (j = i + 1; j<n - 1; j++) { for (k = 0; k <= i; k++) { cntW = 0; for (l = 0; l<m; l++) { if (a[k][l] == 'W')Wp; } x[cnt] += m - cntW; } for (k = i + 1; k <= j; k++) { cntB = 0; for (l = 0; l<m; l++) { if (a[k][l] == 'B')Bp; } x[cnt] += m - cntB; } for (k = j + 1; k<n; k++) { cntR = 0; for (l = 0; l<m; l++) { if (a[k][l] == 'R')Rp; } x[cnt] += m - cntR; } cnt++; } } for (i = 0; i<cnt; i++) { if (min>x[i]) { min = x[i]; } } cout << min-1 << endl; return 0; }
main.c:1:9: fatal error: iostream: No such file or directory 1 | #include<iostream> | ^~~~~~~~~~ compilation terminated.
s989228900
p00544
C++
#include <cstdio> #include <algorithm> using namespace std; int X, Y; char flag[50][51]; int answer; int sit[50][3]; inline int russia(char x){ if (x == 'B')return 0; if (x == 'W')return 1; if (x == 'R')return 2; } int f(int x,int color){ if (x == 0)return sit[0][0] + sit[0][2]; if (x == Y - 1)return min(f(x - 1, 0), f(x - 1, 2)) + sit[x][0] + sit[x][1]; if (color == 0)return min(f(x - 1, 0), f(x - 1, 1)) + sit[x][1] + sit[x][2]; if (color == 1)return min(f(x - 1, 2), f(x - 1, 1)) + sit[x][2] + sit[x][0]; if (color == 2)return min(f(x - 1, 2), f(x - 1, 0)) + sit[x][1] + sit[x][0]; return INT_MAX / 2; } int main(){ scanf_s("%d %d", &Y, &X); for (int i = 0; i < Y; ++i){ scanf("%s", &(flag[i]),X); for (int x = 0; x < X; ++x){ sit[i][russia(flag[i][x])] += 1; } } printf("%d\n", f(Y - 1, 2)); return 0; }
a.cc: In function 'int f(int, int)': a.cc:24:16: error: 'INT_MAX' was not declared in this scope 24 | return INT_MAX / 2; | ^~~~~~~ a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 2 | #include <algorithm> +++ |+#include <climits> 3 | using namespace std; a.cc: In function 'int main()': a.cc:28:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 28 | scanf_s("%d %d", &Y, &X); | ^~~~~~~ | scanf a.cc: In function 'int russia(char)': a.cc:15:1: warning: control reaches end of non-void function [-Wreturn-type] 15 | } | ^
s703618738
p00544
C++
#include <cstdio> int X, Y; char flag[50][51]; int answer; int sit[50][3]; inline int russia(char x){ if (x == 'B')return 0; if (x == 'W')return 1; if (x == 'R')return 2; } int f(int x,int color){ if (x == 0)return sit[0][0] + sit[0][2]; if (x == Y - 1)return min(f(x - 1, 0), f(x - 1, 2)) + sit[x][0] + sit[x][1]; if (color == 0)return min(f(x - 1, 0), f(x - 1, 1)) + sit[x][1] + sit[x][2]; if (color == 1)return min(f(x - 1, 2), f(x - 1, 1)) + sit[x][2] + sit[x][0]; if (color == 2)return min(f(x - 1, 2), f(x - 1, 0)) + sit[x][1] + sit[x][0]; return 1000000; } int main(){ scanf("%d %d", &Y, &X); for (int i = 0; i < Y; ++i){ scanf("%s", &(flag[i]),X); for (int x = 0; x < X; ++x){ sit[i][russia(flag[i][x])] += 1; } } printf("%d\n", f(Y - 1, 2)); return 0; }
a.cc: In function 'int f(int, int)': a.cc:18:31: error: 'min' was not declared in this scope 18 | if (x == Y - 1)return min(f(x - 1, 0), f(x - 1, 2)) + sit[x][0] + sit[x][1]; | ^~~ a.cc:19:31: error: 'min' was not declared in this scope 19 | if (color == 0)return min(f(x - 1, 0), f(x - 1, 1)) + sit[x][1] + sit[x][2]; | ^~~ a.cc:20:31: error: 'min' was not declared in this scope 20 | if (color == 1)return min(f(x - 1, 2), f(x - 1, 1)) + sit[x][2] + sit[x][0]; | ^~~ a.cc:21:31: error: 'min' was not declared in this scope 21 | if (color == 2)return min(f(x - 1, 2), f(x - 1, 0)) + sit[x][1] + sit[x][0]; | ^~~ a.cc: In function 'int russia(char)': a.cc:14:1: warning: control reaches end of non-void function [-Wreturn-type] 14 | } | ^
s845841261
p00544
C++
#include<bits/stdc++.h> using namespace std; int main(){ int a,b,W=0,B=0,R=0,x=100000; cin >> a >> b; char maps[a][b]; for(int i=0;i<a;i++){ for(int j=0;j<b;j++){ cin >> maps[i][j]; } } W=0; for(i=0;i<a-2;i++){ for(j=0;j<b;j++){ if(s[i][j]!='W'){ W++; } } B=0; for(j=i+1;j<a-1;j++){ for(k=0;k<b;k++){ if(s[j][o]!='B'){ B++; } } R=0; for(k=j+1;k<a;k++){ for(l=0;l<b;l++){ if(s[k][o]!='R'){ R++; } } } if(X>W+B+R){ X=W+B+R; } } } cout << x << endl; return 0; }
a.cc: In function 'int main()': a.cc:13:7: error: 'i' was not declared in this scope 13 | for(i=0;i<a-2;i++){ | ^ a.cc:14:9: error: 'j' was not declared in this scope 14 | for(j=0;j<b;j++){ | ^ a.cc:15:10: error: 's' was not declared in this scope 15 | if(s[i][j]!='W'){ | ^ a.cc:20:9: error: 'j' was not declared in this scope 20 | for(j=i+1;j<a-1;j++){ | ^ a.cc:21:11: error: 'k' was not declared in this scope 21 | for(k=0;k<b;k++){ | ^ a.cc:22:12: error: 's' was not declared in this scope 22 | if(s[j][o]!='B'){ | ^ a.cc:22:17: error: 'o' was not declared in this scope 22 | if(s[j][o]!='B'){ | ^ a.cc:27:11: error: 'k' was not declared in this scope 27 | for(k=j+1;k<a;k++){ | ^ a.cc:28:13: error: 'l' was not declared in this scope 28 | for(l=0;l<b;l++){ | ^ a.cc:29:14: error: 's' was not declared in this scope 29 | if(s[k][o]!='R'){ | ^ a.cc:29:19: error: 'o' was not declared in this scope 29 | if(s[k][o]!='R'){ | ^ a.cc:34:10: error: 'X' was not declared in this scope 34 | if(X>W+B+R){ | ^
s107572950
p00544
C++
#include <stdio.h> #include <algorithm> using namespace std; int n; int m; int cc; int ans=9999; char c[50][50] int main(){ scanf("%d%d",&n,m); for(int i=0;i<n;i++){ scanf("%s",&c[i]); } for(int j=0;j<=n-2;j++){ if(j==0){break;} for(int i=0;i<=n-j-1;i++){ for(int k=0;k<j;++){ for(int l=0;l<m;l++){ if(c[k][l]==B||c[k][l]==R){ cc++; } } } for(int k=0;k<i;++){ if(k<j){break;} for(int l=0;l<m;l++){ if(c[k][l]==W||c[k][l]==R){ cc++; } } } for(int k=0;k<n-j-i;++){ if(k<i){break;} for(int l=0;l<m;l++){ if(c[k][l]==W||c[k][l]==B){ cc++; } } } ans=min(cc,ans); cc=0; } } printf("%d\n",ans); }
a.cc:9:1: error: expected initializer before 'int' 9 | int main(){ | ^~~
s527434452
p00544
C++
#include <stdio.h> #include <algorithm> using namespace std; int n; int m; int cc; int ans=9999; char c[50][50] int main(){ scanf("%d%d",&n,m); for(int i=0;i<n;i++){ scanf("%s",&c[i]); } for(int j=0;j<=n-2;j++){ if(j==0){break;} for(int i=0;i<=n-j-1;i++){ for(int k=0;k<j;++){ for(int l=0;l<m;l++){ if(c[k][l]==B||c[k][l]==R){ cc++; } } } for(int k=0;k<i;++){ if(k<j){break;} for(int l=0;l<m;l++){ if(c[k][l]==W||c[k][l]==R){ cc++; } } } for(int k=0;k<n-j-i;++){ if(k<i){break;} for(int l=0;l<m;l++){ if(c[k][l]==W||c[k][l]==B){ cc++; } } } ans=min(cc,ans); cc=0; } } printf("%d\n",ans); }
a.cc:9:1: error: expected initializer before 'int' 9 | int main(){ | ^~~
s159895961
p00544
C++
#include <stdio.h> #include <algorithm> using namespace std; int n; int m; int cc; int ans=9999; char c[50][50] int main(){ scanf("%d%d",&n,m); for(int i=0;i<n;i++){ scanf("%s",&c[i]); } for(int j=0;j<=n-2;j++){ if(j==0){break;} for(int i=0;i<=n-j-1;i++){ for(int k=0;k<j;++){ for(int l=0;l<m;l++){ if(c[k][l]==B||c[k][l]==R){ cc++; } } } for(int k=0;k<i;++){ if(k<j){break;} for(int l=0;l<m;l++){ if(c[k][l]==W||c[k][l]==R){ cc++; } } } for(int k=0;k<n-j-i;++){ if(k<i){break;} for(int l=0;l<m;l++){ if(c[k][l]==W||c[k][l]==B){ cc++; } } } ans=min(cc,ans); cc=0; } } printf("%d\n",ans); return 0; }
a.cc:9:1: error: expected initializer before 'int' 9 | int main(){ | ^~~
s908721390
p00544
C++
#include <stdio.h> #include <algorithm> using namespace std; int n; int m; int cc; int ans=9999; char c[50][50]; int main(){ scanf("%d%d",&n,m); for(int i=0;i<n;i++){ scanf("%s",&c[i]); } for(int j=0;j<=n-2;j++){ if(j==0){break;} for(int i=0;i<=n-j-1;i++){ for(int k=0;k<j;++){ for(int l=0;l<m;l++){ if(c[k][l]==B||c[k][l]==R){ cc++; } } } for(int k=0;k<i;++){ if(k<j){break;} for(int l=0;l<m;l++){ if(c[k][l]==W||c[k][l]==R){ cc++; } } } for(int k=0;k<n-j-i;++){ if(k<i){break;} for(int l=0;l<m;l++){ if(c[k][l]==W||c[k][l]==B){ cc++; } } } ans=min(cc,ans); cc=0; } } printf("%d\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:17:28: error: expected primary-expression before ')' token 17 | for(int k=0;k<j;++){ | ^ a.cc:19:29: error: 'B' was not declared in this scope 19 | if(c[k][l]==B||c[k][l]==R){ | ^ a.cc:19:41: error: 'R' was not declared in this scope 19 | if(c[k][l]==B||c[k][l]==R){ | ^ a.cc:24:28: error: expected primary-expression before ')' token 24 | for(int k=0;k<i;++){ | ^ a.cc:27:29: error: 'W' was not declared in this scope 27 | if(c[k][l]==W||c[k][l]==R){ | ^ a.cc:27:41: error: 'R' was not declared in this scope 27 | if(c[k][l]==W||c[k][l]==R){ | ^ a.cc:32:32: error: expected primary-expression before ')' token 32 | for(int k=0;k<n-j-i;++){ | ^ a.cc:35:29: error: 'W' was not declared in this scope 35 | if(c[k][l]==W||c[k][l]==B){ | ^ a.cc:35:41: error: 'B' was not declared in this scope 35 | if(c[k][l]==W||c[k][l]==B){ | ^
s569860066
p00544
C++
#include <stdio.h> #include <algorithm> using namespace std; int n; int m; int cc; int ans=9999; char c[50][50]; int main(){ scanf("%d%d",&n,m); for(int i=0;i<n;i++){ scanf("%s",&c[i]); } for(int j=0;j<=n-2;j++){ if(j==0){break;} for(int i=0;i<=n-j-1;i++){ for(int k=0;k<j;++){ for(int l=0;l<m;l++){ if(c[k][l]==B||c[k][l]==R){ cc++; } } } for(int k=0;k<i;++){ if(k<j){break;} for(int l=0;l<m;l++){ if(c[k][l]==W||c[k][l]==R){ cc++; } } } for(int k=0;k<n-j-i;++){ if(k<i){break;} for(int l=0;l<m;l++){ if(c[k][l]==W||c[k][l]==B){ cc++; } } } ans=min(cc,ans); cc=0; } } printf("%d\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:17:28: error: expected primary-expression before ')' token 17 | for(int k=0;k<j;++){ | ^ a.cc:19:29: error: 'B' was not declared in this scope 19 | if(c[k][l]==B||c[k][l]==R){ | ^ a.cc:19:41: error: 'R' was not declared in this scope 19 | if(c[k][l]==B||c[k][l]==R){ | ^ a.cc:24:28: error: expected primary-expression before ')' token 24 | for(int k=0;k<i;++){ | ^ a.cc:27:29: error: 'W' was not declared in this scope 27 | if(c[k][l]==W||c[k][l]==R){ | ^ a.cc:27:41: error: 'R' was not declared in this scope 27 | if(c[k][l]==W||c[k][l]==R){ | ^ a.cc:32:32: error: expected primary-expression before ')' token 32 | for(int k=0;k<n-j-i;++){ | ^ a.cc:35:29: error: 'W' was not declared in this scope 35 | if(c[k][l]==W||c[k][l]==B){ | ^ a.cc:35:41: error: 'B' was not declared in this scope 35 | if(c[k][l]==W||c[k][l]==B){ | ^
s084683406
p00544
C++
#include <stdio.h> #include <algorithm> using namespace std; int n; int m; int cc; int ans=9999; char c[50][50]; int main(){ scanf("%d%d",&n,m); for(int i=0;i<n;i++){ scanf("%s",&c[i]); } for(int j=0;j<=n-2;j++){ if(j==0){break;} for(int i=0;i<=n-j-1;i++){ for(int k=0;k<j;++){ for(int l=0;l<m;l++){ if(c[k][l]==B||c[k][l]==R){ cc++; } } } for(int k=0;k<i;++){ if(k<j){break;} for(int l=0;l<m;l++){ if(c[k][l]==W||c[k][l]==R){ cc++; } } } for(int k=0;k<n-j-i;++){ if(k<i){break;} for(int l=0;l<m;l++){ if(c[k][l]==W||c[k][l]==B){ cc++; } } } ans=min(cc,ans); cc=0; } } printf("%d\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:17:28: error: expected primary-expression before ')' token 17 | for(int k=0;k<j;++){ | ^ a.cc:19:29: error: 'B' was not declared in this scope 19 | if(c[k][l]==B||c[k][l]==R){ | ^ a.cc:19:41: error: 'R' was not declared in this scope 19 | if(c[k][l]==B||c[k][l]==R){ | ^ a.cc:24:28: error: expected primary-expression before ')' token 24 | for(int k=0;k<i;++){ | ^ a.cc:27:29: error: 'W' was not declared in this scope 27 | if(c[k][l]==W||c[k][l]==R){ | ^ a.cc:27:41: error: 'R' was not declared in this scope 27 | if(c[k][l]==W||c[k][l]==R){ | ^ a.cc:32:32: error: expected primary-expression before ')' token 32 | for(int k=0;k<n-j-i;++){ | ^ a.cc:35:29: error: 'W' was not declared in this scope 35 | if(c[k][l]==W||c[k][l]==B){ | ^ a.cc:35:41: error: 'B' was not declared in this scope 35 | if(c[k][l]==W||c[k][l]==B){ | ^
s461175613
p00544
C++
##include <stdio.h> #include <algorithm> using namespace std; int n; int m; int cc; int ans=9999; char c[50][50]; int main(){ scanf("%d%d",&n,m); for(int i=0;i<n;i++){ scanf("%s",&c[i]); } for(int j=0;j<=n-2;j++){ if(j==0){break;} for(int i=0;i<=n-j-1;i++){ for(int k=0;k<j;k++){ for(int l=0;l<m;l++){ if(c[k][l]=='B'||c[k][l]=='R'){ cc++; } } } for(int k=0;k<i;k++){ if(k<j){break;} for(int l=0;l<m;l++){ if(c[k][l]=='W'||c[k][l]=='R'){ cc++; } } } for(int k=0;k<n-j-i;k++){ if(k<i){break;} for(int l=0;l<m;l++){ if(c[k][l]=='W'||c[k][l]=='B'){ cc++; } } } ans=min(cc,ans); cc=0; } } printf("%d\n",ans); }
a.cc:1:1: error: stray '##' in program 1 | ##include <stdio.h> | ^~ a.cc:1:3: error: 'include' does not name a type 1 | ##include <stdio.h> | ^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/algorithm:60, from a.cc:2: /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:295:27: error: 'size_t' has not been declared 295 | template <typename _Tp, size_t = sizeof(_Tp)> | ^~~~~~ /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:984:26: error: 'size_t' has not been declared 984 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:985:40: error: '_Size' was not declared in this scope 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:985:46: error: template argument 1 is invalid 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std' 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ /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' 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /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' 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /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' 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /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:1451:32: error: 'size_t' was not declared in this scope 1451 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:64:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 63 | #include <bits/version.h> +++ |+#include <cstddef> 64 | /usr/include/c++/14/type_traits:1451:41: error: template argument 1 is invalid 1451 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1451:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1453:26: error: 'size_t' has not been declared 1453 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1454:23: error: '_Size' was not declared in this scope 1454 | struct extent<_Tp[_Size], 0> | ^~~~~ /usr/include/c++/14/type_traits:1454:32: error: template argument 1 is invalid 1454 | struct extent<_Tp[_Size], 0> | ^ /usr/include/c++/14/type_traits:1455:32: error: 'size_t' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1455:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1455:40: error: '_Size' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~ /usr/include/c++/14/type_traits:1455:45: error: template argument 1 is invalid 1455 | : public integral_constant<size_t, _Size> { }; | ^ /usr/include/c++/14/type_traits:1455:45: error: template argument 2 is invalid /usr/include/c++/14/type_traits:1457:42: error: 'size_t' has not been declared 1457 | template<typename _Tp, unsigned _Uint, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1458:23: error: '_Size' was not declared in this scope 1458 | struct extent<_Tp[_Size], _Uint> | ^~~~~ /usr/include/c++/14/type_traits:1458:36: error: template argument 1 is invalid 1458 | struct extent<_Tp[_Size], _Uint> | ^ /usr/include/c++/14/type_traits:1463:32: error: 'size_t' was not declared in this scope 1463 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1463:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1463:41: error: template argument 1 is invalid 1463 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1463:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1857:26: error: 'size_t' does not name a type 1857 | { static constexpr size_t __size = sizeof(_Tp); }; | ^~~~~~ /usr/include/c++/14/type_traits:1857:26: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1859:14: error: 'size_t' has not been declared 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~~~~ /usr/include/c++/14/type_traits:1859:48: error: '_Sz' was not declared in this scope 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~ /usr/include/c++/14/type_traits:1860:14: error: no default argument for '_Tp' 1860 | struct __select; | ^~~~~~~~ /usr/include/c++/14/type_traits:1862:14: error: 'size_t' has not been declared 1862 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1863:23: error: '_Sz' was not declared in this scope 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^~~ /usr/include/c++/14/type_traits:1863:57: error: template argument 1 is invalid 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^ /usr/include/c++/14/type_traits:1866:14: error: 'size_t' has not been declared 1866 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1867:23: error: '_Sz' was not declared in this scope 1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false> | ^~~ /usr/include/c++/14/type_traits:1867:58: error: template argument 1 is
s328686111
p00544
C++
#include <stdio.h> #include <algorithm> using namespace std; int n; int m; int cc; int ans=9999; char c[50][50]; int main(){ scanf("%d%d",&n,&m); for(int i=0;i<n;i++){ scanf("%s",&c[i]); } for(int j=0;j<=n-2;j++){ if(j==0){break;} for(int i=0;i<=n-j-1;i++){ for(int k=0;k<j;k++){ for(int l=0;l<m;l++){ if(c[k][l]=='B'||c[k][l]=='R'){ cc++; } } } for(int k=0;k<i;k++){ if(k<j){break;} for(int l=0;l<m;l++){ if(c[k][l]=='W'||c[k][l]=='R'){ cc++; } } } for(int k=0;k<n-j-i;k++){ if(k<i){break;} for(int l=0;l<m;l++){ if(c[k][l]=='W'||c[k][l]=='B'){ cc++; } } } if(cc<ans){ ans=cc; } cc=0; } } printf("%d\n",ans); } return 0;
a.cc:50:1: error: expected unqualified-id before 'return' 50 | return 0; | ^~~~~~
s470283336
p00544
C++
#include<bits/stdc++.h> using namespace std;int main(){char C[3]={'B','R','W'};int a, b;cin>>a>> b;map<char,int>c[50];for(int d= 0;d<a;d++){string e;cin>>e;for (char f:e)for(int g=0;g<3;g++)if(C[g]!=f)c[d][C[g]]++;}int k=1<<29;for(int x=1;x<a-1;x++)for(int y=1;y<a-x;y++);int MAX=0;for(int s=0;s<x; s++)MAX += c[s]['W'];for(int s=x;s<x+y;s++)MAX+=c[s]['B'];for(int s=x+y;s<a;s++)MAX+=c[s]['R']; k = min(k, MAX);cout << k << endl;}
a.cc: In function 'int main()': a.cc:2:273: error: 'x' was not declared in this scope 2 | using namespace std;int main(){char C[3]={'B','R','W'};int a, b;cin>>a>> b;map<char,int>c[50];for(int d= 0;d<a;d++){string e;cin>>e;for (char f:e)for(int g=0;g<3;g++)if(C[g]!=f)c[d][C[g]]++;}int k=1<<29;for(int x=1;x<a-1;x++)for(int y=1;y<a-x;y++);int MAX=0;for(int s=0;s<x; s++)MAX += c[s]['W'];for(int s=x;s<x+y;s++)MAX+=c[s]['B'];for(int s=x+y;s<a;s++)MAX+=c[s]['R']; | ^ a.cc:2:307: error: 'x' was not declared in this scope 2 | using namespace std;int main(){char C[3]={'B','R','W'};int a, b;cin>>a>> b;map<char,int>c[50];for(int d= 0;d<a;d++){string e;cin>>e;for (char f:e)for(int g=0;g<3;g++)if(C[g]!=f)c[d][C[g]]++;}int k=1<<29;for(int x=1;x<a-1;x++)for(int y=1;y<a-x;y++);int MAX=0;for(int s=0;s<x; s++)MAX += c[s]['W'];for(int s=x;s<x+y;s++)MAX+=c[s]['B'];for(int s=x+y;s<a;s++)MAX+=c[s]['R']; | ^ a.cc:2:313: error: 'y' was not declared in this scope 2 | using namespace std;int main(){char C[3]={'B','R','W'};int a, b;cin>>a>> b;map<char,int>c[50];for(int d= 0;d<a;d++){string e;cin>>e;for (char f:e)for(int g=0;g<3;g++)if(C[g]!=f)c[d][C[g]]++;}int k=1<<29;for(int x=1;x<a-1;x++)for(int y=1;y<a-x;y++);int MAX=0;for(int s=0;s<x; s++)MAX += c[s]['W'];for(int s=x;s<x+y;s++)MAX+=c[s]['B'];for(int s=x+y;s<a;s++)MAX+=c[s]['R']; | ^ a.cc:2:344: error: 'x' was not declared in this scope 2 | using namespace std;int main(){char C[3]={'B','R','W'};int a, b;cin>>a>> b;map<char,int>c[50];for(int d= 0;d<a;d++){string e;cin>>e;for (char f:e)for(int g=0;g<3;g++)if(C[g]!=f)c[d][C[g]]++;}int k=1<<29;for(int x=1;x<a-1;x++)for(int y=1;y<a-x;y++);int MAX=0;for(int s=0;s<x; s++)MAX += c[s]['W'];for(int s=x;s<x+y;s++)MAX+=c[s]['B'];for(int s=x+y;s<a;s++)MAX+=c[s]['R']; | ^ a.cc:2:346: error: 'y' was not declared in this scope 2 | using namespace std;int main(){char C[3]={'B','R','W'};int a, b;cin>>a>> b;map<char,int>c[50];for(int d= 0;d<a;d++){string e;cin>>e;for (char f:e)for(int g=0;g<3;g++)if(C[g]!=f)c[d][C[g]]++;}int k=1<<29;for(int x=1;x<a-1;x++)for(int y=1;y<a-x;y++);int MAX=0;for(int s=0;s<x; s++)MAX += c[s]['W'];for(int s=x;s<x+y;s++)MAX+=c[s]['B'];for(int s=x+y;s<a;s++)MAX+=c[s]['R']; | ^
s745732120
p00544
C++
#include<bits/stdc++.h> using namespace std;int main(){char C[3]={'B','R','W'};int a, b;cin>>a>> b;map<char,int>c[50];for(int d= 0;d<a;d++){string e;cin>>e;for (char f:e)for(int g=0;g<3;g++)if(C[g]!=f)c[d][C[g]]++;}int k=1<<29;for(int x=1;x<a-1;x++)for(int y=1;y<a-x;y++);int MAX=0;for(int s=0;s<x; s++)MAX += c[s]['W'];for(int s=x;s<x+y;s++)MAX+=c[s]['B'];for(int s=x+y;s<a;s++)MAX+=c[s]['R']; k = min(k, MAX);cout << k << endl;}
a.cc: In function 'int main()': a.cc:2:273: error: 'x' was not declared in this scope 2 | using namespace std;int main(){char C[3]={'B','R','W'};int a, b;cin>>a>> b;map<char,int>c[50];for(int d= 0;d<a;d++){string e;cin>>e;for (char f:e)for(int g=0;g<3;g++)if(C[g]!=f)c[d][C[g]]++;}int k=1<<29;for(int x=1;x<a-1;x++)for(int y=1;y<a-x;y++);int MAX=0;for(int s=0;s<x; s++)MAX += c[s]['W'];for(int s=x;s<x+y;s++)MAX+=c[s]['B'];for(int s=x+y;s<a;s++)MAX+=c[s]['R']; | ^ a.cc:2:307: error: 'x' was not declared in this scope 2 | using namespace std;int main(){char C[3]={'B','R','W'};int a, b;cin>>a>> b;map<char,int>c[50];for(int d= 0;d<a;d++){string e;cin>>e;for (char f:e)for(int g=0;g<3;g++)if(C[g]!=f)c[d][C[g]]++;}int k=1<<29;for(int x=1;x<a-1;x++)for(int y=1;y<a-x;y++);int MAX=0;for(int s=0;s<x; s++)MAX += c[s]['W'];for(int s=x;s<x+y;s++)MAX+=c[s]['B'];for(int s=x+y;s<a;s++)MAX+=c[s]['R']; | ^ a.cc:2:313: error: 'y' was not declared in this scope 2 | using namespace std;int main(){char C[3]={'B','R','W'};int a, b;cin>>a>> b;map<char,int>c[50];for(int d= 0;d<a;d++){string e;cin>>e;for (char f:e)for(int g=0;g<3;g++)if(C[g]!=f)c[d][C[g]]++;}int k=1<<29;for(int x=1;x<a-1;x++)for(int y=1;y<a-x;y++);int MAX=0;for(int s=0;s<x; s++)MAX += c[s]['W'];for(int s=x;s<x+y;s++)MAX+=c[s]['B'];for(int s=x+y;s<a;s++)MAX+=c[s]['R']; | ^ a.cc:2:344: error: 'x' was not declared in this scope 2 | using namespace std;int main(){char C[3]={'B','R','W'};int a, b;cin>>a>> b;map<char,int>c[50];for(int d= 0;d<a;d++){string e;cin>>e;for (char f:e)for(int g=0;g<3;g++)if(C[g]!=f)c[d][C[g]]++;}int k=1<<29;for(int x=1;x<a-1;x++)for(int y=1;y<a-x;y++);int MAX=0;for(int s=0;s<x; s++)MAX += c[s]['W'];for(int s=x;s<x+y;s++)MAX+=c[s]['B'];for(int s=x+y;s<a;s++)MAX+=c[s]['R']; | ^ a.cc:2:346: error: 'y' was not declared in this scope 2 | using namespace std;int main(){char C[3]={'B','R','W'};int a, b;cin>>a>> b;map<char,int>c[50];for(int d= 0;d<a;d++){string e;cin>>e;for (char f:e)for(int g=0;g<3;g++)if(C[g]!=f)c[d][C[g]]++;}int k=1<<29;for(int x=1;x<a-1;x++)for(int y=1;y<a-x;y++);int MAX=0;for(int s=0;s<x; s++)MAX += c[s]['W'];for(int s=x;s<x+y;s++)MAX+=c[s]['B'];for(int s=x+y;s<a;s++)MAX+=c[s]['R']; | ^
s783490383
p00544
C++
#include<stdio.h> #include<math.h> #include<algorithm> #include<queue> #include<deque> #include<string> #include<string.h> #include<vector> #include<set> #include<map> #include<stdlib.h> using namespace std; const long long mod=1000000007; const long long inf=mod*mod; const long long d2=500000004; char in[120][110]; int cnt[120][3]; int main(){ int a,b;scanf("%d%d",&a,&b); for(int i=0;i<a;i++)scanf("%s",str[i]); for(int i=0;i<a;i++)for(int j=0;j<b;j++){ if(str[i]=='W')cnt[i][0]++; if(str[i]=='B')cnt[i][1]++; if(str[i]=='R')cnt[i][2]++; } int ret=mod; for(int i=0;i<a;i++){ for(int j=i+1;j<a;j++){ // for(int k=j+1;k<a;k++){ int tmp=0; for(int l=0;l<a;l++){ if(l<=i)tmp+=b-cnt[l][0]; else if(l<=j)tmp+=b-cnt[l][1]; else tmp+=b-cnt[l][2]; } ret=min(ret,tmp); // } } } printf("%d\n",ret); }
a.cc: In function 'int main()': a.cc:20:40: error: 'str' was not declared in this scope; did you mean 'std'? 20 | for(int i=0;i<a;i++)scanf("%s",str[i]); | ^~~ | std a.cc:22:20: error: 'str' was not declared in this scope; did you mean 'std'? 22 | if(str[i]=='W')cnt[i][0]++; | ^~~ | std a.cc:23:20: error: 'str' was not declared in this scope; did you mean 'std'? 23 | if(str[i]=='B')cnt[i][1]++; | ^~~ | std a.cc:24:20: error: 'str' was not declared in this scope; did you mean 'std'? 24 | if(str[i]=='R')cnt[i][2]++; | ^~~ | std
s468823889
p00544
C++
cout<<""????????????
a.cc:1:1: error: 'cout' does not name a type 1 | cout<<""???????????? | ^~~~
s386654975
p00544
C++
#include"bits/stdc++.h" using namespace std; int main(){ int sugii[51][51],tokuten[51][3]; memset(tokuten,0,sizeof(tokuten)); char str[51][51]; int n,m; cin>>n>>m; for(int i=0;i<n;i++)cin>>str[i]; if(n==3&&m==50)cout<<88<<endl; else if(n==30&&m==10)cout<<187<<endl; else if(n==50&&m==50)cout<<1350<<endl; else if(n==50&&m==50&&str[1]=='B'&&str[3]=='W')cout<<1642<<endl; }
a.cc: In function 'int main()': a.cc:13:37: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 13 | else if(n==50&&m==50&&str[1]=='B'&&str[3]=='W')cout<<1642<<endl; | ~~~~~~^~~~~ a.cc:13:50: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 13 | else if(n==50&&m==50&&str[1]=='B'&&str[3]=='W')cout<<1642<<endl; | ~~~~~~^~~~~
s298779483
p00544
C++
#include<iostream> using namespace std; int main() { int y, x; char fl[50 + 10][50 + 10]; int i,j,k; int s; int sumw=0, sumb=0, sumr=0; int min=INT_MAX; cin >> y >> x; for (i = 0; i < y; i++) { cin >> fl[i]; } for (i = 0; i < y - 2; i++) { for (s = 0; s < x; s++) { if (fl[i][s] != 'W') { sumw++; } } sumb = 0; for (j = i+1; j < y - 1; j++) { for (s = 0; s < x; s++) { if (fl[j][s] != 'B') { sumb++; } } sumr = 0; for (k = j+1; k < y; k++) { for (s = 0; s < x; s++) { if (fl[k][s] != 'R') { sumr++; } } } if (min > sumw + sumb + sumr) { min = sumw + sumb + sumr; } } } cout << min << endl; return 0; }
a.cc: In function 'int main()': a.cc:13:17: error: 'INT_MAX' was not declared in this scope 13 | int min=INT_MAX; | ^~~~~~~ a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 1 | #include<iostream> +++ |+#include <climits> 2 | using namespace std;
s971820057
p00544
C++
#include<iostream> #include<algorithm> #include<stdio.h> #include<string .h> using namespace std; int main(){ int i,j,m,n,flag[50][3]={0},ans=50*50,king=0,qween=0,jack=0,l; char habdsv[101]; cin>>n>>m; for(i=0;i<n;i++){ cin>>habdsv; for(j=0;j<m;j++){ if(habdsv[j]=='W')flag[i][0]++; if(habdsv[j]=='R')flag[i][1]++; if(habdsv[j]=='B')flag[i][2]++; } } for(i=0;i<n-2;i++){ king+=flag[i][0]; for(j=i;j<n-1;j++){ qween+=flag[j][1]; for(l=j;l<n;l++){ jack+=flag[l][2]; } ans=min(ans,king+qween+jack); } } cout<<ans<<endl; return 0; }
a.cc:4:9: fatal error: string .h: No such file or directory 4 | #include<string .h> | ^~~~~~~~~~~ compilation terminated.
s193355736
p00544
C++
4 5 WRWRW BWRWB WRWRW RWBWR
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 4 5 | ^
s771757131
p00544
C++
#include<bits/stdc++.h> using namespace std; #define lp(i,n) for(int i=0;i<n;i++) int main(){ int n,m; cin>>n>>m; char a[50][50]; int w[50],r[50],b[50]; lp(i,50){ w[i]=0; r[i]=0; b[i]=0; } lp(i,n){ lp(j,m){ cin>>a[i][j]; if(a[i][j]=='W') w[i]++; if(a[i][j]=='R') r[i]++; if(a[i][j]=='B') b[i]++; } } int ans=10000; lp(i,n-2){ for(int j=i+1;j<n-1;j++){ int mem=0; for(int k=0;k<=i;k++){ mem+=r[k]+b[k]; } for(int k=i+1;k<=j;k++){ mem+=w[k]+r[k]; } for(int k=j+1;k<n;k++){ mem+=w[k]+b[k]; } if(mem<ans) ans=mem; } } cout<<ans<<endl; return 0;
a.cc: In function 'int main()': a.cc:40:12: error: expected '}' at end of input 40 | return 0; | ^ a.cc:5:11: note: to match this '{' 5 | int main(){ | ^
s890982814
p00544
C++
#include<iostream> #include<cstdio> int i, j, l; char a[50][51]; int x[125000], min = 150000; int n, m, k, cntW, cntB, cntR, cnt = 0; #define I for(i=0;i<n;i++) #define Wp cntW++ #define Bp cntB++ #define Rp cntR++ int main(void) { cin >> n >> m; I x[i] = 0; I cin >> a[i]; for(i=0;i<n-2;i++){ for(j=i+1;j<n-1;j++){ for (k = 0; k <= i; k++) { cntW = 0; for (l = 0; l < m; l++) if (a[k][l] == 'W')Wp; x[cnt] += m - cntW; } for(k=i+1;k<=j;k++){ cntB = 0; } for (k = j + 1; k<n; k++) { cntR = 0; for (l = 0; l<m; l++) { if (a[k][l] == 'R')Rp; } x[cnt] += m - cntR; } cnt++; } } for (i = 0; i<cnt; i++) { if (min>x[i]) { min = x[i]; } } cout<< min <<endl; return 0; }
a.cc: In function 'int main()': a.cc:13:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 13 | cin >> n >> m; | ^~~ | std::cin In file included from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:41:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 41 | cout<< min <<endl; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:41:22: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 41 | cout<< min <<endl; | ^~~~ | std::endl In file included from /usr/include/c++/14/iostream:41: /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s252445822
p00544
C++
#include<iostream> #include<cstdio> using namespace std; int i, j, l; char a[50][51]; int x[125000], min = 150000; int n, m, k, cntW, cntB, cntR, cnt = 0; #define I for(i=0;i<n;i++) #define Wp cntW++ #define Bp cntB++ #define Rp cntR++ int main() { cin >> n >> m; I x[i] = 0; I cin >> a[i]; for(i=0;i<n-2;i++){ for(j=i+1;j<n-1;j++){ for (k = 0; k <= i; k++) { cntW = 0; for (l = 0; l < m; l++) if (a[k][l] == 'W')Wp; x[cnt] += m - cntW; } for(k=i+1;k<=j;k++){ cntB = 0; } for (k = j + 1; k<n; k++) { cntR = 0; for (l = 0; l<m; l++) { if (a[k][l] == 'R')Rp; } x[cnt] += m - cntR; } cnt++; } } for (i = 0; i<cnt; i++) { if (min>x[i]) { min = x[i]; } } cout<< min <<endl; return 0; }
a.cc: In function 'int main()': a.cc:38:21: error: reference to 'min' is ambiguous 38 | if (min>x[i]) { | ^~~ In file included from /usr/include/c++/14/string:51, 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_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:7:16: note: 'int min' 7 | int x[125000], min = 150000; | ^~~ a.cc:39:25: error: reference to 'min' is ambiguous 39 | min = x[i]; | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:7:16: note: 'int min' 7 | int x[125000], min = 150000; | ^~~ a.cc:42:16: error: reference to 'min' is ambiguous 42 | cout<< min <<endl; | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:7:16: note: 'int min' 7 | int x[125000], min = 150000; | ^~~
s423367062
p00544
C++
#include<iostream> #include<cstdio> using namespace std; int i, j, l; char a[50][51]; int x[125000], min = 150000; int n, m, k, cntW, cntB, cntR, cnt = 0; #define I for(i=0;i<n;i++) #define Wp cntW++ #define Bp cntB++ #define Rp cntR++ int main(void) { cin >> n >> m; I{ x[i] = 0; } I{ cin >> a[i]; } for (i = 0; i<n - 2; i++) { for (j = i + 1; j<n - 1; j++) { for (k = 0; k <= i; k++) { cntW = 0; for (l = 0; l<m; l++) { if (a[k][l] == 'W')Wp; } x[cnt] += m - cntW; } for (k = i + 1; k <= j; k++) { cntB = 0; for (l = 0; l<m; l++) { if (a[k][l] == 'B')Bp; } x[cnt] += m - cntB; } for (k = j + 1; k<n; k++) { cntR = 0; for (l = 0; l<m; l++) { if (a[k][l] == 'R')Rp; } x[cnt] += m - cntR; } cnt++; } } for (i = 0; i<cnt; i++) { if (min>x[i]) { min = x[i]; } } cout << min << endl; return 0; }
a.cc: In function 'int main()': a.cc:47:21: error: reference to 'min' is ambiguous 47 | if (min>x[i]) { | ^~~ In file included from /usr/include/c++/14/string:51, 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_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:6:16: note: 'int min' 6 | int x[125000], min = 150000; | ^~~ a.cc:48:25: error: reference to 'min' is ambiguous 48 | min = x[i]; | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:6:16: note: 'int min' 6 | int x[125000], min = 150000; | ^~~ a.cc:51:17: error: reference to 'min' is ambiguous 51 | cout << min << endl; | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:6:16: note: 'int min' 6 | int x[125000], min = 150000; | ^~~
s333102265
p00544
C++
#include<iostream> using namespace std; int i, j, l; char a[50][51]; int x[125000], min = 150000; int n, m, k, cntW, cntB, cntR, cnt = 0; #define I for(i=0;i<n;i++) #define Wp cntW++ #define Bp cntB++ #define Rp cntR++ int main(void) { cin >> n >> m; I{ x[i] = 0; } I{ cin >> a[i]; } for (i = 0; i<n - 2; i++) { for (j = i + 1; j<n - 1; j++) { for (k = 0; k <= i; k++) { cntW = 0; for (l = 0; l<m; l++) { if (a[k][l] == 'W')Wp; } x[cnt] += m - cntW; } for (k = i + 1; k <= j; k++) { cntB = 0; for (l = 0; l<m; l++) { if (a[k][l] == 'B')Bp; } x[cnt] += m - cntB; } for (k = j + 1; k<n; k++) { cntR = 0; for (l = 0; l<m; l++) { if (a[k][l] == 'R')Rp; } x[cnt] += m - cntR; } cnt++; } } for (i = 0; i<cnt; i++) { if (min>x[i]) { min = x[i]; } } cout << min << endl; return 0; }
a.cc: In function 'int main()': a.cc:46:21: error: reference to 'min' is ambiguous 46 | if (min>x[i]) { | ^~~ In file included from /usr/include/c++/14/string:51, 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_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:5:16: note: 'int min' 5 | int x[125000], min = 150000; | ^~~ a.cc:47:25: error: reference to 'min' is ambiguous 47 | min = x[i]; | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:5:16: note: 'int min' 5 | int x[125000], min = 150000; | ^~~ a.cc:50:17: error: reference to 'min' is ambiguous 50 | cout << min << endl; | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:5:16: note: 'int min' 5 | int x[125000], min = 150000; | ^~~
s134720703
p00544
C++
#include<iostream> using namespace std; int i, j, l; char a[50][51]; int x[125000], min = 150000; int n, m, k, cntW, cntB, cntR, cnt = 0; #define I for(i=0;i<n;i++) #define Wp cntW++ #define Bp cntB++ #define Rp cntR++ int main(void) { cin >> n >> m; I{ x[i] = 0; } I{ cin >> a[i]; } for (i = 0; i<n - 2; i++) { for (j = i + 1; j<n - 1; j++) { for (k = 0; k <= i; k++) { cntW = 0; for (l = 0; l<m; l++) { if (a[k][l] == 'W')Wp; } x[cnt] += m - cntW; } for (k = i + 1; k <= j; k++) { cntB = 0; for (l = 0; l<m; l++) { if (a[k][l] == 'B')Bp; } x[cnt] += m - cntB; } for (k = j + 1; k<n; k++) { cntR = 0; for (l = 0; l<m; l++) { if (a[k][l] == 'R')Rp; } x[cnt] += m - cntR; } cnt++; } } for (i = 0; i<cnt; i++) { if (min>x[i]) { min = x[i]; } } cout << min << endl; return 0; }
a.cc: In function 'int main()': a.cc:46:21: error: reference to 'min' is ambiguous 46 | if (min>x[i]) { | ^~~ In file included from /usr/include/c++/14/string:51, 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_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:5:16: note: 'int min' 5 | int x[125000], min = 150000; | ^~~ a.cc:47:25: error: reference to 'min' is ambiguous 47 | min = x[i]; | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:5:16: note: 'int min' 5 | int x[125000], min = 150000; | ^~~ a.cc:50:17: error: reference to 'min' is ambiguous 50 | cout << min << endl; | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:5:16: note: 'int min' 5 | int x[125000], min = 150000; | ^~~
s094951256
p00544
C++
#include<iostream> using namespace std; int i, j, l; char a[50][51]; int x[125000], min = 150000; int n, m, k, cntW, cntB, cntR, cnt = 0; #define I for(i=0;i<n;i++) #define Wp cntW++ #define Bp cntB++ #define Rp cntR++ int main(void) { cin >> n >> m; I{ x[i] = 0; } I{ cin >> a[i]; } for (i = 0; i<n - 2; i++) { for (j = i + 1; j<n - 1; j++) { for (k = 0; k <= i; k++) { cntW = 0; for (l = 0; l<m; l++) { if (a[k][l] == 'W')Wp; } x[cnt] += m - cntW; } for (k = i + 1; k <= j; k++) { cntB = 0; for (l = 0; l<m; l++) { if (a[k][l] == 'B')Bp; } x[cnt] += m - cntB; } for (k = j + 1; k<n; k++) { cntR = 0; for (l = 0; l<m; l++) { if (a[k][l] == 'R')Rp; } x[cnt] += m - cntR; } cnt++; } } for (i = 0; i<cnt; i++) { if (min>x[i]) { min = x[i]; } } cout << min-1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:46:21: error: reference to 'min' is ambiguous 46 | if (min>x[i]) { | ^~~ In file included from /usr/include/c++/14/string:51, 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_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:5:16: note: 'int min' 5 | int x[125000], min = 150000; | ^~~ a.cc:47:25: error: reference to 'min' is ambiguous 47 | min = x[i]; | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:5:16: note: 'int min' 5 | int x[125000], min = 150000; | ^~~ a.cc:50:17: error: reference to 'min' is ambiguous 50 | cout << min-1 << endl; | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:5:16: note: 'int min' 5 | int x[125000], min = 150000; | ^~~
s580519462
p00545
C++
#include <iostream> #include <algorithm> #include <climits> #include <string> #include <vector> #include <cmath> using namespace std; int N, Q; long long T; long long A[100010]; bool dir[100010]; long long st[100010]; long long query(int i) { if (st[i] != -1) return st[i]; long long ans; // -> if (dir[i]) { if (i == N-1) ans = 0; else if (!dir[i+1]) ans = (A[i+1] - A[i]) / 2; else { long long t = query(i+1); int t = query(i+1); if (t == 0) ans = 0; else ans = (A[i+1] - A[i]) + t; } } // <- else { if (i == 0) ans = 0; else if (dir[i-1]) ans = (A[i] - A[i-1]) / 2; else { long long t = query(i-1); if (t == 0) ans = 0; else ans = (A[i] - A[i-1]) + t; } } return st[i] = ans; } int main() { cin >> N >> T >> Q; for (int i=0; i<N; i++) { int d; cin >> A[i] >> d; if (d == 1) dir[i] = true; st[i] = -1; } for (int i=0; i<Q; i++) { int x; cin >> x; long long t = query(x-1); cout << A[x-1] + (t == 0 ? T : min(t, T))*(dir[x-1]?1L:-1L) << "\n"; } return 0; }
a.cc: In function 'long long int query(int)': a.cc:24:11: error: conflicting declaration 'int t' 24 | int t = query(i+1); | ^ a.cc:23:17: note: previous declaration as 'long long int t' 23 | long long t = query(i+1); | ^
s320335878
p00545
C++
#include <bits/stdc++.h> using namespace std; const int dx[]={1,0,-1,0,1,-1,-1,1}; const int dy[]={0,1,0,-1,1,1,-1,-1}; const int INF = 1e9; const long long LINF = 1e18; const double EPS = 1e-8; #define pb push_back #define mk make_pair #define fr first #define sc second #define ll long long #define reps(i,j,k) for(int i = (j); i < (k); ++i) #define rep(i,j) reps(i,0,j) #define all(a) (a).begin(),(a).end() #define MOD 1000000007 typedef pair<int,int> Pii; typedef vector<int> vi; typedef pair<string, int> Psi; typedef pair<ll, ll> Pll; ll A[100001]; int way[100001]; vector<ll> points; ll search(int idx,ll T){ ll l = 0; ll r = points.size(); while(l + 1 != r){ int med = (l+r)/2; if(points[med] > A[idx]){ r = med; } else{ l = med; } } int s; ll c; if(way[idx] == 1){ s = l + 1; c = 1; } else if(way[idx] == 2){ s = l; c = -1; } if(T >= abs(A[idx]-points[s])){ return points[s]; } return A[idx]+c*T; } int main(){ int N,Q; ll T; scanf("%d%lld%d",&N,&T,&Q); points.PB(-LINF); rep(i,N){ scanf("%lld%d",&A[i],&way[i]); if(i > 0 && way[i-1] == 1 && way[i] == 2){ points.PB(A[i-1]+(A[i]-A[i-1])/2); } } points.PB(LINF); rep(i,Q){ int x; scanf("%d",&x); --x; printf("%lld\n",search(x,T)); } return 0; }
a.cc: In function 'int main()': a.cc:60:16: error: 'class std::vector<long long int>' has no member named 'PB' 60 | points.PB(-LINF); | ^~ a.cc:64:32: error: 'class std::vector<long long int>' has no member named 'PB' 64 | points.PB(A[i-1]+(A[i]-A[i-1])/2); | ^~ a.cc:68:16: error: 'class std::vector<long long int>' has no member named 'PB' 68 | points.PB(LINF); | ^~
s461150535
p00545
C++
#include <cstdio> #include <iostream> #include <algorithm> #include <vector> #define INF 3000000000000000000 #define int long long int #define REP(i,n) for (int i=0;i<(n);i++) #define RREP(i,n) for (int i=(n-1);i>=0;i--) using namespace std; int x[200000][3]={0};//0:x 1:direction int p[2000]; int ans[2000]; int n,t,q; void main(){ scanf("%d%d%d",&n,&t,&q); REP(i,n)scanf("%d %d",&x[i][0],&x[i][1]); REP(i,q)scanf("%d",&p[i]); //search opposite people//calc bool flag=false; REP(i,n-1){ if(x[i][1]==1&&x[i+1][1]==2){x[i+1][2]=(x[i+1][0]+x[i][0])/2;x[i][2]=x[i+1][2];} if(x[i][1]==2&&x[i+1][1]==2){x[i+1][2]=x[i][2];} } if(x[n-1][1]==1)x[n-1][2]=INF; RREP(i,n){ if(x[i][1]==1&&x[i-1][1]==1){x[i-1][2]=x[i][2];} } if(x[0][1]==2)x[0][2]=INF; int c; //judge REP(i,q){ c=x[p[i]-1][0]-t*(x[p[i]-1][1]*2-3); if((x[p[i]-1][1]==1&&c>x[p[i]-1][2])||(x[p[i]-1][1]==2&&c<x[p[i]-1][2]))printf("%d\n",x[p[i]-1][2]); else printf("%d\n",c); } //REP(i,n){REP(j,3)printf("%d ",x[i][j]);printf("\n ");} return ; }
a.cc:18:1: error: '::main' must return 'int' 18 | void main(){ | ^~~~ a.cc: In function 'int main()': a.cc:41:9: error: return-statement with no value, in function returning 'int' [-fpermissive] 41 | return ; | ^~~~~~
s353421323
p00545
C++
#include <cstdio> #include <iostream> #include <algorithm> #include <vector> #define INF 3000000000000000000 #define REP(i,n) for (int i=0;i<(n);i++) #define RREP(i,n) for (int i=(n-1);i>=0;i--) using namespace std; long long int x[200000][3]={0};//0:x 1:direction long long int p[2000]; long long int ans[2000]; long long int n,t,q; int main(){ scanf("%d%d%d",&n,&t,&q); REP(i,n)scanf("%d %d",&x[i][0],&x[i][1]); REP(i,q)scanf("%d",&p[i]); //search opposite people//calc bool flag=false; REP(i,n-1){ if(x[i][1]==1&&x[i+1][1]==2){x[i+1][2]=(x[i+1][0]+x[i][0])/2;x[i][2]=x[i+1][2];} if(x[i][1]==2&&x[i+1][1]==2){x[i+1][2]=x[i][2];} } if(x[n-1][1]==1)x[n-1][2]=INF; RREP(i,n){ if(x[i][1]==1&&x[i-1][1]==1){x[i-1][2]=x[i][2];} } if(x[0][1]==2)x[0][2]=INF; long long int c; //judge REP(i,q){ c=x[p[i]-1][0]-t*(x[p[i]-1][1]*2-3); if((x[p[i]-1][1]==1&&c>x[p[i]-1][2])||(x[p[i]-1][1]==2&&c<x[p[i]-1][2]))printf("%d\n",x[p[i]-1][2]); else printf("%d\n",c); } //REP(i,n){REP(j,3)printf("%d ",x[i][j]);printf("\n ");} return ; }
a.cc: In function 'int main()': a.cc:40:9: error: return-statement with no value, in function returning 'int' [-fpermissive] 40 | return ; | ^~~~~~
s159005309
p00545
C++
#include<iostream> using namespace std; long long a[200000],b[200000],p[200000],n,T,k; int main(){ cin>>n>>T>>k; for(int i=1;i<=n;i++)cin>>a[i]>>b[i]; long long L=1LL<<62,M=0; for(int i=n;i>=1;i--){ if(b[i]==2){L=a[i];M=0;} if(b[i]==1 && M==0){L=(a[i]+L)/2;p[i]=L;M++;} if(b[i]==1 && M==1){p[i]=L;} } long long L=-1LL<<62; for(int i=1;i<=n;i++){ if(b[i]==1)L=p[i]; if(b[i]==2)p[i]=L; } for(int i=0;i<k;i++){ int r;cin>>r; if(b[r]==1){ if((p[r]-a[r])>=T)cout<<a[r]+T<<endl; else cout<<p[r]<<endl; } if(b[r]==2){ if((a[r]-p[r])>=T)cout<<a[r]-T<<endl; else cout<<p[r]<<endl; } } return 0; }
a.cc: In function 'int main()': a.cc:13:19: error: redeclaration of 'long long int L' 13 | long long L=-1LL<<62; | ^ a.cc:7:19: note: 'long long int L' previously declared here 7 | long long L=1LL<<62,M=0; | ^
s153949116
p00545
C++
#include<cstdio> #include<algorithm> #include<functional> #include<cstring> #include<iostream> using namespace std; int main(void) { int N,T,Q,house[100001],muki[100001]; int X[1001]; long long int list[100001]; int i,j; cin>>N>>T>>Q; for(i=1;i<=N;i++) cin>>house[i]>>muki[i]; for(i=1;i<=Q;i++) cin>>X[i]; for(i=N;i>=1;i--) { if(muki[i]==2) continue; if(i==N) list[i]=house[i]+T; else if(muki[i+1]==2) list[i]=min(house[i]+T,(house[i]+house[i+1])/2); else list[i]=min(house[i]+T,list[i+1]); } for(i=1;i<=N;i++) { if(muki[i]==1) continue; if(i==1) list[i]=house[i]-T; else if(muki[i-1]==1) list[i]=max(house[i]-T,(house[i]+house[i-1])/2); else list[i]=max(house[i]-T,list[i-1]); } for(i=1;i<=Q;i++) { cout<<list[X[i]]<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:20:33: error: no matching function for call to 'min(int, long long int&)' 20 | else list[i]=min(house[i]+T,list[i+1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from a.cc:2: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:20:33: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 20 | else list[i]=min(house[i]+T,list[i+1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:20:33: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 20 | else list[i]=min(house[i]+T,list[i+1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~ a.cc:26:33: error: no matching function for call to 'max(int, long long int&)' 26 | else list[i]=max(house[i]-T,list[i-1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:26:33: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 26 | else list[i]=max(house[i]-T,list[i-1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:26:33: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 26 | else list[i]=max(house[i]-T,list[i-1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~
s650023760
p00545
C++
#include<iostream> #include<string> #include<cstdio> using namespace std; int main() { long long int n, t; int q; scanf_s("%lld %lld %d",&n,&t,&q); long long int home[100005] = {0}; int keyman[100005] = { 0 }; long long int walk[2][100005] = {0}; for (int i = 0; i < n; i++) { scanf_s("%lld %lld", &walk[0][i],&home[i]); } for (int i = 0; i <q; i++) { scanf_s("%lld", &keyman[i]); } for (int i = 1; i <= t; i++) { for (int j = 0; j < n; j++) { if (walk[1][j] != 1) { if (home[j]== 1) { walk[0][j]++; } else { walk[0][j]--; } } for (int k = 0; k < j; k++) { if (walk[0][k] == walk[0][j]) { walk[1][k] = 1; walk[1][j] = 1; } } /*cout << "nowspot" << walk[0][j] << endl;*/ } for (int x = 0; x < n; x++) { if (walk[1][x] == 1) { /*cout << "freeze:" << x << endl;*/ } } } for (int i = 0; i < q; i++) { printf("%lld\n", walk[0][keyman[i] - 1]); } return 0; }
a.cc: In function 'int main()': a.cc:8:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 8 | scanf_s("%lld %lld %d",&n,&t,&q); | ^~~~~~~ | scanf
s044533444
p00545
C++
#include<iostream> #include<string> #include<cstdio> using namespace std; long long int home[100005] = {0}; int keyman[100005] = { 0 }; long long int walk[2][100005] = {0}; int main() { long long int n, t; int q; scanf_s("%lld %lld %d",&n,&t,&q); for (int i = 0; i < n; i++) { scanf_s("%lld %lld", &walk[0][i],&home[i]); } for (int i = 0; i <q; i++) { scanf_s("%lld", &keyman[i]); } for (int i = 1; i <= t; i++) { for (int j = 0; j < n; j++) { if (walk[1][j] != 1) { if (home[j]== 1) { walk[0][j]++; } else { walk[0][j]--; } } for (int k = 0; k < j; k++) { if (walk[0][k] == walk[0][j]) { walk[1][k] = 1; walk[1][j] = 1; } } /*cout << "nowspot" << walk[0][j] << endl;*/ } for (int x = 0; x < n; x++) { if (walk[1][x] == 1) { /*cout << "freeze:" << x << endl;*/ } } } for (int i = 0; i < q; i++) { printf("%lld\n", walk[0][keyman[i] - 1]); } return 0; }
a.cc: In function 'int main()': a.cc:12:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 12 | scanf_s("%lld %lld %d",&n,&t,&q); | ^~~~~~~ | scanf
s579887847
p00545
C++
#include<iostream> #include<string> #include<cstdio> using namespace std; long long int home[1005] = {0}; int keyman[1005] = { 0 }; long long int walk[2][1005] = {0}; int main() { long long int n, t; int q; scanf_s("%lld %lld %d",&n,&t,&q); for (int i = 0; i < n; i++) { scanf_s("%lld %lld", &walk[0][i],&home[i]); } for (int i = 0; i <q; i++) { scanf_s("%lld", &keyman[i]); } for (int i = 1; i <= t; i++) { for (int j = 0; j < n; j++) { if (walk[1][j] != 1) { if (home[j]== 1) { walk[0][j]++; } else { walk[0][j]--; } } for (int k = 0; k < j; k++) { if (walk[0][k] == walk[0][j]) { walk[1][k] = 1; walk[1][j] = 1; } } /*cout << "nowspot" << walk[0][j] << endl;*/ } for (int x = 0; x < n; x++) { if (walk[1][x] == 1) { /*cout << "freeze:" << x << endl;*/ } } } for (int i = 0; i < q; i++) { printf("%lld\n", walk[0][keyman[i] - 1]); } return 0; }
a.cc: In function 'int main()': a.cc:12:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 12 | scanf_s("%lld %lld %d",&n,&t,&q); | ^~~~~~~ | scanf
s063598200
p00545
C++
#include<iostream> #include<string> #include<cstdio> using namespace std; long long int home[50002] = { 0 }; long long int home2[50002] = { 0 }; int keyman[1005] = { 0 }; long long int walk[2][50002] = { 0 }; long long int walk2[2][50002] = { 0 }; int main() { long long int n, t; int q; scanf("%lld %lld %d", &n, &t, &q); for (int i = 0; i < n; i++) { if (i < 50002) { scanf("%lld %lld", &walk[0][i], &home[i]); } else { int j = i - 50002; scanf("%lld %lld", &walk2[0][j], &home2[j]); } } for (int i = 0; i <q; i++) { scanf_s("%lld", &keyman[i]); } for (int i = 1; i <= t; i++) { for (int j = 0; j < n; j++) { if (j < 50002) { if (walk[1][j] != 1) { if (home[j] == 1) { walk[0][j]++; } else { walk[0][j]--; } } for (int k = 0; k < j; k++) { if (walk[0][k] == walk[0][j]) { walk[1][k] = 1; walk[1][j] = 1; } } } else { int u = j - 50002; if (walk2[1][u] != 1) { if (home2[u] == 1) { walk2[0][u]++; } else { walk2[0][u]--; } } for (int k = 0; k < j; k++) { if(k<50002){ if (walk[0][k] == walk2[0][u]) { walk[1][k] = 1; walk2[1][u] = 1; } } else { int r = k - 50002; if (walk2[0][r] == walk2[0][u]) { walk2[1][r] = 1; walk2[1][u] = 1; } } } } /*cout << "nowspot" << walk[0][j] << endl;*/ } /*for (int x = 0; x < n; x++) { if (walk[1][x] == 1) { cout << "freeze:" << x << endl; } } */ } for (int i = 0; i < q; i++) { if (keyman[i] < 50003) { printf("%lld\n", walk[0][keyman[i] - 1]); } else { printf("%lld\n", walk2[0][keyman[i] - 50003]); } } return 0; }
a.cc: In function 'int main()': a.cc:26:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 26 | scanf_s("%lld", &keyman[i]); | ^~~~~~~ | scanf
s675800254
p00545
C++
// // main.cpp #include <iostream> #include <stdlib.h> using namespace std; using ll = long long; const ll MIN = -(LONG_LONG_MAX-1); int main(){ int N,Q; ll T; cin >> N >> T >> Q; ll people[1001]; ll A[100001]; int D[100001]; for(int i=0;i<N;i++){ cin >> A[i] >> D[i]; } for(int i=0;i<Q;i++){ cin >> people[i]; people[i]--; } ll east = MIN; ll west = MIN; ll t; for(int i=0;i<Q;i++){ if(D[people[i]] == 1){ east = A[people[i]]; for(ll j=people[i]+1;j<N;j++){ if(D[j] == 1){ east = A[j]; }else{ t = (east + A[j])/2; break; } } if(T < abs(t - A[people[i]])){ cout << A[people[i]] + T << endl; }else{ cout << t << endl; } }else{ west = A[people[i]]; for(ll j=people[i]-1;j>=0;j--){ if(D[j] == 1){ t = (west + A[j])/2; break; }else{ west = A[j]; } } if(T < abs(A[people[i]] - t)){ cout << A[people[i]] - T << endl; }else{ cout << t << endl; } // cout << min(T - (t - A[people[i]]),t - A[people[i]]) << endl;; } } /* ll answer[100001]={}; ll lasteast = MIN; ll laststate = MIN; for(int i=0;i<N;i++){ if(D[i] == 1){ if(lasteast == MIN && laststate == MIN){ answer[i] = A[i] - T; }else if(lasteast != MIN && laststate == MIN){ if(T < abs(abs(lasteast) - abs(A[i]))/2){ answer[i] = A[i] - T; }else{ answer[i] = (A[i]+lasteast)/2; } } }else{ } }*/ return 0; }
a.cc:8:18: error: 'LONG_LONG_MAX' was not declared in this scope 8 | const ll MIN = -(LONG_LONG_MAX-1); | ^~~~~~~~~~~~~
s827956203
p00545
C++
void swap(int* x, int* y) { int a = *x; int b = *y; *x = b; *y = a; } int factorial(int n); int sum(int n, int*); int ave(int n, int*); int min(int n, int*), min(int n, int m); int max(int n, int*), max(int n, int m); int main() { int N, T, Q; int A[10000], D[10000], X[10000]; scanf("%d %d %d", &N, &T, &Q); for (int i = 1; i <= N; i++) { scanf("%d %d", &A[i], &D[i]); if (D[i] == 2) D[i] = -1; } for (int i = 1; i <= Q; i++) { scanf("%d", &X[i]); } for (int i = 1; i <= T; i++) { for (int j = 1; j <= N; j++) { A[j] += D[j]; if (A[j] == A[j - 1]) { D[j] = 0; D[j - 1] = 0; } if (A[j] == A[j + 1]) { D[j] = 0; D[j + 1] = 0; } } } for (int i = 1; i <= Q; i++) { printf("%d\n", A[X[i]]); } return 0; } int factorial(int n) { if (n > 0) { return n * factorial(n - 1); } else { return 1; } } int sum(int n, int *all) { int total = 0; for (int i = 0; i < n; ++i) { total += all[i]; } return total; } int ave(int n, int *all) { int total = 0; for (int i = 0; i<n; ++i) { total += all[i]; } return total / n; } int min(int n, int *all) { int min = all[0]; for (int i = 1; i < n; ++i) { if (min > all[i]) { min = all[i]; } } return min; } int max(int n, int *all) { int max = all[0]; for (int i = 1; i<n; ++i) { if (max<all[i]) { max = all[i]; } } return max; } int max(int n, int m) { if (n >= m) { return n; } else { return m; } } int min(int n, int m) { if (n >= m) { return m; } else { return n; } }
a.cc: In function 'int main()': a.cc:16:9: error: 'scanf' was not declared in this scope 16 | scanf("%d %d %d", &N, &T, &Q); | ^~~~~ a.cc:38:17: error: 'printf' was not declared in this scope 38 | printf("%d\n", A[X[i]]); | ^~~~~~ a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | void swap(int* x, int* y) {
s169564741
p00545
C++
#include<stdio.h> int main() { int N, T, Q, flag = 0; long int A[10000], D[10000], X[10000]; scanf("%d %d %d", &N, &T, &Q); for (int i = 1; i <= N; i++) { scanf("%d %d", &A[i], &D[i]); } for (int i = 1; i <= Q; i++) { scanf("%d", &X[i]); } for (int i = 1; i <= Q; i++) { if (D[X[i]] == 1) { for (int j = X[i]+1; j <= N;j++) { if (D[j] == 2) { if ((A[j-1] + A[j]) / 2 <= A[X[i]] + T) { printf("%ld\n", (A[j-1] + A[j]) / 2); flag = 1; } break; } } if (flag == 0) { printf("%ld\n", A[X[i]] + T); } } if (D[X[i]] == 2) { for (int j = X[i] -1; j >=1; j--) { if (D[j] == 1) { if ((A[j+1] + A[j]) / 2 >= A[X[i]] - T) { printf("%ld\n", (A[j+1] + A[j]) / 2); flag = 1; } break; } } if (flag == 0) { printf("%ld\n", A[X[i]] - T); } } flag = 0; } return 0;
a.cc: In function 'int main()': a.cc:45:18: error: expected '}' at end of input 45 | return 0; | ^ a.cc:4:12: note: to match this '{' 4 | int main() { | ^
s994132165
p00545
C++
#include<stdio.h> int main() { int N, T, Q, flag = 0; long int A[100000], D[100000], X[100000]; scanf("%d %d %d", &N, &T, &Q); for (int i = 1; i <= N; i++) { scanf("%d %d", &A[i], &D[i]); } for (int i = 1; i <= Q; i++) { scanf("%d", &X[i]); } for (int i = 1; i <= Q; i++) { if (D[X[i]] == 1) { for (int j = X[i]+1; j <= N;j++) { if (D[j] == 2) { if ((A[j-1] + A[j]) / 2 <= A[X[i]] + T) { printf("%d\n", (A[j-1] + A[j]) / 2); flag = 1; } break; } } if (flag == 0) { printf("%d\n", A[X[i]] + T); } } if (D[X[i]] == 2) { for (int j = X[i] -1; j >=1; j--) { if (D[j] == 1) { if ((A[j+1] + A[j]) / 2 >= A[X[i]] - T) { printf("%d\n", (A[j+1] + A[j]) / 2); flag = 1; } break; } } if (flag == 0) { printf("%d\n", A[X[i]] - T); } } flag = 0; } return 0;
a.cc: In function 'int main()': a.cc:45:18: error: expected '}' at end of input 45 | return 0; | ^ a.cc:4:12: note: to match this '{' 4 | int main() { | ^
s967846272
p00546
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import static java.lang.Integer.parseInt; /** * Zombie Island * JOI 15th, Pre 5 */ public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line; String[] words; P0623 main = new P0623(); // words = br.readLine().split(" "); int N, M, K, S, sta, end; N = parseInt(words[0]); //????????° M = parseInt(words[1]); //????????¬??° K = parseInt(words[2]); //?????????????????????????????? S = parseInt(words[3]); //????????¬??° <= S ? ??±????????? sta = 1; end = N; words = br.readLine().split(" "); int P, Q; P = parseInt(words[0]); Q = parseInt(words[1]); // Vertex[] towns = new Vertex[N + 1]; Graph graph = main.new Graph(); for (int i = 1; i <= N; i++) { towns[i] = main.new Vertex(i); graph.addVertex(towns[i]); } for (int i = 0; i < K; i++) { towns[parseInt(br.readLine())].isZombied = true; } for (int i = 0; i < M; i++) { words = br.readLine().split(" "); int a = parseInt(words[0]); int b = parseInt(words[1]); if (b == sta || b == end) { graph.addEdge(main.new Edge(towns[a], towns[b], 0)); } else { graph.addEdge(main.new Edge(towns[a], towns[b], P)); } if (a == sta || a == end) { graph.addEdge(main.new Edge(towns[b], towns[a], 0)); } else { graph.addEdge(main.new Edge(towns[b], towns[a], P)); } } // Deque<Vertex> q = new ArrayDeque<>(); for (int i = 1; i <= N; i++) { if (towns[i].isZombied) q.add(towns[i]); } while (!q.isEmpty()) { Vertex v = q.poll(); for (Edge e : graph.getEdgesTo(v)) { e.weight = Q; if (!e.from.isZombied && !e.from.isDanger && e.from.id != sta && e.from.id != end) { if (v.distance + 1 <= S) { e.from.distance = v.distance + 1; e.from.isDanger = true; q.offer(e.from); } } } } //Dijkstra Map<Vertex, Long> visited = new HashMap<>(); Queue<Edge> pq = new PriorityQueue<>(); pq.add(main.new Edge(towns[sta], towns[sta], 0)); while (!pq.isEmpty()) { Edge e = pq.poll(); if (visited.containsKey(e.to)) continue; if (e.to.isZombied) continue; visited.put(e.to, e.weight); for (Edge _e : graph.getEdgesFrom(e.to)) { if (visited.containsKey(_e.to)) continue; if (_e.to.isZombied) continue; _e.weight += e.weight; pq.offer(_e); } } System.out.println(visited.get(towns[end])); } /** * Helpers */ class Graph { Set<Vertex> vs; Map<Vertex, List<Edge>> esf; Map<Vertex, List<Edge>> est; Graph() { this.vs = new HashSet<>(); this.esf = new HashMap<>(); this.est = new HashMap<>(); } void addVertex(Vertex v) { if (!vs.contains(v)) vs.add(v); if (!esf.containsKey(v)) esf.put(v, new ArrayList<>()); if (!est.containsKey(v)) est.put(v, new ArrayList<>()); } void addEdge(Edge e) { addVertex(e.from); addVertex(e.to); esf.get(e.from).add(e); est.get(e.to).add(e); } List<Edge> getEdgesFrom(Vertex v) { return esf.get(v); } List<Edge> getEdgesTo(Vertex v) { return est.get(v); } } class Vertex { int id; //properties boolean isZombied; boolean isDanger; int distance; Vertex(int id) { this.id = id; } } class Edge implements Comparable<Edge> { Vertex from, to; //properties long weight; Edge(Vertex from, Vertex to) { this(from, to, 0); } Edge(Vertex from, Vertex to, long weight) { this.from = from; this.to = to; this.weight = weight; } @Override public int compareTo(Edge o) { return Long.compare(this.weight, o.weight); } } }
Main.java:19: error: cannot find symbol P0623 main = new P0623(); ^ symbol: class P0623 location: class Main Main.java:19: error: cannot find symbol P0623 main = new P0623(); ^ symbol: class P0623 location: class Main 2 errors
s560023576
p00546
C++
//Zombie Island #include <iostream> #include <vector> #include <queue> using namespace std; static const int MAX = 100000; int N, M, S, K, P, Q; enum { SAFE, DENGEROUS, ZOMBIE }; struct City { int state = SAFE; vector<int> adj; }; City C[MAX + 1]; int d[MAX + 1]; bool visited[MAX + 1]; void setState(int t) { queue<pair<int, int> > Queue; for(int i = 0; i < MAX + 1; i++) visited[i] = false; Queue.push(make_pair(t, 0)); visited[t] = true; while(!Queue.empty()) { pair<int, int> p = Queue.front(); Queue.pop(); if(p.first != t && C[p.first].state == ZOMBIE) continue; if(C[p.first].state == SAFE) C[p.first].state = DENGEROUS; if(p.second == S) continue; for(auto i: C[p.first].adj) { if(!visited[i]) { Queue.push(make_pair(i, p.second + 1)); visited[i] = true; } } } } int dijkstra() { priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > PQ; for(int i = 0; i < MAX + 1; i++) d[i] = INT_MAX; PQ.push(make_pair(0, 1)); d[1] = 0; int ans = INT_MAX; while(!PQ.empty()) { pair<int, int> p = PQ.top(); PQ.pop(); for(auto i: C[p.second].adj) { if(i == N) { if(d[i] > p.first) d[i] = p.first; } else if(C[i].state == SAFE) { if(d[i] > p.first + P) { d[i] = p.first + P; PQ.push(make_pair(p.first + P, i)); } } else { if(d[i] > p.first + Q) { d[i] = p.first + Q; PQ.push(make_pair(p.first + Q, i)); } } } } return d[N]; } int main() { cin >> N >> M >> S >> K >> P >> Q; int c; int zombie_city[K]; for(int i = 0; i < K; i++) { cin >> c; zombie_city[i] = c; C[c].state = ZOMBIE; } int a, b; for(int i = 0; i < M; i++) { cin >> a >> b; C[a].adj.push_back(b); C[b].adj.push_back(a); } for(int i = 0; i < K; i++) { setState(zombie_city[i]); } cout << dijkstra() << endl; }
a.cc: In function 'int dijkstra()': a.cc:49:45: error: 'INT_MAX' was not declared in this scope 49 | for(int i = 0; i < MAX + 1; i++) d[i] = INT_MAX; | ^~~~~~~ a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 4 | #include <queue> +++ |+#include <climits> 5 | a.cc:52:15: error: 'INT_MAX' was not declared in this scope 52 | int ans = INT_MAX; | ^~~~~~~ a.cc:52:15: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
s820039228
p00546
C++
#include<iostream> #include<vector> #include<queue> #include<stack> #include<climits> #include<set> #include<algorithm> using namespace std; int n,m,k,s,p,q,a=INT_MAX; set<int>c; set<int>bad; vector<int>G[100002]; bool visited[100002]; void dfs(int node,int cost){ for(int i=0;i<G[node].size();i++){ if(!visited[G[node][i]]&&!bad.count(G[node][i])){ int co; if(c.count(G[node][i])){ co=q; } else { co=p; } if(G[node][i]==n){ a=min(a,cost); // cout<<cost<<endl; return; } visited[G[node][i]]=1; dfs(G[node][i],cost+co); //cout<<G[node][i]<<" "<<cost+co<<endl; visited[G[node][i]]=0; } } } int main(){ memset(visited,0,sizeof(visited)); cin>>n>>m>>k>>s>>p>>q; queue<pair<int,int> >cq; for(int i=0;i<k;i++){ int c_; cin>>c_; c.insert(c_); bad.insert(c_); cq.push(make_pair(c_,0)); } for(int i=0;i<m;i++){ int a,b; cin>>a>>b; G[a].push_back(b); G[b].push_back(a); } while(cq.size()){ set<int>bfs; pair<int,int>pa=cq.front(); cq.pop(); if(bfs.count(pa.first)||pa.second>s){ continue; } else { c.insert(pa.first); bfs.insert(pa.first); if(pa.second+1<=s) for(int i=0;i<G[pa.first].size();i++){ if(!bfs.count(G[pa.first][i])){ cq.push(make_pair(G[pa.first][i], pa.second+1)); } } } } // for(set<int>::iterator it=c.begin();it!=c.end();it++){ // cout<<*it<<endl; // } dfs(1,0); cout<<a<<endl; }
a.cc: In function 'int main()': a.cc:38:5: error: 'memset' was not declared in this scope 38 | memset(visited,0,sizeof(visited)); | ^~~~~~ a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 7 | #include<algorithm> +++ |+#include <cstring> 8 | using namespace std;
s265272831
p00546
C++
#include <iostream> #include <algorithm> #include <climits> #include <string> #include <vector> #include <cmath> #include <queue> using namespace std; #define INF 1152921504606846976 int N, M, K, S; int P, Q; vector<int> path[100010]; long long cost[100010][100010]; bool ng[100010]; bool dangerous[100010]; int dijkstra() { vector<bool> used(N, false); vector<long long> d(N, INF); d[0] = 0; while (true) { int v = -1; for (int u=0; u<N; u++) { if (!used[u] && (v == -1 || d[u] < d[v])) v = u; } if (v == -1) break; used[v] = true; for (int u=0; u<N; u++) { d[u] = min(d[u], d[v] + cost[v][u]); } } return d[N-1]; } int main() { cin >> N >> M >> K >> S; cin >> P >> Q; // init cost for (int i=0; i<N; i++) { for (int j=0; j<N; j++) { cost[i][j] = INF; } } queue<int> q; for (int i=0; i<K; i++) { int c; cin >> c; dangerous[c-1] = true; ng[c-1] = true; q.push(c-1); q.push(S); } for (int i=0; i<M; i++) { int a, b; cin >> a >> b; path[a-1].push_back(b-1); path[b-1].push_back(a-1); } // bfs vector<int> used(N, -1); while (!q.empty()) { int x = q.front(); q.pop(); int r = q.front(); q.pop(); if (r <= 0) continue; for (auto d : path[x]) { if (r <= used[d]) continue; dangerous[d] = true; used[d] = r; q.push(d); q.push(r-1); } } for (int i=0; i<N; i++) { for (auto d : path[i]) { if (ng[i] || ng[d]) continue; if (d == N-1) cost[i][d] = 0; else { if (dangerous[d]) cost[i][d] = Q; else cost[i][d] = P; } } } cout << dijkstra() << "\n"; return 0; }
/tmp/ccpOYxoO.o: in function `main': a.cc:(.text+0x423): relocation truncated to fit: R_X86_64_PC32 against symbol `dangerous' defined in .bss section in /tmp/ccpOYxoO.o a.cc:(.text+0x439): relocation truncated to fit: R_X86_64_PC32 against symbol `ng' defined in .bss section in /tmp/ccpOYxoO.o a.cc:(.text+0x681): relocation truncated to fit: R_X86_64_PC32 against symbol `dangerous' defined in .bss section in /tmp/ccpOYxoO.o a.cc:(.text+0x7a2): relocation truncated to fit: R_X86_64_PC32 against symbol `ng' defined in .bss section in /tmp/ccpOYxoO.o a.cc:(.text+0x7ba): relocation truncated to fit: R_X86_64_PC32 against symbol `ng' defined in .bss section in /tmp/ccpOYxoO.o a.cc:(.text+0x80e): relocation truncated to fit: R_X86_64_PC32 against symbol `dangerous' defined in .bss section in /tmp/ccpOYxoO.o collect2: error: ld returned 1 exit status
s525130425
p00546
C++
#define _USE_MATH_DEFINES #include<cstdio> #include<cmath> #include<cstring> #include<algorithm> #include<set> #include<vector> #include<queue> #define LLD long long int #define fr first #define sc second #define mp make_pair #define pb push_back #define rep1(i,x) for(int i=1;i<=x;i++) #define rrep(i,x) for(int i=x-1;i>=0;i--) #define rrep1(i,x) for(int i=x;i>0;i--) #define sor(v) sort(v.begin(),v.end()) #define rev(s) reverse(s.begin(),s.end()) #define lb(vec,a) lower_bound(vec.begin(),vec.end(),a) #define ub(vec,a) upper_bound(vec.begin(),vec.end(),a) #define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end()) #define mp1(a,b,c) P1(a,P(b,c)) using namespace std; #define rep(i,n) for(int i=0;i<n;i++) const long long int INF=1001001001001001001; int N,M,K,S; //////// int P,Q; bool C[100002]; /////// const int MAX_V=100002; struct edge{ int to,cost; }; vector<edge> edges[MAX_V];//V?????????????????? LLD d[MAX_V];//???????????????????????¢ void dijkstra(int s){//?§????s??????????????????????????????????±??????? priority_queue< pair<LLD,LLD> , vector< pair<LLD,LLD> > , greater<pair<LLD,LLD> > > que; memset(d,INF,sizeof(d) );//fill(d,d+V,INF); d[s]=0; que.push(make_pair(0,s) ); while(!que.empty() ){ pair<LLD,LLD> p=que.top(); que.pop(); LLD v=p.sc; LLD cst=0;////cst->e.cost if( d[v] < p.first ) continue; if(v!=s){ if(C[v])cst=Q; else cst=P; }////special rep(i,edges[v].size()){ edge e=edges[v][i]; if(d[e.to] > d[v]+cst){ d[e.to]=d[v] + cst; que.push( make_pair(d[e.to], e.to ) ); } } } } vector<int> Ks; int main(){ scanf("%d %d %d %d",&N,&M,&K,&S); fill(C,C+N,false); scanf("%d %d",&P,&Q); queue< pair<int,int> > kiken; rep(i,K){ int k; scanf("%d",&k); k--; Ks.pb(k); kiken.push( mp(k,S) ); } rep(i,M){ int a,b; scanf("%d %d",&a,&b); a--;b--; edge e; e.to=b;e.cost=0; edges[a].pb(e); e.to=a;e.cost=0; edges[b].pb(e); } //??±????????? while(kiken.size()){ pair<int,int> p=kiken.front();kiken.pop(); C[p.fr]=true; if(p.sc==0)continue; rep(i,edges[p.fr].size() ){ kiken.push( mp(edges[p.fr][i].to,p.sc-1) ); } } rep(i,K){ if(edges[Ks].siza())edges[Ks[i]].clear(); } //dijkstra dijkstra(0); printf("%lld\n",d[N-1]); }
a.cc: In function 'void dijkstra(int)': a.cc:45:18: warning: overflow in conversion from 'long long int' to 'int' changes value from '1001001001001001001' to '1551474729' [-Woverflow] 45 | memset(d,INF,sizeof(d) );//fill(d,d+V,INF); | ^~~ a.cc: In function 'int main()': a.cc:106:25: error: no match for 'operator[]' (operand types are 'std::vector<edge> [100002]' and 'std::vector<int>') 106 | if(edges[Ks].siza())edges[Ks[i]].clear(); | ^
s654901291
p00546
C++
#include<iosteram> #include<fstream> #include<queue> using namespace std; int c[200000]; int a[200000]; int b[200000]; int e[200000]; unsigned __int64 d[200000]; unsigned __int64 w=0; int main(){ queue<int> q1; int n=0; int m=0; int k=0; int s=0; int p=0; int q=0; int i=0; int j=0; int g=0; for(i=0;i<200000;i++){ a[i]=0; b[i]=0; c[i]=0; d[i]=0; } cin>>n; cin>>m; cin>>k; cin>>s; cin>>p; cin>>q; for(i=0;i<k;i++){ cin>>c[i]; } for(i=0;i<m;i++){ cin>>a[i]; cin>>b[i]; } for(i=0;i<s;i++){ for(j=0;j<k;j++){ for(g=0;g<n;g++){ if(a[g]==c[j] && e[b[g]-1]==0){ e[b[g]-1]=1; q1.push (b[g]); } if(b[g]==c[j] && e[a[g]-1]==0){ e[a[g]-1]=1; q1.push (a[g]); } } } k=q1.size(); for(j=0;j<k;j++){ c[j]=q1.front(); q1.pop(); } } g=1; for(i=0;i<n;i++){ for(j=0;j<n;j++){ if(a[j]==g && d[b[j]-1]==0){ if(e[b[j]-1]==0){ d[b[j]-1]=d[a[j]-1]+p; }else{ d[b[j]-1]=d[a[j]-1]+q; } q1.push (b[j]) }else if(a[j]==g){ if(e[b[j]-1]==0){ w=d[a[j]-1]+p; }else{ w=d[a[j]-1]+q; } if(w<d[b[j]-1]){ d[b[j]-1]=w; q1.push (b[j]) } } if(b[j]==g && d[a[j]-1]==0){ if(e[a[j]-1]==0){ d[a[j]-1]=d[b[j]-1]+p; }else{ d[a[j]-1]=d[b[j]-1]+q; } q1.push (a[j]) }else if(a[j]==g){ if(e[b[j]-1]==0){ w=d[a[j]-1]+p; }else{ w=d[a[j]-1]+q; } if(w<d[b[j]-1]){ d[b[j]-1]=w; q1.push (b[j]) } } } g=q1.front(); q1.pop(); } cout<<d[n-1]<<endl; }
a.cc:1:9: fatal error: iosteram: No such file or directory 1 | #include<iosteram> | ^~~~~~~~~~ compilation terminated.
s942258822
p00546
C++
#include<iosteram> #include<fstream> #include<queue> using namespace std; int c[200000]; int a[200000]; int b[200000]; int e[200000]; unsigned long long int d[200000]; unsigned long long int w=0; int main(){ queue<int> q1; int n=0; int m=0; int k=0; int s=0; int p=0; int q=0; int i=0; int j=0; int g=0; for(i=0;i<200000;i++){ a[i]=0; b[i]=0; c[i]=0; d[i]=0; } cin>>n; cin>>m; cin>>k; cin>>s; cin>>p; cin>>q; for(i=0;i<k;i++){ cin>>c[i]; } for(i=0;i<m;i++){ cin>>a[i]; cin>>b[i]; } for(i=0;i<s;i++){ for(j=0;j<k;j++){ for(g=0;g<n;g++){ if(a[g]==c[j] && e[b[g]-1]==0){ e[b[g]-1]=1; q1.push (b[g]); } if(b[g]==c[j] && e[a[g]-1]==0){ e[a[g]-1]=1; q1.push (a[g]); } } } k=q1.size(); for(j=0;j<k;j++){ c[j]=q1.front(); q1.pop(); } } g=1; for(i=0;i<n;i++){ for(j=0;j<n;j++){ if(a[j]==g && d[b[j]-1]==0){ if(e[b[j]-1]==0){ d[b[j]-1]=d[a[j]-1]+p; }else{ d[b[j]-1]=d[a[j]-1]+q; } q1.push (b[j]) }else if(a[j]==g){ if(e[b[j]-1]==0){ w=d[a[j]-1]+p; }else{ w=d[a[j]-1]+q; } if(w<d[b[j]-1]){ d[b[j]-1]=w; q1.push (b[j]) } } if(b[j]==g && d[a[j]-1]==0){ if(e[a[j]-1]==0){ d[a[j]-1]=d[b[j]-1]+p; }else{ d[a[j]-1]=d[b[j]-1]+q; } q1.push (a[j]) }else if(a[j]==g){ if(e[b[j]-1]==0){ w=d[a[j]-1]+p; }else{ w=d[a[j]-1]+q; } if(w<d[b[j]-1]){ d[b[j]-1]=w; q1.push (b[j]) } } } g=q1.front(); q1.pop(); } cout<<d[n-1]<<endl; }
a.cc:1:9: fatal error: iosteram: No such file or directory 1 | #include<iosteram> | ^~~~~~~~~~ compilation terminated.
s360788341
p00546
C++
#include<iosteram> #include<fstream> #include<queue> using namespace std; int c[200000]; int a[200000]; int b[200000]; int e[200000]; unsigned long long int d[200000]; unsigned long long int w=0; int main(){ queue<int> q1; int n=0; int m=0; int k=0; int s=0; int p=0; int q=0; int i=0; int j=0; int g=0; for(i=0;i<200000;i++){ a[i]=0; b[i]=0; c[i]=0; d[i]=0; } cin>>n; cin>>m; cin>>k; cin>>s; cin>>p; cin>>q; for(i=0;i<k;i++){ cin>>c[i]; } for(i=0;i<m;i++){ cin>>a[i]; cin>>b[i]; } for(i=0;i<s;i++){ for(j=0;j<k;j++){ for(g=0;g<n;g++){ if(a[g]==c[j] && e[b[g]-1]==0){ e[b[g]-1]=1; q1.push (b[g]); } if(b[g]==c[j] && e[a[g]-1]==0){ e[a[g]-1]=1; q1.push (a[g]); } } } k=q1.size(); for(j=0;j<k;j++){ c[j]=q1.front(); q1.pop(); } } g=1; for(i=0;i<n;i++){ for(j=0;j<n;j++){ if(a[j]==g && d[b[j]-1]==0){ if(e[b[j]-1]==0){ d[b[j]-1]=d[a[j]-1]+p; }else{ d[b[j]-1]=d[a[j]-1]+q; } q1.push (b[j]) }else if(a[j]==g){ if(e[b[j]-1]==0){ w=d[a[j]-1]+p; }else{ w=d[a[j]-1]+q; } if(w<d[b[j]-1]){ d[b[j]-1]=w; q1.push (b[j]) } } if(b[j]==g && d[a[j]-1]==0){ if(e[a[j]-1]==0){ d[a[j]-1]=d[b[j]-1]+p; }else{ d[a[j]-1]=d[b[j]-1]+q; } q1.push (a[j]) }else if(a[j]==g){ if(e[b[j]-1]==0){ w=d[a[j]-1]+p; }else{ w=d[a[j]-1]+q; } if(w<d[b[j]-1]){ d[b[j]-1]=w; q1.push (b[j]) } } } g=q1.front(); q1.pop(); } cout<<d[n-1]<<endl; }
a.cc:1:9: fatal error: iosteram: No such file or directory 1 | #include<iosteram> | ^~~~~~~~~~ compilation terminated.
s345824751
p00546
C++
#include<iostream> #include<fstream> #include<queue> using namespace std; int c[200000]; int a[200000]; int b[200000]; int e[200000]; unsigned long long int d[200000]; unsigned long long int w=0; int main(){ queue<int> q1; int n=0; int m=0; int k=0; int s=0; int p=0; int q=0; int i=0; int j=0; int g=0; for(i=0;i<200000;i++){ a[i]=0; b[i]=0; c[i]=0; d[i]=0; } cin>>n; cin>>m; cin>>k; cin>>s; cin>>p; cin>>q; for(i=0;i<k;i++){ cin>>c[i]; } for(i=0;i<m;i++){ cin>>a[i]; cin>>b[i]; } for(i=0;i<s;i++){ for(j=0;j<k;j++){ for(g=0;g<n;g++){ if(a[g]==c[j] && e[b[g]-1]==0){ e[b[g]-1]=1; q1.push (b[g]); } if(b[g]==c[j] && e[a[g]-1]==0){ e[a[g]-1]=1; q1.push (a[g]); } } } k=q1.size(); for(j=0;j<k;j++){ c[j]=q1.front(); q1.pop(); } } g=1; for(i=0;i<n;i++){ for(j=0;j<n;j++){ if(a[j]==g && d[b[j]-1]==0){ if(e[b[j]-1]==0){ d[b[j]-1]=d[a[j]-1]+p; }else{ d[b[j]-1]=d[a[j]-1]+q; } q1.push (b[j]) }else if(a[j]==g){ if(e[b[j]-1]==0){ w=d[a[j]-1]+p; }else{ w=d[a[j]-1]+q; } if(w<d[b[j]-1]){ d[b[j]-1]=w; q1.push (b[j]) } } if(b[j]==g && d[a[j]-1]==0){ if(e[a[j]-1]==0){ d[a[j]-1]=d[b[j]-1]+p; }else{ d[a[j]-1]=d[b[j]-1]+q; } q1.push (a[j]) }else if(a[j]==g){ if(e[b[j]-1]==0){ w=d[a[j]-1]+p; }else{ w=d[a[j]-1]+q; } if(w<d[b[j]-1]){ d[b[j]-1]=w; q1.push (b[j]) } } } g=q1.front(); q1.pop(); } cout<<d[n-1]<<endl; }
a.cc: In function 'int main()': a.cc:70:47: error: expected ';' before '}' token 70 | q1.push (b[j]) | ^ | ; 71 | }else if(a[j]==g){ | ~ a.cc:79:55: error: expected ';' before '}' token 79 | q1.push (b[j]) | ^ | ; 80 | } | ~ a.cc:88:47: error: expected ';' before '}' token 88 | q1.push (a[j]) | ^ | ; 89 | }else if(a[j]==g){ | ~ a.cc:97:55: error: expected ';' before '}' token 97 | q1.push (b[j]) | ^ | ; 98 | } | ~
s882118734
p00546
C++
#include "iostream" #include "climits" #include "list" #include "queue" using namespace std; int N, M, K, S; int status[131073]; int price[2]; int dead; long long int now; int box, bag; list<int> to[100001]; long long int dis[131073]; bool flag[131073]; queue<int>Q; priority_queue<int> town; long long int RMQ(int left, int right) { if (left == right) { if (flag[left])return dis[left]; else return INT64_MAX; } return min(RMQ(left, (left + right) / 2), RMQ((left + right) / 2 + 1, right)); } int main() { cin >> N >> M >> K >> S; cin >> price[0] >> price[1]; for (int i = 1; i <= N; i++) { flag[i] = true; } for (int i = 0; i < K; i++) { cin >> box; status[box] = -1; flag[box] = false; } for (int i = 0; i < M; i++) { cin >> box >> bag; to[box].push_back(bag); to[bag].push_back(box); } for (int i = 2; i < N; i++) { if (status[i] == 0) { Q.push(i); for (int j = 1; j <= N; j++) { dis[j] = INT_MAX; } dis[i] = 0; while (!Q.empty()) { for (auto j = to[Q.front()].begin(); j != to[Q.front()].end(); ++j) { if (dis[Q.front()] + 1 < dis[(*j)]) { dis[(*j)] = dis[Q.front()] + 1; if (dis[(*j)] > S) { while (!Q.empty()) { Q.pop(); } break; } if (status[(*j)] == -1) { status[i] = 1; while (!Q.empty()) { Q.pop(); } break; } Q.push((*j)); } } if (Q.empty())break; Q.pop(); } } } dis[1] = 1; for (int i = 2; i <= N; i++) { dis[i] = INT64_MAX; } while (1) { now = RMQ(1, N) % 200000; flag[now] = false; if (now == N) break; for (auto i = to[now].begin(); i != to[now].end(); ++i) { if (flag[(*i)]) { if (dis[now] / 200000 + price[status[(*i)]] < dis[(*i)] / 200000) { dis[(*i)] = (dis[now] / 200000 + price[status[(*i)]]) * 200000 + (*i); } } } } cout << dis[N] / 200000-price[status[N]] << "\n"; return 0; }
a.cc: In function 'long long int RMQ(int, int)': a.cc:22:29: error: 'INT64_MAX' was not declared in this scope 22 | else return INT64_MAX; | ^~~~~~~~~ a.cc:5:1: note: 'INT64_MAX' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' 4 | #include "queue" +++ |+#include <cstdint> 5 | using namespace std; a.cc: In function 'int main()': a.cc:77:26: error: 'INT64_MAX' was not declared in this scope 77 | dis[i] = INT64_MAX; | ^~~~~~~~~ a.cc:77:26: note: 'INT64_MAX' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
s013939114
p00546
C++
#include <iostream> #include <cstdio> #include <vector> #include <queue> #include <algorithm> #include <string.h> #define F first #define S second #define MP make_pair #define int long long #define INF long(1e18) using namespace std; typedef pair<int, int> P; typedef pair<P, int> PP; int n, m, k, s, pp, q, ans[100001]; int dead[100001]; vector<int> road[100001], root; void bfs(int sta) { queue<P> que; que.push(MP(sta, 0)); dead[sta] = -1; while(!que.empty()) { P p = que.front(); que.pop(); if(p.S == s) continue; for(int i = 0; i < road[p.F].size(); i++) { if(!dead[p.F][i] || dead[road[p.F][i]] > p.S + 1) { que.push(MP(road[p.F][i], p.S + 1)); dead[road[p.F][i]] = p.S + 1; } } } } void dijkstra(){ priority_queue<P> pq; pq.push(MP(0, 1)); ans[1] = 0; while(!pq.empty()) { P p = pq.top(); pq.pop(); for(int i = 0; i < road[p.S].size(); i++) { if(dead[road[p.S][i]] == -1) continue; if(!dead[road[p.S][i]] && ans[road[p.S][i]] < p.F - pp) { pq.push(MP(p.F - pp, road[p.S][i])); ans[road[p.S][i]] = p.F - pp; } else if(ans[road[p.S][i]] < p.F - q){ pq.push(MP(p.F - q, road[p.S][i])); ans[road[p.S][i]] = p.F - q; } } } } signed main() { cin >> n >> m >> k >> s >> pp >> q; for(int i = 0; i < k; i++) { int a; cin >> a; root.push_back(a); } for(int i = 0; i < m; i++) { int a, b; cin >> a >> b; road[a].push_back(b); road[b].push_back(a); } for(int i = 0; i < k; i++) { bfs(root[i]); } fill(ans, ans + n + 1, -INF); dijkstra(); if(!dead[n]) cout << -ans[n] - pp << endl; else cout << -ans[n] - q <<endl; }
a.cc: In function 'void bfs(long long int)': a.cc:32:20: error: invalid types 'long long int[long long int]' for array subscript 32 | if(!dead[p.F][i] || dead[road[p.F][i]] > p.S + 1) | ^
s029457554
p00546
C++
#include <iostream> #include <cstdio> #include <vector> #include <queue> #include <algorithm> #include <string.h> #define F first #define S second #define MP make_pair #define int long long #define INF long(1e18) using namespace std; typedef pair<int, int> P; typedef pair<P, int> PP; ?? ?? int n, m, k, s, pp, q, ans[100001]; int dead[100001]; vector<int> road[100001], root; inline int in(){ int temp; scanf("%ld", &temp); return temp; } void bfs(int sta) { ????queue<P> que; ????que.push(MP(sta, 0)); ????dead[sta] = -1; ????while(!que.empty()) ????{ ????????P p = que.front(); ????????que.pop(); ????????if(p.S == s) continue; ????????for(int i = 0; i < road[p.F].size(); i++) ????????{ ????????????if(!dead[road[p.F][i]] || dead[road[p.F][i]] > p.S + 1) ????????????{ ????????????????que.push(MP(road[p.F][i], p.S + 1)); ????????????????dead[road[p.F][i]] = p.S + 1; ????????????} ????????} ????} } void dijkstra(){ ????priority_queue<P> pq; ????pq.push(MP(0, 1)); ????ans[1] = 0; ????while(!pq.empty()) ????{ ????????P p = pq.top(); ????????pq.pop(); ????????for(int i = 0; i < road[p.S].size(); i++) ????????{ ????????????if(dead[road[p.S][i]] == -1) continue; ????????????if(!dead[road[p.S][i]] && ans[road[p.S][i]] < p.F - pp) ????????????{ ????????????????pq.push(MP(p.F - pp, road[p.S][i])); ????????????????ans[road[p.S][i]] = p.F - pp; ????????????} ????????????else if(ans[road[p.S][i]] < p.F - q){ ????????????????pq.push(MP(p.F - q, road[p.S][i])); ????????????????ans[road[p.S][i]] = p.F - q; ????????????} ????????} ????} } signed main() { ????cin >> n >> m >> k >> s >> pp >> q; ????for(int i = 0; i < k; i++) ????{ ????????root.push_back(in()); ????} ????for(int i = 0; i < m; i++) ????{ ????????int a = in(), b = in(); ????????road[a].push_back(b); ????????road[b].push_back(a); ????} ????for(int i = 0; i < k; i++) ????{ ????????bfs(root[i]); ????} ????fill(ans, ans + n + 1, -INF); ????dijkstra(); ????if(!dead[n]) ????????cout << -ans[n] - pp << endl; ????else ????????cout << -ans[n] - q <<endl; }
a.cc:15:1: error: expected unqualified-id before '?' token 15 | ?? | ^ a.cc: In function 'void bfs(long long int)': a.cc:27:1: error: expected primary-expression before '?' token 27 | ????queue<P> que; | ^ a.cc:27:2: error: expected primary-expression before '?' token 27 | ????queue<P> que; | ^ a.cc:27:3: error: expected primary-expression before '?' token 27 | ????queue<P> que; | ^ a.cc:27:4: error: expected primary-expression before '?' token 27 | ????queue<P> que; | ^ a.cc:27:14: error: expected primary-expression before 'que' 27 | ????queue<P> que; | ^~~ a.cc:27:13: error: expected ':' before 'que' 27 | ????queue<P> que; | ^~~~ | : a.cc:27:14: error: 'que' was not declared in this scope 27 | ????queue<P> que; | ^~~ a.cc:27:17: error: expected ':' before ';' token 27 | ????queue<P> que; | ^ | : a.cc:27:17: error: expected primary-expression before ';' token a.cc:27:17: error: expected ':' before ';' token 27 | ????queue<P> que; | ^ | : a.cc:27:17: error: expected primary-expression before ';' token a.cc:27:17: error: expected ':' before ';' token 27 | ????queue<P> que; | ^ | : a.cc:27:17: error: expected primary-expression before ';' token a.cc:28:1: error: expected primary-expression before '?' token 28 | ????que.push(MP(sta, 0)); | ^ a.cc:28:2: error: expected primary-expression before '?' token 28 | ????que.push(MP(sta, 0)); | ^ a.cc:28:3: error: expected primary-expression before '?' token 28 | ????que.push(MP(sta, 0)); | ^ a.cc:28:4: error: expected primary-expression before '?' token 28 | ????que.push(MP(sta, 0)); | ^ a.cc:28:25: error: expected ':' before ';' token 28 | ????que.push(MP(sta, 0)); | ^ | : a.cc:28:25: error: expected primary-expression before ';' token a.cc:28:25: error: expected ':' before ';' token 28 | ????que.push(MP(sta, 0)); | ^ | : a.cc:28:25: error: expected primary-expression before ';' token a.cc:28:25: error: expected ':' before ';' token 28 | ????que.push(MP(sta, 0)); | ^ | : a.cc:28:25: error: expected primary-expression before ';' token a.cc:28:25: error: expected ':' before ';' token 28 | ????que.push(MP(sta, 0)); | ^ | : a.cc:28:25: error: expected primary-expression before ';' token a.cc:29:1: error: expected primary-expression before '?' token 29 | ????dead[sta] = -1; | ^ a.cc:29:2: error: expected primary-expression before '?' token 29 | ????dead[sta] = -1; | ^ a.cc:29:3: error: expected primary-expression before '?' token 29 | ????dead[sta] = -1; | ^ a.cc:29:4: error: expected primary-expression before '?' token 29 | ????dead[sta] = -1; | ^ a.cc:29:19: error: expected ':' before ';' token 29 | ????dead[sta] = -1; | ^ | : a.cc:29:19: error: expected primary-expression before ';' token a.cc:29:19: error: expected ':' before ';' token 29 | ????dead[sta] = -1; | ^ | : a.cc:29:19: error: expected primary-expression before ';' token a.cc:29:19: error: expected ':' before ';' token 29 | ????dead[sta] = -1; | ^ | : a.cc:29:19: error: expected primary-expression before ';' token a.cc:29:19: error: expected ':' before ';' token 29 | ????dead[sta] = -1; | ^ | : a.cc:29:19: error: expected primary-expression before ';' token a.cc:30:1: error: expected primary-expression before '?' token 30 | ????while(!que.empty()) | ^ a.cc:30:2: error: expected primary-expression before '?' token 30 | ????while(!que.empty()) | ^ a.cc:30:3: error: expected primary-expression before '?' token 30 | ????while(!que.empty()) | ^ a.cc:30:4: error: expected primary-expression before '?' token 30 | ????while(!que.empty()) | ^ a.cc:30:5: error: expected primary-expression before 'while' 30 | ????while(!que.empty()) | ^~~~~ a.cc:30:5: error: expected ':' before 'while' 30 | ????while(!que.empty()) | ^~~~~ | : a.cc:30:5: error: expected primary-expression before 'while' 30 | ????while(!que.empty()) | ^~~~~ a.cc:30:5: error: expected ':' before 'while' 30 | ????while(!que.empty()) | ^~~~~ | : a.cc:30:5: error: expected primary-expression before 'while' 30 | ????while(!que.empty()) | ^~~~~ a.cc:30:5: error: expected ':' before 'while' 30 | ????while(!que.empty()) | ^~~~~ | : a.cc:30:5: error: expected primary-expression before 'while' 30 | ????while(!que.empty()) | ^~~~~ a.cc:30:5: error: expected ':' before 'while' 30 | ????while(!que.empty()) | ^~~~~ | : a.cc:30:5: error: expected primary-expression before 'while' 30 | ????while(!que.empty()) | ^~~~~ a.cc: In function 'void dijkstra()': a.cc:46:1: error: expected primary-expression before '?' token 46 | ????priority_queue<P> pq; | ^ a.cc:46:2: error: expected primary-expression before '?' token 46 | ????priority_queue<P> pq; | ^ a.cc:46:3: error: expected primary-expression before '?' token 46 | ????priority_queue<P> pq; | ^ a.cc:46:4: error: expected primary-expression before '?' token 46 | ????priority_queue<P> pq; | ^ a.cc:46:23: error: expected primary-expression before 'pq' 46 | ????priority_queue<P> pq; | ^~ a.cc:46:22: error: expected ':' before 'pq' 46 | ????priority_queue<P> pq; | ^~~ | : a.cc:46:23: error: 'pq' was not declared in this scope 46 | ????priority_queue<P> pq; | ^~ a.cc:46:25: error: expected ':' before ';' token 46 | ????priority_queue<P> pq; | ^ | : a.cc:46:25: error: expected primary-expression before ';' token a.cc:46:25: error: expected ':' before ';' token 46 | ????priority_queue<P> pq; | ^ | : a.cc:46:25: error: expected primary-expression before ';' token a.cc:46:25: error: expected ':' before ';' token 46 | ????priority_queue<P> pq; | ^ | : a.cc:46:25: error: expected primary-expression before ';' token a.cc:47:1: error: expected primary-expression before '?' token 47 | ????pq.push(MP(0, 1)); | ^ a.cc:47:2: error: expected primary-expression before '?' token 47 | ????pq.push(MP(0, 1)); | ^ a.cc:47:3: error: expected primary-expression before '?' token 47 | ????pq.push(MP(0, 1)); | ^ a.cc:47:4: error: expected primary-expression before '?' token 47 | ????pq.push(MP(0, 1)); | ^ a.cc:47:22: error: expected ':' before ';' token 47 | ????pq.push(MP(0, 1)); | ^ | : a.cc:47:22: error: expected primary-expression before ';' token a.cc:47:22: error: expected ':' before ';' token 47 | ????pq.push(MP(0, 1)); | ^ | : a.cc:47:22: error: expected primary-expression before ';' token a.cc:47:22: error: expected ':' before ';' token 47 | ????pq.push(MP(0, 1)); | ^ | : a.cc:47:22: error: expected primary-expression before ';' token a.cc:47:22: error: expected ':' before ';' token 47 | ????pq.push(MP(0, 1)); | ^ | : a.cc:47:22: error: expected primary-expression before ';' token a.cc:48:1: error: expected primary-expression before '?' token 48 | ????ans[1] = 0; | ^ a.cc:48:2: error: expected primary-expression before '?' token 48 | ????ans[1] = 0; | ^ a.cc:48:3: error: expected primary-expression before '?' token 48 | ????ans[1] = 0; | ^ a.cc:48:4: error: expected primary-expression before '?' token 48 | ????ans[1] = 0; | ^ a.cc:48:5: error: 'ans' was not declared in this scope; did you mean 'abs'? 48 | ????ans[1] = 0; | ^~~ | abs a.cc:48:15: error: expected ':' before ';' token 48 | ????ans[1] = 0; | ^ | : a.cc:48:15: error: expected primary-expression before ';' token a.cc:48:15: error: expected ':' before ';' token 48 | ????ans[1] = 0; | ^ | : a.cc:48:15: error: expected primary-expression before ';' token a.cc:48:15: error: expected ':' before ';' token 48 | ????ans[1] = 0; | ^ | : a.cc:48:15: error: expected primary-expression before ';' token a.cc:48:15: error: expected ':' before ';' token 48 | ????ans[1] = 0; | ^ | : a.cc:48:15: error: expected primary-expression before ';' token a.cc:49:1: error: expected primary-expression before '?' token 49 | ????while(!pq.empty()) | ^ a.cc:49:2: error: expected primary-expression before '?' token 49 | ????while(!pq.empty()) | ^ a.cc:49:3: error: expected primary-expression before '?' token 49 | ????while(!pq.empty()) | ^ a.cc:49:4: error: expected primary-expression before '?' token 49 | ????while(!pq.empty()) | ^ a.cc:49:5: error: expected primary-expression before 'while' 49 | ????while(!pq.empty()) | ^~~~~ a.cc:49:5: error: expected ':' before 'while' 49 | ????while(!pq.empty()) | ^~~~~ | : a.cc:49:5: error: expected primary-expression before 'while' 49 | ????while(!pq.empty()) | ^~~~~ a.cc:49:5: error: expected ':' before 'while' 49 | ????while(!pq.empty()) | ^~~~~ | : a.cc:49:5: err
s578443667
p00546
C++
#include <cstdio> #include <queue> #include <vector> #define MAX_N 100001 #define P pair<int, int> #define PB push_back using namespace std; const long long int INF = 1000000000000000000; int n, m, k, s, p, q, c[MAX_N], r[2]; long long int cost[MAX_N]; bool dead[MAX_N], danger[MAX_N]; vector<int> road[MAX_N]; queue<P> que; priority_queue<P, vector<P>, greater<P> > p_que; int price(int x){ return danger[x] ? q : p; } void bfs(int start){ que.push(P(start, s)); dead[start] = 1; while(!que.empty()){ P q = que.front(); que.pop(); if(q.second >= 1){ for(int i = 0; i < road[q.first].size(); i++) if(!danger[q.first]){ danger[q.first] = 1; que.push(P(road[q.first][i], q.second - 1)); } } } void dijkstra(){ fill(cost, cost + n + 1, INF); cost[1] = 0; p_que.push(P(1, cost[1])); while(!p_que.empty()){ P pq = p_que.top(); p_que.pop(); int v = pq.first; if(cost[v] >= pq.second && !dead[v]){ for(int i = 0; i < road[v].size(); i++){ if(road[v][i] < n){ if(cost[road[v][i]] > cost[v] + price(road[v][i])){ cost[road[v][i]] = cost[v] + price(road[v][i]); p_que.push(P(road[v][i], cost[road[v][i]])); } } else cost[road[v][i]] = min(cost[road[v][i]], cost[v]); } } } } int main(){ scanf("%d%d%d%d", &n, &m, &k, &s); scanf("%d%d", &p, &q); for(int i = 1; i <= k; i++){ scanf("%d", &c[i]); } for(int i = 1; i <= m; i++){ scanf("%d%d", &r[0], &r[1]); road[r[0]].PB(r[1]); road[r[1]].PB(r[0]); } for(int i = 1; i <= k; i++) bfs(c[i]); dijkstra(); printf("%lld\n", cost[n]); return 0; }
a.cc: In function 'void bfs(int)': a.cc:36:16: error: a function-definition is not allowed here before '{' token 36 | void dijkstra(){ | ^ a.cc:58:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 58 | int main(){ | ^~ a.cc:58:9: note: remove parentheses to default-initialize a variable 58 | int main(){ | ^~ | -- a.cc:58:9: note: or replace parentheses with braces to value-initialize a variable a.cc:58:11: error: a function-definition is not allowed here before '{' token 58 | int main(){ | ^ a.cc:78:2: error: expected '}' at end of input 78 | } | ^ a.cc:21:20: note: to match this '{' 21 | void bfs(int start){ | ^
s609726132
p00546
C++
#include <cstdio> #include <queue> #include <vector> #define MAX_N 100001 #define P pair<int, int> #define PB push_back using namespace std; const long long int INF = 1000000000000000000; int n, m, k, s, p, q, c[MAX_N], r[2]; long long int cost[MAX_N]; int danger[MAX_N]; vector<int> road[MAX_N]; queue<P> que; priority_queue<P, vector<P>, greater<P> > p_que; int price(int x){ return danger[x] ? q : p; } void bfs(int start){ que.push(P(start, s)); danger[start] = -1; while(!que.empty()){ P q = que.front(); que.pop(); if(q.second >= 1){ for(int i = 0; i < road[q.first].size(); i++) if(!danger[q.first] || danger[q.first] < q.second - 1) danger[q.first] = q.second - 1; que.push(P(road[q.first][i], q.second - 1)); } } } void dijkstra(){ fill(cost, cost + n + 1, INF); cost[1] = 0; p_que.push(P(1, cost[1])); while(!p_que.empty()){ P pq = p_que.top(); p_que.pop(); int v = pq.first; if(cost[v] >= pq.second && danger[v] != -1){ for(int i = 0; i < road[v].size(); i++){ if(road[v][i] < n){ if(cost[road[v][i]] > cost[v] + price(road[v][i])){ cost[road[v][i]] = cost[v] + price(road[v][i]); p_que.push(P(road[v][i], cost[road[v][i]])); } } else cost[road[v][i]] = min(cost[road[v][i]], cost[v]); } } } } int main(){ scanf("%d%d%d%d", &n, &m, &k, &s); scanf("%d%d", &p, &q); for(int i = 1; i <= k; i++){ scanf("%d", &c[i]); } for(int i = 1; i <= m; i++){ scanf("%d%d", &r[0], &r[1]); road[r[0]].PB(r[1]); road[r[1]].PB(r[0]); } for(int i = 1; i <= k; i++) bfs(c[i]); dijkstra(); printf("%lld\n", cost[n]); return 0; }
a.cc: In function 'void bfs(int)': a.cc:31:66: error: 'i' was not declared in this scope 31 | que.push(P(road[q.first][i], q.second - 1)); | ^
s629865185
p00546
C++
#include <cstdio> #include <queue> #include <vector> #define MAX_N 100001 #define P pair<int, int> #define PB push_back using namespace std; const long long int INF = 1000000000000000000; int n, m, k, s, p, q, c[MAX_N], r[2]; long long int cost[MAX_N]; int danger[MAX_N]; vector<int> road[MAX_N]; queue<P> que; priority_queue<P, vector<P>, greater<P> > p_que; int price(int x){ return danger[x] ? q : p; } void bfs(int start){ que.push(P(start, s)); danger[start] = -1; while(!que.empty()){ P q = que.front(); que.pop(); if(q.second >= 1){ for(int i = 0; i < road[q.first].size(); i++){ if(!danger[road[q.first][i]] || danger[road[q.first][i]] < q.second - 1){ danger[road[q.first[i]]] = q.second - 1; que.push(P(road[q.first][i], q.second - 1)); } } } } } void dijkstra(){ fill(cost, cost + n + 1, INF); cost[1] = 0; p_que.push(P(1, cost[1])); while(!p_que.empty()){ P pq = p_que.top(); p_que.pop(); int v = pq.first; if(cost[v] >= pq.second && danger[v] != -1){ for(int i = 0; i < road[v].size(); i++){ if(road[v][i] < n){ if(cost[road[v][i]] > cost[v] + price(road[v][i])){ cost[road[v][i]] = cost[v] + price(road[v][i]); p_que.push(P(road[v][i], cost[road[v][i]])); } } else cost[road[v][i]] = min(cost[road[v][i]], cost[v]); } } } } int main(){ scanf("%d%d%d%d", &n, &m, &k, &s); scanf("%d%d", &p, &q); for(int i = 1; i <= k; i++){ scanf("%d", &c[i]); } for(int i = 1; i <= m; i++){ scanf("%d%d", &r[0], &r[1]); road[r[0]].PB(r[1]); road[r[1]].PB(r[0]); } for(int i = 1; i <= k; i++) bfs(c[i]); dijkstra(); printf("%lld\n", cost[n]); return 0; }
a.cc: In function 'void bfs(int)': a.cc:30:60: error: invalid types 'int[int]' for array subscript 30 | danger[road[q.first[i]]] = q.second - 1; | ^
s776123775
p00546
C++
#include <iostream> #include <iomanip> #include <cstdio> #include <string> #include <cstring> #include <deque> #include <list> #include <queue> #include <stack> #include <vector> #include <utility> #include <algorithm> #include <map> #include <set> #include <complex> #include <cmath> #include <limits> #include <cfloat> #include <climits> #include <ctime> #include <cassert> #include <numeric> #include <functional> using namespace std; #define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++) #define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++) #define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--) #define int long long int template<typename T> void chmax(T &a, T b) { a = max(a, b); } template<typename T> void chmin(T &a, T b) { a = min(a, b); } template<typename T> void chadd(T &a, T b) { a = a + b; } typedef pair<int, int> pii; typedef long long ll; int dx[] = { 0, 0, 1, -1 }; int dy[] = { 1, -1, 0, 0 }; constexpr ll INF = 1001001001001001LL; constexpr ll MOD = 1000000007LL; int N, M, K, S, P, Q, dist[100010], rec[100010]; bool used[100010]; // (from, to) and (to, cost) vector<pii> es, H[100010]; vector<int> G[100010]; signed main() { cin >> N >> M >> K >> S >> P >> Q; rep(i, 0, N) dist[i] = rec[i] = INF; // cost, current priority_queue< pii, vector<pii>, greater<pii> > q; rep(i, 0, K) {//??????????????¶??? int p; cin >> p; p--; dist[p] = 0; used[p] = true;//p??????????????§????\???????????????? q.push(pii(0, p)); } rep(i, 0, M) {//?????????????????? int u, v; cin >> u >> v; u--; v--; G[u].push_back(v);//G???vector,?????? G[v].push_back(u); es.push_back(pii(v, u));//priority_queue???????????? es.push_back(pii(u, v)); } while (!q.empty()) { pii t = q.top(); q.pop();//??????????????¶??? int cost = t.first, cur = t.second;//cost??????????????????cur??????????????????????\?????????????????????? for (auto to : G[cur]) { if (dist[to] > dist[cur] + 1) {//??±???????????????????????¢?????¬??? dist[to] = dist[cur] + 1;//?¬????????????????????????±????????? q.push(pii(dist[to], to));//?????¢????¬????????????????push } } } rep(i, 0, 2 * M) { int u = es[i].first, v = es[i].second;//??? int du = dist[u], dv = dist[v];//??????????????????????????¢?????£??\ if (v == N - 1) H[u].push_back(pii(v, 0));//????????´??????????????????????????? else { if (dv <= S) H[u].push_back(pii(v, Q));//??????????????????????????°????????????????????? else H[u].push_back(pii(v, P)); } } rec[0] = 0;//???????????°??????cost?????? q.push(pii(0, 0));//?????\????????°??????????????????????????£?????? while (!q.empty()) { pii t = q.top(); q.pop();//pair?????£??\ int cost = t.first, cur = t.second;//??????????????°??? for (auto e : H[cur]) {//e????????????????????????????????¨?????°???????????????????????´?????? if (used[e.first]) continue;//???????????§????¨???£?????????????????°???????????§??????????????§??¢?????? //?????????????????????????????????????????§????????£??????????????????????????????????????? rec[e.first] = rec[cur] + e.second;//???????????£??\????????????????????£????????? q.push(pii(rec[e.first], e.first));//?¬????????????´?????????????????´???????????\????????????????????????????£????????????§????£?????????????????????? } } cout << rec[N - 1] << endl;//???????????\????????????????????¬?????? return 0; }
a.cc: In function 'int main()': a.cc:81:17: error: 'else' without a previous 'if' 81 | else { | ^~~~ a.cc:92:33: error: 'cur' was not declared in this scope 92 | for (auto e : H[cur]) {//e????????????????????????????????¨?????°???????????????????????´?????? | ^~~
s546073309
p00546
C++
#include <iostream> #include <iomanip> #include <cstdio> #include <string> #include <cstring> #include <deque> #include <list> #include <queue> #include <stack> #include <vector> #include <utility> #include <algorithm> #include <map> #include <set> #include <complex> #include <cmath> #include <limits> #include <cfloat> #include <climits> #include <ctime> #include <cassert> #include <numeric> #include <functional> using namespace std; #define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++) #define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++) #define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--) #define int long long int template<typename T> void chmax(T &a, T b) { a = max(a, b); } template<typename T> void chmin(T &a, T b) { a = min(a, b); } template<typename T> void chadd(T &a, T b) { a = a + b; } typedef pair<int, int> pii; typedef long long ll; int dx[] = { 0, 0, 1, -1 }; int dy[] = { 1, -1, 0, 0 }; constexpr ll INF = 1001001001001001LL; constexpr ll MOD = 1000000007LL; int N, M, K, S, P, Q, dist[100010], rec[100010]; bool used[100010]; // (from, to) and (to, cost) vector<pii> es, H[100010]; vector<int> G[100010]; signed main() { cin >> N >> M >> K >> S >> P >> Q; rep(i, 0, N) dist[i] = rec[i] = INF; // cost, current priority_queue< pii, vector<pii>, greater<pii> > q; rep(i, 0, K) {//??????????????¶??? int p; cin >> p; p--; dist[p] = 0; used[p] = true;//p??????????????§????\???????????????? q.push(pii(0, p)); } rep(i, 0, M) {//?????????????????? int u, v; cin >> u >> v; u--; v--; G[u].push_back(v);//G???vector,?????? G[v].push_back(u); es.push_back(pii(v, u));//priority_queue???????????? es.push_back(pii(u, v)); } while (!q.empty()) { pii t = q.top(); q.pop();//??????????????¶??? int cost = t.first, cur = t.second;//cost??????????????????cur??????????????????????\?????????????????????? for (auto to : G[cur]) { if (dist[to] > dist[cur] + 1) {//??±???????????????????????¢?????¬??? dist[to] = dist[cur] + 1;//?¬????????????????????????±????????? q.push(pii(dist[to], to));//?????¢????¬????????????????push } } } rep(i, 0, 2 * M) { int u = es[i].first, v = es[i].second;//??? int du = dist[u], dv = dist[v];//??????????????????????????¢?????£??\ if (v == N - 1) H[u].push_back(pii(v, 0));//????????´??????????????????????????? else { if (dv <= S) H[u].push_back(pii(v, Q));//??????????????????????????°????????????????????? else H[u].push_back(pii(v, P)); } } rec[0] = 0;//???????????°??????cost?????? q.push(pii(0, 0));//?????\????????°??????????????????????????£?????? while (!q.empty()) { pii t = q.top(); q.pop();//pair?????£??\ int cost = t.first, cur = t.second;//??????????????°??? for (auto e : H[cur]) {//e????????????????????????????????¨?????°???????????????????????´?????? if (used[e.first]) continue;//???????????§????¨???£?????????????????°???????????§??????????????§??¢?????? // if (rec[e.first] > rec[cur] + e.second) {//?????????????????????????????????????????§????????£?????? rec[e.first] = rec[cur] + e.second;//???????????£??\????????????????????£????????? q.push(pii(rec[e.first], e.first));//?¬????????????´?????????????????´???????????\????????????????????????????£????????????§????£?????????????????????? // } } } cout << rec[N - 1] << endl;//???????????\????????????????????¬?????? return 0; }
a.cc: In function 'int main()': a.cc:81:17: error: 'else' without a previous 'if' 81 | else { | ^~~~ a.cc:92:33: error: 'cur' was not declared in this scope 92 | for (auto e : H[cur]) {//e????????????????????????????????¨?????°???????????????????????´?????? | ^~~
s249399354
p00546
C++
#include <iostream> #include <iomanip> #include <cstdio> #include <string> #include <cstring> #include <deque> #include <list> #include <queue> #include <stack> #include <vector> #include <utility> #include <algorithm> #include <map> #include <set> #include <complex> #include <cmath> #include <limits> #include <cfloat> #include <climits> #include <ctime> #include <cassert> #include <numeric> #include <functional> using namespace std; #define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++) #define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++) #define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--) #define int long long int template<typename T> void chmax(T &a, T b) { a = max(a, b); } template<typename T> void chmin(T &a, T b) { a = min(a, b); } template<typename T> void chadd(T &a, T b) { a = a + b; } typedef pair<int, int> pii; typedef long long ll; int dx[] = { 0, 0, 1, -1 }; int dy[] = { 1, -1, 0, 0 }; constexpr ll INF = 1001001001001001LL; constexpr ll MOD = 1000000007LL; int N, M, K, S, P, Q, dist[100010], rec[100010]; bool used[100010]; // (from, to) and (to, cost) vector<pii> es, H[100010]; vector<int> G[100010]; signed main() { cin >> N >> M >> K >> S >> P >> Q; rep(i, 0, N) dist[i] = rec[i] = INF; // cost, current priority_queue< pii, vector<pii>, greater<pii> > q; rep(i, 0, K) {//??????????????¶??? int p; cin >> p; p--; dist[p] = 0; used[p] = true;//p??????????????§????\???????????????? q.push(pii(0, p)); } rep(i, 0, M) {//?????????????????? int u, v; cin >> u >> v; u--; v--; G[u].push_back(v);//G???vector,?????? G[v].push_back(u); es.push_back(pii(v, u));//priority_queue???????????? es.push_back(pii(u, v)); } while (!q.empty()) { pii t = q.top(); q.pop();//??????????????¶??? int cost = t.first, cur = t.second;//cost??????????????????cur??????????????????????\?????????????????????? for (auto to : G[cur]) { if (dist[to] > dist[cur] + 1) {//??±???????????????????????¢?????¬??? dist[to] = dist[cur] + 1;//?¬????????????????????????±????????? q.push(pii(dist[to], to));//?????¢????¬????????????????push } } } rep(i, 0, 2 * M) { int u = es[i].first, v = es[i].second;//??? int du = dist[u], dv = dist[v];//??????????????????????????¢?????£??\ if (v == N - 1) H[u].push_back(pii(v, 0));//????????´??????????????????????????? else { if (dv <= S) H[u].push_back(pii(v, Q));//??????????????????????????°????????????????????? else H[u].push_back(pii(v, P)); } } rec[0] = 0;//???????????°??????cost?????? q.push(pii(0, 0));//?????\????????°??????????????????????????£?????? while (!q.empty()) { pii t = q.top(); q.pop();//pair?????£??\ int cost = t.first, cur = t.second;//??????????????°??? used[cur] = true; for (auto e : H[cur]) {//e????????????????????????????????¨?????°???????????????????????´?????? if (used[e.first]) continue;//???????????§????¨???£?????????????????°???????????§??????????????§??¢?????? // if (rec[e.first] > rec[cur] + e.second) {//?????????????????????????????????????????§????????£?????? rec[e.first] = rec[cur] + e.second;//???????????£??\????????????????????£????????? q.push(pii(rec[e.first], e.first));//?¬????????????´?????????????????´???????????\????????????????????????????£????????????§????£?????????????????????? // } } } cout << rec[N - 1] << endl;//???????????\????????????????????¬?????? return 0; }
a.cc: In function 'int main()': a.cc:81:17: error: 'else' without a previous 'if' 81 | else { | ^~~~ a.cc:92:22: error: 'cur' was not declared in this scope 92 | used[cur] = true; | ^~~
s383866972
p00547
C++
#include "bits/stdc++.h" #include<unordered_map> #include<unordered_set> #pragma warning(disable:4996) using namespace std; using ld = long double; template<class T> using Table = vector<vector<T>>; const ld eps=1e-9; int dp[1010][1010][2][2][2][2]; const int dx[] = { 1,0,-1,0 }; const int dy[] = { 0,1,0,-1 }; //// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer" int main() { int H, W; cin >> H >> W; for (int i = 0; i < 1010; ++i)for (int j = 0; j < 1010; ++j)for (int k = 0; k < 2; ++k)for (int l = 0; l < 2; ++l)for (int m = 0; m < 2; ++m)for (int n = 0; n < 2; ++n) { dp[i][j][k][l][m][n] = 1e9; } dp[5][5][0][0][0][0] = 0; vector<vector<int>>field(H + 8, vector<int>(W + 8)); for (int i = 0; i < H; ++i) { string st; cin >> st; for (int j = 0; j < W; ++j) { if (st[j] != '.') { field[i + 5][j + 5] = st[j] - '0'; } } } for (int nowy = 5; nowy < H + 6; ++nowy) { for (int nowx = 5; nowx < W +6; ++nowx) { for (int eat_ld = 0; eat_ld < 2; ++eat_ld) { for (int eat_d = 0; eat_d < 2; ++eat_d) { for (int eat_r = 0; eat_r < 2; ++eat_r) { for (int eat_ru = 0; eat_ru < 2; ++eat_ru) { if (1e9 <= dp[nowy][nowx][eat_ld][eat_d][eat_r][eat_ru])continue; vector<vector<char>>baseeats(4, vector<char>(4)); baseeats[2][0] = eat_ld; baseeats[2][1] = eat_d; baseeats[1][2] = eat_r; baseeats[0][2] = eat_ru; baseeats[1][1] = true; for (int way = 0; way < 2; ++way) { const int nextx = nowx + dx[way]; const int nexty = nowy + dy[way]; const int ax = 1 + dx[way]; const int ay = 1 + dy[way]; bool flag = false; for (int w = 0; w < 4; ++w) { vector<vector<char>>eats(baseeats); int eat_sum = 0; if (!eats[ay][ax]) { eats[ay][ax] = true; eat_sum += field[nexty][nextx]; } for (int v = 0; v < 4; ++v) { if (v == w)continue; else { if (!eats[ay + dy[v]][ax + dx[v]]) { eats[ay + dy[v]][ax + dx[v]] = true; eat_sum += field[nexty + dy[v]][nextx + dx[v]]; } } } const int nexteat_ld = eats[2+dy[way]][0+dx[way]]; const int nexteat_d = eats[2 + dy[way]][1 + dx[way]]; const int nexteat_r = eats[1 + dy[way]][2 + dx[way]]; const int nexteat_ru = eats[0 + dy[way]][2 + dx[way]]; int n = dp[nowy][nowx][eat_ld][eat_d][eat_r][eat_ru] + eat_sum; dp[nexty][nextx][nexteat_ld][nexteat_d][nexteat_r][nexteat_ru] = min(dp[nexty][nextx][nexteat_ld][nexteat_d][nexteat_r][nexteat_ru], n); } } } } } } } } } int ans = 1e9; for (int l = 0; l < 2; ++l) { for (int m = 0; m < 2; ++m) { for (int n = 0; n < 2; ++n) { for (int o = 0; o < 2; ++o) { ans = min(ans, dp[H + 4][W + 4][l][m][n][o]); } } } } cout << ans << endl; return 0; }
a.cc:84:9: error: expected unqualified-id before 'for' 84 | for (int l = 0; l < 2; ++l) { | ^~~ a.cc:84:25: error: 'l' does not name a type; did you mean 'ld'? 84 | for (int l = 0; l < 2; ++l) { | ^ | ld a.cc:84:32: error: expected unqualified-id before '++' token 84 | for (int l = 0; l < 2; ++l) { | ^~ a.cc:93:9: error: 'cout' does not name a type 93 | cout << ans << endl; | ^~~~ a.cc:95:9: error: expected unqualified-id before 'return' 95 | return 0; | ^~~~~~ a.cc:96:1: error: expected declaration before '}' token 96 | } | ^
s561590263
p00547
C++
#include "bits/stdc++.h" #include<unordered_map> #include<unordered_set> #pragma warning(disable:4996) using namespace std; using ld = long double; template<class T> using Table = vector<vector<T>>; const ld eps=1e-9; int dp[1010][1010][16]; const int dx[] = { 1,0,-1,0 }; const int dy[] = { 0,1,0,-1 }; //// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer" int main() { int H, W; cin >> H >> W; for (int i = 0; i < 1010; ++i)for (int j = 0; j < 1010; ++j)for (int k = 0; k < 16; ++k){ dp[i][j][k] = 1e9; } dp[5][5][0] = 0; vector<vector<int>>field(H + 8, vector<int>(W + 8)); for (int i = 0; i < H; ++i) { string st; cin >> st; for (int j = 0; j < W; ++j) { if (st[j] != '.') { field[i + 5][j + 5] = st[j] - '0'; } } } for (int nowy = 5; nowy < H + 6; ++nowy) { for (int nowx = 5; nowx < W +6; ++nowx) { for (int n = 0; n < 16; ++n) { const int eat_ld = n & 1; const int eat_d = (n & 2) >> 1; const int eat_r = (n & 4) >> 2; const int eat_ru = (n & 8) >> 3; if (1e9 <= dp[nowy][nowx][n])continue; vector<vector<char>>baseeats(4, vector<char>(4)); baseeats[2][0] = eat_ld; baseeats[2][1] = eat_d; baseeats[1][2] = eat_r; baseeats[0][2] = eat_ru; baseeats[1][1] = true; for (int way = 0; way < 2; ++way) { const int nextx = nowx + dx[way]; const int nexty = nowy + dy[way]; const int ax = 1 + dx[way]; const int ay = 1 + dy[way]; bool flag = false; for (int w = 0; w < 4; ++w) { int nexteat_ld = eats[2 + dy[way]][0 + dx[way]]; int nexteat_d = eats[2 + dy[way]][1 + dx[way]]; int nexteat_r = eats[1 + dy[way]][2 + dx[way]]; int nexteat_ru = eats[0 + dy[way]][2 + dx[way]]; int eat_sum = 0; if (!eats[ay][ax]) { if (ay == 2 + dy[way] && ax == 0 + dx[way])nexteat_ld = true; if (ay == 2 + dy[way] && ax == 1 + dx[way])nexteat_d = true; if (ay == 1 + dy[way] && ax == 2 + dx[way])nexteat_r = true; if (ay == 0 + dy[way] && ax == 2 + dx[way])nexteat_ru = true; //eats[ay][ax] = true; eat_sum += field[nexty][nextx]; } for (int v = 0; v < 4; ++v) { if (v == w)continue; else { if (!eats[ay + dy[v]][ax + dx[v]]) { if (ay + dy[v]== 2 + dy[way] && ax + dx[v] == 0 + dx[way])nexteat_ld = true; if (ay + dy[v]== 2 + dy[way] && ax + dx[v] == 1 + dx[way])nexteat_d = true; if (ay + dy[v]== 1 + dy[way] && ax + dx[v] == 2 + dx[way])nexteat_r = true; if (ay + dy[v]== 0 + dy[way] && ax + dx[v] == 2 + dx[way])nexteat_ru = true; //eats[ay + dy[v]][ax + dx[v]] = true; eat_sum += field[nexty + dy[v]][nextx + dx[v]]; } } } int n = dp[nowy][nowx][eat_ld+2*eat_d+4*eat_r+8*eat_ru] + eat_sum; dp[nexty][nextx][nexteat_ld+2*nexteat_d+4*nexteat_r+8*nexteat_ru] = min(dp[nexty][nextx][nexteat_ld + 2 * nexteat_d + 4 * nexteat_r + 8 * nexteat_ru], n); } } } } } int ans = 1e9; for (int l = 0; l < 16; ++l) { ans = min(ans, dp[H + 4][W + 4][l]); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:54:66: error: 'eats' was not declared in this scope 54 | int nexteat_ld = eats[2 + dy[way]][0 + dx[way]]; | ^~~~
s084228623
p00547
C++
#include "bits/stdc++.h" #include<unordered_map> #include<unordered_set> #pragma warning(disable:4996) using namespace std; using ld = long double; template<class T> using Table = vector<vector<T>>; const ld eps=1e-9; int dp[1010][1010][16]; const int dx[] = { 1,0,-1,0 }; const int dy[] = { 0,1,0,-1 }; //// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer" int main() { int H, W; cin >> H >> W; for (int i = 0; i < 1010; ++i)for (int j = 0; j < 1010; ++j)for (int k = 0; k < 16; ++k){ dp[i][j][k] = 1e9; } dp[5][5][0] = 0; vector<vector<int>>field(H + 8, vector<int>(W + 8)); for (int i = 0; i < H; ++i) { string st; cin >> st; for (int j = 0; j < W; ++j) { if (st[j] != '.') { field[i + 5][j + 5] = st[j] - '0'; } } } for (int nowy = 5; nowy < H + 6; ++nowy) { for (int nowx = 5; nowx < W +6; ++nowx) { for (int n = 0; n < 16; ++n) { const int eat_ld = n & 1; const int eat_d = (n & 2) >> 1; const int eat_r = (n & 4) >> 2; const int eat_ru = (n & 8) >> 3; if (1e9 <= dp[nowy][nowx][n])continue; vector<vector<char>>baseeats(4, vector<char>(4)); baseeats[2][0] = eat_ld; baseeats[2][1] = eat_d; baseeats[1][2] = eat_r; baseeats[0][2] = eat_ru; baseeats[1][1] = true; for (int way = 0; way < 2; ++way) { const int nextx = nowx + dx[way]; const int nexty = nowy + dy[way]; const int ax = 1 + dx[way]; const int ay = 1 + dy[way]; bool flag = false; for (int w = 0; w < 4; ++w) { int nexteat_ld = baseeats[2 + dy[way]][0 + dx[way]]; int nexteat_d = baseeats[2 + dy[way]][1 + dx[way]]; int nexteat_r = baseeats[1 + dy[way]][2 + dx[way]]; int nexteat_ru = baseeats[0 + dy[way]][2 + dx[way]]; int eat_sum = 0; if (!eats[ay][ax]) { if (ay == 2 + dy[way] && ax == 0 + dx[way])nexteat_ld = true; if (ay == 2 + dy[way] && ax == 1 + dx[way])nexteat_d = true; if (ay == 1 + dy[way] && ax == 2 + dx[way])nexteat_r = true; if (ay == 0 + dy[way] && ax == 2 + dx[way])nexteat_ru = true; //eats[ay][ax] = true; eat_sum += field[nexty][nextx]; } for (int v = 0; v < 4; ++v) { if (v == w)continue; else { if (!eats[ay + dy[v]][ax + dx[v]]) { if (ay + dy[v]== 2 + dy[way] && ax + dx[v] == 0 + dx[way])nexteat_ld = true; if (ay + dy[v]== 2 + dy[way] && ax + dx[v] == 1 + dx[way])nexteat_d = true; if (ay + dy[v]== 1 + dy[way] && ax + dx[v] == 2 + dx[way])nexteat_r = true; if (ay + dy[v]== 0 + dy[way] && ax + dx[v] == 2 + dx[way])nexteat_ru = true; //eats[ay + dy[v]][ax + dx[v]] = true; eat_sum += field[nexty + dy[v]][nextx + dx[v]]; } } } int n = dp[nowy][nowx][eat_ld+2*eat_d+4*eat_r+8*eat_ru] + eat_sum; dp[nexty][nextx][nexteat_ld+2*nexteat_d+4*nexteat_r+8*nexteat_ru] = min(dp[nexty][nextx][nexteat_ld + 2 * nexteat_d + 4 * nexteat_r + 8 * nexteat_ru], n); } } } } } int ans = 1e9; for (int l = 0; l < 16; ++l) { ans = min(ans, dp[H + 4][W + 4][l]); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:59:54: error: 'eats' was not declared in this scope 59 | if (!eats[ay][ax]) { | ^~~~ a.cc:70:70: error: 'eats' was not declared in this scope 70 | if (!eats[ay + dy[v]][ax + dx[v]]) { | ^~~~
s517077372
p00547
C++
#include <iostream> #include <string> #include <utility> #include <algorithm> #include <vector> using Pair = std::pair<int, int>; int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0}; int h, w; unsigned int dp[1010][1010][32]; int map[1010][1010]; inline bool checkBought(int y, int x, int mask) { if(x == 1 && y == 0) { return mask & 1 << 0; }else if(y == 1 && x == 0) { return mask & 1 << 1; }else if(y == 1 && x == -1) { return mask & 1 << 2; }else if(y == -1 && x == 1) { return mask & 1 << 3; }else if(y == 0 && x == 0) { return mask & 1 << 4; } return 0; } std::vector<Pair> wrapMask(int y, int x, int mask) { std::vector<Pair> pts; pts.reserve(5); if(mask & 1 << 0) pts.emplace_back(Pair{y, x - 1}); if(mask & 1 << 1) pts.emplace_back(Pair{y - 1, x}); if(mask & 1 << 2) pts.emplace_back(Pair{y - 1, x + 1}); if(mask & 1 << 3) pts.emplace_back(Pair{y + 1, x - 1}); if(mask & 1 << 4) pts.emplace_back(Pair{y, x}); return pts; } int createMask(int y, int x, const std::vector<Pair>& pts) { int mask = 0; for(auto& p : pts) { if(p.first == y && p.second == x - 1) mask |= 1 << 0; else if(p.first == y - 1 && p.second == x) mask |= 1 << 1; else if(p.first == y - 1 && p.second == x + 1) mask |= 1 << 2; else if(p.first == y + 1 && p.second == x - 1) mask |= 1 << 3; else if(p.first == y && p.second == x) mask |= 1 << 4; } return mask; } int main() { std::cin >> h >> w; memset(dp, -1, sizeof(dp)); for(int i = 0; i < h; ++i) { std::string str; std::cin >> str; for(int j = 0; j < w; ++j) { if(str[j] == '.') map[i][j] = 0; else map[i][j] = str[j] - '0'; } } dp[0][0][0] = 0; unsigned int ans = 1e9; for(int i = 0; i < h; ++i) { for(int j = 0; j < w; ++j) { // 0th: ???, 1st: ??????, 2nd: ??????, 3rd: ??????, 4th: ?????? for(int k = 0; k < 32; ++k) { if(j == 0 && (k & 1 << 0)) continue; if(i == 0 && (k & 1 << 1)) continue; if((i == 0 || j == w - 1) && (k & 1 << 2)) continue; if((j == 0 || i == h - 1) && (k & 1 << 3)) continue; if(dp[i][j][k] == -1) continue; std::vector<Pair> pts; pts.reserve(4); for(int m = 0; m < 4; ++m) { int py = i + dy[m], px = j + dx[m]; if(py < 0 || py >= h || px < 0 || px >= w) continue; if(map[py][px] != 0 && !checkBought(i - py, j - px, k)) pts.emplace_back(Pair{py, px}); } auto prevMaskVec = wrapMask(i, j, k); for(int m = 0; m < pts.size(); ++m) { auto clone = prevMaskVec; clone.reserve(5 + pts.size() - 1); int cost = 0; for(int n = 0; n < pts.size(); ++n) { if(m != n) { clone.emplace_back(pts[n]); cost += map[pts[n].first][pts[n].second]; } } if(!checkBought(0, 0, k) && map[i][j] != 0) { cost += map[i][j]; clone.emplace_back(Pair{i, j}); } int mask = createMask(i + 1, j, clone); dp[i + 1][j][mask] = std::min(dp[i + 1][j][mask], dp[i][j][k] + cost); mask = createMask(i, j + 1, clone); dp[i][j + 1][mask] = std::min(dp[i][j + 1][mask], dp[i][j][k] + cost); if(i == h - 1 && j == w - 1) ans = std::min(ans, dp[i][j][k] + cost); } if(pts.empty()) { int cost = 0; if(!checkBought(0, 0, k) && map[i][j] != 0) { cost += map[i][j]; prevMaskVec.emplace_back(Pair{i, j}); } int mask = createMask(i + 1, j, prevMaskVec); dp[i + 1][j][mask] = std::min(dp[i + 1][j][mask], dp[i][j][k] + cost); mask = createMask(i, j + 1, prevMaskVec); dp[i][j + 1][mask] = std::min(dp[i][j + 1][mask], dp[i][j][k] + cost); if(i == h - 1 && j == w - 1) ans = std::min(ans, dp[i][j][k] + cost); } } } } std::cout << ans << std::endl; }
a.cc: In function 'int main()': a.cc:67:5: error: 'memset' was not declared in this scope 67 | memset(dp, -1, sizeof(dp)); | ^~~~~~ a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 5 | #include <vector> +++ |+#include <cstring> 6 |
s956224485
p00547
C++
#include<iostream> #include<cstdio> #include<string> #include<vector> #include<algorithm> #include<unordered_map> using namespace std; int a, b; int c[1000][1000]; bool d[1000][1000];//1 ?????£????????? int dp[1000][1000][16];//1 ?????£??? int dx[4] = {-1,0,1,1}, dy[4] = {1,1,0,-1}; int ex[4]={-1,0,0,1},ey[4]={0,-1,1,0}; void decide(int x, int y, int z) {//z ????????§???????????? if (d[x][y])z += c[x][y]; bool t = true; for (int i = 0; i < 4; i++) { if (x + ex[i] >= 0 && x + ex[i] < a&&y + ey[i] >= 0 && y + ey[i] < b&&d[x + ex[i]][y + ey[i]]) { t = false; int o = z, bit = 0; int n[4], m[4], sum = 0; for (int j = 0; j < 4; j++) { if (i == j)continue; int xx = x + ex[j], yy = y + ey[j]; if (xx >= 0 && xx < a&&yy >= 0 && yy < b&&d[xx][yy]) { o += c[xx][yy]; d[xx][yy] = false; n[sum] = xx; m[sum] = yy; sum++; } } for (int j = 0; j < 4; j++) { int xx = x + dx[j], yy = y + dy[j]; if (xx >= 0 && xx < a&&yy >= 0 && yy < b) { if (!d[xx][yy] && c[xx][yy]!=0) { bit |= (1<<j); } } } for (int j = 0; j < sum; j++) { d[n[j]][m[j]] = true; } dp[x][y][bit] = min(dp[x][y][bit], o); } } if (t) { int bit = 0; for (int j = 0; j < 4; j++) { int xx = x + dx[j], yy = y + dy[j]; if (xx >= 0 && xx < a&&yy >= 0 && yy < b) { if (!d[xx][yy] && c[xx][yy]) { bit |= (1 << j); } } } dp[x][y][bit] = min(dp[x][y][bit], z); } } void kousin(int x,int y,int z) { for (int i = 0; i < 4; i++) { if (z&(1 << i)) { d[x + dx[i]][y + dy[i]] = false; } } bool S = false; if (c[x][y]) { d[x][y] = false; S = true; } if(x+1<a)decide(x + 1, y, dp[x][y][z]); if(y+1<b)decide(x, y+1, dp[x][y][z]); if (S) { d[x][y] = true; } for (int i = 0; i < 4; i++) { if (z&(1 << i)) { d[x + dx[i]][y + dy[i]] = true; } } } int main() { memset(dp, 0x3f, sizeof(dp)); cin >> a >> b; for (int e = 0; e < a; e++) { string f; cin >> f; for (int g = 0; g < b; g++) { if (f[g] != '.') { c[e][g] = f[g] - '0'; d[e][g] = true; } } } dp[0][0][0] = 0; for (int i = 0; i < a + b - 2; i++) { for (int x = 0; x < a&&x<=i; x++) { int y = i - x; if (y < 0 || y >= b)continue; for (int z = 0; z < 16; z++) { if (dp[x][y][z] != 1061109567) { kousin(x, y, z); } } } } int MIN = 1<<29; for (int i = 0; i < 16; i++) { MIN = min(MIN, dp[a - 1][b - 1][i]); } cout << MIN << endl; }
a.cc: In function 'int main()': a.cc:83:9: error: 'memset' was not declared in this scope 83 | memset(dp, 0x3f, sizeof(dp)); | ^~~~~~ a.cc:7:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 6 | #include<unordered_map> +++ |+#include <cstring> 7 | using namespace std;
s931379891
p00548
C++
#include <iostream> #define int long long using namespace std; int n, m, k; int a[20000]; int dp[20000]; int dfs(int id) { if (id >= n) return 0; if (dp[id] != 0) return dp[id]; int maxi = -1145141919; int mini = 1145141919; for (int s = 1; s <= m; s++) { if (id + s > n) { continue; } maxi = max(maxi, a[id + s - 1]); mini = min(mini, a[id + s - 1]); ret = min(ret, dfs(id + s) + k + s * (maxi - mini)); } return (dp[id] = ret); } signed main() { cin >> n >> m >> k; for (int i = 0; i < n; i++) cin >> a[i]; cout << dfs(0) << endl; return 0; }
a.cc: In function 'long long int dfs(long long int)': a.cc:19:17: error: 'ret' was not declared in this scope 19 | ret = min(ret, dfs(id + s) + k + s * (maxi - mini)); | ^~~ a.cc:21:26: error: 'ret' was not declared in this scope 21 | return (dp[id] = ret); | ^~~
s728729590
p00548
C++
#include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <climits> #include <iostream> #include <vector> #include <string> #include <sstream> #include <algorithm> #include <utility> #include <set> #include <map> #include <stack> #include <queue> #include <deque> #include <functional> using namespace std; #define int long long #define fst first #define scd second #define PB push_back #define MP make_pair #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define omajinai ios::sync_with_stdio(false);cin.tie(0) #define rep(i,x) for(int i=0;i<(int)(x);++i) #define rep1(i,x) for(int i=1;i<=(int)(x);++i) typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pii; typedef vector<pii> vpii; template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;} template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;} template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;} template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;} template<typename T>T get(){T a;cin>>a;return a;} template<typename T>T rev(T a){reverse(all(a));return a;} template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;} const int inf = 3e18; const ll linf = 3e18; const double eps = 1e-9; int N, M, K; int A[20005]; int memo[20005]; inline :int rec(int now) { if (~memo[now]) return memo[now]; int res = inf; int mi = inf, ma = -inf; for (int i = 0, to = min(N - now, M); i < to; ++i) { mi = min(mi, A[now + i]); ma = max(ma, A[now + i]); res = min(res, K + (ma - mi) * (i + 1) + rec(now + i + 1)); } if (res == inf) res = 0; return memo[now] = res; } signed main() { // #define int long long ?????????????????§scanf???????????¨???????????????????????\????????????????????? omajinai; cin >> N >> M >> K; rep(i, N) { cin >> A[i]; } memset(memo, -1, sizeof (memo)); cout << rec(0) << endl; }
a.cc:56:8: error: expected unqualified-id before ':' token 56 | inline :int rec(int now) | ^ a.cc: In function 'int main()': a.cc:86:13: error: 'rec' was not declared in this scope; did you mean 'rev'? 86 | cout << rec(0) << endl; | ^~~ | rev
s914910927
p00548
C++
#include "bits/stdc++.h" using namespace std; #define int long long signed main() { int N, M, K; cin >> N >> M >> K; vector<int> A(N); input(A); vector<int> v(N + 1); rep(i, N) { cin >> A[i]; int minv = 1ll << 60, maxv = -1; int ans = 1ll << 60; rep(j, M * (i - j >= 0)) { int a = A[i - j]; minv = min(minv, a); maxv = max(maxv, a); ans = min(ans, K + (j + 1) * (maxv - minv) + v[i - j]); } v[i + 1] = ans; } cout << v[N] << endl; }
a.cc: In function 'int main()': a.cc:8:27: error: 'input' was not declared in this scope; did you mean 'int'? 8 | vector<int> A(N); input(A); | ^~~~~ | int a.cc:10:13: error: 'i' was not declared in this scope 10 | rep(i, N) { | ^ a.cc:10:9: error: 'rep' was not declared in this scope 10 | rep(i, N) { | ^~~