submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s281867000
p00139
C
char s[101];A(){char a[101],b[101],t,t2;return sscanf(s,">'%[=]#%[=]%c%c",a,b,&t,&t2)==3&&t=='~'&&strlen(a)==strlen(b);}B(){short*q;char*p=s,l=0;if(*(q=p++)=='^>'){for(;*(q=++p)=='=Q';p++)l++;if(l>0&&*(q=p++)=='~~'&&*++p==0)return 1;}return 0;}main(){scanf("%*d\n");for(;~scanf("%[^\n]\n",s);){if(A())puts("A");else if(B())puts("B");elseputs("NA");}}
main.c:1:13: error: return type defaults to 'int' [-Wimplicit-int] 1 | char s[101];A(){char a[101],b[101],t,t2;return sscanf(s,">'%[=]#%[=]%c%c",a,b,&t,&t2)==3&&t=='~'&&strlen(a)==strlen(b);}B(){short*q;char*p=s,l=0;if(*(q=p++)=='^>'){for(;*(q=++p)=='=Q';p++)l++;if(l>0&&*(q=p++)=='~~'&&*++p==0)return 1;}return 0;}main(){scanf("%*d\n");for(;~scanf("%[^\n]\n",s);){if(A())puts("A");else if(B())puts("B");elseputs("NA");}} | ^ main.c: In function 'A': main.c:1:48: error: implicit declaration of function 'sscanf' [-Wimplicit-function-declaration] 1 | char s[101];A(){char a[101],b[101],t,t2;return sscanf(s,">'%[=]#%[=]%c%c",a,b,&t,&t2)==3&&t=='~'&&strlen(a)==strlen(b);}B(){short*q;char*p=s,l=0;if(*(q=p++)=='^>'){for(;*(q=++p)=='=Q';p++)l++;if(l>0&&*(q=p++)=='~~'&&*++p==0)return 1;}return 0;}main(){scanf("%*d\n");for(;~scanf("%[^\n]\n",s);){if(A())puts("A");else if(B())puts("B");elseputs("NA");}} | ^~~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'sscanf' +++ |+#include <stdio.h> 1 | char s[101];A(){char a[101],b[101],t,t2;return sscanf(s,">'%[=]#%[=]%c%c",a,b,&t,&t2)==3&&t=='~'&&strlen(a)==strlen(b);}B(){short*q;char*p=s,l=0;if(*(q=p++)=='^>'){for(;*(q=++p)=='=Q';p++)l++;if(l>0&&*(q=p++)=='~~'&&*++p==0)return 1;}return 0;}main(){scanf("%*d\n");for(;~scanf("%[^\n]\n",s);){if(A())puts("A");else if(B())puts("B");elseputs("NA");}} main.c:1:48: warning: incompatible implicit declaration of built-in function 'sscanf' [-Wbuiltin-declaration-mismatch] 1 | char s[101];A(){char a[101],b[101],t,t2;return sscanf(s,">'%[=]#%[=]%c%c",a,b,&t,&t2)==3&&t=='~'&&strlen(a)==strlen(b);}B(){short*q;char*p=s,l=0;if(*(q=p++)=='^>'){for(;*(q=++p)=='=Q';p++)l++;if(l>0&&*(q=p++)=='~~'&&*++p==0)return 1;}return 0;}main(){scanf("%*d\n");for(;~scanf("%[^\n]\n",s);){if(A())puts("A");else if(B())puts("B");elseputs("NA");}} | ^~~~~~ main.c:1:48: note: include '<stdio.h>' or provide a declaration of 'sscanf' main.c:1:99: error: implicit declaration of function 'strlen' [-Wimplicit-function-declaration] 1 | char s[101];A(){char a[101],b[101],t,t2;return sscanf(s,">'%[=]#%[=]%c%c",a,b,&t,&t2)==3&&t=='~'&&strlen(a)==strlen(b);}B(){short*q;char*p=s,l=0;if(*(q=p++)=='^>'){for(;*(q=++p)=='=Q';p++)l++;if(l>0&&*(q=p++)=='~~'&&*++p==0)return 1;}return 0;}main(){scanf("%*d\n");for(;~scanf("%[^\n]\n",s);){if(A())puts("A");else if(B())puts("B");elseputs("NA");}} | ^~~~~~ main.c:1:1: note: include '<string.h>' or provide a declaration of 'strlen' +++ |+#include <string.h> 1 | char s[101];A(){char a[101],b[101],t,t2;return sscanf(s,">'%[=]#%[=]%c%c",a,b,&t,&t2)==3&&t=='~'&&strlen(a)==strlen(b);}B(){short*q;char*p=s,l=0;if(*(q=p++)=='^>'){for(;*(q=++p)=='=Q';p++)l++;if(l>0&&*(q=p++)=='~~'&&*++p==0)return 1;}return 0;}main(){scanf("%*d\n");for(;~scanf("%[^\n]\n",s);){if(A())puts("A");else if(B())puts("B");elseputs("NA");}} main.c:1:99: warning: incompatible implicit declaration of built-in function 'strlen' [-Wbuiltin-declaration-mismatch] 1 | char s[101];A(){char a[101],b[101],t,t2;return sscanf(s,">'%[=]#%[=]%c%c",a,b,&t,&t2)==3&&t=='~'&&strlen(a)==strlen(b);}B(){short*q;char*p=s,l=0;if(*(q=p++)=='^>'){for(;*(q=++p)=='=Q';p++)l++;if(l>0&&*(q=p++)=='~~'&&*++p==0)return 1;}return 0;}main(){scanf("%*d\n");for(;~scanf("%[^\n]\n",s);){if(A())puts("A");else if(B())puts("B");elseputs("NA");}} | ^~~~~~ main.c:1:99: note: include '<string.h>' or provide a declaration of 'strlen' main.c: At top level: main.c:1:121: error: return type defaults to 'int' [-Wimplicit-int] 1 | char s[101];A(){char a[101],b[101],t,t2;return sscanf(s,">'%[=]#%[=]%c%c",a,b,&t,&t2)==3&&t=='~'&&strlen(a)==strlen(b);}B(){short*q;char*p=s,l=0;if(*(q=p++)=='^>'){for(;*(q=++p)=='=Q';p++)l++;if(l>0&&*(q=p++)=='~~'&&*++p==0)return 1;}return 0;}main(){scanf("%*d\n");for(;~scanf("%[^\n]\n",s);){if(A())puts("A");else if(B())puts("B");elseputs("NA");}} | ^ main.c: In function 'B': main.c:1:152: error: assignment to 'short int *' from incompatible pointer type 'char *' [-Wincompatible-pointer-types] 1 | char s[101];A(){char a[101],b[101],t,t2;return sscanf(s,">'%[=]#%[=]%c%c",a,b,&t,&t2)==3&&t=='~'&&strlen(a)==strlen(b);}B(){short*q;char*p=s,l=0;if(*(q=p++)=='^>'){for(;*(q=++p)=='=Q';p++)l++;if(l>0&&*(q=p++)=='~~'&&*++p==0)return 1;}return 0;}main(){scanf("%*d\n");for(;~scanf("%[^\n]\n",s);){if(A())puts("A");else if(B())puts("B");elseputs("NA");}} | ^ main.c:1:159: warning: multi-character character constant [-Wmultichar] 1 | char s[101];A(){char a[101],b[101],t,t2;return sscanf(s,">'%[=]#%[=]%c%c",a,b,&t,&t2)==3&&t=='~'&&strlen(a)==strlen(b);}B(){short*q;char*p=s,l=0;if(*(q=p++)=='^>'){for(;*(q=++p)=='=Q';p++)l++;if(l>0&&*(q=p++)=='~~'&&*++p==0)return 1;}return 0;}main(){scanf("%*d\n");for(;~scanf("%[^\n]\n",s);){if(A())puts("A");else if(B())puts("B");elseputs("NA");}} | ^~~~ main.c:1:173: error: assignment to 'short int *' from incompatible pointer type 'char *' [-Wincompatible-pointer-types] 1 | char s[101];A(){char a[101],b[101],t,t2;return sscanf(s,">'%[=]#%[=]%c%c",a,b,&t,&t2)==3&&t=='~'&&strlen(a)==strlen(b);}B(){short*q;char*p=s,l=0;if(*(q=p++)=='^>'){for(;*(q=++p)=='=Q';p++)l++;if(l>0&&*(q=p++)=='~~'&&*++p==0)return 1;}return 0;}main(){scanf("%*d\n");for(;~scanf("%[^\n]\n",s);){if(A())puts("A");else if(B())puts("B");elseputs("NA");}} | ^ main.c:1:180: warning: multi-character character constant [-Wmultichar] 1 | char s[101];A(){char a[101],b[101],t,t2;return sscanf(s,">'%[=]#%[=]%c%c",a,b,&t,&t2)==3&&t=='~'&&strlen(a)==strlen(b);}B(){short*q;char*p=s,l=0;if(*(q=p++)=='^>'){for(;*(q=++p)=='=Q';p++)l++;if(l>0&&*(q=p++)=='~~'&&*++p==0)return 1;}return 0;}main(){scanf("%*d\n");for(;~scanf("%[^\n]\n",s);){if(A())puts("A");else if(B())puts("B");elseputs("NA");}} | ^~~~ main.c:1:204: error: assignment to 'short int *' from incompatible pointer type 'char *' [-Wincompatible-pointer-types] 1 | char s[101];A(){char a[101],b[101],t,t2;return sscanf(s,">'%[=]#%[=]%c%c",a,b,&t,&t2)==3&&t=='~'&&strlen(a)==strlen(b);}B(){short*q;char*p=s,l=0;if(*(q=p++)=='^>'){for(;*(q=++p)=='=Q';p++)l++;if(l>0&&*(q=p++)=='~~'&&*++p==0)return 1;}return 0;}main(){scanf("%*d\n");for(;~scanf("%[^\n]\n",s);){if(A())puts("A");else if(B())puts("B");elseputs("NA");}} | ^ main.c:1:211: warning: multi-character character constant [-Wmultichar] 1 | char s[101];A(){char a[101],b[101],t,t2;return sscanf(s,">'%[=]#%[=]%c%c",a,b,&t,&t2)==3&&t=='~'&&strlen(a)==strlen(b);}B(){short*q;char*p=s,l=0;if(*(q=p++)=='^>'){for(;*(q=++p)=='=Q';p++)l++;if(l>0&&*(q=p++)=='~~'&&*++p==0)return 1;}return 0;}main(){scanf("%*d\n");for(;~scanf("%[^\n]\n",s);){if(A())puts("A");else if(B())puts("B");elseputs("NA");}} | ^~~~ main.c: At top level: main.c:1:245: error: return type defaults to 'int' [-Wimplicit-int] 1 | char s[101];A(){char a[101],b[101],t,t2;return sscanf(s,">'%[=]#%[=]%c%c",a,b,&t,&t2)==3&&t=='~'&&strlen(a)==strlen(b);}B(){short*q;char*p=s,l=0;if(*(q=p++)=='^>'){for(;*(q=++p)=='=Q';p++)l++;if(l>0&&*(q=p++)=='~~'&&*++p==0)return 1;}return 0;}main(){scanf("%*d\n");for(;~scanf("%[^\n]\n",s);){if(A())puts("A");else if(B())puts("B");elseputs("NA");}} | ^~~~ main.c: In function 'main': main.c:1:252: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 1 | char s[101];A(){char a[101],b[101],t,t2;return sscanf(s,">'%[=]#%[=]%c%c",a,b,&t,&t2)==3&&t=='~'&&strlen(a)==strlen(b);}B(){short*q;char*p=s,l=0;if(*(q=p++)=='^>'){for(;*(q=++p)=='=Q';p++)l++;if(l>0&&*(q=p++)=='~~'&&*++p==0)return 1;}return 0;}main(){scanf("%*d\n");for(;~scanf("%[^\n]\n",s);){if(A())puts("A");else if(B())puts("B");elseputs("NA");}} | ^~~~~ main.c:1:252: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:1:252: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] main.c:1:252: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:1:302: error: implicit declaration of function 'puts' [-Wimplicit-function-declaration] 1 | char s[101];A(){char a[101],b[101],t,t2;return sscanf(s,">'%[=]#%[=]%c%c",a,b,&t,&t2)==3&&t=='~'&&strlen(a)==strlen(b);}B(){short*q;char*p=s,l=0;if(*(q=p++)=='^>'){for(;*(
s513067872
p00139
C
#include<stdio.h> int main(void){ char w[201]; int a,i,j,k; a=getchar(); for(j=0;j<a;j++){ gets(w); if(w[0]!='>'){printf("NA\n");goto la;} if(w[1]=='\''){ int c; for(i=2;w[i]!='#';i++){ if(w[i]!='='){printf("NA\n");goto la;} c++; } i++; for(k=0;k<c;k++){ if(w[i++]!='='){printf("NA\n");goto la;} } if(w[i++]!='~'){printf("NA\n");goto la;} if(w[i]!='\0'){printf("NA\n");goto la;} printf("A\n"); } if(w[1]=='^'){ for(i=2;w[i]=='~';i+=2){ if(w[i]!='Q'){printf("NA\n");goto la;} if(w[i+1]!='='){printf("NA\n");goto la;} } if(w[i]!='~'){printf("NA\n");goto la;} if(w[i+1]!='~'){printf("NA\n");goto la;} if(w[i+2]!='\0'){printf("NA\n");goto la;} printf("B\n"); } la: } return 0; }
main.c: In function 'main': main.c:8:5: error: implicit declaration of function 'gets'; did you mean 'fgets'? [-Wimplicit-function-declaration] 8 | gets(w); | ^~~~ | fgets
s312332447
p00139
C
#include <stdio.h> int main(int argc, const char * argv[]) { int num; int i, j, k, l; scanf("%d", &num); for (l = 0; l < num + 1; l++) { char snake[200]; int bodyacnt = 0; int bodybcnt = 0; int midcnt = 0; int endacnt = 0; int endbcnt = 0; int nacnt = 0; for (i = 0; i < 200; i++) { scanf("%c", &snake[i]); if (snake[i] == '\n') { // printf("%d\n", i); break; } } if (snake[0] == '>') { if (snake[1] == '\'') { for (j = 2; j < i; j++) { if (snake[j] == '=') { bodyacnt++; } else if (snake[j] == '#'){ break; } } else nacnt++; for (k = j; k < i; k++) { if (snake[k] == '=') { midcnt++; } else if (snake[k] == '~'){ endacnt++; if (endacnt == 2) { nacnt++; } } else nacnt++; } } else if (snake[1] == '^') { for (j = 2; j < i / 2; j+=2) { if (snake[j] == 'Q' && snake[j + 1] == '=') { bodybcnt++; } else nacnt++; } if (snake[i - 2] == '~' && snake[i - 1] == '~' && snake[i - 3] != '~') { endbcnt++; } } else nacnt++; } if (bodybcnt > 0 && endbcnt == 1 && nacnt == 0){ printf("B\n"); } else if (bodyacnt == midcnt && endacnt == 1 && nacnt == 0 && bodyacnt > 0) { printf("A\n"); } else if (l != 0)printf("NA\n"); } return 0; }
main.c: In function 'main': main.c:34:17: error: expected '}' before 'else' 34 | else nacnt++; | ^~~~ main.c:62:13: error: 'bodybcnt' undeclared (first use in this function) 62 | if (bodybcnt > 0 && endbcnt == 1 && nacnt == 0){ | ^~~~~~~~ main.c:62:13: note: each undeclared identifier is reported only once for each function it appears in main.c:62:29: error: 'endbcnt' undeclared (first use in this function) 62 | if (bodybcnt > 0 && endbcnt == 1 && nacnt == 0){ | ^~~~~~~ main.c:62:45: error: 'nacnt' undeclared (first use in this function) 62 | if (bodybcnt > 0 && endbcnt == 1 && nacnt == 0){ | ^~~~~ main.c:65:18: error: 'bodyacnt' undeclared (first use in this function) 65 | else if (bodyacnt == midcnt && endacnt == 1 && nacnt == 0 && bodyacnt > 0) { | ^~~~~~~~ main.c:65:30: error: 'midcnt' undeclared (first use in this function) 65 | else if (bodyacnt == midcnt && endacnt == 1 && nacnt == 0 && bodyacnt > 0) { | ^~~~~~ main.c:65:40: error: 'endacnt' undeclared (first use in this function) 65 | else if (bodyacnt == midcnt && endacnt == 1 && nacnt == 0 && bodyacnt > 0) { | ^~~~~~~ main.c: At top level: main.c:71:5: error: expected identifier or '(' before 'return' 71 | return 0; | ^~~~~~ main.c:72:1: error: expected identifier or '(' before '}' token 72 | } | ^
s223803985
p00139
C
#include <stdio.h> int main(int argc, const char * argv[]) { int num; int i, j, k, l; char snake[200]; int bodyacnt = 0; int bodybcnt = 0; int midcnt = 0; int endacnt = 0; int endbcnt = 0; int nacnt = 0; scanf("%d", &num); for (l = 0; l < num + 1; l++) { snake[200] = {0}; bodyacnt = 0; bodybcnt = 0; midcnt = 0; endacnt = 0; endbcnt = 0; nacnt = 0; for (i = 0; i < 200; i++) { scanf("%c", &snake[i]); if (snake[i] == '\n') { // printf("%d\n", i); break; } } if (snake[0] == '>') { if (snake[1] == '\'') { for (j = 2; j < i; j++) { if (snake[j] == '=') { bodyacnt++; } else if (snake[j] == '#'){ break; } } else nacnt++; for (k = j; k < i; k++) { if (snake[k] == '=') { midcnt++; } else if (snake[k] == '~'){ endacnt++; if (endacnt == 2) { nacnt++; } } else nacnt++; } } else if (snake[1] == '^') { for (j = 2; j < i / 2; j+=2) { if (snake[j] == 'Q' && snake[j + 1] == '=') { bodybcnt++; } else nacnt++; } if (snake[i - 2] == '~' && snake[i - 1] == '~' && snake[i - 3] != '~') { endbcnt++; } } else nacnt++; } if (bodybcnt > 0 && endbcnt == 1 && nacnt == 0){ printf("B\n"); } else if (bodyacnt == midcnt && endacnt == 1 && nacnt == 0 && bodyacnt > 0) { printf("A\n"); } else if (l != 0)printf("NA\n"); } return 0; }
main.c: In function 'main': main.c:17:22: error: expected expression before '{' token 17 | snake[200] = {0}; | ^ main.c:41:17: error: expected '}' before 'else' 41 | else nacnt++; | ^~~~ main.c: At top level: main.c:78:5: error: expected identifier or '(' before 'return' 78 | return 0; | ^~~~~~ main.c:79:1: error: expected identifier or '(' before '}' token 79 | } | ^
s235308415
p00139
C
#include <stdio.h> int main(int argc, const char * argv[]) { int num; int i, j, k, l; char snake[200]; int bodyacnt = 0; int bodybcnt = 0; int midcnt = 0; int endacnt = 0; int endbcnt = 0; int nacnt = 0; scanf("%d", &num); for (l = 0; l < num + 1; l++) { snake[200] = {0}; bodyacnt = 0; bodybcnt = 0; midcnt = 0; endacnt = 0; endbcnt = 0; nacnt = 0; for (i = 0; i < 200; i++) { scanf("%c", &snake[i]); if (snake[i] == '\n') { // printf("%d\n", i); break; } } if (snake[0] == '>') { if (snake[1] == '\'') { for (j = 2; j < i; j++) { if (snake[j] == '=') { bodyacnt++; } else if (snake[j] == '#'){ break; } else nacnt++; } for (k = j; k < i; k++) { if (snake[k] == '=') { midcnt++; } else if (snake[k] == '~'){ endacnt++; if (endacnt == 2) { nacnt++; } } else nacnt++; } } else if (snake[1] == '^') { for (j = 2; j < i / 2; j+=2) { if (snake[j] == 'Q' && snake[j + 1] == '=') { bodybcnt++; } else nacnt++; } if (snake[i - 2] == '~' && snake[i - 1] == '~' && snake[i - 3] != '~') { endbcnt++; } } else nacnt++; } if (bodybcnt > 0 && endbcnt == 1 && nacnt == 0){ printf("B\n"); } else if (bodyacnt == midcnt && endacnt == 1 && nacnt == 0 && bodyacnt > 0) { printf("A\n"); } else if (l != 0)printf("NA\n"); } return 0; }
main.c: In function 'main': main.c:17:22: error: expected expression before '{' token 17 | snake[200] = {0}; | ^
s112773985
p00139
C++
#include <iostream> #include <string> using namespace std; int main() { int n; cin >> n; for(int i = 0; i < n; i++) { string s; cin >> s; bool a[4] = {}, b[3] = {}; int cnt = 0; for(int j = 0; j < s.size(); j++) { if(s[j] == '>') { if(!a[1] && s[j+1] == ''') a[0] = true; if(s[j+1] == '^') b[0] = true; } else if(a[0] && s[j] == '=') { a[1] = true; cnt++; } else if(b[0] && s.substr(j,2) == "Q=") { b[1] = true; } else if(a[1] && s[j] == '#') { a[0] = false; a[2] = true; } else if(a[2] && s[j] == '=') { cnt--; } else if(a[1] && cnt == 0 && j+1 == s.size() && s[j] == '~') { a[3] = true; } else if(b[1] && j+2 == s.size() && s.substr(j,2) == "~~") { b[2] = true; } } if(a[3]) cout << 'A' << endl; else if(b[2]) cout << 'B' << endl; else cout << "NA" << endl; } }
a.cc:13:31: error: empty character constant 13 | if(!a[1] && s[j+1] == ''') a[0] = true; | ^~ a.cc:13:33: warning: missing terminating ' character 13 | if(!a[1] && s[j+1] == ''') a[0] = true; | ^ a.cc:13:33: error: missing terminating ' character 13 | if(!a[1] && s[j+1] == ''') a[0] = true; | ^~~~~~~~~~~~~~~ a.cc: In function 'int main()': a.cc:13:33: error: expected ';' before 'if' 13 | if(!a[1] && s[j+1] == ''') a[0] = true; | ^ | ; 14 | if(s[j+1] == '^') b[0] = true; | ~~ a.cc:15:7: error: expected primary-expression before '}' token 15 | } else if(a[0] && s[j] == '=') { | ^ a.cc:14:39: error: expected ')' before '}' token 14 | if(s[j+1] == '^') b[0] = true; | ^ | ) 15 | } else if(a[0] && s[j] == '=') { | ~ a.cc:13:11: note: to match this '(' 13 | if(!a[1] && s[j+1] == ''') a[0] = true; | ^ a.cc:15:7: error: expected primary-expression before '}' token 15 | } else if(a[0] && s[j] == '=') { | ^
s873124361
p00139
C++
#include<iostream> #include<string> using namespace std; int main(void){ string str; int n; cin>>n; while(n--){ cin>>str; int ca = 0; int cntsha = 0; bool a = true; if(str.size()%2 == 0){ if(str[str.size() / 2] == '#')str[str.size()/2] = '='; for(int i = 2 ; i < str.size() - 1 ; i ++){ if(str[i] != '='){ a = false; break; } } if(a)ca = 1; } if(ca != 1){ bool b = true; for(int i = 2 ; i < str.size() - 2 ; i ++){ //cout<<str[i]; if(i%2){ if(str[i] != '='){ b = false; //cout<<i<<endl; break; } }else{ if(str[i] != 'Q'){ b = false; //cout<<i<<endl; break; } } } if(b){ ca = 2; } } if(ca == 1){ cout<<"A"<<endl; }else if(ca == 2){ cout<<"B"<<endl; }else{ cout<<"NA"<<endl; } } } #include<iostream> #include<string> using namespace std; int main(void){ string str; int n; cin>>n; while(n--){ cin>>str; int ca = 0; int cntsha = 0; bool a = true; if(str.size()%2 == 0){ if(str[str.size() / 2] == '#')str[str.size()/2] = '='; for(int i = 2 ; i < str.size() - 1 ; i ++){ if(str[i] != '='){ a = false; break; } } if(a)ca = 1; } if(ca != 1){ bool b = true; for(int i = 2 ; i < str.size() - 2 ; i ++){ //cout<<str[i]; if(i%2){ if(str[i] != '='){ b = false; //cout<<i<<endl; break; } }else{ if(str[i] != 'Q'){ b = false; //cout<<i<<endl; break; } } } if(b){ ca = 2; } } if(ca == 1){ cout<<"A"<<endl; }else if(ca == 2){ cout<<"B"<<endl; }else{ cout<<"NA"<<endl; } } }
a.cc:59:5: error: redefinition of 'int main()' 59 | int main(void){ | ^~~~ a.cc:5:5: note: 'int main()' previously defined here 5 | int main(void){ | ^~~~
s798187683
p00139
C++
#include <iostream> #include <string> #include <sstream> #include <algorithm> #include <vector> #include <utility> #include <stack> #include <queue> #include <map> #include <set> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) #define repc(i,s,e) for(int i=(s); i<(e); i++) #define pb(n) push_back((n)) #define mp(n,m) make_pair((n),(m)) #define all(r) r.begin(),r.end() #define fi first #define se second typedef long long ll; typedef vector<int> vi; typedef vector<vi> vii; typedef vector<ll> vl; typedef vector<vl> vll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; int main() { int n; string s; cin >> n; rep(i, n) { cin >> s; string ans; if (s[0] == '>'&&s[s.size() - 1] == '~') { if (s[1] == '\'') { ans = "A"; for (int i = 2; i < s.size() - 1) { if (i == s.size() / 2) { if (s[i] != '#') { ans = "NA"; break; } } else { if (s[i] != '=') { ans = "NA"; break; } } } } else if (s[1] == '^'&&s[s.size()-2]=='~') { ans = "B"; for (int i = 2; i < s.size() - 2; i += 2) { if (s[i] != 'Q' || s[i + 1] != '=') { ans = "NA"; break; } } } else ans = "NA"; } else { ans = "NA"; } cout << ans << endl; } }
a.cc: In function 'int main()': a.cc:45:65: error: expected ';' before ')' token 45 | for (int i = 2; i < s.size() - 1) { | ^ | ;
s797087883
p00139
C++
#include <string> #include <iostream> using namespace std; int n; string s; bool check() { if(s.size() < 6) return 0; if(s[0] != '>') return 0; if(s[1] != '\'') { int cnt = 0; for(int i = 2; i < s.size() - 1; i++) { if(s[i] != '=') break; cnt++; } if(s[2 + cnt] != '#') return 0; for(int j = cnt + 3; j < s.size(); j++) { if(s[i] != '=') break; cnt--; } if(cnt) return 0; if(2 + cnt + 1 != s.size()) return 0; return s[2 + cnt] == '~' ? 1 : 0; } if(s[1] != '^') { int cnt = 0; for(int i = 2; i < s.size() - 2; i += 2) { if(s[i] != 'Q' || s[i + 1] != '=') break; cnt += 2; } if(cnt + 4 != s.size()) return 0; return (s[cnt + 2] == '~' && s[cnt + 3] == '~') ? 2 : 0; } return 0; } int main() { scanf("%d", &n); for(int i = 0; i < n; i++) { cin >> s; printf("%s\n", !check() ? "NA" : (check() == 1 ? "A" : "B")); } return 0; }
a.cc: In function 'bool check()': a.cc:16:30: error: 'i' was not declared in this scope 16 | if(s[i] != '=') break; | ^
s989626371
p00139
C++
#include <iostream> #define NA cout << "NA" << endl; goto LABEL using namespace std; int main() { int snakeCount; cin >> snakeCount; for(int loopCount = 0; loopCount < snakeCount; loopCount++) { char arr[201]; ???in >> arr; int i = 0; if(arr[i]!='>') { NA; } i++; if(arr[i]=='\'') { int equalCount = 0; bool mode = false; for(int j = i+1; j < 201; j++) { if(arr[j]=='=') { if(!mode) { equalCount++; }else { equalCount--; } }else if(arr[j]=='#') { if(!mode && equalCount>0) { mode = !mode; }else { NA; } }else if(arr[j]=='~') { if(arr[j+1]=='\0'&&equalCount==0&&mode) { cout << "A" << endl; goto LABEL; }else { NA; } }else { NA; } } }else if(arr[i]=='^') { int count = 0; for(int j = i+1; j < 201; j++) { if(arr[j]=='Q'&&arr[j+1]=='=') { j++; count++; continue; }else if(arr[j]=='~'&&arr[j+1]=='~'&&arr[j+2]=='\0'&&count>0) { cout<< "B" << endl; goto LABEL; }else { NA; } } }else { NA; } LABEL:; } return 0; }
a.cc: In function 'int main()': a.cc:14:17: error: expected primary-expression before '?' token 14 | ???in >> arr; | ^ a.cc:14:18: error: expected primary-expression before '?' token 14 | ???in >> arr; | ^ a.cc:14:19: error: expected primary-expression before '?' token 14 | ???in >> arr; | ^ a.cc:14:20: error: 'in' was not declared in this scope; did you mean 'int'? 14 | ???in >> arr; | ^~ | int a.cc:14:29: error: expected ':' before ';' token 14 | ???in >> arr; | ^ | : a.cc:14:29: error: expected primary-expression before ';' token a.cc:14:29: error: expected ':' before ';' token 14 | ???in >> arr; | ^ | : a.cc:14:29: error: expected primary-expression before ';' token a.cc:14:29: error: expected ':' before ';' token 14 | ???in >> arr; | ^ | : a.cc:14:29: error: expected primary-expression before ';' token
s474514801
p00139
C++
#include <iostream> #include <string> using namespace std; string solv(string s){ int ss = s.size(); if(s[0] != '>' || s[ss-1] != '~')return "NA"; if(s[ss-2] == '~'){ if(s[1] != '^')return "NA"; for(int i = 0;i < ss-2;i++){ if(s[i] == 'Q' && s[i+1] == '=')return "B"; } }else{ fi(s[1] != ''')return "NA"; int a = 0, f = 0; for(int i = 1;i < ss-1;i++){ if(s[i] == '=' && !f)a++; if(s[i] == '#')f = 1; if(f && !a)return "NA"; if(s[i] == '=' && f)a--; } return a ? "NA" : "A"; } return "NA"; } int main(){ int n;cin >> n; string s; while(n--){ cin >> s; cout << solv(s) << endl; } return 0; }
a.cc:14:28: error: empty character constant 14 | fi(s[1] != ''')return "NA"; | ^~ a.cc:14:30: warning: missing terminating ' character 14 | fi(s[1] != ''')return "NA"; | ^ a.cc:14:30: error: missing terminating ' character 14 | fi(s[1] != ''')return "NA"; | ^~~~~~~~~~~~~~ a.cc: In function 'std::string solv(std::string)': a.cc:14:30: error: expected ')' before 'int' 14 | fi(s[1] != ''')return "NA"; | ~ ^ | ) 15 | int a = 0, f = 0; | ~~~ a.cc:15:28: error: 'f' was not declared in this scope 15 | int a = 0, f = 0; | ^ a.cc:17:46: error: 'a' was not declared in this scope 17 | if(s[i] == '=' && !f)a++; | ^ a.cc:19:34: error: 'a' was not declared in this scope 19 | if(f && !a)return "NA"; | ^ a.cc:20:45: error: 'a' was not declared in this scope 20 | if(s[i] == '=' && f)a--; | ^ a.cc:22:24: error: 'a' was not declared in this scope 22 | return a ? "NA" : "A"; | ^
s625689710
p00139
C++
#include<iostream> #include<string> using namespace std; int main(){ int n,size; string s,a,b; for(cin>>n;n>0;n--){ cin>>s; size = s.size(); if(size%2){cout<<"NA"<<endl;continue} a=">'"; b=">^"; for(int i=0;i<size/2-2;i++){a=a+"=";b=b+"Q=";} a+="#"; for(int i=0;i<size/2-2;i++){a=a+"=";} a+="~"; b+="~~"; if (s==a)cout<<"A"<<endl; else if (s==b)cout<<"B"<<endl; else cout<<"NA"<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:10:41: error: expected ';' before '}' token 10 | if(size%2){cout<<"NA"<<endl;continue} | ^ | ;
s831674028
p00139
C++
import java.lang.*; import java.util.*; class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); for(int i=0;i<n;i++){ String s=sc.next(); if(s.matches("^>'(=+)#\\1~$")) System.out.println("A"); else if(s.matches("^>\\^(Q=)+~~$")) System.out.println("B"); else System.out.println("NA"); } } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.lang.*; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.util.*; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:5:15: error: expected ':' before 'static' 5 | public static void main(String[] args){ | ^~~~~~~ | : a.cc:5:33: error: 'String' has not been declared 5 | public static void main(String[] args){ | ^~~~~~ a.cc:5:42: error: expected ',' or '...' before 'args' 5 | public static void main(String[] args){ | ^~~~ a.cc:18:2: error: expected ';' after class definition 18 | } | ^ | ; a.cc: In static member function 'static void Main::main(int*)': a.cc:6:17: error: 'Scanner' was not declared in this scope 6 | Scanner sc=new Scanner(System.in); | ^~~~~~~ a.cc:7:23: error: 'sc' was not declared in this scope 7 | int n=sc.nextInt(); | ^~ a.cc:9:25: error: 'String' was not declared in this scope 9 | String s=sc.next(); | ^~~~~~ a.cc:10:28: error: 's' was not declared in this scope 10 | if(s.matches("^>'(=+)#\\1~$")) | ^ a.cc:11:33: error: 'System' was not declared in this scope 11 | System.out.println("A"); | ^~~~~~ a.cc:13:33: error: 'System' was not declared in this scope 13 | System.out.println("B"); | ^~~~~~ a.cc:15:33: error: 'System' was not declared in this scope 15 | System.out.println("NA"); | ^~~~~~
s196853041
p00139
C++
#include <iostream> #include <string> using namespace std; int main() { int n; string snake; int idx; int count; cin >> n; getline(cin,snake); for(int i=0;i<n;i++) { getline(cin,snake); //明らかにどちらのヘビでもない if(snake[0]!='>') { cout << "NA" << endl; break; } else { //A種であるか判定 if(snake[1]=='\'') { if(snake[2]!='=') { cout << "NA" << endl; goto NA; } idx=3; count=1; while(1) { if(snake[idx]!='=' && snake[idx]!='#') { cout << "NA" << endl; goto NA; } else if(snake[idx]=='=') { idx++; count++; } else if(snake[idx]=='#') { idx++; break; } } while(1) { if(snake[idx]!='=' && snake[idx]!='~') { cout << "NA" << endl; goto NA; } else if(snake[idx]=='=') { idx++; count--; } else if(snake[idx]=='~' && idx==snake.length()-1) { if(count==0) break; else { cout << "NA" << endl; goto NA; } } else { cout << "NA" << endl; goto NA; } } cout << "A" << endl; } //B種であるか判定 else if(snake[1]=='^') { if(snake[2]!='Q') { cout << "NA" << endl; goto NA;p } if(snake[3]!='=') { cout << "NA" << endl; goto NA; } idx=4; while(1) { if(snake[idx]!='Q') break; idx++; if(snake[idx]!='=') { cout << "NA" << endl; goto NA; } idx++; } if((snake[idx]!='~' || snake[idx+1]!='~') || snake.length()>idx+2) { cout << "NA" << endl; goto NA; } cout << "B" << endl; } else { cout << "NA" << endl; goto NA; } } NA: ; } return 0; }
a.cc: In function 'int main()': a.cc:132:19: error: 'p' was not declared in this scope 132 | goto NA;p | ^
s668691960
p00139
C++
#include <stdio.h> #include <math.h> int main(){ int syucnt[1000]={0},n,i,t,l,gou=0; char input[10000]; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%s",input); l = strlen(input); if(input[l-1]=='~'&&input[l-2]=='~'){//B種の調べ for(t=2;t<=l-4;t=t+2){ if(input[t]=='Q'&&input[t+1]=='='){ gou++; } } if(gou*2==l-4){ syucnt[i]=2; }else syucnt[i]=3; gou=0; }else if(input[l/2]=='#'&&input[l-1]=='~'&&(l-4)%2==0){ int j=2; for(t=0;t<(l-4)/2;t++){ if(input[j]=='='&&input[l-j]=='='){ gou++; } j++; } if(gou==((l-4)/2)){ syucnt[i]=1; }else syucnt[i]=3; gou=0; }else syucnt[i]=3; } for(i=0;i<n;i++){//出力 if(syucnt[i]==1){ puts("A"); }else if(syucnt[i]==2){ puts("B"); }else if(syucnt[i]==3){ puts("NA"); } } return 0; }
a.cc: In function 'int main()': a.cc:9:21: error: 'strlen' was not declared in this scope 9 | l = strlen(input); | ^~~~~~ a.cc:3:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include <math.h> +++ |+#include <cstring> 3 | int main(){
s959987430
p00139
C++
#include <iostream> #include <algorithm> using namespace std; int main() { int Tc; string s; while(cin>>Tc) { while(Tc--) { cin >> s; int const N = s.size(); bool NA = 0; bool isA; if(s[0] != '>') NA = 1; if(s[1] == '\'') { for(int i=2; i<(N-3)/2+2; i++) if(s[i]!='=') NA=1; if(s.substr(2, (N-3)/2) + "~" != s.substr(3+(N-3)/2)) NA = 1; if(s[(N-3)/2+2] != '#') NA = 1; isA = 1; } else if(s[1] == '^') { int cnt; for(cnt=2; cnt<N-2; cnt+=2) { if(!(s[cnt] == 'Q' && s[cnt+1] == '=')) NA = 1; } if(!(s[cnt] == '~' && s[cnt+1] == '~')) NA = 1; if(cnt+2 != N) NA = 1 isA = 0; } else { NA = 1; } if(NA) cout << "NA" << endl; else if(isA) cout << "A" << endl; else cout << "B" << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:27:30: error: expected ';' before 'isA' 27 | if(cnt+2 != N) NA = 1 | ^ | ; 28 | isA = 0; | ~~~
s178823101
p00139
C++
#include <iostream> #include <algorithm> #include <string> using namespace std; int main() { int Tc; string s; while(cin>>Tc) { while(Tc--) { cin >> s; int const N = s.size(); bool NA = 0; bool isA; if(s[0] != '>') NA = 1; if(s[1] == '\'') { for(int i=2; i<(N-3)/2+2; i++) if(s[i]!='=') NA=1; if(s.substr(2, (N-3)/2) + "~" != s.substr(3+(N-3)/2)) NA = 1; if(s[(N-3)/2+2] != '#') NA = 1; isA = 1; } else if(s[1] == '^') { int cnt; for(cnt=2; cnt<N-2; cnt+=2) { if(!(s[cnt] == 'Q' && s[cnt+1] == '=')) NA = 1; } if(!(s[cnt] == '~' && s[cnt+1] == '~')) NA = 1; if(cnt+2 != N) NA = 1 isA = 0; } else { NA = 1; } if(NA) cout << "NA" << endl; else if(isA) cout << "A" << endl; else cout << "B" << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:28:30: error: expected ';' before 'isA' 28 | if(cnt+2 != N) NA = 1 | ^ | ; 29 | isA = 0; | ~~~
s447625713
p00140
C
#include <bits/stdc++.h> using namespace std; int main(){ int n, src, dir = 1, dst, spc; cin >> n; for(int i=0;i<n;i++){ cin >> src >> dst; spc = 0; if(src<dst || (src>dst && src>=6))dir = 1; else dir = -1; int j=0; do{ if(src+j>9){ j=5-src; dir = -1; } if(spc++ != 0)cout << " "; cout << src+j; }while(src+(dir>0 ? j++ : j--)!=dst); if(i!=n-1)cout << endl; } return 0; }
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory 1 | #include <bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s300247453
p00140
C
#include<stdio.h> int main(){ int n,a,b,i; scanf("%d",&n); while(n-->0){ scanf("%d %d",&a,&b); if(a>=0&&5>=a){ if(b>a){ for(i=a;i<b;i++) printf("%d ",i); printf("%d\n",b); } else { for(i=a;i>b;i--) printf("%d ",i); printf("%d\n",b); } } else { if(b>5&&10>b&&b>a){ for(i=a;i<b;i++) printf("%d ",i); printf("%d\n",b); } else if(b>=0&&5>=b){ for(i=a;i<10;i++) printf("%d ",i); for(i=5;i>b;i--) printf("%d ",i); printf("%d\n",b); } else if(b>=6&&9>=b&&b<a){ for(i=a;i<10;i++) printf("%d ",i); for(i=5;i>0;i--) printf("%d ",i); for(i=0;i<b;i++) printf("%d ",i); printf("%d\n",b); } } return 0; }
main.c: In function 'main': main.c:45:1: error: expected declaration or statement at end of input 45 | } | ^
s283686932
p00140
C
#include <stdio.h> int main(void) { int datanum,datamax; int start,end; int i; scanf("%d",&datamax); for(datanum=0;datanum<datamax;datanum++) { scanf("%d %d",&start,&end); if(start<=5 && end<start) { for(i=start;i>=end;i--) { printf("%d",i); if(i>end)printf(" "); } } else if(start<=5 && end>start) { for(i=start;i<=end;i++) { printf("%d",i); if(i<end)printf(" "); } } else if(start<end) { for(i=start;i<end;i++) { printf("%d",i); if(i<end)printf(" "); } } else if(end<=5) { for(i=start;i<=9;i++) { printf("%d ",i); } for(i=5;i>=end;i--) { printf("%d",i); if(i>end)printf(" "); } } else { for(i=start;i<=9;i++) { printf("%d ",i); } printf("5 4 3 2 1 0 1 2 3 4 5 "); for(i=6;i<=end;i++) { printf("%d",i); if(i<end)printf(" "); } } } } return 0; }
main.c:45:9: error: expected identifier or '(' before 'return' 45 | return 0; | ^~~~~~ main.c:46:1: error: expected identifier or '(' before '}' token 46 | } | ^
s988174633
p00140
C
#include <stdio.h> int main(void) { int datanum,datamax; int start,end; int i; scanf("%d",&datamax); for(datanum=0;datanum<datamax;datanum++) { scanf("%d %d",&start,&end); if(start<=5 && end<start) { for(i=start;i>=end;i--) { printf("%d",i); if(i>end)printf(" "); } } else if(start<=5 && end>start) { for(i=start;i<=end;i++) { printf("%d",i); if(i<end)printf(" "); } } else if(start<end) { for(i=start;i<end;i++) { printf("%d",i); if(i<end)printf(" "); } } else if(end<=5) { for(i=start;i<=9;i++) { printf("%d ",i); } for(i=5;i>=end;i--) { printf("%d",i); if(i>end)printf(" "); } } else { for(i=start;i<=9;i++) { printf("%d ",i); } printf("5 4 3 2 1 0 1 2 3 4 5 "); for(i=6;i<=end;i++) { printf("%d",i); if(i<end)printf(" "); } } } } return 0; }
main.c:45:9: error: expected identifier or '(' before 'return' 45 | return 0; | ^~~~~~ main.c:46:1: error: expected identifier or '(' before '}' token 46 | } | ^
s899061354
p00140
C
#include <stdio.h> int main(void) { int datanum,datamax; int start,end; int i; scanf("%d",&datamax); for(datanum=0;datanum<datamax;datanum++) { scanf("%d %d",&start,&end); if(start<=5 && end<start) { for(i=start;i>=end;i--) { printf("%d",i); if(i>end)printf(" "); } } else if(start<=5 && end>start) { for(i=start;i<=end;i++) { printf("%d",i); if(i<end)printf(" "); } } else if(start<end) { for(i=start;i<end;i++) { printf("%d",i); if(i<end)printf(" "); } } else if(end<=5) { for(i=start;i<=9;i++) { printf("%d ",i); } for(i=5;i>=end;i--) { printf("%d",i); if(i>end)printf(" "); } } else { for(i=start;i<=9;i++) { printf("%d ",i); } printf("5 4 3 2 1 0 1 2 3 4 5 "); for(i=6;i<=end;i++) { printf("%d",i); if(i<end)printf(" "); } } } } return 0; }
main.c:45:9: error: expected identifier or '(' before 'return' 45 | return 0; | ^~~~~~ main.c:46:1: error: expected identifier or '(' before '}' token 46 | } | ^
s188267760
p00140
C
#include <Stdio.h> #include <math.h> int main(void) { int bus_stop[15] = {0,1,2,3,4,5,6,7,8,9,5,4,3,2,1}; int start, end, spin, n_spin; int num, i, j, idx1, idx2; scanf("%d", &num); while(num--) { scanf("%d %d", &start, &end); for(j = 0; j < 10; j++) { if(bus_stop[j] == start) { idx1 = j; } if(bus_stop[j] == end) { idx2 = j; } } spin = (idx1 + 1) + (15 - idx2); n_spin = fabs(idx2 - idx1) + 1; if(n_spin < spin) { if(start > end) { for(i = idx1; i >= idx2; i--) { printf("%d", bus_stop[i]); if(i == idx2) putchar('\n'); else putchar(' '); } } else if(start < end) { for(i = idx1; i <= idx2; i++) { printf("%d", bus_stop[i]); if(i == idx2) putchar('\n'); else putchar(' '); } } } else if(spin < n_spin) { for(i = idx1; i >= 0; i--) { printf("%d", bus_stop[i]); if(i == idx2) putchar('\n'); else putchar(' '); } for(i = 14; i >= idx2; i--) { printf("%d", bus_stop[i]); if(i == idx2) putchar('\n'); else putchar(' '); } } } return(0); }
main.c:1:10: fatal error: Stdio.h: No such file or directory 1 | #include <Stdio.h> | ^~~~~~~~~ compilation terminated.
s988198973
p00140
C++
#include <iostream> #include <cstdio> #include <algorithm> #include <cassert> #include <vector> #include <string> #include <cmath> #include <map> using namespace std; const int MAX= 10000100; #define loop(i,a,b) for(int i = a ; i < b ; i ++) #define rep(i,a) loop(i,0,a) #define all(a) (a).begin(),(a).end() #define ll long long int #define gcd(a,b) __gcd(a,b) int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);} int lcm(int a, int b) {return a*b / gcd(a, b);} #deefine N 15 int d[N] = {0, 1, 2, 3, 4, 5 ,6 ,7 ,8 ,9 ,5 ,4 ,3 ,2 ,1}; int main(void){ int n ; while(n--){ int a,b; cin>>a>>b; if(a<=5 && b < a){ a = 15 - a; } while(d[a] != b){ cout<<d[a]<<" "; a = (a + 1) % N; } cout<<d[a]<<endl; } }
a.cc:22:2: error: invalid preprocessing directive #deefine; did you mean #define? 22 | #deefine N 15 | ^~~~~~~ | define a.cc:23:7: error: 'N' was not declared in this scope 23 | int d[N] = {0, 1, 2, 3, 4, 5 ,6 ,7 ,8 ,9 ,5 ,4 ,3 ,2 ,1}; | ^ a.cc: In function 'int main()': a.cc:33:11: error: 'd' was not declared in this scope 33 | while(d[a] != b){ | ^ a.cc:35:21: error: 'N' was not declared in this scope 35 | a = (a + 1) % N; | ^ a.cc:37:11: error: 'd' was not declared in this scope 37 | cout<<d[a]<<endl; | ^
s322307748
p00140
C++
#include<stdio.h> int main(){ int n,s,f; int w; while(1){ scanf("%d",&n);if(n==0)break; for(int i=0;i<n;i++) scanf("%d %d",&s,&f); if(s<=5){ if(s<f){ for(int i=s;i<=f;i++) { if(i!=s)printf(" "); printf("%d",i); } } else if(s>f){ for(int i=s;i>=f;i--) { if(i!=s)printf(" "); printf("%d",i); } } if(s>5){ if(f>6){ for(int i=s;i<=f;i++) { if(i!=s)printf(" "); printf("%d",i); } } if(f<=5){ for(int i=s;i<=9;i++) { if(i!=s)printf(" "); printf("%d",i); } for(int i=5;i>=f;i--) { if(i!=5)printf(" "); printf("%d",i); } } } return 0; }
a.cc: In function 'int main()': a.cc:55:2: error: expected '}' at end of input 55 | } | ^ a.cc:8:9: note: to match this '{' 8 | while(1){ | ^ a.cc:55:2: error: expected '}' at end of input 55 | } | ^ a.cc:3:11: note: to match this '{' 3 | int main(){ | ^
s877082216
p00140
C++
import java.util.Scanner; import java.util.ArrayList; import java.util.Iterator; import java.util.Collections; import java.util.Comparator; class Main{ public static void main(String args[]){ Scanner in = new Scanner(System.in); int d[]={9,5,4,3,2,1,0,1,2,3,4,5,6,7,8,9}; int n = in.nextInt(); for(int i = 0; i < n; i++){ int s =in.nextInt(), e = in.nextInt(); ArrayList<String> al = new ArrayList<String>(); for(int j = 0; j < d.length; j++){ StringBuilder sb = new StringBuilder(); if(d[j] == s){ for(int k = j; k < d.length; k++){ if(k != j) sb.append(" "); sb.append((char)('0' + d[k])); if(d[k] == e){ al.add(sb.toString()); break; } } } } Collections.sort(al, new Comp()); System.out.println(al.get(0)); } } } class Comp implements Comparator<String>{ public int compare(String a, String b){ int l1 = a.length(), l2 = b.length(); if(l1 > l2) return 1; else if (l1 == l2) return 0; else return -1; } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.Scanner; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.util.ArrayList; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import java.util.Iterator; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: 'import' does not name a type 4 | import java.util.Collections; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:6:1: error: 'import' does not name a type 6 | import java.util.Comparator; | ^~~~~~ a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:9:15: error: expected ':' before 'static' 9 | public static void main(String args[]){ | ^~~~~~~ | : a.cc:9:33: error: 'String' has not been declared 9 | public static void main(String args[]){ | ^~~~~~ a.cc:35:2: error: expected ';' after class definition 35 | } | ^ | ; a.cc: In static member function 'static void Main::main(int*)': a.cc:10:17: error: 'Scanner' was not declared in this scope 10 | Scanner in = new Scanner(System.in); | ^~~~~~~ a.cc:14:25: error: 'in' was not declared in this scope; did you mean 'int'? 14 | int n = in.nextInt(); | ^~ | int a.cc:17:25: error: 'ArrayList' was not declared in this scope 17 | ArrayList<String> al = new ArrayList<String>(); | ^~~~~~~~~ a.cc:17:35: error: 'String' was not declared in this scope 17 | ArrayList<String> al = new ArrayList<String>(); | ^~~~~~ a.cc:17:43: error: 'al' was not declared in this scope 17 | ArrayList<String> al = new ArrayList<String>(); | ^~ a.cc:17:52: error: 'ArrayList' does not name a type 17 | ArrayList<String> al = new ArrayList<String>(); | ^~~~~~~~~ a.cc:17:70: error: expected primary-expression before ')' token 17 | ArrayList<String> al = new ArrayList<String>(); | ^ a.cc:18:46: error: request for member 'length' in 'd', which is of non-class type 'int [16]' 18 | for(int j = 0; j < d.length; j++){ | ^~~~~~ a.cc:19:33: error: 'StringBuilder' was not declared in this scope 19 | StringBuilder sb = new StringBuilder(); | ^~~~~~~~~~~~~ a.cc:21:62: error: request for member 'length' in 'd', which is of non-class type 'int [16]' 21 | for(int k = j; k < d.length; k++){ | ^~~~~~ a.cc:22:60: error: 'sb' was not declared in this scope; did you mean 's'? 22 | if(k != j) sb.append(" "); | ^~ | s a.cc:23:49: error: 'sb' was not declared in this scope; did you mean 's'? 23 | sb.append((char)('0' + d[k])); | ^~ | s a.cc:24:60: error: 'e' was not declared in this scope 24 | if(d[k] == e){ | ^ a.cc:31:25: error: 'Collections' was not declared in this scope 31 | Collections.sort(al, new Comp()); | ^~~~~~~~~~~ a.cc:31:50: error: expected type-specifier before 'Comp' 31 | Collections.sort(al, new Comp()); | ^~~~ a.cc:32:25: error: 'System' was not declared in this scope 32 | System.out.println(al.get(0)); | ^~~~~~ a.cc: At global scope: a.cc:37:23: error: expected initializer before 'Comparator' 37 | class Comp implements Comparator<String>{ | ^~~~~~~~~~
s389722728
p00140
C++
int main() { const int busstop[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; const int bussize = sizeof(busstop) / sizeof(int); int n; while (cin >> n) { while (n--) { int a, b; cin >> a >> b; int s = 0; for (; s < bussize; ++s) { if (busstop[s] == a) break; } vector<int> ans; for (int i = s; i < bussize; ++i) { ans.push_back(busstop[i]); if (busstop[i] == b) break; } if (1 <= a && a <= 5 && b < a) { vector<int> rev; for (int i = s; i >= 0; --i) { rev.push_back(busstop[i]); if (busstop[i] == b) break; } if (rev.size() < ans.size()) ans = rev; } for (int i = 0; i < ans.size()-1; ++i) cout << ans[i] << " "; cout << ans.back() << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:7:10: error: 'cin' was not declared in this scope 7 | while (cin >> n) { | ^~~ a.cc:18:7: error: 'vector' was not declared in this scope 18 | vector<int> ans; | ^~~~~~ a.cc:18:14: error: expected primary-expression before 'int' 18 | vector<int> ans; | ^~~ a.cc:20:9: error: 'ans' was not declared in this scope 20 | ans.push_back(busstop[i]); | ^~~ a.cc:26:16: error: expected primary-expression before 'int' 26 | vector<int> rev; | ^~~ a.cc:28:9: error: 'rev' was not declared in this scope 28 | rev.push_back(busstop[i]); | ^~~ a.cc:32:13: error: 'rev' was not declared in this scope 32 | if (rev.size() < ans.size()) | ^~~ a.cc:32:26: error: 'ans' was not declared in this scope 32 | if (rev.size() < ans.size()) | ^~~ a.cc:36:27: error: 'ans' was not declared in this scope 36 | for (int i = 0; i < ans.size()-1; ++i) | ^~~ a.cc:37:9: error: 'cout' was not declared in this scope 37 | cout << ans[i] << " "; | ^~~~ a.cc:38:7: error: 'cout' was not declared in this scope 38 | cout << ans.back() << endl; | ^~~~ a.cc:38:15: error: 'ans' was not declared in this scope 38 | cout << ans.back() << endl; | ^~~ a.cc:38:29: error: 'endl' was not declared in this scope 38 | cout << ans.back() << endl; | ^~~~
s114721271
p00140
C++
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; int num[]={0,1,2,3,4,5,6,7,8,9,5,4,3,2,1,0}; for(int i=0,x,y;i<n;i++){ cin>>x>>y; if(x<6&&y<6&&y-x>0){ cout<<num[x]; for(int j=x+1;j<=y;j++)cout<<" "<<num[j]; cout<<endl; } else if(x<6&&y<6){ cout<<num[15-x]; for(int j=16-x;j<16-y;j++)cout<<" "<<num[j]; cout<<endl; } else{ cout<<num[x]; for(int j=x+1;num[j-1]!=y;j++){ if(j==16)j=1; cout<<" "<<num[j]; } cout<<endl; } }
a.cc: In function 'int main()': a.cc:28:6: error: expected '}' at end of input 28 | } | ^ a.cc:4:1: note: to match this '{' 4 | { | ^
s432671545
p00140
C++
#include <iostream> using namespace std; int s[15] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1}; void disp(int a, int b){ for(int i = a+1;;i++){ cout << " " << s[i%15]; if(s[i%15] == b){cout << endl;return 0;} } } int main(){ int n, a, b;cin >> n; while(n--){ cin >> a >> b;cout << a; if(6 <= a && a <= 9)disp(a, b); else disp(0 < b-a ? a : 15-a, b); } return 0; }
a.cc: In function 'void disp(int, int)': a.cc:8:54: error: return-statement with a value, in function returning 'void' [-fpermissive] 8 | if(s[i%15] == b){cout << endl;return 0;} | ^
s731469887
p00140
C++
int main(){int s,t,d,n;scanf("%d",&n);while(n--){scanf("%d %d",&s,&t);d=(t<s&&s<6)? -1:1;while(t!=s){printf("%d ",s);s+=d;if(s>9){d=-1;s=5;}elseif(s<0){d=1;s=1;}}printf("%d\n",t);}return 0;}
a.cc: In function 'int main()': a.cc:1:24: error: 'scanf' was not declared in this scope 1 | int main(){int s,t,d,n;scanf("%d",&n);while(n--){scanf("%d %d",&s,&t);d=(t<s&&s<6)? -1:1;while(t!=s){printf("%d ",s);s+=d;if(s>9){d=-1;s=5;}elseif(s<0){d=1;s=1;}}printf("%d\n",t);}return 0;} | ^~~~~ a.cc:1:102: error: 'printf' was not declared in this scope 1 | int main(){int s,t,d,n;scanf("%d",&n);while(n--){scanf("%d %d",&s,&t);d=(t<s&&s<6)? -1:1;while(t!=s){printf("%d ",s);s+=d;if(s>9){d=-1;s=5;}elseif(s<0){d=1;s=1;}}printf("%d\n",t);}return 0;} | ^~~~~~ a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | int main(){int s,t,d,n;scanf("%d",&n);while(n--){scanf("%d %d",&s,&t);d=(t<s&&s<6)? -1:1;while(t!=s){printf("%d ",s);s+=d;if(s>9){d=-1;s=5;}elseif(s<0){d=1;s=1;}}printf("%d\n",t);}return 0;} a.cc:1:141: error: 'elseif' was not declared in this scope 1 | int main(){int s,t,d,n;scanf("%d",&n);while(n--){scanf("%d %d",&s,&t);d=(t<s&&s<6)? -1:1;while(t!=s){printf("%d ",s);s+=d;if(s>9){d=-1;s=5;}elseif(s<0){d=1;s=1;}}printf("%d\n",t);}return 0;} | ^~~~~~ a.cc:1:163: error: 'printf' was not declared in this scope 1 | int main(){int s,t,d,n;scanf("%d",&n);while(n--){scanf("%d %d",&s,&t);d=(t<s&&s<6)? -1:1;while(t!=s){printf("%d ",s);s+=d;if(s>9){d=-1;s=5;}elseif(s<0){d=1;s=1;}}printf("%d\n",t);}return 0;} | ^~~~~~ a.cc:1:163: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
s144031501
p00141
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import static java.lang.Integer.parseInt; /** * Spiral Pattern */ public class P0141 { static final int[][] DIR = { {-1, 0}, {0, 1}, {1, 0}, {0, -1}, }; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line; String[] words; while ((line = br.readLine()) != null && !line.isEmpty()) { int d = parseInt(line); for (int i = 0; i < d; i++) { int n = parseInt(br.readLine()); char[][] grid = new char[n][n]; int[] path = new int[n]; for (int j = 0; j < grid.length; j++) { Arrays.fill(grid[j], ' '); } for (int j = 0; j < n; j++) { path[j] = n - j; if (j > 0 && (j & 1) == 0) path[j]++; } int y = n, x = 0; for (int j = 0; j < path.length; j++) { for (int k = 0; k < path[j]; k++) { y += DIR[j % 4][0]; x += DIR[j % 4][1]; grid[y][x] = '#'; } } // for (int j = 0; j < grid.length; j++) { System.out.println(grid[j]); } if (i < d - 1) System.out.println(); } } } }
Main.java:11: error: class P0141 is public, should be declared in a file named P0141.java public class P0141 { ^ 1 error
s406305991
p00141
C
#include<stdio.h> #include<string.h> int N,s,i,j,mv[4][2]={{0,-1},{1,0},{0,1},{-1,0}},x,y,S,r; char M[105][105],E[3][30]={"#","##\n#","###\n# #\n# #"}; int c(int n){return 0<=n-1&&n+1<100;} int c2(int x,int y) { int i,m[5]={1,0,-1,0,1},c=0,c2=0; for(i=0;i<4;i++) { if(M[y+m[i]][x+m[i+1]]=='#')c++; if((mv[i][1]&&M[y+(mv[i][1]*2)][x]=='#')||(mv[i][0]&&M[y][x+(mv[i][0]*2)]=='#'))c2++; } return c>1?1:c2==4?2:0; } int main() { for(scanf("%d",&N);puts("")) { memset(M,0,sizeof(M)); scanf("%d",&S);s=S; if(s<4)puts(E[s-1]); else { for(i=0,x=0,y=s-1;;i=(i+1)%4) { for(;0<=y+mv[i][1]&&y+mv[i][1]<s&&0<=x+mv[i][0]&&x+mv[i][0]<s;y+=mv[i][1],x+=mv[i][0]) { if(c(x)&&c(y)&&(r=c2(x,y))) { if(r==2)M[y][x]='#'; goto e; } M[y][x]='#'; if((mv[i][1]&&M[y+(mv[i][1]*2)][x]=='#')||(mv[i][0]&&M[y][x+(mv[i][0]*2)]=='#')) break; } } e:for(i=0;i<S;i++,puts("")) for(j=0;j<S;j++) printf("%c",M[i][j]==0?' ':M[i][j]); } } return 0; }
main.c: In function 'main': main.c:21:36: error: expected ';' before ')' token 21 | for(scanf("%d",&N);puts("")) | ^ | ;
s236143090
p00141
C++
d = gets.to_i d.times do |i| n = gets.to_i a = Array.new(n).map { Array.new(n, 0) } a.map! {|r| [9] + r + [9]} a.unshift [9] * (n + 2) a<< [9] * (n + 2) y = n x = 1 dy = -1 dx = 0 loop do a[y][x] = 1 if a[y + dy][x + dx] == 0 a[y + dx][x - dy] = 9 y += dy x += dx else dy, dx = dx, -dy if a[y + dy][x + dx] == 0 a[y - dx][x + dy] = 9 y += dy x += dx else break end end end a[1..-2].each do |r| puts r.map {|x| x == 1 ? '#' : ' '} * '' end puts if i < d - 1 end
a.cc:29:7: error: too many decimal points in number 29 | a[1..-2].each do |r| | ^~~ a.cc:30:47: error: empty character constant 30 | puts r.map {|x| x == 1 ? '#' : ' '} * '' | ^~ a.cc:1:1: error: 'd' does not name a type 1 | d = gets.to_i | ^ a.cc:5:5: error: 'a' does not name a type 5 | a.map! {|r| [9] + r + [9]} | ^ a.cc:6:5: error: 'a' does not name a type 6 | a.unshift [9] * (n + 2) | ^ a.cc:30:47: error: expected unqualified-id before '\x0' 30 | puts r.map {|x| x == 1 ? '#' : ' '} * '' | ^~
s708768147
p00141
C++
d = gets.to_i d.times do |i| n = gets.to_i a = Array.new(n).map { Array.new(n, 0) } a.map! {|r| [9] + r + [9]} a.unshift [9] * (n + 2) a<< [9] * (n + 2) y = n x = 1 dy = -1 dx = 0 loop do a[y][x] = 1 if a[y + dy][x + dx] == 0 a[y + dx][x - dy] = 9 y += dy x += dx else dy, dx = dx, -dy if a[y + dy][x + dx] == 0 a[y - dx][x + dy] = 9 y += dy x += dx else break end end end a[1..-2].each do |r| puts r[1..-2].map {|x| x == 1 ? '#' : ' '} * '' end puts if i < d - 1 end
a.cc:29:7: error: too many decimal points in number 29 | a[1..-2].each do |r| | ^~~ a.cc:30:16: error: too many decimal points in number 30 | puts r[1..-2].map {|x| x == 1 ? '#' : ' '} * '' | ^~~ a.cc:30:54: error: empty character constant 30 | puts r[1..-2].map {|x| x == 1 ? '#' : ' '} * '' | ^~ a.cc:1:1: error: 'd' does not name a type 1 | d = gets.to_i | ^ a.cc:5:5: error: 'a' does not name a type 5 | a.map! {|r| [9] + r + [9]} | ^ a.cc:6:5: error: 'a' does not name a type 6 | a.unshift [9] * (n + 2) | ^ a.cc:30:54: error: expected unqualified-id before '\x0' 30 | puts r[1..-2].map {|x| x == 1 ? '#' : ' '} * '' | ^~
s780725581
p00141
C++
#include <iostream> #include <cstdio> #include <cstdlib> #include <queue> #include <stack> #include <vector> #include <algorithm> #include <string> #include <cstring> #include <cmath> #include <complex> #include <map> #include <climits> #include <sstream> using namespace std; #define reep(i,a,b) for(int i=(a);i<(b);++i) #define rep(i,n) reep((i),0,(n)) #define ALL(v) (v).begin(),(v).end() #define PB push_back #define EPS 1e-8 #define F first #define S second #define mkp make_pair static const double PI=6*asin(0.5); typedef long long ll; typedef complex<double> CP; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef vector<int> vint; static const int INF=1<<24; template <class T> void initvv(vector<vector<T> > &v,int a,int b, const T &t = T()){ v.assign(a,vector<T>(b,t)); } //v.erase(unique(v.begin(),v.end()),v.end()); int dx[]={-1,0,1,0}; int dy[]={0,1,0,-1}; int main(){ int n; cin>>n; rep(l,n){ if(i) cout<<endl; int m; cin>>m; // cout<<m<<endl; if(m==1){ cout<<"#\n"; continue; } if(m==2){ cout<<"##\n"; cout<<"# \n"; continue; } if(m==3){ /* ### # # # # */ cout<<"###\n"; cout<<"# #\n"; cout<<"# #\n"; // cout<<"\n"; continue; } if(m==4){ cout<<"####\n"; cout<<"# #\n"; cout<<"# #\n"; cout<<"# ##\n"; // cout<<endl; continue; } vector<vector<char> > vv; initvv(vv,m,m); rep(i,m){ rep(j,m) vv[i][j]=' '; } rep(i,m){ vv[0][i]='#'; vv[m-1][i]='#'; vv[i][m-1]='#'; vv[i][0]='#'; } vv[m-1][1]=' '; int x=m-1,y=2; int c=0; while(1){ // cout<<x<<" "<<y<<endl; if(vv[x+dx[c]*2][y+dy[c]*2]==' '){ x+=dx[c]; y+=dy[c]; vv[x][y]='#'; } else if(vv[x+2*dx[(c+1)%4]][y+2*dy[(c+1)%4]]==' '&&vv[x+dx[(c+1)%4+dx[(c+2)%4]]][y+dy[(c+1)%4]+dy[(c+2)%4]]==' '){ c++; c%=4; x+=dx[c]; y+=dy[c]; vv[x][y]='#'; } else{ break; } } /* ###### # # # ## # # # # # # # # #### */ rep(i,m){ rep(j,m){ cout<<vv[i][j]; } cout<<endl; } cout<<endl; } }
a.cc: In function 'int main()': a.cc:47:20: error: 'i' was not declared in this scope 47 | if(i) cout<<endl; | ^
s227032673
p00141
C++
#include <iostream> #include <string> using namespace std; int d; string map[105]; int n; void visit() { int dx[4] = {0,1,0,-1}; int dy[4] = {-1,0,1,0}; int sum, flg = 0; int x = 2,y = n; map[y][x] = ' '; int ab[4] = {2,2,2,2}; while(1) { sum = 0; while(1) { if(map[y+dy[flg]*2][x+dx[flg]*2] != '#' && map[y+dy[flg]][x+dx[flg]] != ' ' ) { flg++; // cout << sum << endl; break; } map[y+dy[flg]][x+dx[flg]] = ' '; y = y + dy[flg]; x = x + dx[flg]; sum++; } if(flg == 4) flg = 0; if(sum == 0) break; ab[0] = ab[1]; ab[1] = ab[2]; ab[2] = sum; if(ab[0] == 1 && ab[2] == 1 && ab[1] == 1) break; } } int main() { cin >> d; for(int l=0;l<d;l++) { cin >> n; if(n == 1) { cout << "#" <<endl ; if(l != d-1) cout << endl; continue; } for(int i=0;i<=n+1;i++){ map[i].resize(n+2); for(int j=0;j<=n+1;j++){ map[i][j] = '#'; if(i == 0 || j == 0 || i == n+1 || j == n+1) map[i][j] = '.'; } } visit(); for(int i=1;i<=n;i++){ for(int j=1;j<map[i].size()-1;j++) { cout << map[i][j]; } cout << endl; } if(l != d-1) cout << endl; } return 0 }
a.cc: In function 'int main()': a.cc:77:9: error: expected ';' before '}' token 77 | return 0 | ^ | ; 78 | } | ~
s168767529
p00141
C++
#include <iostream> #include <string> using namespace std; ?? int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1}; ?? int main(){ int d; cin >> d; for(int t = 0;t < d;t++){ if(t) cout << endl; char s[100][100]; int n; cin >> n; for(int i = 0;i < n;i++){ for(int j = 0;j < n;j++) s[i][j] = ' '; } int x = n - 1,y = 0,dir = 0; for(int k = 0;k < n;k++){ bool flag = false; while(1){ int nx = x + dx[dir],ny = y + dy[dir]; if(nx < 0 || nx >= n + 1 || ny < 0 || ny >= n + 1 || s[nx][ny] == '#') break; s[x][y] = '#'; flag = true; x = nx; y = ny; } if(x)x -= dx[dir]; if(y)y -= dy[dir]; if(!flag) break; dir = (dir + 1) % 4; } for(int i = 0;i < n;i++) { for(int j = 0;j < n;j++){ cout << s[i][j]; } cout << endl;} } } #include <iostream> #include <string> using namespace std; ?? int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1}; ?? int main(){ int d; cin >> d; for(int t = 0;t < d;t++){ if(t) cout << endl; char s[100][100]; int n; cin >> n; for(int i = 0;i < n;i++){ for(int j = 0;j < n;j++) s[i][j] = ' '; } int x = n - 1,y = 0,dir = 0; for(int k = 0;k < n;k++){ bool flag = false; while(1){ int nx = x + dx[dir],ny = y + dy[dir]; if(nx < 0 || nx >= n + 1 || ny < 0 || ny >= n + 1 || s[nx][ny] == '#') break; s[x][y] = '#'; flag = true; x = nx; y = ny; } if(x)x -= dx[dir]; if(y)y -= dy[dir]; if(!flag) break; dir = (dir + 1) % 4; } for(int i = 0;i < n;i++) { for(int j = 0;j < n;j++){ cout << s[i][j]; } cout << endl;} } }
a.cc:7:1: error: expected unqualified-id before '?' token 7 | ?? | ^ a.cc:9:22: error: expected unqualified-id before ',' token 9 | int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1}; | ^ a.cc:9:28: error: expected constructor, destructor, or type conversion before '=' token 9 | int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1}; | ^ a.cc:11:1: error: expected unqualified-id before '?' token 11 | ?? | ^ a.cc:87:1: error: expected unqualified-id before '?' token 87 | ?? | ^ a.cc:89:22: error: expected unqualified-id before ',' token 89 | int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1}; | ^ a.cc:89:28: error: expected constructor, destructor, or type conversion before '=' token 89 | int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1}; | ^ a.cc:91:1: error: expected unqualified-id before '?' token 91 | ?? | ^
s719229739
p00141
C++
#include <iostream> #include <string> #include <algorithm> #include <math.h> #include <vector> #include <set> using namespace std; typedef long long LL; static const double EPS = 1e-9; #define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i) #define REP(i,n) FOR(i,0,n) int nx,ny,nr; int dx[4] = {1,0,-1,0}; int dy[4] = {0,1,0,-1}; int a[100][100]; bool plot(int x, int y, int r, int n){ int count = 0; bool flag = true; if((x+2*dx[r]>=0&&x+2*dx[r]<n)&& y+2*dy[r]>=0&&y+2*dy[r]<n&&a[x+2*dx[r]][y+2*dy[r]]==1) return false; x+=dx[r]; y+=dy[r]; while((x>=0&&x<n)&&(y>=0&&y<n)){ if((x+2*dx[r]>=0&&x+2*dx[r]<n)&&y+2*dy[r]>=0&&y+2*dy[r]<n&&a[x+2*dx[r]][y+2*dy[r]]==1) flag = false; a[x][y] = 1; x+=dx[r]; y+=dy[r]; count++; if(!flag) break; } x-=dx[r];y-=dy[r]; nx=x; ny=y; nr=(r+1)%4; if(count<2) return false; return true; } int main(void){ int d; cin>>d; while(d--){ int n; cin>>n; memset(a,0,sizeof(a)); a[0][n-1]=1; nx=0; ny=n-1; nr=3; while(plot(nx,ny,nr,n)); REP(i,n){ REP(j,n) printf("%c",(a[j][i]==1)?'#':' '); cout << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:42:5: error: 'memset' was not declared in this scope 42 | memset(a,0,sizeof(a)); | ^~~~~~ a.cc:7:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 6 | #include <set> +++ |+#include <cstring> 7 |
s894289504
p00141
C++
ar MAP[104][104]; int nx,ny,vx=0,vy=-1; void rotate(){ //‰E‰ñ‚è‚ɉñ“]‚·‚é int tx=vx,ty=vy; vx=-ty;vy=tx; } int main(){ int s; //ƒ}ƒbƒv‚̍L‚³ int n; //ˆ—‚·‚éŒÂ” int t; //I—¹”»’è—p scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d",&s); memset(MAP,'#',104*104); for(int x=1;x<1+s+2;x++){ for(int y=1;y<1+s+2;y++){ MAP[x][y]=' '; } } nx=2,ny=s+1;t=0;vx=0;vy=-1; while(1){ MAP[nx][ny]='#'; if(MAP[nx+vx*2][ny+vy*2]=='#'){ if(t>0) break; t=2; rotate(); } else { t--; nx+=vx;ny+=vy; } } //•\ަ if(i!=0) puts(""); for(int y=2;y<1+s+1;y++){ for(int x=2;x<1+s+1;x++){ printf("%c",MAP[x][y]); } puts(""); } } return 0; }
a.cc:1:1: error: 'ar' does not name a type; did you mean 'char'? 1 | ar MAP[104][104]; | ^~ | char a.cc: In function 'int main()': a.cc:11:9: error: 'scanf' was not declared in this scope 11 | scanf("%d",&n); | ^~~~~ a.cc:14:24: error: 'MAP' was not declared in this scope 14 | memset(MAP,'#',104*104); | ^~~ a.cc:14:17: error: 'memset' was not declared in this scope 14 | memset(MAP,'#',104*104); | ^~~~~~ a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' +++ |+#include <cstring> 1 | ar MAP[104][104]; a.cc:33:26: error: 'puts' was not declared in this scope 33 | if(i!=0) puts(""); | ^~~~ a.cc:36:33: error: 'printf' was not declared in this scope 36 | printf("%c",MAP[x][y]); | ^~~~~~ a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | ar MAP[104][104]; a.cc:38:25: error: 'puts' was not declared in this scope 38 | puts(""); | ^~~~
s827415441
p00141
C++
#include <iostream> #include <algorithm> using namespace std; main(){ int n; char data[100][100]; int dx[] = {0, 1, 0, -1}; int dy[] = {-1, 0, 1, 0}; int t; while(cin >> t){ { for(int tc=0;tc<t;tc++){ cin >> n; if(tc != 0) cout << endl; if(n == 1){ cout << "#" << endl; f = false; continue; } int y = n-1; int x = 0; fill(data[0], data[100], ' '); data[y][x] = '#'; int d = 0; while(1){ int ty = y + dy[d]; int tx = x + dx[d]; if(ty<0 || ty>=n){ d = (d+1)%4; continue; } if(tx<0 || tx>=n){ d = (d+1)%4; continue; } if(data[ty][tx] == '#') break; int tty = ty + dy[d]; int ttx = tx + dx[d]; if((tty>=0 || tty<n) && (ttx>=0 || ttx<n)){ if(data[tty][ttx] == '#'){ d = (d+1)%4; continue; } } int cnt = 0; for(int i=0;i<4;i++){ int tty = ty + dy[i]; int ttx = tx + dx[i]; if(tty<0 || tty>=n) continue; if(ttx<0 || ttx>=n) continue; if(data[tty][ttx] == '#') cnt++; } if(cnt > 1) break; data[ty][tx] = '#'; y = ty; x = tx; } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ cout << data[i][j]; } cout << endl; } } } return 0; }
a.cc:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 6 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:19:9: error: 'f' was not declared in this scope 19 | f = false; | ^ a.cc:63:2: error: expected '}' at end of input 63 | } | ^ a.cc:6:7: note: to match this '{' 6 | main(){ | ^
s540334741
p00141
C++
import java.util.Scanner; public class Main { char[][] makeSpiral(int n){ char[][] pattern=new char[n][n]; int dir=0; int x=0,y=n-n%2; int[] dx={0,1,0,-1}; int[] dy={-1,0,1,0}; for(int i=0;i<n;++i){ for(int j=0;j<n;++j){ pattern[i][j]=' '; } } int notTurn=2; boolean end=false; while(!end){ if(n%2==0||notTurn<2){ x+=dx[dir]; y+=dy[dir]; } --notTurn; switch(dir){ case 0: if(y<=0||(y!=1&&pattern[x][y-2]=='*')){ if(notTurn>0){ end=true; } else{ dir=1; notTurn=2; } } break; case 1: if(x>=n-1||(x!=n-2&&pattern[x+2][y]=='*')){ if(notTurn>0){ end=true; } else{ dir=2; notTurn=2; } } break; case 2: if(y>=n-1||(y!=n-2&&pattern[x][y+2]=='*')){ if(notTurn>0){ end=true; } else{ dir=3; notTurn=2; } } break; case 3: if(x<=0||(x!=1&&pattern[x-2][y]=='*')){ if(notTurn>0){ end=true; } else{ dir=0; notTurn=2; } } break; } pattern[x][y]='*'; } return pattern; } void io(){ Scanner s=new Scanner(System.in); int setnum=s.nextInt(); for(int i=0;i<setnum;++i){ int n=s.nextInt(); char[][] pattern=makeSpiral(n); if(i>0)System.out.println(); for(int y=0;y<n;++y){ for(int x=0;x<n;++x){ System.out.print(pattern[x][y]); } System.out.println(); } } s.close(); } public static void main(String[] args) { new Main().io(); } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.Scanner; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: expected unqualified-id before 'public' 4 | public class Main { | ^~~~~~
s970003937
p00141
C++
#include<queue> #include<map> #include<cstring> using namespace std; #define fr first #define sc second #define INF 100 typedef pair<int,int>Pt; int main(){ int d,n,dx[]={-1,0,1,0},dy[]={0,1,0,-1}; char mas[101][101]; //上右下左 bool ok = false; cin >> d; while(d--){ if(ok) cout << endl; memset(mas,' ',sizeof(mas)); cin >> n; for(int i=0,x=n-1,MUKI=0,y=0;i<n;i++,x+=dx[MUKI],y+=dy[MUKI]) mas[x][y] = '#'; for(int i=0,cnt=n,x=0,y=0,MUKI=1;i<n-1;i++,MUKI=(MUKI+1)%4){ for(int j=0;j<cnt;j++,x+=dx[MUKI],y+=dy[MUKI]) mas[x][y] = '#'; x-=dx[MUKI],y-=dy[MUKI]; if(i%2==1)cnt-=2; } for(int i=0;i<n;i++){ for(int j=0;j<n;j++) cout << mas[i][j]; cout << endl; } ok = true; } }
a.cc: In function 'int main()': a.cc:13:3: error: 'cin' was not declared in this scope 13 | cin >> d; | ^~~ a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 3 | #include<cstring> +++ |+#include <iostream> 4 | using namespace std; a.cc:15:12: error: 'cout' was not declared in this scope 15 | if(ok) cout << endl; | ^~~~ a.cc:15:12: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:15:20: error: 'endl' was not declared in this scope 15 | if(ok) cout << endl; | ^~~~ a.cc:4:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 3 | #include<cstring> +++ |+#include <ostream> 4 | using namespace std; a.cc:25:28: error: 'cout' was not declared in this scope 25 | for(int j=0;j<n;j++) cout << mas[i][j]; | ^~~~ a.cc:25:28: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:26:7: error: 'cout' was not declared in this scope 26 | cout << endl; | ^~~~ a.cc:26:7: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:26:15: error: 'endl' was not declared in this scope 26 | cout << endl; | ^~~~ a.cc:26:15: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
s446672591
p00141
C++
#include<iostream> using namespace std; char a[102][102]; int dx[]={ 0,1,0,-1}; int dy[]={-1,0,1,0}; int main(){ bool fst=true; int n; cin>>n; while(n--){ memset(a,' ',sizeof(a)); int m,y,x,dir; cin>>m; y=m;x=1;dir=0; a[y][x]='#'; while(1){ for(int i=0;i<m-1;i++){ if(a[y+2*dy[dir]][x+2*dx[dir]]=='#')break; y+=dy[dir]; x+=dx[dir]; a[y][x]='#'; } dir=(dir+1)%4; if(a[y+2*dy[dir]][x+2*dx[dir]]=='#')break; if(a[y-1][x-1]=='#'||a[y-1][x+1]=='#'||a[y+1][x-1]=='#'||a[y+1][x+1]=='#')break; } for(int i=1;i<=m;i++){ for(int j=1;j<=m;j++)cout<<a[i][j]; cout<<endl; } if(!fst)cout<<endl; fst=false; } return 0; }
a.cc: In function 'int main()': a.cc:14:17: error: 'memset' was not declared in this scope 14 | memset(a,' ',sizeof(a)); | ^~~~~~ a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include<iostream> +++ |+#include <cstring> 2 | using namespace std;
s061789909
p00141
C++
#include <iostream> #define rep(i,n) for(int i=0;i<(int)(n);i++) const int INF = 10000000; using namespace std; int main() { char b[100][100]; int n, d, dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1}; cin >> d; rep(t, d) { memset(b, ' ', sizeof(b)); cin >> n; rep(i, n) b[0][i]='#'; int x=0, y=0, nn = n, direct=0; while (1) { for (int i=0; i<nn; i++) { b[x][y] = '#'; x+=dx[direct]; y+=dy[direct]; } x-=dx[direct]; y-=dy[direct]; direct++; direct%=4; if (n%2==0 && nn<=2) break; for (int i=0; i<nn; i++) { b[x][y] = '#'; x+=dx[direct]; y+=dy[direct]; } x-=dx[direct]; y-=dy[direct]; direct++; direct%=4; nn-=2; if (nn<=1) break; } rep(y, n) { rep(x, n) cout << b[x][y]; cout << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:14:17: error: 'memset' was not declared in this scope 14 | memset(b, ' ', sizeof(b)); | ^~~~~~ a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 |
s398658395
p00142
C++
#include <iostream> #include <set> using namespace std; const int MAX = 10001; int main(void){ int square[MAX]; for (int i=1; i < MAX+1; i++) square[i-1] = i*i; while (true){ int n; cin >> n; if (n == 0) break; int m = (n-1)/2; int raw_mod[n-1],mod[m]; for(int i = 0; i < n-1; i++) raw_mod[i] = square[i]%n; sort(raw_mod,raw_mod+n-1); mod[0] = raw_mod[0]; int size; for(int i = 1, j = 1; i < n-1; i++){ if (mod[j-1] != raw_mod[i]){ mod[j] = raw_mod[i]; j++; } size = j; } int hist[MAX] = {}; for (int i = 0; i < size-1; i++) for (int j = i+1; j < size; j++){ int tmp1 = mod[i]-mod[j]; if (tmp1 < 0) tmp1 += n; if (tmp1 > m) tmp1 = n-tmp1; int tmp2 = mod[j]-mod[i]; if (tmp2 < 0) tmp2 += n; if (tmp2 > m) tmp2 = n-tmp2; hist[tmp1-1] += 1; hist[tmp2-1] += 1; } for(int i = 0; i < m; i++) cout << hist[i] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:19:9: error: 'sort' was not declared in this scope; did you mean 'short'? 19 | sort(raw_mod,raw_mod+n-1); | ^~~~ | short
s137272820
p00142
C++
using System.Linq; using System.Collections.Generic; using System; public class Hello { public static void Main() { while (true) { var n = int.Parse(Console.ReadLine().Trim()); if (n == 0) break; var n2 = (n - 1) / 2; var w1 = new List<int>(); for (int i = 1; i < n; i++) w1.Add(i * i % n); var w2 = w1.Distinct().ToArray(); var ret = new int[n2]; for (int i = 0; i < w2.Length; i++) for (int j = 0; j < w2.Length; j++) if (i != j) { var z = w2[i] - w2[j]; if (z < 0) z += n; if (z > n2) z = n - z; ret[z-1]++; } foreach (var x in ret) Console.WriteLine(x); } } }
a.cc:1:7: error: expected nested-name-specifier before 'System' 1 | using System.Linq; | ^~~~~~ a.cc:2:7: error: expected nested-name-specifier before 'System' 2 | using System.Collections.Generic; | ^~~~~~ a.cc:3:7: error: expected nested-name-specifier before 'System' 3 | using System; | ^~~~~~ a.cc:5:1: error: expected unqualified-id before 'public' 5 | public class Hello | ^~~~~~
s404028511
p00142
C++
g#include <iostream> #include <set> #include <cstring> using namespace std; int n; int main() { while (cin >> n, n != 0) { set<int> mod; for (int i = 1; i < n; i++) mod.insert( (i*i) % n ); int count[(n-1)/2+1]; memset(count, 0, sizeof(count)); for (set<int>::iterator si = mod.begin(); si != mod.end(); si++) { for (set<int>::iterator sj = mod.begin(); sj != mod.end(); sj++) { if (*si == *sj) continue; int dif = *si - *sj; if (dif < 0) dif += n; if (dif > (n-1)/2) dif = n - dif; count[dif]++; } } for (int i = 1; i <= (n-1)/2; i++) cout << count[i] << endl; } return 0; }
a.cc:1:2: error: stray '#' in program 1 | g#include <iostream> | ^ a.cc:1:1: error: 'g' does not name a type 1 | g#include <iostream> | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/bits/stl_tree.h:63, from /usr/include/c++/14/set:62, from a.cc:2: /usr/include/c++/14/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_tr
s137805844
p00142
C++
#include <set> #include <cstdio> int i,n,v[9999];main(){for(;scanf("%d",&n),n;){std::set<int>t;for(i=1;i<n;i++)v[i]=0,t.insert(i*i%n);for(auto s=t.begin(),S;s!=t.end();s++)for(S=s;++S!=t.end();v[i>n/2?n-i:i]+=2)i=*S-*s;for(i=1;i<=n/2;i++)printf("%d\n",v[i]);}}
a.cc:3:17: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 3 | int i,n,v[9999];main(){for(;scanf("%d",&n),n;){std::set<int>t;for(i=1;i<n;i++)v[i]=0,t.insert(i*i%n);for(auto s=t.begin(),S;s!=t.end();s++)for(S=s;++S!=t.end();v[i>n/2?n-i:i]+=2)i=*S-*s;for(i=1;i<=n/2;i++)printf("%d\n",v[i]);}} | ^~~~ a.cc: In function 'int main()': a.cc:3:106: error: declaration of 'auto S' has no initializer 3 | int i,n,v[9999];main(){for(;scanf("%d",&n),n;){std::set<int>t;for(i=1;i<n;i++)v[i]=0,t.insert(i*i%n);for(auto s=t.begin(),S;s!=t.end();s++)for(S=s;++S!=t.end();v[i>n/2?n-i:i]+=2)i=*S-*s;for(i=1;i<=n/2;i++)printf("%d\n",v[i]);}} | ^~~~
s013121992
p00142
C++
#include <set> #include <iostream> int i,n,v[9999];main(){for(;cin>>n,n;){std::set<int>t;for(i=1;i<n;i++)v[i]=0,t.insert(i*i%n);for(std::set<int>::iterator s=t.begin(),S=s,T=t.end();s!=T;S=++s)for(;++S!=T;v[i>n/2?n-i:i]+=2)i=*S-*s;for(i=0;i<n/2;)cout<<v[++i]<<endl;}}
a.cc:3:17: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 3 | int i,n,v[9999];main(){for(;cin>>n,n;){std::set<int>t;for(i=1;i<n;i++)v[i]=0,t.insert(i*i%n);for(std::set<int>::iterator s=t.begin(),S=s,T=t.end();s!=T;S=++s)for(;++S!=T;v[i>n/2?n-i:i]+=2)i=*S-*s;for(i=0;i<n/2;)cout<<v[++i]<<endl;}} | ^~~~ a.cc: In function 'int main()': a.cc:3:29: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 3 | int i,n,v[9999];main(){for(;cin>>n,n;){std::set<int>t;for(i=1;i<n;i++)v[i]=0,t.insert(i*i%n);for(std::set<int>::iterator s=t.begin(),S=s,T=t.end();s!=T;S=++s)for(;++S!=T;v[i>n/2?n-i:i]+=2)i=*S-*s;for(i=0;i<n/2;)cout<<v[++i]<<endl;}} | ^~~ | std::cin In file included from a.cc:2: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:3:212: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 3 | int i,n,v[9999];main(){for(;cin>>n,n;){std::set<int>t;for(i=1;i<n;i++)v[i]=0,t.insert(i*i%n);for(std::set<int>::iterator s=t.begin(),S=s,T=t.end();s!=T;S=++s)for(;++S!=T;v[i>n/2?n-i:i]+=2)i=*S-*s;for(i=0;i<n/2;)cout<<v[++i]<<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:3:226: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 3 | int i,n,v[9999];main(){for(;cin>>n,n;){std::set<int>t;for(i=1;i<n;i++)v[i]=0,t.insert(i*i%n);for(std::set<int>::iterator s=t.begin(),S=s,T=t.end();s!=T;S=++s)for(;++S!=T;v[i>n/2?n-i:i]+=2)i=*S-*s;for(i=0;i<n/2;)cout<<v[++i]<<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) | ^~~~
s982968051
p00142
C++
#include <iostream> #include <cmath> #include <vector> #include <cstring> using namespace std; typedef pair<int,int> P; int n; int main(){ while(cin >> n ,n){ int ans[(n-1)/2]; memset(ans,0,sizeof(ans)); vector<int> v; vector<int> nv; int nn = n; for(int i = 1 ; i < nn ; i++){ v.push_back(i*i%n); } sort(v.begin(),v.end()); for(int i = 1 ; i < nn ; i++){ if(v[i] != v[i-1]){ nv.push_back(v[i-1]); } } for(int i = 0 ; i < nv.size(); i++){ for(int j = 0 ; j < nv.size() ; j++){ if(i == j) continue; int res = nv[i]-nv[j]; if(res < 0){ res += nn; } if(res > (nn-1)/2){ res = nn - res; } ans[res-1]++; } } int i; for(i = 0 ; i < (n-1)/2 ; i++){ cout << ans[i] << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:21:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'? 21 | sort(v.begin(),v.end()); | ^~~~ | sqrt
s174080278
p00142
C++
#include<iostream> #include<sstream> #include<map> #include<vector> #include<string> #include<algorithm> using namespace std; int main() { int n; for(;cin>>n,n;) { map<int,bool>hash; vector<int> data; for(int i=1;i<n;i++) { if(hash.count(i*i%n)==0) { hash[i*i%n]=true; data.push_back(i*i%n); } } int ans[(n-1)/2+2]; memset(ans,0,sizeof(ans)); for(int i=0;i<data.size()-1;i++) for(int j=i+1;j<data.size();j++) { int tmp=data[i]-data[j]; if(tmp<0) tmp+=n; if(tmp>(n-1)/2) tmp=n-tmp; ans[tmp]++; tmp=data[j]-data[i]; if(tmp<0) tmp+=n; if(tmp>(n-1)/2) tmp=n-tmp; ans[tmp]++; } for(int i=1;i<=(n-1)/2;i++) cout<<ans[i]<<endl; } }
a.cc: In function 'int main()': a.cc:26:7: error: 'memset' was not declared in this scope 26 | memset(ans,0,sizeof(ans)); | ^~~~~~ a.cc:7:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 6 | #include<algorithm> +++ |+#include <cstring> 7 | using namespace std;
s286093643
p00143
Java
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); int N=in.nextInt(); while(N-->0) { double xp1=in.nextDouble(),yp1=in.nextDouble(); double xp2=in.nextDouble(),yp2=in.nextDouble(); double xp3=in.nextDouble(),yp3=in.nextDouble(); double xk=in.nextDouble(),yk=in.nextDouble(); double xs=in.nextDouble(),ys=in.nextDouble(); int k=0; if(judge(xp1,yp1,xp2,yp2,xk,yk,xs,ys))//壁と交差する k++; if(judge(xp2,yp2,xp3,yp3,xk,yk,xs,ys)) k++; if(judge(xp3,yp3,xp1,yp1,xk,yk,xs,ys)) k++; System.out.println(kabe==1 ? "OK":"NG"); } } static boolean judge(double x1,double y1,double x2,double y2,double x3,double y3,double x4,double y4) { double jc1=(x1-x2)*(y3-y1)+(y1-y2)*(x1-x3); double jd1=(x1-x2)*(y4-y1)+(y1-y2)*(x1-x4); double jc2=(x3-x4)*(y1-y3)+(y3-y4)*(x3-x1); double jd2=(x3-x4)*(y2-y3)+(y3-y4)*(x3-x2); return jc1*jd1<0 && jc2*jd2<0; } }
Main.java:22: error: cannot find symbol System.out.println(kabe==1 ? "OK":"NG"); ^ symbol: variable kabe location: class Main 1 error
s341987857
p00143
C++
#include <stdio.h> #include <math.h> int main(void){ int n; cin >> n; rep(i,n) { int count = 0; double x[8],y[8],a,b,c,d,p,q,det; //入力を多少簡略化 for(int i=0;i<8;i++) { printf("x%d =? ",i+1); scanf("%lf" ,&x[i]); printf("y%d =? ",i+1); scanf("%lf" ,&y[i]); } rep(j,3) { //(x1,y1)(x2,y2)を結ぶax+by=p の係数 a = y[j]-y[j+1]; b = x[j+1]-x[j]; p = x[j+1]*y[j]-x[j]*y[j+1]; //(x3,y3)(x4,y4)を結ぶcx+dy=q の係数 c = y[6]-y[7]; d = x[7]-x[6]; q = x[7]*y[6]-x[6]*y[7]; //係数についての行列式 det = a*d-c*b; //det=0で解は存在しない(この問題については2線分は同一直線上にないから) if(fabs(det) < 0.00001){ } else { ansx = (d*p - b*q)/det; ansy = (-c*p + a*q)/det; //ansxがどちらの線分のx座標範囲にも含まれるかを判定 if((x[0] - ansx)*(x[1] - ansx) <= 0.00001 && (x[6] - ansx)*(x[7] - ansx) <= 0.00001 ) { count++; } } } if(count == 1) cout << "OK" << endl; else cout << "NG" << endl; } }
a.cc: In function 'int main()': a.cc:6:5: error: 'cin' was not declared in this scope; did you mean 'sin'? 6 | cin >> n; | ^~~ | sin a.cc:7:9: error: 'i' was not declared in this scope 7 | rep(i,n) { | ^ a.cc:7:5: error: 'rep' was not declared in this scope; did you mean 'frexp'? 7 | rep(i,n) { | ^~~ | frexp
s772042849
p00143
C++
#include <iostream> #include <stdio.h> #include <fstream> #include <algorithm> #include <string> #include <list> #include <map> #include <set> #include <queue> #include <stack> #include <vector> #include <limits.h> #include <math.h> #define rep(i,n) for (int i = 0; (i) < (n); ++ (i)) using namespace std; int main(void){ int n; cin >> n; rep(i,n) { int count = 0; double x[8],y[8],a,b,c,d,p,q,det; //入力を多少簡略化 for(int i=0;i<8;i++) { cin >> x[i] >> y[i]; } rep(j,3) { //(x1,y1)(x2,y2)を結ぶax+by=p の係数 a = y[j]-y[j+1]; b = x[j+1]-x[j]; p = x[j+1]*y[j]-x[j]*y[j+1]; //(x3,y3)(x4,y4)を結ぶcx+dy=q の係数 c = y[6]-y[7]; d = x[7]-x[6]; q = x[7]*y[6]-x[6]*y[7]; //係数についての行列式 det = a*d-c*b; //det=0で解は存在しない(この問題については2線分は同一直線上にないから) if(fabs(det) < 0.00001){ } else { ansx = (d*p - b*q)/det; ansy = (-c*p + a*q)/det; //ansxがどちらの線分のx座標範囲にも含まれるかを判定 if((x[0] - ansx)*(x[1] - ansx) <= 0.00001 && (x[6] - ansx)*(x[7] - ansx) <= 0.00001 ) { count++; } } } if(count == 1) cout << "YES" << endl; else cout << "NO" << endl; } }
a.cc: In function 'int main()': a.cc:39:17: error: 'ansx' was not declared in this scope 39 | ansx = (d*p - b*q)/det; | ^~~~ a.cc:40:17: error: 'ansy' was not declared in this scope 40 | ansy = (-c*p + a*q)/det; | ^~~~
s009454604
p00143
C++
#include <iostream> #include <stdio.h> #include <fstream> #include <algorithm> #include <string> #include <list> #include <map> #include <set> #include <queue> #include <stack> #include <vector> #include <limits.h> #include <math.h> #define rep(i,n) for (int i = 0; (i) < (n); ++ (i)) using namespace std; int main(void){ int n; cin >> n; rep(i,n) { int count = 0; double x[8],y[8],a,b,c,d,p,q,det; //入力を多少簡略化 for(int k=0;k<8;k++) { cin >> x[k] >> y[k]; } rep(j,3) { //(x1,y1)(x2,y2)を結ぶax+by=p の係数 a = y[j]-y[j+1]; b = x[j+1]-x[j]; p = x[j+1]*y[j]-x[j]*y[j+1]; //(x3,y3)(x4,y4)を結ぶcx+dy=q の係数 c = y[6]-y[7]; d = x[7]-x[6]; q = x[7]*y[6]-x[6]*y[7]; //係数についての行列式 det = a*d-c*b; //det=0で解は存在しない(この問題については2線分は同一直線上にないから) if(fabs(det) < 0.00001){ } else { ansx = (d*p - b*q)/det; ansy = (-c*p + a*q)/det; //ansxがどちらの線分のx座標範囲にも含まれるかを判定 if((x[0] - ansx)*(x[1] - ansx) <= 0.00001 && (x[6] - ansx)*(x[7] - ansx) <= 0.00001 ) { count++; } } } if(count == 1) cout << "OK" << endl; else cout << "NG" << endl; } }
a.cc: In function 'int main()': a.cc:39:17: error: 'ansx' was not declared in this scope 39 | ansx = (d*p - b*q)/det; | ^~~~ a.cc:40:17: error: 'ansy' was not declared in this scope 40 | ansy = (-c*p + a*q)/det; | ^~~~
s577823723
p00143
C++
#include <iostream> #include <stdio.h> #include <fstream> #include <algorithm> #include <string> #include <list> #include <map> #include <set> #include <queue> #include <stack> #include <vector> #include <limits.h> #include <math.h> #define rep(i,n) for (int i = 0; (i) < (n); ++ (i)) #define EPS 1e-10 using namespace std; int main(void){ int n; cin >> n; rep(i,n) { int count = 0; double x[5],y[5],a,b,c,d,p,q,det,ansx; //入力を多少簡略化 for(int k=0;k<5;k++) { cin >> x[k] >> y[k]; } rep(j,3) { //(x1,y1)(x2,y2)を結ぶax+by=p の係数 if(j != 2) { a = y[j]-y[j+1]; b = x[j+1]-x[j]; p = x[j+1]*y[j]-x[j]*y[j+1]; //(x3,y3)(x4,y4)を結ぶcx+dy=q の係数 c = y[3]-y[4]; d = x[4]-x[3]; q = x[4]*y[3]-x[3]*y[4]; //係数についての行列式 det = a*d-c*b; //det=0で解は存在しない(この問題については2線分は同一直線上にないから if(fabs(det) > EPS){ ansx = (d*p - b*q)/det; ansy = (-c*p + a*q)/det; //ansxがどちらの線分のx座標範囲にも含まれるかを判定 if((x[j] - ansx)*(x[j+1] - ansx) <= EPS && (x[3] - ansx)*(x[4] - ansx) <= EPS ) { count++; } } } else { a = y[j]-y[0]; b = x[0]-x[j]; p = x[0]*y[j]-x[j]*y[0]; //(x3,y3)(x4,y4)を結ぶcx+dy=q の係数 c = y[3]-y[4]; d = x[4]-x[3]; q = x[4]*y[3]-x[3]*y[4]; //係数についての行列式 det = a*d-c*b; //det=0で解は存在しない(この問題については2線分は同一直線上にないから if(fabs(det) > EPS){ ansx = (d*p - b*q)/det; //ansxがどちらの線分のx座標範囲にも含まれるかを判定 if((x[j] - ansx)*(x[0] - ansx) <= EPS && (x[3] - ansx)*(x[4] - ansx) <= EPS ) { count++; } } } } if(count == 1) cout << "OK" << endl; else cout << "NG" << endl; } }
a.cc: In function 'int main()': a.cc:41:21: error: 'ansy' was not declared in this scope; did you mean 'ansx'? 41 | ansy = (-c*p + a*q)/det; | ^~~~ | ansx
s952153956
p00143
C++
include <iostream> #include <stdio.h> #include <fstream> #include <algorithm> #include <string> #include <list> #include <map> #include <set> #include <queue> #include <stack> #include <vector> #include <limits.h> #include <math.h> #define rep(i,n) for (int i = 0; (i) < (n); ++ (i)) #define EPS 1e-10 using namespace std; int main(void){ int n; cin >> n; rep(i,n) { int count = 0; double x[5],y[5],a,b,c,d,p,q,det,ansx; for(int k=0;k<5;k++) { cin >> x[k] >> y[k]; } rep(j,3) { if(j != 2) { a = y[j]-y[j+1]; b = x[j+1]-x[j]; p = x[j+1]*y[j]-x[j]*y[j+1]; c = y[3]-y[4]; d = x[4]-x[3]; q = x[4]*y[3]-x[3]*y[4]; //係数についての行列式 det = a*d-c*b; //det=0で解は存在しない(この問題については2線分は同一直線上にないから if(fabs(det) > EPS){ ansx = (d*p - b*q)/det; if((x[j] - ansx)*(x[j+1] - ansx) <= EPS && (x[3] - ansx)*(x[4] - ansx) <= EPS && fabs(ansx - x[j]) > EPS && fabs(ansx - x[j+1]) > EPS ) { count++; } } } else { a = y[j]-y[0]; b = x[0]-x[j]; p = x[0]*y[j]-x[j]*y[0]; c = y[3]-y[4]; d = x[4]-x[3]; q = x[4]*y[3]-x[3]*y[4]; //係数についての行列式 det = a*d-c*b; if(fabs(det) > EPS){ ansx = (d*p - b*q)/det; if((x[j] - ansx)*(x[0] - ansx) <= EPS && (x[3] - ansx)*(x[4] - ansx) <= EPS && fabs(ansx - x[j]) > EPS && fabs(ansx - x[0]) > EPS ) { count++; } } } } if(count == 1) cout << "OK" << endl; else cout << "NG" << endl; } }
a.cc:1:1: error: 'include' does not name a type 1 | include <iostream> | ^~~~~~~ In file included from /usr/include/wchar.h:53, from /usr/include/c++/14/cwchar:44, from /usr/include/c++/14/bits/postypes.h:40, from /usr/include/c++/14/iosfwd:42, from /usr/include/c++/14/ios:40, from /usr/include/c++/14/istream:40, from /usr/include/c++/14/fstream:40, from a.cc:3: /usr/include/x86_64-linux-gnu/bits/types/mbstate_t.h:6:9: error: '__mbstate_t' does not name a type 6 | typedef __mbstate_t mbstate_t; | ^~~~~~~~~~~ /usr/include/wchar.h:104:59: error: 'size_t' has not been declared 104 | const wchar_t *__restrict __src, size_t __n) | ^~~~~~ /usr/include/wchar.h:109:8: error: 'size_t' does not name a type 109 | extern size_t wcslcpy (wchar_t *__restrict __dest, | ^~~~~~ /usr/include/wchar.h:61:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 60 | # include <bits/types/locale_t.h> +++ |+#include <cstddef> 61 | #endif /usr/include/wchar.h:115:8: error: 'size_t' does not name a type 115 | extern size_t wcslcat (wchar_t *__restrict __dest, | ^~~~~~ /usr/include/wchar.h:115:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/wchar.h:126:59: error: 'size_t' has not been declared 126 | const wchar_t *__restrict __src, size_t __n) | ^~~~~~ /usr/include/wchar.h:133:63: error: 'size_t' has not been declared 133 | extern int wcsncmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n) | ^~~~~~ /usr/include/wchar.h:142:25: error: 'size_t' has not been declared 142 | size_t __n) __THROW; | ^~~~~~ /usr/include/wchar.h:150:27: error: 'size_t' has not been declared 150 | size_t __n, locale_t __loc) __THROW; | ^~~~~~ /usr/include/wchar.h:159:8: error: 'size_t' does not name a type 159 | extern size_t wcsxfrm (wchar_t *__restrict __s1, | ^~~~~~ /usr/include/wchar.h:159:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/wchar.h:174:8: error: 'size_t' does not name a type 174 | extern size_t wcsxfrm_l (wchar_t *__s1, const wchar_t *__s2, | ^~~~~~ /usr/include/wchar.h:174:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/wchar.h:212:8: error: 'size_t' does not name a type 212 | extern size_t wcscspn (const wchar_t *__wcs, const wchar_t *__reject) | ^~~~~~ /usr/include/wchar.h:212:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/wchar.h:216:8: error: 'size_t' does not name a type 216 | extern size_t wcsspn (const wchar_t *__wcs, const wchar_t *__accept) | ^~~~~~ /usr/include/wchar.h:216:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/wchar.h:247:8: error: 'size_t' does not name a type 247 | extern size_t wcslen (const wchar_t *__s) __THROW __attribute_pure__; | ^~~~~~ /usr/include/wchar.h:247:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/wchar.h:265:8: error: 'size_t' does not name a type 265 | extern size_t wcsnlen (const wchar_t *__s, size_t __maxlen) | ^~~~~~ /usr/include/wchar.h:265:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/wchar.h:272:59: error: 'size_t' has not been declared 272 | extern "C++" wchar_t *wmemchr (wchar_t *__s, wchar_t __c, size_t __n) | ^~~~~~ /usr/include/wchar.h:275:38: error: 'size_t' has not been declared 275 | size_t __n) | ^~~~~~ /usr/include/wchar.h:283:63: error: 'size_t' has not been declared 283 | extern int wmemcmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n) | ^~~~~~ /usr/include/wchar.h:288:58: error: 'size_t' has not been declared 288 | const wchar_t *__restrict __s2, size_t __n) __THROW; | ^~~~~~ /usr/include/wchar.h:292:63: error: 'size_t' has not been declared 292 | extern wchar_t *wmemmove (wchar_t *__s1, const wchar_t *__s2, size_t __n) | ^~~~~~ /usr/include/wchar.h:296:53: error: 'size_t' has not been declared 296 | extern wchar_t *wmemset (wchar_t *__s, wchar_t __c, size_t __n) __THROW; | ^~~~~~ /usr/include/wchar.h:302:59: error: 'size_t' has not been declared 302 | const wchar_t *__restrict __s2, size_t __n) | ^~~~~~ /usr/include/wchar.h:317:27: error: 'mbstate_t' does not name a type 317 | extern int mbsinit (const mbstate_t *__ps) __THROW __attribute_pure__; | ^~~~~~~~~ /usr/include/wchar.h:321:8: error: 'size_t' does not name a type 321 | extern size_t mbrtowc (wchar_t *__restrict __pwc, | ^~~~~~ /usr/include/wchar.h:321:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/wchar.h:326:8: error: 'size_t' does not name a type 326 | extern size_t wcrtomb (char *__restrict __s, wchar_t __wc, | ^~~~~~ /usr/include/wchar.h:326:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/wchar.h:330:8: error: 'size_t' does not name a type 330 | extern size_t __mbrlen (const char *__restrict __s, size_t __n, | ^~~~~~ /usr/include/wchar.h:330:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/wchar.h:332:8: error: 'size_t' does not name a type 332 | extern size_t mbrlen (const char *__restrict __s, size_t __n, | ^~~~~~ /usr/include/wchar.h:332:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/wchar.h:362:8: error: 'size_t' does not name a type 362 | extern size_t mbsrtowcs (wchar_t *__restrict __dst, | ^~~~~~ /usr/include/wchar.h:362:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/wchar.h:368:8: error: 'size_t' does not name a type 368 | extern size_t wcsrtombs (char *__restrict __dst, | ^~~~~~ /usr/include/wchar.h:368:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/wchar.h:376:8: error: 'size_t' does not name a type 376 | extern size_t mbsnrtowcs (wchar_t *__restrict __dst, | ^~~~~~ /usr/include/wchar.h:376:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/wchar.h:382:8: error: 'size_t' does not name a type 382 | extern size_t wcsnrtombs (char *__restrict __dst, | ^~~~~~ /usr/include/wchar.h:382:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/wchar.h:396:42: error: 'size_t' has not been declared 396 | extern int wcswidth (const wchar_t *__s, size_t __n) __THROW; | ^~~~~~ /usr/include/wchar.h:695:59: error: 'size_t' has not been declared 695 | const wchar_t *__restrict __src, size_t __n) | ^~~~~~ /usr/include/wchar.h:718:8: error: '__FILE' does not name a type; did you mean 'EMFILE'? 718 | extern __FILE *open_wmemstream (wchar_t **__bufloc, size_t *__sizeloc) __THROW | ^~~~~~ | EMFILE /usr/include/wchar.h:725:19: error: '__FILE' was not declared in this scope; did you mean 'EMFILE'? 725 | extern int fwide (__FILE *__fp, int __mode) __THROW; | ^~~~~~ | EMFILE /usr/include/wchar.h:725:27: error: '__fp' was not declared in this scope 725 | extern int fwide (__FILE *__fp, int __mode) __THROW; | ^~~~ /usr/include/wchar.h:725:33: error: expected primary-expression before 'int' 725 | extern int fwide (__FILE *__fp, int __mode) __THROW; | ^~~ /usr/include/wchar.h:725:43: error: expression list treated as compound expression in initializer [-fpermissive] 725 | extern int fwide (__FILE *__fp, int __mode) __THROW; | ^ /usr/include/wchar.h:732:22: error: '__FILE' was not declared in this scope; did you mean 'EMFILE'? 732 | extern int fwprintf (__FILE *__restrict __stream, | ^~~~~~ | EMFILE /usr/include/wchar.h:732:30: error: expected primary-expression before '__restrict' 732 | extern int fwprintf (__FILE *__restrict __stream, | ^~~~~~~~~~ /usr/include/wchar.h:733:22: error: expected primary-expression before 'const' 733 | const wchar_t *__restrict __format, ...) | ^~~~~ /usr/include/wchar.h:733:58: error: expected primary-expression before '...' token 733 | const wchar_t *__restrict __format, ...) |
s362336486
p00143
C++
#include <bits/stdc++.h> using namespace std; typedef double D; typedef complex<D> P; #define EPS (1e-10) D dot(P a, P b) { return real(conj(a) * b); } D cross(P a, P b) { return imag(conj(a) * b); } int ccw(P p0, P p1, P p2) { P a = p1 - p0; P b = p2 - p0; if (cross(a,b) > EPS) return 1; if (cross(a,b) < -EPS) return -1; if (dot(a,b) < -EPS) return 2; if (norm(a) < norm(b)) return -2; return 0; } bool check(P p1, P p2, P p3, P p4) { return (ccw(p1, p2, p3)*ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1)*ccw(p3, p4, p2) <= 0); } int main() { int n; P P[3], T[2]; scanf("%d", &n); while (n--) { for (int i = 0; i < 3; i++) { scanf("%lf %lf", &P[i].real(), &P[i].imag()); } for (int i = 0; i < 2; i++) { scanf("%lf %lf", &T[i].real(), &T[i].imag()); } int cnt = 0; if (check(P[0], P[1], T[0], T[1])) { cnt++; } if (check(P[0], P[2], T[0], T[1])) { cnt++; } if (check(P[1], P[2], T[0], T[1])) { cnt++; } if (cnt % 2) { puts("OK"); } else { puts("NG"); } } return 0; }
a.cc: In function 'int main()': a.cc:45:40: error: lvalue required as unary '&' operand 45 | scanf("%lf %lf", &P[i].real(), &P[i].imag()); | ~~~~~~~~~^~ a.cc:45:54: error: lvalue required as unary '&' operand 45 | scanf("%lf %lf", &P[i].real(), &P[i].imag()); | ~~~~~~~~~^~ a.cc:49:40: error: lvalue required as unary '&' operand 49 | scanf("%lf %lf", &T[i].real(), &T[i].imag()); | ~~~~~~~~~^~ a.cc:49:54: error: lvalue required as unary '&' operand 49 | scanf("%lf %lf", &T[i].real(), &T[i].imag()); | ~~~~~~~~~^~
s138996255
p00143
C++
#include <iostream> #include <algorithm> #include <cassert> #include <cctype> #include <complex> #include <cstdio> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) typedef complex<double> P; int n; double x1,y1,x2,y2,x3,y3,x4,y4,x5,y5; double cr(P a, P b) { return (a.real() * b.imag() - a.imag() * b.real()); } int naibu(P a,P b,P c,P p){ return cr(p-a,b-a)>0&&cr(p-b,c-b)>0&&cr(p-c,a-c)>0||cr(p-a,b-a)<0&&cr(p-b,c-b)<0&&cr(p-c,a-c)<0; } int main(){ cin>>n; while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4>>x5>>y5){ P a=P(x1,y1),b=P(x2,y2),c=P(x3,y3),d=P(x4,y4),e=P(x5,y5); cout<<(naibu(a,b,c,d)^naibu(a,b,c,e)?"OK":"NG")<<endl; } }
a.cc:20:11: error: 'double y1' redeclared as different kind of entity 20 | double x1,y1,x2,y2,x3,y3,x4,y4,x5,y5; | ^~ In file included from /usr/include/features.h:523, from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683, from /usr/include/c++/14/bits/requires_hosted.h:31, from /usr/include/c++/14/iostream:38, from a.cc:1: /usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)' 257 | __MATHCALL (y1,, (_Mdouble_)); | ^~~~~~~~~~ a.cc: In function 'int main()': a.cc:32:22: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'double(double) noexcept') 32 | while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4>>x5>>y5){ | ~~~~~~~^~~~ | | | | | double(double) noexcept | std::basic_istream<char>::__istream_type {aka std::basic_istream<char>} In file included from /usr/include/c++/14/iostream:42: /usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 170 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed: a.cc:32:24: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double (*)(double) noexcept' 32 | while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4>>x5>>y5){ | ^~ /usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 174 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed: a.cc:32:24: error: invalid conversion from 'double (*)(double) noexcept' to 'short int' [-fpermissive] 32 | while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4>>x5>>y5){ | ^~ | | | double (*)(double) noexcept a.cc:32:24: error: cannot bind rvalue '(short int)y1' to 'short int&' /usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 177 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed: a.cc:32:24: error: invalid conversion from 'double (*)(double) noexcept' to 'short unsigned int' [-fpermissive] 32 | while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4>>x5>>y5){ | ^~ | | | double (*)(double) noexcept a.cc:32:24: error: cannot bind rvalue '(short unsigned int)y1' to 'short unsigned int&' /usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 181 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed: a.cc:32:24: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive] 32 | while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4>>x5>>y5){ | ^~ | | | double (*)(double) noexcept a.cc:32:24: error: cannot bind rvalue '(int)y1' to 'int&' /usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed: a.cc:32:24: error: invalid conversion from 'double (*)(double) noexcept' to 'unsigned int' [-fpermissive] 32 | while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4>>x5>>y5){ | ^~ | | | double (*)(double) noexcept a.cc:32:24: error: cannot bind rvalue '(unsigned int)y1' to 'unsigned int&' /usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed: a.cc:32:24: error: invalid conversion from 'double (*)(double) noexcept' to 'long int' [-fpermissive] 32 | while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4>>x5>>y5){ | ^~ | | | double (*)(double) noexcept a.cc:32:24: error: cannot bind rvalue '(long int)y1' to 'long int&' /usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed: a.cc:32:24: error: invalid conversion from 'double (*)(double) noexcept' to 'long unsigned int' [-fpermissive] 32 | while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4>>x5>>y5){ | ^~ | | | double (*)(double) noexcept a.cc:32:24: error: cannot bind rvalue '(long unsigned int)y1' to 'long unsigned int&' /usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 199 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed: a.cc:32:24: error: invalid conversion from 'double (*)(double) noexcept' to 'long long int' [-fpermissive] 32 | while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4>>x5>>y5){ | ^~ | | | double (*)(double) noexcept a.cc:32:24: error: cannot bind rvalue '(long long int)y1' to 'long long int&' /usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 203 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed: a.cc:32:24: error: invalid conversion from 'double (*)(double) noexcept' to 'long long unsigned int' [-fpermissive] 32 | while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4>>x5>>y5){ | ^~ | | | double (*)(double) noexcept a.cc:32:24: error: cannot bind rvalue '(long long unsigned int)y1' to 'long long unsigned int&' /usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 328 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed: a.cc:32:24: error: invalid conversion from 'double (*)(double) noexcept' to 'void*' [-fpermissive] 32 | while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4>>x5>>y5){ | ^~ | | | double (*)(double) noexcept a.cc:32:24: error: cannot bind rvalue '(void*)y1' to 'void*&' /usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed: a.cc:32:24: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive] 32 | while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4>>x5>>y5){ | ^~ | | | double (*)(double) noexcept /usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_typ
s620895897
p00143
C++
#include<cmath> #include<algorithm> #include<iostream> #include<vector> using namespace std; double EPS = 1e-10; double add(double a, double b){ if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0; return a+b; } struct point{ double x, y; point(){} point(double x,double y) : x(x) , y(y){} point operator + (point p){ return point(add(x,p.x), add(y,p.y)); } point operator - (point p){ return point(add(x,-p.x), add(y,-p.y)); } point operator * (double d){ return point(x*d,y*d); } }; struct segment{ point a,b; }; double dot(point a, point b) { return (a.x * b.x + a.y * b.y); } double cross(point a, point b) { return (a.x * b.y - a.y * b.x); } int is_intersected_ls(point a1, point a2, point b1, point b2) { return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) && ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS ); } double vec_abs(point a){ return sqrt(a.x*a.x+a.y*a.y); } int ccw(point p0, point p1, point p2){ point a = p1 - p0; point b = p2 - p0; if(cross(a,b)>EPS)return +1; if(cross(a,b)<EPS)return -1; if(dot(a,b)<-EPS)return +2; if(a.x*a.x+a.y*a.y<b.x*b.x+b.y*b.y)return -2; return 0; } int inside(point t,point* p,int N){ int i,count=0,j=0; segment lt,lp; p[N]=p[0]; p[N+1]=p[1]; lt.a=lt.b=t; lt.b.x=INT_MAX; for(i=1;i<=N;i++){ lp.a=lp.b=p[i]; if(!is_intersected_ls(lp.a,lp.b,lt.a,lt.b)){ if(i==j+1){ lp.b=p[j]; if(is_intersected_ls(lp.a,lp.b,lt.a,lt.b))count++; } else if(ccw(lt.a,lt.b,p[i])*ccw(lt.a,lt.b,p[j])<0)count++; j=i; } } return count & 1; } int main(void){ int n; point p[5],k,s; cin >> n; while(n--){ for(int i=0;i<3;i++) cin >> p[i].x >> p[i].y; cin >> k.x >> k.y >> s.x >> s.y; if(inside(k,p,3)!=inside(s,p,3))cout << "OK" << endl; else cout << "NG" << endl; } return 0; }
a.cc: In function 'int inside(point, point*, int)': a.cc:72:10: error: 'INT_MAX' was not declared in this scope 72 | lt.b.x=INT_MAX; | ^~~~~~~ a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 4 | #include<vector> +++ |+#include <climits> 5 |
s557266083
p00144
Java
import java.util.*; public class Main { static final int inf = 99999; int[][] a; Main(){ Scanner sc = new Scanner(System.in); int n, m, s, t; while(sc.hasNext()){ n = sc.nextInt(); a = new int[n+1][n+1]; for(int i = 0; i <= n; ++i) for(int j = i+1; j <= n; ++j) a[i][j] = a[j][i] = inf; for(int i = 0; i < n; ++i){ s = sc.nextInt(); m = sc.nextInt(); for(int j = 0; j < m; ++j){ t = sc.nextInt(); a[s][t] = 1; } } for(int k = 1; k <= n; ++k) for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) a[i][j] = Math.min(a[i][j], a[i][k]+a[k][j]); n = sc.nextInt(); for(int i = 0; i < n; ++i){ s = sc.nextInt(); t = sc.nextInt(); m = sc.nextInt(); if(a[s][t] < u) System.out.println(Integer.toString(a[s][t]+1)); else System.out.println("NA"); } } } public static void main(String[] args){ new Main(); } }
Main.java:39: error: cannot find symbol if(a[s][t] < u) ^ symbol: variable u location: class Main 1 error
s453737668
p00144
Java
import java.util.*; import java.io.*; import static java.util.Arrays.*; import static java.util.Collections.*; import static java.lang.Math.*; public class Main { int INF = 1 << 28; //long INF = 1L << 62; double EPS = 1e-10; int n; int[][] es; void run() { Scanner sc = new Scanner(System.in); n = sc.nextInt(); es = new int[n][n]; for (int[] a: es) fill(a, INF); for (int i=0;i<n;i++) es[i][i] = 0; for (int i=0;i<n;i++) { int r = sc.nextInt()-1, k = sc.nextInt(); for (int j=0;j<k;j++) { int t = sc.nextInt()-1; es[r][t] = 1; } } for (int k=0;k<n;k++) for (int i=0;i<n;i++) for (int j=0;j<n;j++) { es[i][j] = min(es[i][j], es[i][k] + es[k][j]); } int p = sc.nextInt(); for (int i=0;i<p;i++) { int s = sc.nextInt()-1, d = sc.nextInt()-1, v = sc.nextInt(); System.out.println((es[s][d] + 1 <= v ? es[s][d] + 1 : "NA")); } } String bfs(int s, int t, int v) { LinkedList<V> q = new LinkedList<V>(); q.add(new V(s, v)); boolean[] used = new boolean[n]; used[s] = true; for (;! q.isEmpty();) { V cur = q.removeFirst(); if (t == cur.p) return "" + (v - cur.c + 1); if (cur.c == 1) continue; for (int i=0;i<n;i++) if (! used[i] && es[cur.p][i] ) { used[i] = true; q.addLast(new V(i, cur.c - 1)); } } return "NA"; } class V { int p, c; V(int p, int c) { this.p = p; this.c = c; } } void debug(Object... os) { System.err.println(Arrays.deepToString(os)); } public static void main(String[] args) { new Main().run(); } }
Main.java:50: error: bad operand types for binary operator '&&' for (int i=0;i<n;i++) if (! used[i] && es[cur.p][i] ) { ^ first type: boolean second type: int 1 error
s491295069
p00144
C
#include <stdio.h> #define N 101 int check(int s,int d,int v); int root[N][N]; /* rooter path */ int distance[N]; /* already visited flag */ int main(){ int n,r,k,t; int p,s,d,v; int i,j; char c; int ans; /* init root */ for(i=0;i<N;i++){ for(j=0;j<N;j++){ root[i][j]=0; } } /* input */ scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d",&r); scanf("%d",&k); for(j=0;j<k;j++){ scanf("%d",&t); root[r][j] = t; } } scanf("%d",&p); for(i=0;i<p;i++){ scanf("%d %d %d",&s,&d,&v); ans = check(s,d,v); printf(ans?"%d\n":"NA\n",ans); } return 0; } int check(int s,int d,int v){ int i,ret,id,num,nextid; for(i=0;i<N;i++)distance[i]=0; distance[s]=1; for(i=1;i<v;i++){ for(j=0;j<N;j++){ if(distance[j]==i){ for(k=0;root[id][k]>0;k++){ nextid=root[id][k]; if(distance[nextid]==0){ distance[nextid]=i+1; } } } } } return distance[d]; }
main.c: In function 'check': main.c:54:13: error: 'j' undeclared (first use in this function) 54 | for(j=0;j<N;j++){ | ^ main.c:54:13: note: each undeclared identifier is reported only once for each function it appears in main.c:56:21: error: 'k' undeclared (first use in this function) 56 | for(k=0;root[id][k]>0;k++){ | ^
s754010032
p00144
C
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #define VD void #define U4 unsigned int #define U1 unsigned char #define S4 int /* ---------- ?????°?????? ------------ */ #define MAX_COUNT_ROUTER (100) /* ?????????????????§??° */ #define MAX_CNT_PACKET (1000) /* PACKET????????§??° */ #define NOT_CONNECTED (0) /* ???????????\?¶??????? */ #define IS_CONNECTED (1) /* ???????????\?¶??????? */ #define END_SEARCH (-1) /* ??¢?´¢????±???????????????? */ #define IS_COMPLETE (1) /* ??¢?´¢?????? */ #define NOT_COMPLETE (0) /* ??¢?´¢????????? */ #define NA (-1) /* #NA */ S4 main() { /* ---------- ?????°?????? ---------- */ U4 u4_t_numRouter; /* ?????????????????? */ U1 u1_t_delimiter; /* ??????????????? */ S4 s4_t_TTL; /* TTL */ S4 s4_t_srcRouter; /* ???????????????????????? */ S4 s4_t_dstRouter; /* ????????????????????? */ S4 s4_tp_connectedRouter[MAX_COUNT_ROUTER + 1][MAX_COUNT_ROUTER + 1] = { 0 }; /* ???????????\?¶??????±???????????????????´???????????????? */ S4 s4_tp_searchRouter[MAX_COUNT_ROUTER + 1]; /* ??¢?´¢????±???????????????? */ S4 s4_tp_nextSearchRouter[MAX_COUNT_ROUTER]; /* ?¬??????¢?´¢????±???????????????? */ S4 s4_tp_result[MAX_CNT_PACKET]; /* ??????????´???¨?????? */ U1 u1_t_isComplete; /* ??¢?´¢??????????????° */ /* ---------- ???????????° ---------- */ U4 u4_t_routerNumber; /* ??????????????? */ U4 u4_t_cntPacket; /* ?????±????????° */ S4 s4_t_searchRouter; /* ??¢?´¢????±???????????????? */ S4 s4_t_nextSearchRouterIndex; /* ?¬??????¢?´¢????±????????????????????´???¨?????????????????? */ /* ---------- ???????????? ---------- */ U4 u4_t_ri; /* ???????????\?¶??????±????´?????????? */ U4 u4_t_pi; /* ?????±???????????±????´?????????? */ S4 s4_t_hop; /* ???????????°(?????????????????±??°) */ S4 s4_t_si; /* ??¢?´¢??¨????????? */ U4 u4_t_ni; /* ?¬??????¢?´¢????±????????????????????´???¨????????? */ U4 u4_t_ci; /* ??¢?´¢????±???????????????????????????¨????????? */ S4 s4_t_oi; /* ??????????????¨????????????????????? */ S4 s4_t_oi2; /* ??????????????¨????????????????????? */ /* ??????????????°?????\??? */ scanf("%d%c", &u4_t_numRouter, &u1_t_delimiter); /* ---------- ??????????????\?¶??????±?????\??? ---------- */ for (u4_t_ri = (U4)1; u4_t_ri <= u4_t_numRouter; u4_t_ri++) { u1_t_delimiter = ' '; /* ???????????????????????\?¶??????±?????????????????? */ while (u1_t_delimiter != '\n') { scanf("%d%c", &u4_t_routerNumber, &u1_t_delimiter); s4_tp_connectedRouter[u4_t_ri][u4_t_routerNumber] = (S4)IS_CONNECTED; } } /* ---------- ??¢?´¢ ---------- */ scanf("%d%c", &u4_t_cntPacket, &u1_t_delimiter); /* ?????????????????±????´????????????????????????? */ s4_t_oi = (S4)0; /* ?????±???????????°????????¢?´¢????????? */ for (u4_t_pi = (U4)0; u4_t_pi < u4_t_cntPacket; u4_t_pi++) { /* ???????????????????????????????????????????????????TTL?????\??? */ scanf("%d %d %d%c", &s4_t_srcRouter, &s4_t_dstRouter, &s4_t_TTL, &u1_t_delimiter); /* 1???????????¢?´¢????????????????????´??\????????£????????????????¢?????????? */ s4_tp_searchRouter[0] = s4_t_srcRouter; s4_tp_searchRouter[1] = (S4)END_SEARCH; u1_t_isComplete = (U1)NOT_COMPLETE; s4_t_hop = (S4)2; /* ???????????°???TTL????¶???????????????¢?´¢????????????????????§??¢??? */ while ((s4_t_hop <= s4_t_TTL) && (u1_t_isComplete != (U1)IS_COMPLETE)) { s4_t_si = (S4)0; /* ??¢?´¢????±?????????????????????????????????¢?´¢????????????????????§??¢??? */ while ((s4_tp_searchRouter[s4_t_si] != (S4)END_SEARCH) && (u1_t_isComplete != (U1)IS_COMPLETE)) { /* ??¢?´¢????±????????????¨????????????????????´??\????????£?????????????¢???? */ s4_t_searchRouter = s4_tp_searchRouter[s4_t_si]; if (s4_tp_connectedRouter[s4_t_searchRouter][s4_t_dstRouter] == (S4)IS_CONNECTED) { u1_t_isComplete = (U1)IS_COMPLETE; } /* ?????¨?????¢?´¢????±??????????????????´??\????????£?????????????????? = ?¬??????¢?´¢????±?????????? */ if (u1_t_isComplete != (U1)IS_COMPLETE) { for (u4_t_ni = (U4)0; u4_t_ni <= u4_t_numRouter; u4_t_ni++) { if (s4_tp_connectedRouter[s4_t_searchRouter][u4_t_ni] == (S4)IS_CONNECTED) { s4_tp_nextSearchRouter[u4_t_ni] = (S4)IS_CONNECTED; } } } s4_t_si++; } if (u1_t_isComplete != (U1)IS_COMPLETE) { /* ??¢?´¢????±????????????????????????£???????????????????????¨???????????????????????§??????????????°????¢??????? */ s4_t_hop++; } /* ?¬??????¢?´¢????±???????????????¢?´¢????±?????????????????????? */ s4_t_nextSearchRouterIndex = (S4)0; for (u4_t_ci = (U4)0; u4_t_ci < u4_t_numRouter; u4_t_ci++) { if (s4_tp_nextSearchRouter[u4_t_ci] == (S4)IS_CONNECTED) { s4_tp_searchRouter[s4_t_nextSearchRouterIndex] = u4_t_ci; s4_t_nextSearchRouterIndex++; /* ????????? */ s4_tp_nextSearchRouter[u4_t_ci] = (S4)NOT_CONNECTED; } } s4_tp_searchRouter[s4_t_nextSearchRouterIndex] = (S4)END_SEARCH; } /* TTL??\????????°?????§????????´??? */ if (u1_t_isComplete == (U1)IS_COMPLETE) { s4_tp_result[s4_t_oi] = s4_t_hop; } else { s4_tp_result[s4_t_oi] = NA; } s4_t_oi++; } /* ???????????? */ for (s4_t_oi2 = (S4)0; s4_t_oi2 < s4_t_oi; s4_t_oi2++) { if (s4_tp_result[s4_t_oi2] == (S4)NA) { printf("NA"); } else { printf("%d", s4_tp_result[s4_t_oi2]); } /* ????????\?????????????????? */ if (s4_t_oi2 != s4_t_oi - 1) { printf("\n); } } return((U4)0); }
main.c: In function 'main': main.c:154:32: warning: missing terminating " character 154 | printf("\n); | ^ main.c:154:32: error: missing terminating " character 154 | printf("\n); | ^~~~~ main.c:155:17: error: expected expression before '}' token 155 | } | ^ main.c:154:32: error: expected ';' before '}' token 154 | printf("\n); | ^ | ; 155 | } | ~
s035023961
p00144
C
#include<stdio.h> #define N 100000 int main(void) { int n,p,r,k,t,a,count[101]; int queue[1000000],head=0,tail=0; int router[101][101],visited[101],i,j,b; struct mail{ int s; int d; int v; }packet[N]; for(i=0;i<101;i++) { for(j=0;j<101;j++) { router[i][j]=0; } } scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%d%d",&r,&k); for(j=1;j<=k;j++) { scanf("%d",&t); router[r][t]=1; } } for(i=1;i<=n;i++) { router[i][i]=0; } scanf("%d",&p); for(i=1;i<=p;i++) { scanf("%d%d%d",&packet[i].s,&packet[i].d,&packet[i].v); } for(i=1;i<=p;i++) { for(b=0;b<101;b++) count[b]=0; count[packet[i].s]=1; queue[tail++]=packet[i].s; for(b=0;b<=n;b++) visited[b]=0; visited[packet[i].s]=1; while(head!=tail) { a=queue[head++]; for(j=1;j<=n;j++) { if(router[a][j]==1 && visited[j]==0) { queue[tail++]=j; visited[j]=1; count[j]=count[a]+1; } } } if(count[packet[i].d]<=packet[i].v && count[packet[i].d]!=0)printf("%d\n",count[packet[i].d]); else printf("NA\n"); } return 0; } #include<stdio.h> #define N 100000 int main(void) { int n,p,r,k,t,a,count[101]; int queue[1000000],head=0,tail=0; int router[101][101],visited[101],i,j,b; struct mail{ int s; int d; int v; }packet[N]; for(i=0;i<101;i++) { for(j=0;j<101;j++) { router[i][j]=0; } } scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%d%d",&r,&k); for(j=1;j<=k;j++) { scanf("%d",&t); router[r][t]=1; } } for(i=1;i<=n;i++) { router[i][i]=0; } scanf("%d",&p); for(i=1;i<=p;i++) { scanf("%d%d%d",&packet[i].s,&packet[i].d,&packet[i].v); } for(i=1;i<=p;i++) { for(b=0;b<101;b++) count[b]=0; count[packet[i].s]=1; queue[tail++]=packet[i].s; for(b=0;b<=n;b++) visited[b]=0; visited[packet[i].s]=1; while(head!=tail) { a=queue[head++]; for(j=1;j<=n;j++) { if(router[a][j]==1 && visited[j]==0) { queue[tail++]=j; visited[j]=1; count[j]=count[a]+1; } } } if(count[packet[i].d]<=packet[i].v && count[packet[i].d]!=0)printf("%d\n",count[packet[i].d]); else printf("NA\n"); } return 0; }
main.c:87:5: error: redefinition of 'main' 87 | int main(void) | ^~~~ main.c:4:5: note: previous definition of 'main' with type 'int(void)' 4 | int main(void) | ^~~~
s945470445
p00144
C
#include<stdio.h> int main(void) { int n,p,r,k,t,a,count[101]; int queue[1000000],head=0,tail=0; int router[101][101],visited[101],i,j,b; struct mail{ int s; int d; int v; }packet[100000]; for(i=0;i<101;i++) { for(j=0;j<101;j++) { router[i][j]=0; } } scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%d%d",&r,&k); for(j=1;j<=k;j++) { scanf("%d",&t); router[r][t]=1; } } for(i=1;i<=n;i++) { router[i][i]=0; } scanf("%d",&p); for(i=1;i<=p;i++) { scanf("%d%d%d",&packet[i].s ,&packet[i].d ,&packet[i].v); } for(i=1;i<=p;i++) { for(b=0;b<101;b++) count[b]=0; count[packet[i].s]=1; queue[tail++]=packet[i].s; for(b=0;b<101;b++) visited[b]=0; visited[packet[i].s]=1; while(head!=tail) { a=queue[head++]; for(j=1;j<=n;j++) { if(router[a][j]==1 && visited[j]==0) { queue[tail++]=j; visited[j]=1; count[j]=count[a]+1; } } } if(count[packet[i].d<=packet[i].v && count[packet[i].d] != 0)printf("%d\n",count[packet[i].d]); else printf("NA\n"); } return 0; }
main.c: In function 'main': main.c:117:61: error: expected ']' before ')' token 117 | if(count[packet[i].d<=packet[i].v && count[packet[i].d] != 0)printf("%d\n",count[packet[i].d]); | ^ | ]
s346120193
p00144
C
#include<stdio.h> int main(void) { int n,p,r,k,t,a,count[101]; int queue[1000000],head=0,tail=0; int router[101][101],visited[101],i,j,b; struct mail{ int s; int d; int v; }packet[100000]; for(i=0;i<101;i++) { for(j=0;j<101;j++) { router[i][j]=0; } } scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%d%d",&r,&k); for(j=1;j<=k;j++) { scanf("%d",&t); router[r][t]=1; } } for(i=1;i<=n;i++) { router[i][i]=0; } scanf("%d",&p); for(i=1;i<=p;i++) { scanf("%d%d%d",&packet[i].s ,&packet[i].d ,&packet[i].v); } for(i=1;i<=p;i++) { for(b=0;b<101;b++) count[b]=0; count[packet[i].s]=1; queue[tail++]=packet[i].s; for(b=0;b<101;b++) visited[b]=0; visited[packet[i].s]=1; while(head!=tail) { a=queue[head++]; for(j=1;j<=n;j++) { if(router[a][j]==1 && visited[j]==0) { queue[tail++]=j; visited[j]=1; count[j]=count[a]+1; } } } if(count[packet[i].d<=packet[i].v && count[packet[i].d] != 0)printf("%d\n",count[packet[i].d]); else printf("NA\n"); } return 0; }
main.c: In function 'main': main.c:117:61: error: expected ']' before ')' token 117 | if(count[packet[i].d<=packet[i].v && count[packet[i].d] != 0)printf("%d\n",count[packet[i].d]); | ^ | ]
s644749863
p00144
C++
#include <iostream> #include <algorithm> using namespace std; int main(){ int n; int r,k,t; int p; int s,d,b; int ans=0; int box[111][111]; cin >> n; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ box[i][j]=INT_MAX; } } for(int i=0;i<n;i++){ cin >> r >> k; for(int j=0;j<k;j++){ cin >> t; box[r-1][t-1]=1; } } for(int z=0;z<n;z++){ for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ box[i][j]=min(box[i][j],box[i][z]+box[z][j]); } } } cin >> p; for(int i=0;i<p;i++){ cin >> s >> d >> b; ans=box[s-1][d-1]+1; if(ans<=b){ cout << box[s-1][d-1]+1 << endl; }else{ cout << "NA" << endl; } } }
a.cc: In function 'int main()': a.cc:14:17: error: 'INT_MAX' was not declared in this scope 14 | box[i][j]=INT_MAX; | ^~~~~~~ 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;
s795633102
p00144
C++
#include <iostream> #include <algorithm> using namespace std; int main(){ int n; int r,k,t; int p; int s,d,b; int ans=0; int box[111][111]; cin >> n; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ box[i][j]=INT_MAX; } } for(int i=0;i<n;i++){ cin >> r >> k; for(int j=0;j<k;j++){ cin >> t; box[r-1][t-1]=1; } } for(int z=0;z<n;z++){ for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ box[i][j]=min(box[i][j],box[i][z]+box[z][j]); } } } cin >> p; for(int i=0;i<p;i++){ cin >> s >> d >> b; ans=box[s-1][d-1]+1; if(ans<=b){ cout << box[s-1][d-1]+1 << endl; }else{ cout << "NA" << endl; } } }
a.cc: In function 'int main()': a.cc:14:17: error: 'INT_MAX' was not declared in this scope 14 | box[i][j]=INT_MAX; | ^~~~~~~ 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;
s345337633
p00144
C++
#include <stdio.h> #include <cmath> #include <algorithm> #include <queue> using namespace std; struct Packet{ Packet(){ ttl = current = 0; } void copy(Packet t){ ttl = t.ttl; current = t.current; for(int i=0; i < 101; i++)checkTable[i] = t.checkTable[i]; } Packet(int arg_ttl,int loc){ ttl = arg_ttl; for(int i=0; i < 101; i++)checkTable[i] = 0; checkTable[loc] = 1; current = loc; } void set(int loc){ checkTable[loc] = 1; current = loc; } int ttl,checkTable[101],current; }; int main(){ int n,r,k,to,table[101][101],num_of_packet,start,goal,t_limit; Packet tmp; for(int i=1; i < 101; i++){ for(int k=1; k < 101; k++){ table[i][k] = 0; } } scanf("%d",&n); for(int i = 0; i < n; i++){ scanf("%d %d",&r,&k); for(int p=0;p < k; p++){ scanf("%d",&to); table[r][to] = 1; } } scanf("%d",&num_of_packet); queue<Packet> Q; bool FLG; for(int i=0; i < num_of_packet; i++){ scanf("%d %d %d",&start,&goal,&t_limit); FLG = false; if(t_limit <= 1){ printf("NA\n"); FLG = true; } if(!FLG){ for(int d = 1; d <= n; d++){ if(d != start && table[start][d] == 1){ Packet p(t_limit-1,start); p.set(d); Q.push(p); } } } while(!Q.empty()){ tmp.copy(Q.front()); Q.pop(); if(tmp.ttl > 0 && tmp.current == goal){ printf("%d\n",t_limit - tmp.ttl+1); FLG = true; while(!Q.empty())Q.pop(); memo[start][goal] = t_limit - tmp.ttl+1; break; } if(tmp.ttl > 1 && t_limit-tmp.ttl + 1 <= n){ for(int m=1; m <= n; m++){ if(m != tmp.current && tmp.checkTable[m] == 0 && table[tmp.current][m] == 1){ Packet q; q.copy(tmp); q.ttl--; q.set(m); Q.push(q); } } } if(FLG)break; } if(!FLG){ printf("NA\n"); } } return 0; }
a.cc: In function 'int main()': a.cc:90:33: error: 'memo' was not declared in this scope 90 | memo[start][goal] = t_limit - tmp.ttl+1; | ^~~~
s565191709
p00144
C++
#include<iostream> #include<cstdio> #include<algorithm> #include<string> #include<vector> #include<queue> #include<set> #include<functional> #include<unordered_map> using namespace std; vector<int>rinsetu[100]{}; unordered_map<int, int>taiou; int main() { int a; cin >> a; for (int b = 0; b < a; b++) { int c, d; scanf("%d%d", &c, &d); taiou[c] = b; for (int e = 0; e < d; e++) { int f; scanf("%d", &f); rinsetu[b].push_back(f); } } int b; cin >> b; for (int c = 0; c < b; c++) { int g, h, i; scanf("%d%d%d", &g, &h, &i); int e[100]{}; memset(e, -1, sizeof(e)); queue<int>Q; e[taiou[g]] = 1; Q.push(g); while (Q.size()) { int o = Q.front(); Q.pop(); o = taiou[o]; if (e[o] > i)break; for (int p : rinsetu[o]) { if (e[taiou[p]] == -1) { e[taiou[p]] = e[o] + 1; Q.push(p); } } } if (e[taiou[h]] == -1||e[taiou[h]]>i)puts("NA"); else cout << e[taiou[h]] << endl; } }
a.cc: In function 'int main()': a.cc:29:17: error: 'memset' was not declared in this scope 29 | memset(e, -1, sizeof(e)); | ^~~~~~ a.cc:9:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 8 | #include<functional> +++ |+#include <cstring> 9 | #include<unordered_map>
s320564803
p00144
C++
/* ????????????????????????????????????????????? */ #include <stdio.h> /* ?????°???????????? */ typedef void VD; typedef signed char I1; typedef unsigned char U1; typedef signed short I2; typedef unsigned short U2; typedef signed int I4; typedef unsigned int U4; /* ?????°?????? */ #define MAX_ROUTER 100 #define MAX_TTL 10000 #define CONNECT 1 #define DISCONNECT 0 #define SENTINEL -1 #define TRUE 1 #define FALSE 0 #define INPUT_SUCCESS 0 #define INPUT_ERORR -1 /* ????????????????????£?¨? */ VD setInit(VD); I1 inputConnectInfo(VD); I1 inputTransmitPacket(VD); I4 CalcDijikstra(I4 i4Sender,I4 i4Destination,I4 i4TTL); /* ??°?????????????????° */ I1 u1Connect[MAX_ROUTER+1][MAX_ROUTER+1]; I4 i4RouterNum; I4 main(VD) { I1 i1ErrorCheck; I4 i4CalcNum; I4 i4RoopCnt1; I4 i4RoopCnt2; setInit(); i1ErrorCheck = inputConnectInfo(); if(i1ErrorCheck == INPUT_SUCCESS){ scanf("%d",&i4CalcNum); for( i4RoopCnt1=0; i4RoopCnt1<i4CalcNum; i4RoopCnt1++) { inputTransmitPacket(); } } else{ ; } return 0; } VD setInit(VD) { I4 i4RoopCnt1; I4 i4RoopCnt2; for( i4RoopCnt1=1; i4RoopCnt1<=MAX_ROUTER; i4RoopCnt1++) { for(i4RoopCnt2=1; i4RoopCnt2<=MAX_ROUTER; i4RoopCnt2++) { u1Connect[i4RoopCnt1][i4RoopCnt2] = DISCONNECT; } } return; } I1 inputConnectInfo(VD) { I1 i1Return; I4 i4RoopCnt1; I4 i4RoopCnt2; I4 i4RouterCnt; I4 i4ConnectNum; I4 i4AccessPoint; i1Return = INPUT_SUCCESS; scanf("%d",&i4RouterNum); if(i4RouterNum <= (I4)MAX_ROUTER){ for( i4RoopCnt1=1; i4RoopCnt1<=i4RouterNum; i4RoopCnt1++) { scanf("%d%d",&i4RouterCnt,&i4ConnectNum); for( i4RoopCnt2=0; i4RoopCnt2<i4ConnectNum; i4RoopCnt2++) { scanf("%d",&i4AccessPoint); u1Connect[i4RouterCnt][i4AccessPoint] = CONNECT; } u1Connect[i4RouterCnt][i4RouterNum+1] = SENTINEL; } } else{ i1Return = INPUT_ERORR; } return i1Return; } I1 inputTransmitPacket(VD) { I1 i1Return; I4 i4StartRouter; I4 i4GoalRouter; I4 i4TTL; I4 i4Ans; i1Return = INPUT_SUCCESS; scanf("%d%d%d",&i4StartRouter,&i4GoalRouter,&i4TTL); if(i4TTL <= MAX_TTL){ i4Ans = CalcDijikstra(i4StartRouter,i4GoalRouter,i4TTL,1); if(i4Ans > 0){ printf("%d\n",i4Ans); } else{ printf("NA\n"); } } else{ i1Return = INPUT_ERORR; } return i1Return; } I4 CalcDijikstra(I4 i4Sender,I4 i4Destination,I4 i4TTL) { I1 i1StarTable[MAX_ROUTER+1][MAX_ROUTER+1]; I4 i4MinVal[MAX_ROUTER+1]; I4 i4RoopCnt1; I4 i4RoopCnt2; I4 i4RoopCnt3; for( i4RoopCnt1=1; i4RoopCnt1<=MAX_ROUTER; i4RoopCnt1++){ i4MinVal[i4RoopCnt1] = 0; for(i4RoopCnt2=1; i4RoopCnt2<=MAX_ROUTER; i4RoopCnt2++){ i1StarTable[i4RoopCnt1][i4RoopCnt2] = FALSE; } } i1StarTable[1][i4Sender] = TRUE; for(i4RoopCnt1=1; i4RoopCnt1<MAX_ROUTER; i4RoopCnt1++){ if(i4TTL <= i4RoopCnt1){ return 0; } else{ ; } for(i4RoopCnt2=1; i4RoopCnt2<=MAX_ROUTER; i4RoopCnt2++){ if(i1StarTable[i4RoopCnt1][i4RoopCnt2] == TRUE){ for(i4RoopCnt3=1; i4RoopCnt3<=MAX_ROUTER; i4RoopCnt3++){ if(u1Connect[i4RoopCnt2][i4RoopCnt3] == CONNECT){ if(i4RoopCnt3 == i4Destination){ return i4RoopCnt1+1; } else{ ; } i1StarTable[i4RoopCnt1+1][i4RoopCnt3] = TRUE; } } } else{ ; } } } return 0; }
a.cc: In function 'I1 inputTransmitPacket()': a.cc:113:38: error: too many arguments to function 'I4 CalcDijikstra(I4, I4, I4)' 113 | i4Ans = CalcDijikstra(i4StartRouter,i4GoalRouter,i4TTL,1); | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:31:4: note: declared here 31 | I4 CalcDijikstra(I4 i4Sender,I4 i4Destination,I4 i4TTL); | ^~~~~~~~~~~~~
s410534821
p00144
C++
&#65279;#include<iostream> #include<queue> using namespace std; int main(){ int n; //making graph cin >> n; int data[n+1][n+1]; for(int i = 0; i <= n; i++){ for(int j = 0; j <= n; j++){ data[i][j] = 0; } } int from, to, conesum; for(int i = 0; i < n; i++){ cin >> from >> conesum; for(int j = 0; j < conesum; j++){ cin >> to; data[from][to] = 1; } } //making graph end //judge int sumpake; cin >> sumpake; queue<int> Q; int ttl, myposi, min, sumin, sumina, finish = 0; for(int i = 0; i < sumpake; i++){ min = 0; cin >> from >> to >> ttl; myposi = from; for(int j = 0; j < ttl; j++){ if(j != 0){ for(int l = 0; l < sumina; l++){ //cout << "sumina " << sumina << endl; if(Q.front() == to){ min = j; finish = 1; //cout << "much" << endl; break; } myposi = Q.front(); //cout << "pop " << Q.front()<<endl; Q.pop(); for(int k = 1; k <= n; k++){ if(data[myposi][k] == 1) { Q.push(k); sumin++; } } } if(finish == 1) break; }else{ sumin = 0; for(int k = 1; k <= n; k++){ if(data[myposi][k] == 1) { Q.push(k); sumin++; } } } // for(int k = 1; k <= n; k++){ // if(data[myposi][k] == 1) { // Q.push(k); // sumin++; // } // } sumina = sumin; sumin = 0; } if(min == 0) cout << "NA"; else cout << min+1; cout << endl; finish = 0; while(!Q.empty()) Q.pop(); } return 0; }
a.cc:1:2: error: stray '#' in program 1 | &#65279;#include<iostream> | ^ a.cc:1:9: error: stray '#' in program 1 | &#65279;#include<iostream> | ^ a.cc:1:3: error: expected unqualified-id before numeric constant 1 | &#65279;#include<iostream> | ^~~~~ a.cc:1:10: error: 'include' does not name a type 1 | &#65279;#include<iostream> | ^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/deque:62, from /usr/include/c++/14/queue:62, 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> |
s753366548
p00144
C++
import java.util.*; public class Main { static final int inf = 99999; int[][] a; Main(){ Scanner sc = new Scanner(System.in); int n, m, s, t; while(sc.hasNext()){ n = sc.nextInt(); a = new int[n+1][n+1]; for(int i = 0; i <= n; ++i) for(int j = i+1; j <= n; ++j) a[i][j] = a[j][i] = inf; for(int i = 0; i < n; ++i){ s = sc.nextInt(); m = sc.nextInt(); for(int j = 0; j < m; ++j){ t = sc.nextInt(); a[s][t] = 1; } } for(int k = 1; k <= n; ++k) for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) a[i][j] = Math.min(a[i][j], a[i][k]+a[k][j]); n = sc.nextInt(); for(int i = 0; i < n; ++i){ s = sc.nextInt(); t = sc.nextInt(); m = sc.nextInt(); if(a[s][t] < u) System.out.println(Integer.toString(a[s][t]+1)); else System.out.println("NA"); } } } public static void main(String[] args){ new Main(); } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.*; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: expected unqualified-id before 'public' 3 | public class Main | ^~~~~~
s541658539
p00144
C++
#include<iostream> #include<cstdio> using namespace std; #define SUB 103 int net[SUB][SUB],n,maxx=0; typedef pair<int,int> BVB; int ans(int,int,int); int main(){ int i,j,p,num,n1,th; cin >> n; for(i=0;i<n;i++){ //net's info cin >> num >> n1; if(num >= maxx)maxx = num; for(int k=0;k<maxx;k++)net[num][k]=0; //siyoukanou for(j=0;j<n1;j++){ cin >> th; net[num][th]=1; } }//net's info // cout << "maxx =" << maxx << endl; for(int m=0;m<maxx;m++){ for(int n=0;n<maxx;n++){ if(net[m][n]!=1)net[m][n]=0; } } int pkn; cin >> pkn; int st,ed,c,answer; for(i=0;i<pkn;i++){//pack's info cin >> st >> ed >> c; answer = ans(st,ed,c); if(answer != -2)cout << answer << endl; else cout << "NA" << endl; }//pack's info } //ƒLƒ…[(•’ʂ̔z—ñ‚Å‚à‚¢‚¢‚¯‚Ç)‚ɂǂñ‚Ç‚ñ“ü‚ê‚Ä‚¢‚«TTL‚ª‚O–¢–ž‚ɂȂé‘O‚É–Ú“I’n‚É“ž’B‚Å‚«‚é‚©‚Ç‚¤‚©‚𒲂ׂé //ƒ‹[ƒ^”‚Í–Ú“I’n‚É“ž’B‚µ‚½’n“_‚ÌTTL‚©‚çŒvŽZ‚µ‚Ä‚¾‚· int ans(int st,int ed,int c){ queue<BVB> Nari; int i,j,k,l,cal=0,mem=0; BVB next,fr; fr.first=st; fr.second=c; Nari.push(fr); /* cout << "FIRST next.second = " << c << endl; cout << "FIRST cal = " << cal << endl; */ if(st == ed && c != 0)return 1; while(1){ next=Nari.front(); Nari.pop(); next.second=next.second-1; if(fr.second == (next.second+1) && next.second == 0 && next.first != ed)return -2; if(next.second < 0)break; //I—¹ðŒ //cout << "next.second = " << next.second << endl; for(i=1;i<=maxx;i++){//‚¢‚¯‚éêŠ‚ðƒLƒ…[‚É“ü‚ê‚é if(net[next.first][i] == 1)mem++; if(net[next.first][i] == 1 && i == ed ){ //–Ú“I’n“ž’B /* cout << "GOOOOOOOOOL!!! i = " << i <<endl; cout << " cal = " << cal << endl; cout << " next.second = " << next.second << endl; */ return (fr.second - next.second)+1; } if(net[next.first][i] == 1)Nari.push(BVB(i,next.second)); if(mem == n)break; } } return -2; }
a.cc: In function 'int ans(int, int, int)': a.cc:79:3: error: 'queue' was not declared in this scope 79 | queue<BVB> Nari; | ^~~~~ a.cc:3:1: note: 'std::queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>' 2 | #include<cstdio> +++ |+#include <queue> 3 | a.cc:79:12: error: expected primary-expression before '>' token 79 | queue<BVB> Nari; | ^ a.cc:79:14: error: 'Nari' was not declared in this scope 79 | queue<BVB> Nari; | ^~~~
s787286364
p00144
C++
#include<iostream> #include<queue> #define MAX_N 110 bool A[MAX_N][MAX_N]; int rooter_num; using namespace std; int bfs(int,int); int main() { int n,startNode,goalNode,TTL; int r,k,t; memset(A,false,sizeof(A)); cin>>rooter_num; for(int i=0;i<rooter_num;i++) { cin>>r>>k; for(int j=0;j<k;j++) { cin>>t; A[r][t]=true; } } for(int i=1;i<=rooter_num;i++) { for(int j=1;j<=rooter_num;j++) { cout<<A[i][j]; } cout<<endl; } cin>>n; for(int i=0;i<n;i++) { cin>>startNode>>goalNode>>TTL; int a=bfs(startNode,goalNode); if(a>TTL)cout<<"NA"<<endl; else cout<<a<<endl; } } int bfs(int startNode,int goalNode) { queue<int>Q; int visited[rooter_num+1]; memset(visited,false,sizeof(visited)); int currentNode=startNode; Q.push(currentNode); visited[currentNode]=true; while(!Q.empty()) { currentNode=Q.front(); Q.pop(); for(int nextNode=1;nextNode<=rooter_num;nextNode++) { if(A[currentNode][nextNode]==false)continue; if(nextNode==goalNode)return visited[currentNode]+1; if(visited[nextNode]==false) { visited[nextNode]=visited[currentNode]+1; Q.push(nextNode); } } } return MAX_N; }
a.cc: In function 'int main()': a.cc:12:3: error: 'memset' was not declared in this scope 12 | memset(A,false,sizeof(A)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include<queue> +++ |+#include <cstring> 3 | #define MAX_N 110 a.cc: In function 'int bfs(int, int)': a.cc:45:3: error: 'memset' was not declared in this scope 45 | memset(visited,false,sizeof(visited)); | ^~~~~~ a.cc:45:3: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
s939377788
p00145
Java
import java.io.*; import java.util.*; public class Main{ public static void main(String args[]){ try{ new Main(); }catch(IOException e){ e.printStackTrace(); } } public Main() throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String line = in.readLine(); int size = Integer.parseInt(line); List<Cards> data = new ArrayList<Cards>(); for(int i=0; i<size; i++){ line = in.readLine(); String[] tmp = line.split(" "); long a = Long.parseLong(tmp[0]); long b = Long.parseLong(tmp[1]); data.add(new Cards(a, b)); } long cost = 0; cost = get_cost(data, cost); System.out.println(cost); } public long get_cost(List<Cards> data, long cost){ if(data.size() > 1){ long min = Long.MAX_VALUE; for(int n=0; n<data.size()-1; n++){ long c = Cards.join_cost(data.get(n), data.get(n+1)); List<Cards> temp = new ArrayList<Cards>(data); temp.set(n+1, Cards.join(data.get(n), data.get(n+1))); temp.remove(n); long m = get_cost(temp, cost+c); if(min > m){ min = m; } } return min; }else{ return cost; } } }
Main.java:32: error: cannot find symbol public long get_cost(List<Cards> data, long cost){ ^ symbol: class Cards location: class Main Main.java:17: error: cannot find symbol List<Cards> data = new ArrayList<Cards>(); ^ symbol: class Cards location: class Main Main.java:17: error: cannot find symbol List<Cards> data = new ArrayList<Cards>(); ^ symbol: class Cards location: class Main Main.java:23: error: cannot find symbol data.add(new Cards(a, b)); ^ symbol: class Cards location: class Main Main.java:36: error: cannot find symbol long c = Cards.join_cost(data.get(n), data.get(n+1)); ^ symbol: variable Cards location: class Main Main.java:37: error: cannot find symbol List<Cards> temp = new ArrayList<Cards>(data); ^ symbol: class Cards location: class Main Main.java:37: error: cannot find symbol List<Cards> temp = new ArrayList<Cards>(data); ^ symbol: class Cards location: class Main Main.java:38: error: cannot find symbol temp.set(n+1, Cards.join(data.get(n), data.get(n+1))); ^ symbol: variable Cards location: class Main 8 errors
s262946515
p00145
Java
import java.io.*; import java.util.*; public class Main{ public static void main(String args[]){ try{ new Main(); }catch(IOException e){ e.printStackTrace(); } } public Main() throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String line = in.readLine(); int size = Integer.parseInt(line); List<Cards> data = new ArrayList<Cards>(); for(int i=0; i<size; i++){ line = in.readLine(); String[] tmp = line.split(" "); long a = Long.parseLong(tmp[0]); long b = Long.parseLong(tmp[1]); data.add(new Cards(a, b)); } long cost = 0; cost = get_cost(data, cost); System.out.println(cost); } public long get_cost(List<Cards> data, long cost){ if(data.size() > 1){ long min = Long.MAX_VALUE; for(int n=0; n<data.size()-1; n++){ long c = Cards.join_cost(data.get(n), data.get(n+1)); List<Cards> temp = new ArrayList<Cards>(data); temp.set(n+1, Cards.join(data.get(n), data.get(n+1))); temp.remove(n); long m = get_cost(temp, cost+c); if(min > m){ min = m; } } return min; }else{ return cost; } } } lass Cards{ long above; long bottom; public Cards(long a, long b){ this.above = a; this.bottom = b; } static Cards join(Cards c1, Cards c2){ return new Cards(c1.above, c2.bottom); } static long join_cost(Cards c1, Cards c2){ return c1.above * c1.bottom * c2.above * c2.bottom; } }
Main.java:53: error: class, interface, enum, or record expected lass Cards{ ^ Main.java:55: error: unnamed classes are a preview feature and are disabled by default. long bottom; ^ (use --enable-preview to enable unnamed classes) Main.java:56: error: class, interface, enum, or record expected public Cards(long a, long b){ ^ Main.java:58: error: class, interface, enum, or record expected this.bottom = b; ^ Main.java:59: error: class, interface, enum, or record expected } ^ Main.java:63: error: class, interface, enum, or record expected } ^ Main.java:67: error: class, interface, enum, or record expected } ^ 7 errors
s114933014
p00145
C++
#include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <deque> #include <complex> #include <stack> #include <queue> #include <cstdio> #include <cctype> #include <cstring> #include <ctime> #include <iterator> #include <bitset> #include <numeric> #include <list> #include <iomanip> #if __cplusplus >= 201103L #include <array> #include <tuple> #include <initializer_list> #include <unordered_set> #include <unordered_map> #include <forward_list> #define cauto const auto& #else #endif using namespace std; namespace{ typedef long long LL; typedef pair<int,int> pii; typedef pair<LL,LL> pll; typedef vector<int> vint; typedef vector<vector<int> > vvint; typedef vector<long long> vll, vLL; typedef vector<vector<long long> > vvll, vvLL; #define VV(T) vector<vector< T > > template <class T> void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){ v.assign(a, vector<T>(b, t)); } template <class F, class T> void convert(const F &f, T &t){ stringstream ss; ss << f; ss >> t; } #define reep(i,a,b) for(int i=(a);i<(b);++i) #define rep(i,n) reep((i),0,(n)) #define ALL(v) (v).begin(),(v).end() #define PB push_back #define F first #define S second #define mkp make_pair #define RALL(v) (v).rbegin(),(v).rend() #define MOD 1000000007LL #define EPS 1e-8 static const int INF=1<<24; void mainmain(){ int n; cin>>n; vector<pll> v(n); rep(i,3){ cin>>v[i].F>>v[i].S; } ll ans=0; while(v.size()!=1){ // rep(i,v.size()){ // cout<<v[i].F<<" "<<v[i].S<<endl; // } // cout<<endl; ll x=-1,y=0; rep(i,v.size()-1){ if(y<v[i].F*v[i+1].S){ x=i; y=v[i].F*v[i+1].S; } if(y<v[i].S*v[i+1].F){ x=i; y=v[i].S*v[i+1].F; } } ans+=v[x].F*v[x].S*v[x+1].F*v[x+1].S; if(v[x].F*v[x+1].S>v[x].S*v[x+1].F) v[x]=mkp(v[x+1].F,v[x].S); else v[x]=mkp(v[x].F,v[x+1].S); reep(i,x+1,v.size()-1){ swap(v[i],v[i+1]); } v.pop_back(); } cout<<ans<<endl; } } main() try{ mainmain(); } catch(...){ }
a.cc: In function 'void {anonymous}::mainmain()': a.cc:91:9: error: 'll' was not declared in this scope; did you mean 'vll'? 91 | ll ans=0; | ^~ | vll a.cc:97:19: error: expected ';' before 'x' 97 | ll x=-1,y=0; | ^~ | ; a.cc:99:28: error: 'y' was not declared in this scope 99 | if(y<v[i].F*v[i+1].S){ | ^ a.cc:100:33: error: 'x' was not declared in this scope 100 | x=i; | ^ a.cc:103:28: error: 'y' was not declared in this scope 103 | if(y<v[i].S*v[i+1].F){ | ^ a.cc:104:33: error: 'x' was not declared in this scope 104 | x=i; | ^ a.cc:108:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 108 | ans+=v[x].F*v[x].S*v[x+1].F*v[x+1].S; | ^~~ | abs a.cc:108:24: error: 'x' was not declared in this scope 108 | ans+=v[x].F*v[x].S*v[x+1].F*v[x+1].S; | ^ a.cc:116:15: error: 'ans' was not declared in this scope; did you mean 'abs'? 116 | cout<<ans<<endl; | ^~~ | abs a.cc: At global scope: a.cc:122:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 122 | main() try{ | ^~~~
s936799723
p00145
C++
#include <iostream> #include <algorithm> using namespace std; int u[100], b[100]; int dp[100][100]; int main(void){ int n; cin >> n; for(int i = 0; i < n; i++){ cin >> u[i] >> b[i]; } for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ if(i != j) dp[i][j] = INT_MAX; } dp[i][i] = 0; } for(int i = 1; i <= n; i++){ for(int j = 0; j < n - i; j++){ for(int k = j; k < j + i; k++){ dp[j][j+i] = min(dp[j][j+i], dp[j][k] + dp[k+1][j+i] + u[j] * b[k] * u[k+1] * b[j+i]); } } } cout << dp[0][n-1] << endl; return 0; }
a.cc: In function 'int main()': a.cc:17:29: error: 'INT_MAX' was not declared in this scope 17 | if(i != j) dp[i][j] = INT_MAX; | ^~~~~~~ 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;
s996347186
p00145
C++
#include<iostream> #include<math.h> #include<vector> #include<algorithm> #include<cstdio> #include <string> using namespace std; int a[100],b[100]; int dp[100][100]; int main(){ int n,i,j,k; cin >> n; for(i=0;i<n;i++) cin >> a[i] >> b[i]; for(i=0;i<n;i++) for(j=0;j<n;j++) dp[i][j] = INT_MAX; for(i=0;i<n;i++) dp[i][i] = 0; for(i=2;i<=n;i++){ for(j=0;j<=n-i;j++){ for(k=j+1;k<j+i;k++){ dp[j][j+i-1] = min(dp[j][j+i-1] , dp[j][k-1] + dp[k][j+i-1] + a[j] * b[k-1] * a[k] * b[j+i-1]); } } } cout << dp[0][n-1] << endl; }
a.cc: In function 'int main()': a.cc:16:50: error: 'INT_MAX' was not declared in this scope 16 | for(i=0;i<n;i++) for(j=0;j<n;j++) dp[i][j] = INT_MAX; | ^~~~~~~ a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 5 | #include<cstdio> +++ |+#include <climits> 6 | #include <string>
s533253224
p00145
C++
#include <iostream> #include <vector> #include <map> using namespace std; typedef pair<int, int> P; vector<P> D; int n, a, b; int DP[101][101]; void solve() { for(int i=0; i<n; i++) { for(int j=0; j<n; j++) { if(i!=j) DP[i][j] = INT_MAX; else DP[i][j] = 0; } } for(int i=1; i<n; i++) { for(int j=0; j<n-i; j++) { for(int k=j; k<j+i; k++) { int cost = D[j].first * D[k].second * D[k+1].first * D[j+i].second; DP[j][j+i] = min(DP[j][j+i], cost + DP[j][k] + DP[k+1][j+i]); } } } cout << DP[0][n-1] << endl; } int main(int argc, char** argv) { cin >> n; for(int i=0; i<n; i++) { cin >> a >> b; P p(a, b); D.push_back(p); } solve(); }
a.cc: In function 'void solve()': a.cc:19:45: error: 'INT_MAX' was not declared in this scope 19 | if(i!=j) DP[i][j] = INT_MAX; | ^~~~~~~ a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 3 | #include <map> +++ |+#include <climits> 4 |
s516876148
p00145
C++
#include <iostream> #include <vector> #include <climit> #include <map> using namespace std; typedef pair<int, int> P; vector<P> D; int n, a, b; int DP[101][101]; void solve() { for(int i=0; i<n; i++) { for(int j=0; j<n; j++) { if(i!=j) DP[i][j] = INT_MAX; else DP[i][j] = 0; } } for(int i=1; i<n; i++) { for(int j=0; j<n-i; j++) { for(int k=j; k<j+i; k++) { int cost = D[j].first * D[k].second * D[k+1].first * D[j+i].second; DP[j][j+i] = min(DP[j][j+i], cost + DP[j][k] + DP[k+1][j+i]); } } } cout << DP[0][n-1] << endl; } int main(int argc, char** argv) { cin >> n; for(int i=0; i<n; i++) { cin >> a >> b; P p(a, b); D.push_back(p); } solve(); }
a.cc:3:10: fatal error: climit: No such file or directory 3 | #include <climit> | ^~~~~~~~ compilation terminated.
s613662559
p00145
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; long long dp[101][101][101]; long long a[101],b[101]; #define rep(i,n) for(int i=0;i<n;i++) int main(){ int n; cin >> n; rep(i,n) cin >> a[i+1] >> b[i+1]; rep(i,101)rep(j,101)rep(k,101) dp[i][j][k] = INT_MAX; for(int j=1;j<=n;j++) dp[0][j][j] = 0; for(int j=1;j<=n;j++){ for(int k=1;k<=n;k++){ if(j != k)dp[1][j][k] = a[j] * b[j] * a[k] * b[k]; } } for(int i=2;i<=n;i++){ for(int j=1;j<=n;j++){ for(int k=1;k<=n;k++){ dp[i][i][k] = min( dp[i][i][k] , dp[i-1][j][k] + a[i] * b[i] * a[j] * b[k] ); dp[i][k][i] = min( dp[i][k][i] , dp[i-1][j][k] + a[i] * b[i] * a[k] * b[j] ); } } } long long ans = INT_MAX; rep(i,n+1)rep(j,n+1) ans = min(ans,dp[n-1][i][j]); cout << ans << endl; }
a.cc: In function 'int main()': a.cc:13:54: error: 'INT_MAX' was not declared in this scope 13 | rep(i,101)rep(j,101)rep(k,101) dp[i][j][k] = INT_MAX; | ^~~~~~~ a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 3 | #include <algorithm> +++ |+#include <climits> 4 | using namespace std; a.cc:29:25: error: 'INT_MAX' was not declared in this scope 29 | long long ans = INT_MAX; | ^~~~~~~ a.cc:29:25: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
s628918948
p00145
C++
#include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <map> #include <utility> #include <set> #include <iostream> #include <string> #include <vector> #include <algorithm> #include <sstream> #include <complex> #include <stack> #include <queue> using namespace std; typedef long long LL; typedef pair<int, int> PII; typedef complex<double> P; static const double EPS = 1e-8; static const int INF = (int)1e8; #define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i) #define REP(i,n) FOR(i,0,n) unsigned int dp[101][101]; int main(void){ int n; cin>>n; vector<PII> v(n); REP(i,n)cin>>v[i].first>>v[i].second; REP(i,n+1)REP(j,n+1)dp[i][j] = (i==j)?0:INF; FOR(i,1,n){ REP(j,n-i+1){ FOR(k,j,j+i){ int cost = v[j].first * v[k].second * v[k+1].first * v[j+i].second; dp[j][j+i] = min(dp[j][j+1],cost+dp[j][k]+dp[k+1][j+i]); } } } cout<<dp[0][n-1] return 0; }
a.cc: In function 'int main()': a.cc:42:19: error: expected ';' before 'return' 42 | cout<<dp[0][n-1] | ^ | ; 43 | 44 | return 0; | ~~~~~~
s494913038
p00145
C++
#include <iostream> #include <vector> using namespace std; typedef pair<int,int> P; int dp[101][101]; vector<P> v; const int INF=(1<<31)-1; int dfs(int d,int u){ if(u==d) return 0; if(dp[d][u]!=INF) return dp[d][u]; int minCost=INF; for(int i = d; i < u; i++){ minCost=min(minCost,v[d].second*v[u].first*v[i].first*v[i+1].second+dfs(d,i)+dfs(i+1,u)); } dp[d][u]=minCost; return dp[d][u]; } int main(){ int n; cin>>n; for(int i = 0; i < n; i++){ int over,down; cin>>over>>down; v.push_back(P(over,down)); } reverse(v.begin(),v.end()); for(int i = 0; i < 101; i++) fill(dp[i],dp[i]+101,INF); cout<<dfs(0,n-1)<<endl; return 0; }
a.cc:11:22: warning: integer overflow in expression of type 'int' results in '2147483647' [-Woverflow] 11 | const int INF=(1<<31)-1; | ~~~~~~~^~ a.cc: In function 'int main()': a.cc:35:9: error: 'reverse' was not declared in this scope 35 | reverse(v.begin(),v.end()); | ^~~~~~~
s653836757
p00146
C
#include <stdio.h> // printf(), scanf() #include <stdlib.h> // abs() #include <string.h> // memset() #include <stdbool.h> #define MAX_N 15 #define MAX_S (1 << MAX_N) const double INF = 1e10; int n; int s[MAX_N], l[MAX_N], p[MAX_N]; double dp[MAX_N][MAX_S]; int w[MAX_N][MAX_S]; short prev[MAX_N][MAX_S][2]; int ord[MAX_N]; int main(int argc, char **argv) { scanf("%d", &n); for (int i = 0; i < n; ++i) scanf("%d%d%d", &s[i], &l[i], &p[i]); memset(prev, -1, sizeof(prev)); int S = 1; for (int i = 0; i < n; i++, S <<= 1) w[i][S] = p[i]; int e = 1 << n; for (int k = 1; k < e; ++k) { S = 1; for (int i = 0; i < n; ++i, S <<= 1) { if (k & S) continue; int t = k | S; for (int j = 0; j < n; ++j) { if (i == j || w[j][k] == 0) continue; int d = abs(l[i] - l[j]); double x = dp[j][k] + d * ((70 + 20 * w[j][k])) / 2000.0); if (dp[i][t] == 0 || x < dp[i][t]) { dp[i][t] = x; w[i][t] = w[j][k] + p[i]; prev[i][t][0] = j; prev[i][t][1] = k; } } } } double min = INF; int u = 0; for (int i = 0; i < n; ++i) { double y = dp[i][e - 1]; if (y == 0) continue; if (y < min) { min = y; u = i; } } ord[0] = u; int v = e - 1; for (int k = 1; k < n; ++k) { ord[k] = prev[u][v][0]; v = prev[u][v][1]; u = ord[k]; } for (int i = n - 1; i >= 0; --i) printf("%d%c", s[ord[i]], (i != 0) ? ' ' : '\n'); return 0; }
main.c: In function 'main': main.c:46:89: error: expected ',' or ';' before ')' token 46 | double x = dp[j][k] + d * ((70 + 20 * w[j][k])) / 2000.0); | ^
s655888029
p00146
C
#include <stdio.h> #include <math.h> #include <stdlib.h> int i,j,n,num[20],dist[20],wei[20],next[10000000]; double search(int code,int weg,int now){ if(code>=(int)pow(2.0,n)-1)return 0; int div=2,sel,i,wgg; double ttt=999999999,tim,addt; if(next[code]>=0){ sel=now;wgg=weg;i=code;tim=0.0; while(i<(int)pow(2.0,n)-1){ tim+=abs(dist[sel]-dist[next[i]])*(wgg+70)/2000.0; sel=i; wgg+=wei[i]; i+=(int)pow(2.0,next[i]); } return tim; } for(i=0;i<n;i++,div*=2){ if(code%div<div/2){ if(now==-1)addt=0; else addt=abs(dist[now]-dist[i])*(weg+70)/2000.0; tim=addt+search(code+div/2,weg+wei[i],i); if(ttt>tim){ttt=tim;sel=i;} } } next[code]=sel; return ttt; } int main(){ scanf("%d",&n); for(i=int(pow(2.0,n));i>=0;i--)next[i]=-1; for(i=0;i<n;i++){ scanf("%d %d %d",&num[i],&dist[i],&wei[i]); wei[i]*=20; } search(0,0,-1); for(i=0,j=0;i<n;i++){ printf("%d%s",num[next[j]],i<n-1?" ":"\n"); j+=(int)pow(2.0,next[j]); } return 0; }
main.c: In function 'main': main.c:43:15: error: expected expression before 'int' 43 | for(i=int(pow(2.0,n));i>=0;i--)next[i]=-1; | ^~~
s269898212
p00146
C++
#include<bits/stdc++.h> using namespace std; #define INF 1000000007 int main(void){ int n; cin >> n; int k[n][3]; for(int i = 0; i < n; i++) cin >> k[i][0] >> k[i][1] >> k[i][2]; int we[1 << n];{ for(int i = 0; i < (1 << n); i++){ we[i] = 0; for(int j = 0; j < n; j++){ if(!(i & (1 << i))) we[i] += k[i][2] * 20; } } double dp[1 << n][2]; int ro[1 << n]; fill(dp, dp + (1 << n), INF); fill(ro, ro + (1 << n), -1); dp[0][0] = 0; dp[0][1] = -1; ro[0] = -1; for(int i = 0; i < (1 << n); i++){ if(dp[i][0] != INF){ for(int j = 0; j < n; j++){ if(!(i & (1 << i))){ double cost; if(i == 0) cost = k[j][1] / (2000 / 70); else if(i + (i << j) == (1 << n - 1){ cost = abs(k[dp[i][1]][1] - k[j][1]) / (2000 / (70 + we[i]); cost += abs(k[n - 1][1] - k[j][1]) / (2000 / (70 + we[1 << n - 1]); } else cost = abs(k[dp[i][1]][1] - k[j][1]) / (2000 / (70 + we[i]); if(dp[i + (i << j)][0] > dp[i][0] + cost){ dp[i + (i << j)][0] = dp[i][0] + cost; dp[i + (i << j)][1] = j; ro[i + (i << j)] = i; } } } } } int ans[n], p = 1 << n - 1; for(int i = n - 1; i >= 0; i--){ ans[i] = ro[p]; p = ro[p]; } cout << ans[0]; for(int i = 1; i < n; i++) cout << ' ' << ans[i]; cout << endl; return 0; }
a.cc: In function 'int main()': a.cc:27:77: error: expected ')' before '{' token 27 | else if(i + (i << j) == (1 << n - 1){ | ~ ^ | ) a.cc:50:2: error: expected '}' at end of input 50 | } | ^ a.cc:4:15: note: to match this '{' 4 | int main(void){ | ^ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = double (*)[2]; _Tp = int; typename __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, void>::__type = void]': /usr/include/c++/14/bits/stl_algobase.h:998:21: required from 'void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = double (*)[2]; _Tp = int]' 998 | { std::__fill_a1(__first, __last, __value); } | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1029:20: required from 'void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = double (*)[2]; _Tp = int]' 1029 | std::__fill_a(__first, __last, __value); | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:19:6: required from here 19 | fill(dp, dp + (1 << n), INF); fill(ro, ro + (1 << n), -1); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:952:18: error: incompatible types in assignment of 'const int' to 'double [2]' 952 | *__first = __tmp; | ~~~~~~~~~^~~~~~~
s927665773
p00146
C++
#include <bits/stdc++.h> #define FOR(i,a,b) for(int i= (a); i<((int)b); ++i) #define RFOR(i,a) for(int i=(a); i >= 0; --i) #define FOE(i,a) for(auto i : a) #define ALL(c) (c).begin(), (c).end() #define RALL(c) (c).rbegin(), (c).rend() #define DUMP(x) cerr << #x << " = " << (x) << endl; #define SUM(x) std::accumulate(ALL(x), 0LL) #define MIN(v) *std::min_element(v.begin(), v.end()) #define MAX(v) *std::max_element(v.begin(), v.end()) #define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end()) #define BIT_ON(bit, i) (bit & (1LL << i)) #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()); typedef long long LL; template<typename T> using V = std::vector<T>; template<typename T> using VV = std::vector<std::vector<T>>; template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>; template<typename T> using VVVV = std::vector<std::vector<std::vector<std::vector<T>>>>; template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; } template<class T> inline void print(T x) { std::cout << x << std::endl; } template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) { if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; } template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; } template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); } template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); } const int INF = 1L << 30; const double EPS = 1e-9; const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No"; const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 }; // 4近傍(右, 下, 左, 上) const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 }; using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; V<tuple<int, int, int>> v(N); FOR(i, 0, N) { int S, D, V; cin >> S >> D >> V; v[i] = make_tuple(S, D, V); } VV<int> dist(101, V<int>(101, 0)); FOR(i, 0, N) { FOR(j, 0, N) { int a, b, c, d, e, f; tie(a, b, c) = v[i]; tie(d, e, f) = v[j]; dist[i][j] = dist[j][i] = abs(b - e); } } vector<int> weight(1LL << N); FOR(b, 0, 1LL << N) { int w = 0; FOR(i, 0, N) { if ((BIT_ON(b, i)) { w += get<2>(v[i]); } } weight[b] = w; } VV<int> pre(1LL << N, V<int>(N, -1)); VV<double> dp(1LL << N, V<double>(N, INF)); FOR(i, 0, N) { dp[1LL << i][i] = 0; } FOR(b, 0, 1LL << N) { FOR(i, 0, N) { FOR(j, 0, N) { if (BIT_ON(b, i) and not BIT_ON(b, j)) { int d = dist[i][j]; int w = weight[b] * 20; double cost = (2000.0 / (70.0 + w)) * d; if (dp[b][i] + cost < dp[b | (1LL << j)][j]) { dp[b | (1LL << j)][j] = dp[b][i] + cost; pre[b | (1LL << j)][j] = i; } } } } } int now = -1; double mini_cost = INF; FOR(i, 0, N) { if (dp[(1LL << N) - 1][i] < mini_cost) { mini_cost = dp[(1LL << N) - 1][i]; now = i; } } vector<int> ans; auto b = (1LL << N) - 1; while (now != -1) { ans.emplace_back(get<0>(v[now])); int p = now; now = pre[b][now]; b &= ~(1LL << p); } FOR(i, 0, ans.size()) { if (i != 0) { cout << " "; } cout << ans[i]; } cout << endl; return 0; }
a.cc: In function 'int main()': a.cc:67:31: error: expected ')' before '{' token 67 | if ((BIT_ON(b, i)) { | ~ ^~ | ) a.cc:70:9: error: expected primary-expression before '}' token 70 | } | ^
s830695542
p00146
C++
#include<iostream> #include<vector> #include<queue> #include<map> #include<functional> #include<tuple> #include<algorithm> #include<cmath> #include<cfloat> using namespace std; class Store { public: double distance, gold; Store(double d, double g) :distance(d), gold(g) {} }; enum {COST, GOLD, ID, PATH}; typedef tuple<double, double, int, vector<int>> Node; double upperbound; vector<int> bfs(const vector<Store>& store, int start) { int n = store.size(); priority_queue<Node, vector<Node>, greater<Node>> q; q.push(Node(0.0, 0.0, start, {start})); while(!q.empty()) { Node current = q.top(); q.pop(); if(get<COST>(current) >= upperbound) break; if(get<PATH>(current).size() == n) { upperbound = get<COST>(current); return get<PATH>(current); } for(int i = 0; i < n; ++i) { vector<int> path = get<PATH>(current); if(find(path.begin(), path.end(), i) != path.end()) continue; int id = get<ID>(current); double gold = get<GOLD>(current); double cost = get<COST>(current); gold += store[id].gold; cost += fabs(store[id].distance - store[i].distance) * (70.0 + gold) / 2000.0; path.push_back(i); q.push(Node(cost, gold, i, path)); } } return vector<int>; } int main() { int n; cin >> n; vector<Store> store; map<int, int> id; for(int i = 0; i < n; ++i) { int no; double distance, gold; cin >> no >> distance >> gold; id[id.size()] = no; store.push_back(Store(distance, gold * 20.0)); } vector<int> answer; upperbound = DBL_MAX; for(int i = 0; i < n; ++i) { vector<int> result = bfs(store, i); if(!result.empty()) answer = result; } for(int i = 0; i < answer.size(); ++i) cout << (i == 0 ? "" : " ") << id[answer[i]]; cout << endl; }
a.cc: In function 'std::vector<int> bfs(const std::vector<Store>&, int)': a.cc:47:23: error: expected primary-expression before ';' token 47 | return vector<int>; | ^
s468493152
p00146
C++
// AOJ 0146 #include<cstdio> #include<cstdlib> #include<algorithm> #include<limits> #include<vector> #define rep(i,a) for( int i = 0; i != (a); ++i ) #define repi(i,a,b) for( int i = (a); i != (b); ++i ) const int MAX_V = 15; const double INF = std::numeric_limits<double>::max()/4.0; int n; int ord[MAX_V], d[MAX_V], w[MAX_V]; double dp[MAX_V][1<<MAX_V]; double ans = INF; int ansOrd[MAX_V]; void rec( int v, double t, int ws, int S, std::vector<int> &ords ) { if( t > dp[v][S] ) return; if( S == (1<<n)-1 && ans > t ) { ans = t; rep( i, n ) ansOrd[i] = ords[i]; return; } rep( u, n ) { if( !(S>>u&1) ) { double vel = 2000.0/(70.0+ws), tim = t+abs(d[u]-d[v])/vel; ords.push_back( ord[u] ); if( dp[u][S|1<<u] > tim ) { dp[u][S|1<<u] = tim; rec( u, tim, ws+w[u]*20, S|1<<u, ords ); } ords.pop_back(); } } return; } int main() { scanf( "%d", &n ); rep( i, n ) scanf( "%d%d%d", ord+i, d+i, w+i ); std::fill( (double*)dp, (double*)(size_t(dp)+sizeof(dp)), INF ); rep( i, n ) rec( i, 0, w[i]*20, 1<<i, std::vector<int>( 1, ord[i] ) ); rep( i, n ) printf( "%d%c", ansOrd[i], i==n-1?'\n':' ' ); return 0; }
a.cc: In function 'int main()': a.cc:61:48: error: cannot bind non-const lvalue reference of type 'std::vector<int>&' to an rvalue of type 'std::vector<int>' 61 | rec( i, 0, w[i]*20, 1<<i, std::vector<int>( 1, ord[i] ) ); | ^~~~~~~~~~~~~~~~~~~~~~~~ a.cc:19:61: note: initializing argument 5 of 'void rec(int, double, int, int, std::vector<int>&)' 19 | void rec( int v, double t, int ws, int S, std::vector<int> &ords ) | ~~~~~~~~~~~~~~~~~~^~~~
s663342854
p00146
C++
# define _CRT_SECURE_NO_WARNINGS 1 # define _USE_MATH_DEFINES # include <iostream> # include <intrin.h> # include <numeric> # include <string> # include <bitset> # include <vector> # include <algorithm> # include <cstdlib> # include <cstdio> # include <cstring> # include <cstdlib> # include <iomanip> # include <queue> # include <sstream> # include <climits> # include <cmath> # include <list> # include <functional> # include <string> # include <ctime> # include <set> # include <forward_list> # include <map> # include <stack> using namespace std; # define INF ((int)(1<<25)) # define REP(i,n) for(int i=0;i<(int)n;i++) # define FOR(i,n) REP(i,n) # define TORAD 2.0*M_PI/360.0 # define INT(x) int x;cin>>x; # define ALL(x) (x).begin(),(x).end() # define RALL(x) (x).rbegin(),(x).rend() # define DEBUG(x) cout<<#x<<" :"<<x<<endl; # define EPS 1e-12 template<class T> void debug(T a) { for (auto i : a)cout << i << endl; } typedef vector<int> vi; typedef vector<string> vs; typedef pair<int, int> pii; typedef pair<int, pii> piii; int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 }; typedef pair< double, vi > pdv; int n; int dis[17] = {}, num[17] = {}, vol[17] = {}; pdv memo[1 << 15][16]; double calcw(int bit) { double ans = 0.0; for (int i = 0; i < n; i++) { if (bit & 1 << i)ans += vol[i] * 20.0; } return ans; } pdv dp(int bit, int prev) { if (__popcnt(bit) == n)return pdv(0.0, {}); if (memo[bit][prev].first >= 0.0)return memo[bit][prev]; double w = calcw(bit); double speed = 2000.0 / (70.0 + w); pdv ans(9999999999.0, {}); for (int i = 0; i < n; i++) { if (bit & 1 << i)continue; pdv s = dp(bit | 1 << i, i); s.first += 1.0*abs(dis[i] - dis[prev]) / speed; if (ans.first > s.first) { ans = s; ans.second.push_back(num[i]); } } return memo[bit][prev] = ans; } int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> num[i] >> dis[i] >> vol[i]; } for (int i = 0; i < 1 << 15; i++) { for (int j = 0; j < 16; j++) { memo[i][j] = pdv(-1.0, {}); } } pdv ans = dp(0, n); reverse(ALL(ans.second)); for (int i = 0; i < n; i++) { if (i)cout << " "; cout << ans.second[i]; } cout << endl; }
a.cc:4:11: fatal error: intrin.h: No such file or directory 4 | # include <intrin.h> | ^~~~~~~~~~ compilation terminated.
s802618456
p00146
C++
# define _CRT_SECURE_NO_WARNINGS 1 # define _USE_MATH_DEFINES # include <iostream> # include <numeric> # include <string> # include <bitset> # include <vector> # include <algorithm> # include <cstdlib> # include <cstdio> # include <cstring> # include <cstdlib> # include <iomanip> # include <queue> # include <sstream> # include <climits> # include <cmath> # include <list> # include <functional> # include <string> # include <ctime> # include <set> # include <forward_list> # include <map> # include <stack> using namespace std; # define INF ((int)(1<<25)) # define REP(i,n) for(int i=0;i<(int)n;i++) # define FOR(i,n) REP(i,n) # define TORAD 2.0*M_PI/360.0 # define INT(x) int x;cin>>x; # define ALL(x) (x).begin(),(x).end() # define RALL(x) (x).rbegin(),(x).rend() # define DEBUG(x) cout<<#x<<" :"<<x<<endl; # define EPS 1e-12 template<class T> void debug(T a) { for (auto i : a)cout << i << endl; } typedef vector<int> vi; typedef vector<string> vs; typedef pair<int, int> pii; typedef pair<int, pii> piii; int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 }; typedef pair< double, vi > pdv; int n; int dis[17] = {}, num[17] = {}, vol[17] = {}; pdv memo[1 << 15][16]; double calcw(int bit) { double ans = 0.0; for (int i = 0; i < n; i++) { if (bit & 1 << i)ans += vol[i] * 20.0; } return ans; } pdv dp(int bit, int prev) { if (__popcnt(bit) == n)return pdv(0.0, {}); if (memo[bit][prev].first >= 0.0)return memo[bit][prev]; double w = calcw(bit); double speed = 2000.0 / (70.0 + w); pdv ans(9999999999.0, {}); for (int i = 0; i < n; i++) { if (bit & 1 << i)continue; pdv s = dp(bit | 1 << i, i); s.first += 1.0*abs(dis[i] - dis[prev]) / speed; if (ans.first > s.first) { ans = s; ans.second.push_back(num[i]); } } return memo[bit][prev] = ans; } int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> num[i] >> dis[i] >> vol[i]; } for (int i = 0; i < 1 << 15; i++) { for (int j = 0; j < 16; j++) { memo[i][j] = pdv(-1.0, {}); } } pdv ans = dp(0, n); reverse(ALL(ans.second)); for (int i = 0; i < n; i++) { if (i)cout << " "; cout << ans.second[i]; } cout << endl; }
a.cc: In function 'pdv dp(int, int)': a.cc:65:13: error: '__popcnt' was not declared in this scope 65 | if (__popcnt(bit) == n)return pdv(0.0, {}); | ^~~~~~~~
s528975123
p00146
C++
#include <iostream> #include <cstdio> #include <vector> #include <algorithm> #include <complex> #include <cstring> #include <cstdlib> #include <string> #include <cmath> #include <queue> using namespace std; #define REP(i,n) for(int i=0;i<(int)n;++i) #define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i) #define ALL(c) (c).begin(), (c).end() const int INF = 1<<29; typedef double Weight; typedef vector<Weight> Array; typedef vector<Array> Matrix; const int M = 15; int m[15]; vector<vector<double> > best(1<<M,vector<double>(15, INF)); Weight best[1<<M][M]; int prev[1<<M][M]; void buildPath(int S, int i, vector<int> &path) { if (!S) return; buildPath(S^(1<<i), prev[S][i], path); path.push_back(i); } Weight shortestHamiltonPath(Matrix w, int s, vector<int> &path) { int n = w.size(); int N = 1 << n; // REP(S,N) REP(i,n) best[S][i] = INF; best[1<<s][s] = 0; REP(S,N) { int we = 0; REP(i,n) // ツ個サツ催敖づ個重ツつウツづーツ計ツ算 if (S&(1<<i)) we += m[i]; REP(i,n) if (S&(1<<i)) REP(j,n) { if (best[S|(1<<j)][j] > best[S][i] + w[i][j] * (we + 70)) { best[S|(1<<j)][j] = best[S][i] + w[i][j] * (we + 70); prev[S|(1<<j)][j] = i; } } } int t = min_element(best[N-1], best[N-1]+n) - best[N-1]; // ツ可スツ氾板姪堋づ個陳クツ点ツづ終ツづュツづゥツづ個つェツ暗ェツ氾板短ツつュツづ按づゥツつゥ path.clear(); buildPath(N-1, t, path); return best[N-1][t]; } int main() { int n; while(cin >> n) { int a[n], l[n]; REP(i,n) { cin >> a[i] >> l[i] >> m[i]; m[i] *= 20; } Matrix mat(n, Array(n)); REP(i,n) REP(j,n) mat[i][j] = abs(l[j]-l[i]); int mi = INF; vector<int> path; REP(i,n) { vector<int> tpath; int t = shortestHamiltonPath(mat, i, tpath); if (t < mi) { path = tpath; mi = t; } } REP(i, path.size()) { if (i) cout << " "; cout << a[path[i]]; } cout << endl; } }
a.cc:26:8: error: conflicting declaration 'Weight best [32768][15]' 26 | Weight best[1<<M][M]; | ^~~~ a.cc:25:25: note: previous declaration as 'std::vector<std::vector<double> > best' 25 | vector<vector<double> > best(1<<M,vector<double>(15, INF)); | ^~~~ a.cc: In function 'void buildPath(int, int, std::vector<int>&)': a.cc:30:23: error: reference to 'prev' is ambiguous 30 | buildPath(S^(1<<i), prev[S][i], path); | ^~~~ In file included from /usr/include/c++/14/string:47, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)' 244 | prev(_BidirectionalIterator __x, typename | ^~~~ a.cc:27:8: note: 'int prev [32768][15]' 27 | int prev[1<<M][M]; | ^~~~ a.cc: In function 'Weight shortestHamiltonPath(Matrix, int, std::vector<int>&)': a.cc:48:13: error: reference to 'prev' is ambiguous 48 | prev[S|(1<<j)][j] = i; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)' 244 | prev(_BidirectionalIterator __x, typename | ^~~~ a.cc:27:8: note: 'int prev [32768][15]' 27 | int prev[1<<M][M]; | ^~~~ a.cc:52:43: error: no match for 'operator+' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<double> >, std::vector<double> >::value_type' {aka 'std::vector<double>'} and 'int') 52 | int t = min_element(best[N-1], best[N-1]+n) - best[N-1]; // ツ可スツ氾板姪堋づ個陳クツ点ツづ終ツづュツづゥツづ個つェツ暗ェツ氾板短ツつュツづ按づゥツつゥ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:627:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)' 627 | operator+(typename reverse_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:627:5: note: template argument deduction/substitution failed: a.cc:52:44: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' 52 | int t = min_element(best[N-1], best[N-1]+n) - best[N-1]; // ツ可スツ氾板姪堋づ個陳クツ点ツづ終ツづュツづゥツづ個つェツ暗ェツ氾板短ツつュツづ按づゥツつゥ | ^ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)' 1798 | operator+(typename move_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: template argument deduction/substitution failed: a.cc:52:44: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'int' 52 | int t = min_element(best[N-1], best[N-1]+n) - best[N-1]; // ツ可スツ氾板姪堋づ個陳クツ点ツづ終ツづュツづゥツづ個つェツ暗ェツ氾板短ツつュツづ按づゥツつゥ | ^ In file included from /usr/include/c++/14/string:54: /usr/include/c++/14/bits/basic_string.h:3598:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3598 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3598:5: note: template argument deduction/substitution failed: a.cc:52:44: note: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<double> >, std::vector<double> >::value_type' {aka 'std::vector<double>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 52 | int t = min_element(best[N-1], best[N-1]+n) - best[N-1]; // ツ可スツ氾板姪堋づ個陳クツ点ツづ終ツづュツづゥツづ個つェツ暗ェツ氾板短ツつュツづ按づゥツつゥ | ^ /usr/include/c++/14/bits/basic_string.h:3616:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3616 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3616:5: note: template argument deduction/substitution failed: a.cc:52:44: note: mismatched types 'const _CharT*' and 'std::vector<double>' 52 | int t = min_element(best[N-1], best[N-1]+n) - best[N-1]; // ツ可スツ氾板姪堋づ個陳クツ点ツづ終ツづュツづゥツづ個つェツ暗ェツ氾板短ツつュツづ按づゥツつゥ | ^ /usr/include/c++/14/bits/basic_string.h:3635:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3635 | operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3635:5: note: template argument deduction/substitution failed: a.cc:52:44: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int' 52 | int t = min_element(best[N-1], best[N-1]+n) - best[N-1]; // ツ可スツ氾板姪堋づ個陳クツ点ツづ終ツづュツづゥツづ個つェツ暗ェツ氾板短ツつュツづ按づゥツつゥ | ^ /usr/include/c++/14/bits/basic_string.h:3652:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3652 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3652:5: note: template argument deduction/substitution failed: a.cc:52:44: note: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<double> >, std::vector<double> >::value_type' {aka 'std::vector<double>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 52 | int t = min_element(best[N-1], best[N-1]+n) - best[N-1]; // ツ可スツ氾板姪堋づ個陳クツ点ツづ終ツづュツづゥツづ個つェツ暗ェツ氾板短ツつュツづ按づゥツつゥ | ^ /usr/include/c++/14/bits/basic_string.h:3670:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)' 3670 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3670:5: note: template argument deduction/substitution failed: a.cc:52:44: note: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<double> >, std::vector<double> >::value_type' {aka 'std::vector<double>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 52 | int t = min_element(best[N-1], best[N-1]+n) - best[N-1]; // ツ可スツ氾板姪堋づ個陳クツ点ツづ終ツづュツづゥツづ個つェツ暗ェツ氾板短ツつュツづ按づゥツつゥ | ^ /usr/include/c++/14/bits/basic_string.h:3682:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3682 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3682:5: note: template argument deduction/substitution failed: a.cc:52:44: note: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<double> >, std::vector<double> >::value_type' {aka 'std::vector<double>'} is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 52 | int t = min_element(best[N-1], best[N-1]+n) - best[N-1]; // ツ可スツ氾板姪堋づ個陳クツ点ツづ終ツづュツづゥツづ個つェツ暗ェツ氾板短ツつュツづ按づゥツつゥ | ^ /usr/include/c++/14/bits/basic_string.h:3689:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3689 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3689:5: note: template argument deduction/substitution failed: a.cc:52:44: note: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<double> >, std::vector<double> >::value_type' {aka 'std::vector<double>'} is not derived from 'const std::__cxx11::basic_stri
s429557724
p00146
C++
#include <iostream> #include <cstdio> #include <cstring> #include <vector> #include <cmath> using namespace std; int id[20],dist[20],cnt[20]; double dp[1<<15][15]; pair<int,int> prev[1<<15][15]; int W[1<<15]; int main(){ int n; while(cin >> n && n){ for(int i = 0 ; i < n ; i++){ cin >> id[i] >> dist[i] >> cnt[i]; } for(int i = 0 ; i < (1<<15) ; i++) for(int j = 0 ; j < 15 ; j++) dp[i][j] = 1e12; for(int i = 0 ; i < n ; i++) dp[0][i] = 0; for(int i = 0 ; i < (1<<n) ; i++){ int aaa = 0; for(int j = 0 ; j < n ; j++) if(i>>j&1) aaa += cnt[j]; W[i] = aaa; } for(int i = 0 ; i < (1<<n) ; i++){ for(int j = 0 ; j < n ; j++){ for(int k = 0 ; k < n ; k++){ double cost = abs(dist[j]-dist[k]) / ( 2000.0 / (70+20*W[i]) )+dp[i][j]; if( dp[i|(1<<k)][k] > cost + 1e-9 ){ prev[i|(1<<k)][k] = make_pair(i,j); dp[i|(1<<k)][k] = cost; } } } } double minCost = 1e12; for(int i = 0 ; i < n ; i++){ minCost = min( dp[(1<<n)-1][i] , minCost) ; } for(int i = 0 ; i < n ; i++){ if( fabs(minCost - dp[(1<<n)-1][i]) < 1e-9){ int bit = (1<<n)-1; int k = i; vector<int> idd; while(bit){ idd.push_back(k); pair<int,int> tmp = prev[bit][k]; bit = tmp.first; k = tmp.second; } reverse(idd.begin(),idd.end()); for(int j = 0 ; j < n ; j++) cout << id[idd[j]] << (char)(j==n-1?10:32); } } } }
a.cc: In function 'int main()': a.cc:37:49: error: reference to 'prev' is ambiguous 37 | prev[i|(1<<k)][k] = make_pair(i,j); | ^~~~ In file included from /usr/include/c++/14/string:47, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)' 244 | prev(_BidirectionalIterator __x, typename | ^~~~ a.cc:10:15: note: 'std::pair<int, int> prev [32768][15]' 10 | pair<int,int> prev[1<<15][15]; | ^~~~ a.cc:55:61: error: reference to 'prev' is ambiguous 55 | pair<int,int> tmp = prev[bit][k]; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)' 244 | prev(_BidirectionalIterator __x, typename | ^~~~ a.cc:10:15: note: 'std::pair<int, int> prev [32768][15]' 10 | pair<int,int> prev[1<<15][15]; | ^~~~ a.cc:59:33: error: 'reverse' was not declared in this scope 59 | reverse(idd.begin(),idd.end()); | ^~~~~~~
s223331614
p00147
Java
import static java.util.Arrays.deepToString; import java.util.Arrays; import java.util.PriorityQueue; import java.util.Scanner; import java.util.concurrent.PriorityBlockingQueue; public class Main_pq { public static void main(String[] args) { new Main_pq().run(); } void tr(Object... os) { System.err.println(deepToString(os)); } Scanner sc = new Scanner(System.in); public void run() { int[] ans = new int[100]; PriorityQueue<Event> pq = new PriorityQueue<Event>(); int[] table = new int[17]; Arrays.fill(table, -1); int nextGroup = 0; for (int i = 0; i < 100; i++) { Event e = new Event(); e.id = i; e.move = Event.ARRIVE; e.initTime = i * 5; e.time = i * 5; e.num = i % 5 == 1 ? 5 : 2; e.duration = 17*(i%2) + 3*(i%3)+19; pq.add(e); } while (!pq.isEmpty()) { Event e = pq.poll(); if (e.move == Event.LEAVE) { for (int i = 0; i < table.length; i++) { if (table[i] == e.id) table[i] = -1; } } else if (e.move == Event.ARRIVE) { int pos = -1; if (nextGroup == e.id) { for (int i = 0; i + e.num <= table.length; i++) { boolean ok = true; for (int j = 0; j < e.num; j++) { if (table[i+j] != -1) { ok = false; break; } } if (ok) { pos = i; break; } } } if (pos >= 0) { // 座る ans[e.id] = e.time - e.initTime; for (int j = 0; j < e.num; j++) { table[pos + j] = e.id; } e.time += e.duration; e.move = Event.LEAVE; pq.add(e); nextGroup++; } else { // 空いてなければ待つ。時刻+1して席が空くのを待つ手抜き実装 e.time++; pq.add(e); } } } for (;sc.hasNext();) { int n = sc.nextInt(); System.out.println(ans[n]); } } class Event implements Comparable<Event> { static final int LEAVE = 0; static final int ARRIVE = 1; int id; int initTime; int move; int time; int num; int duration; @Override public int compareTo(Event o) { int c = time - o.time; if (c == 0) c = move - o.move; if (c == 0) c = id - o.id; return c; } } }
Main.java:9: error: class Main_pq is public, should be declared in a file named Main_pq.java public class Main_pq { ^ 1 error
s819945273
p00147
Java
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class M2ain { public static void main(String[] args) { int[] seats = new int[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; int[] groupMembers = new int[] {2, 5, 2, 2, 2}; int[] eatTimes = new int[] {19, 39, 25, 36, 22, 42}; int headGroup = -1; int pastMinutes = 0; List<Integer> waitTime = new ArrayList<Integer>(); while (waitTime.size() <= 100) { // たべおわる for (int i = 0; i < seats.length; i++) { seats[i] = seats[i] == 0 ? 0 : seats[i] - 1; } // 来店 if (headGroup == -1 && pastMinutes % 5 == 0) { headGroup = pastMinutes / 5; } // ちゃくせき while (headGroup != -1) { int needsSequencialSeats = groupMembers[headGroup % 5]; int sequencialSeats = 0; int startIndex = -1; for (int i = 0; i < seats.length; i++) { sequencialSeats = seats[i] == 0 ? sequencialSeats + 1 : 0; if (sequencialSeats == needsSequencialSeats) { startIndex = i - (needsSequencialSeats - 1); break; } } if (startIndex != -1) { // すわれたみたい waitTime.add(headGroup, pastMinutes - (headGroup * 5)); for (int i = startIndex; i < (startIndex + needsSequencialSeats); i++) { seats[i] = eatTimes[headGroup % 6]; } headGroup = ((headGroup * 5) < pastMinutes) ? headGroup + 1 : -1; } else { // すわれなかったみたい break; } } pastMinutes++; } Scanner sc = new Scanner(System.in); while (sc.hasNext()) { System.out.println(waitTime.get(sc.nextInt())); } } }
Main.java:5: error: class M2ain is public, should be declared in a file named M2ain.java public class M2ain { ^ 1 error
s434004678
p00147
Java
<?php $waitTime = array(0, 0, 0, 0, 0, 0, 14, 9, 4, 0, 0, 8, 3, 2, 0, 0, 15, 10, 15, 10, 6, 12, 7, 9, 11, 6, 23, 18, 13, 8, 3, 23, 18, 13, 8, 3, 34, 29, 24, 22, 17, 28, 23, 24, 19, 27, 34, 29, 35, 30, 28, 31, 28, 23, 24, 28, 42, 37, 32, 27, 22, 42, 37, 32, 27, 22, 53, 48, 43, 41, 36, 47, 42, 43, 38, 46, 64, 59, 54, 49, 44, 61, 56, 51, 46, 44, 72, 67, 62, 57, 52, 72, 67, 62, 57, 52, 83, 78, 73, 71); while($input = fscanf(STDIN, "%d")){ fprintf(STDOUT, "%d\n", $waitTime[$input]); } return(0); ?>
Main.java:1: error: class, interface, enum, or record expected <?php ^ Main.java:104: error: class, interface, enum, or record expected while($input = fscanf(STDIN, "%d")){ ^ Main.java:106: error: class, interface, enum, or record expected } ^ Main.java:108: error: class, interface, enum, or record expected ?> ^ 4 errors
s245304611
p00147
Java
import java.util.ArrayList; import java.util.List; import java.util.Scanner; /** * プログラミングコンテスト<br> * 0147:Fukushimaken * * @author t690593 * */ public class Fukushimaken { /** 最大グループ数 */ static final int MAX_GROUP_NUKMBER = 100; /** 客の到着間隔 */ static final int TIME_INTERVAL = 5; /** 座席 */ static int[] sheets = new int[17]; /** 各グループの待ち時間 */ static int[] waitTimes = new int[100]; /** インプット */ static List<Integer> inputs = new ArrayList<Integer>(); /** インプットの最大グループ番号 */ static int maxGroupNumber; /** * メイン * * @param args */ public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNextInt()) { int inputNum = scanner.nextInt(); if (maxGroupNumber < inputNum) { maxGroupNumber = inputNum; } inputs.add(inputNum); } // 先頭のグループ番号 int frontGroup = 0; // 最後尾のグループ番号 int endGroup = 0; // 経過時間:分単位 int time = 0; while (true) { // 5分間隔でお店に客がくる(最後尾は最大グループ数より大きくならない) if (time % TIME_INTERVAL == 0 && endGroup < MAX_GROUP_NUKMBER) { endGroup++; } for (int i = frontGroup; i < endGroup; i++) { int ninzu = i % 5 == 1 ? 5 : 2; int startPos = getOpendSheetsPosition(ninzu); if (startPos >= 0) { // 座れる場合 secureSheets(startPos, calcMealtime(i), ninzu); waitTimes[i] = time - i * 5; frontGroup++; } else { // 座れない場合 break; } } // 入力されたグループ番号の最大番号が席に座るか、全てのグループが席に座ったら終了 if (frontGroup == MAX_GROUP_NUKMBER || frontGroup > maxGroupNumber) { break; } // 座席の食事時間を時間経過とともに減らす for (int i = 0; i < sheets.length; i++) { if (sheets[i] > 0) { sheets[i] = sheets[i] - 1; } } time++; } for (int input : inputs) { System.out.println(waitTimes[input]); } } /** * 空いている席の最初の席番号を返却する<br> * 席が空いていない場合、-1を返却する * * @param peopleNum * グループの人数 * @return 空いている席の最初の席番号 */ private static int getOpendSheetsPosition(int peopleNum) { int startPos = -1; int openedSheetNum = 0; for (int i = 0; i < sheets.length; i++) { if (sheets[i] == 0) { if (startPos == -1) { startPos = i; } openedSheetNum++; } else { startPos = -1; openedSheetNum = 0; } if (openedSheetNum == peopleNum) { return startPos; } } return -1; } /** * 対象グループの食事時間を計算する * * @param targetGroup * 対象グループ番号 * @return 食事間 */ private static int calcMealtime(int targetGroup) { return 17 * (targetGroup % 2) + 3 * (targetGroup % 3) + 19; } /** * 座席を確保する * * @param startPos * 席確保する最初の席番号 * @param mealtime * 確保する時間(食事時間) * @param peopleNum * グループ人数 */ private static void secureSheets(int startPos, int mealtime, int peopleNum) { for (int i = 0; i < peopleNum; i++) { sheets[i + startPos] = mealtime; } } }
Main.java:12: error: class Fukushimaken is public, should be declared in a file named Fukushimaken.java public class Fukushimaken { ^ 1 error