submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s326122236
p00200
C++
#include<iostream> #include<cstring> #include<vector> using namespace std; #define rep(i,n) for(int i=0;i<n;++i) #define INF 300000 struct E { int a,b,c,t; E(){}; E(int a,int b,int c,int t):a(a),b(b),c(c),t(t){}; }; //E cs[700]; unsigned int d[150]; int main() { int n,m,k,p,q,r; while(cin >> n >> m) { if(n==0 && m==0)break; vector<E> cs; int ta,tb,tc,tt; rep(i,n) { cin >> ta>>tb>>tc >>tt; cs.push_back =( E(ta,tb,tc,tt)); cs.push_back( E(tb,ta,tc,tt)); } cin >> k; rep(i,k) { memset(d,INF,150*sizeof(int)); cin >> p >> q >>r; d[p] = 0; bool update = false; if(r==0)while(true) { update = false; rep(j,m*2) { if(d[cs[j].a] != INF && d[cs[j].b] > d[cs[j].a] + cs[j].c) { update = true; d[cs[j].b] = d[cs[j].a] + cs[j].c; } } if(!update) break; } if(r==1)while(true) { update = false; rep(j,m*2) { if(d[cs[j].a] != INF && d[cs[j].b] > d[cs[j].a] + cs[j].t) { update = true; d[cs[j].b] = d[cs[j].a] + cs[j].t; } } if(!update) break; } cout << d[q] << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:28:16: error: invalid use of member function 'std::vector<E>::push_back' (did you forget the '()' ?) 28 | cs.push_back =( E(ta,tb,tc,tt)); | ~~~^~~~~~~~~
s937679448
p00200
C++
#include <iostream> #include <algorithm> using namespace std; const int INF = 1000000; int cost[301][301],time[301][301]; void time_WF(int m){ for(int k = 0;k <= m;++k){ for(int i = 0;i <= m;++i){ for(int j = 0;j <= m;++j){ time[i][j] = min(time[i][j],time[i][k] + time[k][j]); } } } return; } void cost_WF(int m){ for(int k = 0;k <= m;++k){ for(int i = 0;i <= m;++i){ for(int j = 0;j <= m;++j){ cost[i][j] = min(cost[i][j],cost[i][k] + cost[k][j]); } } } return; } int main(){ int n,m; while(cin >> n >> m,n || m){ int a,b,icost,itime,c,r; for(int i = 0;i <= m;++i){ for(int j = 0;j <= m;++j){ if(i == j) { cost[i][i] = 0; time[i][i] = 0; } else { cost[i][j] = cost[j][i] = INF; time[i][j] = time[j][i] = INF; } } } for(int i = 0;i < n;++i){ cin >> a >> b >> icost >> itime; cost[a][b] = cost[b][a] = icost; time[a][b] = time[b][a] = itime; } cin >> c; for(int i = 0;i < c;++i){ cin >> a >> b >> r; if(r == 1){ time_WF(m); cout << time[a][b] << endl; } else { cost_WF(m); cout << cost[a][b] << endl; } } } return 0; }
a.cc:5:33: error: 'int time [301][301]' redeclared as different kind of entity 5 | int cost[301][301],time[301][301]; | ^ In file included from /usr/include/pthread.h:23, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157, from /usr/include/c++/14/ext/atomicity.h:35, from /usr/include/c++/14/bits/ios_base.h:39, 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/time.h:76:15: note: previous declaration 'time_t time(time_t*)' 76 | extern time_t time (time_t *__timer) __THROW; | ^~~~ a.cc: In function 'void time_WF(int)': a.cc:10:39: warning: pointer to a function used in arithmetic [-Wpointer-arith] 10 | time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:10:42: warning: pointer to a function used in arithmetic [-Wpointer-arith] 10 | time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:10:56: warning: pointer to a function used in arithmetic [-Wpointer-arith] 10 | time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:10:59: warning: pointer to a function used in arithmetic [-Wpointer-arith] 10 | time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:10:67: warning: pointer to a function used in arithmetic [-Wpointer-arith] 10 | time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:10:70: warning: pointer to a function used in arithmetic [-Wpointer-arith] 10 | time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:10:80: warning: pointer to a function used in arithmetic [-Wpointer-arith] 10 | time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:10:83: warning: pointer to a function used in arithmetic [-Wpointer-arith] 10 | time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:10:72: error: invalid operands of types 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} and 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} to binary 'operator+' 10 | time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ~~~~~~~~~~ ^ ~~~~~~~~~~ | | | | | time_t(time_t*) noexcept {aka long int(long int*) noexcept} | time_t(time_t*) noexcept {aka long int(long int*) noexcept} a.cc: In function 'int main()': a.cc:34:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 34 | time[i][i] = 0; | ^ a.cc:34:50: warning: pointer to a function used in arithmetic [-Wpointer-arith] 34 | time[i][i] = 0; | ^ a.cc:34:52: error: assignment of read-only location '*(time + (((sizetype)i) * 2))' 34 | time[i][i] = 0; | ~~~~~~~~~~~^~~ a.cc:38:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 38 | time[i][j] = time[j][i] = INF; | ^ a.cc:38:50: warning: pointer to a function used in arithmetic [-Wpointer-arith] 38 | time[i][j] = time[j][i] = INF; | ^ a.cc:38:60: warning: pointer to a function used in arithmetic [-Wpointer-arith] 38 | time[i][j] = time[j][i] = INF; | ^ a.cc:38:63: warning: pointer to a function used in arithmetic [-Wpointer-arith] 38 | time[i][j] = time[j][i] = INF; | ^ a.cc:38:65: error: assignment of read-only location '*(time + (((sizetype)j) + ((sizetype)i)))' 38 | time[i][j] = time[j][i] = INF; | ~~~~~~~~~~~^~~~~ a.cc:45:31: warning: pointer to a function used in arithmetic [-Wpointer-arith] 45 | time[a][b] = time[b][a] = itime; | ^ a.cc:45:34: warning: pointer to a function used in arithmetic [-Wpointer-arith] 45 | time[a][b] = time[b][a] = itime; | ^ a.cc:45:44: warning: pointer to a function used in arithmetic [-Wpointer-arith] 45 | time[a][b] = time[b][a] = itime; | ^ a.cc:45:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 45 | time[a][b] = time[b][a] = itime; | ^ a.cc:45:49: error: assignment of read-only location '*(time + (((sizetype)b) + ((sizetype)a)))' 45 | time[a][b] = time[b][a] = itime; | ~~~~~~~~~~~^~~~~~~ a.cc:52:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 52 | cout << time[a][b] << endl; | ^ a.cc:52:50: warning: pointer to a function used in arithmetic [-Wpointer-arith] 52 | cout << time[a][b] << endl; | ^
s894190535
p00200
C++
#include <iostream> #include <algorithm> using namespace std; const int INF = 1000000; int cost[301][301],time[301][301]; int main(){ int n,m; while(cin >> n >> m,n || m){ int a,b,icost,itime,c,r; for(int i = 0;i <= m;++i){ for(int j = 0;j <= m;++j){ if(i == j) { cost[i][i] = 0; time[i][i] = 0; } else { cost[i][j] = cost[j][i] = INF; time[i][j] = time[j][i] = INF; } } } for(int i = 0;i < n;++i){ cin >> a >> b >> icost >> itime; cost[a][b] = cost[b][a] = icost; time[a][b] = time[b][a] = itime; } cin >> c; for(int i = 0;i < c;++i){ cin >> a >> b >> r; for(int k = 0;k <= m;++k){ for(int i = 0;i <= m;++i){ for(int j = 0;j <= m;++j){ if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); else cost[i][j] = min(cost[i][j],cost[i][k] + cost[k][j]); } } } if(r == 1) cout << time[a][b] << endl; else cout << cost[a][b] << endl; } } return 0; }
a.cc:5:33: error: 'int time [301][301]' redeclared as different kind of entity 5 | int cost[301][301],time[301][301]; | ^ In file included from /usr/include/pthread.h:23, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157, from /usr/include/c++/14/ext/atomicity.h:35, from /usr/include/c++/14/bits/ios_base.h:39, 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/time.h:76:15: note: previous declaration 'time_t time(time_t*)' 76 | extern time_t time (time_t *__timer) __THROW; | ^~~~ a.cc: In function 'int main()': a.cc:14:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 14 | time[i][i] = 0; | ^ a.cc:14:50: warning: pointer to a function used in arithmetic [-Wpointer-arith] 14 | time[i][i] = 0; | ^ a.cc:14:52: error: assignment of read-only location '*(time + (((sizetype)i) * 2))' 14 | time[i][i] = 0; | ~~~~~~~~~~~^~~ a.cc:18:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 18 | time[i][j] = time[j][i] = INF; | ^ a.cc:18:50: warning: pointer to a function used in arithmetic [-Wpointer-arith] 18 | time[i][j] = time[j][i] = INF; | ^ a.cc:18:60: warning: pointer to a function used in arithmetic [-Wpointer-arith] 18 | time[i][j] = time[j][i] = INF; | ^ a.cc:18:63: warning: pointer to a function used in arithmetic [-Wpointer-arith] 18 | time[i][j] = time[j][i] = INF; | ^ a.cc:18:65: error: assignment of read-only location '*(time + (((sizetype)j) + ((sizetype)i)))' 18 | time[i][j] = time[j][i] = INF; | ~~~~~~~~~~~^~~~~ a.cc:25:31: warning: pointer to a function used in arithmetic [-Wpointer-arith] 25 | time[a][b] = time[b][a] = itime; | ^ a.cc:25:34: warning: pointer to a function used in arithmetic [-Wpointer-arith] 25 | time[a][b] = time[b][a] = itime; | ^ a.cc:25:44: warning: pointer to a function used in arithmetic [-Wpointer-arith] 25 | time[a][b] = time[b][a] = itime; | ^ a.cc:25:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 25 | time[a][b] = time[b][a] = itime; | ^ a.cc:25:49: error: assignment of read-only location '*(time + (((sizetype)b) + ((sizetype)a)))' 25 | time[a][b] = time[b][a] = itime; | ~~~~~~~~~~~^~~~~~~ a.cc:33:66: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:33:69: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:33:83: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:33:86: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:33:94: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:33:97: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:33:107: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:33:110: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:33:99: error: invalid operands of types 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} and 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} to binary 'operator+' 33 | if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ~~~~~~~~~~ ^ ~~~~~~~~~~ | | | | | time_t(time_t*) noexcept {aka long int(long int*) noexcept} | time_t(time_t*) noexcept {aka long int(long int*) noexcept} a.cc:38:50: warning: pointer to a function used in arithmetic [-Wpointer-arith] 38 | if(r == 1) cout << time[a][b] << endl; | ^ a.cc:38:53: warning: pointer to a function used in arithmetic [-Wpointer-arith] 38 | if(r == 1) cout << time[a][b] << endl; | ^
s508195455
p00200
C++
#include <iostream> #include <algorithm> using namespace std; const int INF = 1000000; int cost[301][301],time[301][301]; int main(){ int n,m; while(cin >> n >> m && (n != 0 || m != 0)){ int a,b,icost,itime,c,r; for(int i = 0;i <= m;++i){ for(int j = 0;j <= m;++j){ if(i == j) { cost[i][i] = 0; time[i][i] = 0; } else { cost[i][j] = INF; time[i][j] = INF; } } } for(int i = 0;i < n;++i){ cin >> a >> b >> icost >> itime; cost[a][b] = cost[b][a] = icost; time[a][b] = time[b][a] = itime; } cin >> c; for(int i = 0;i < c;++i){ cin >> a >> b >> r; for(int k = 0;k <= m;++k){ for(int i = 0;i <= m;++i){ for(int j = 0;j <= m;++j){ if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); else cost[i][j] = min(cost[i][j],cost[i][k] + cost[k][j]); } } } if(r == 1) cout << time[a][b] << endl; else cout << cost[a][b] << endl; } } return 0; }
a.cc:5:33: error: 'int time [301][301]' redeclared as different kind of entity 5 | int cost[301][301],time[301][301]; | ^ In file included from /usr/include/pthread.h:23, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157, from /usr/include/c++/14/ext/atomicity.h:35, from /usr/include/c++/14/bits/ios_base.h:39, 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/time.h:76:15: note: previous declaration 'time_t time(time_t*)' 76 | extern time_t time (time_t *__timer) __THROW; | ^~~~ a.cc: In function 'int main()': a.cc:14:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 14 | time[i][i] = 0; | ^ a.cc:14:50: warning: pointer to a function used in arithmetic [-Wpointer-arith] 14 | time[i][i] = 0; | ^ a.cc:14:52: error: assignment of read-only location '*(time + (((sizetype)i) * 2))' 14 | time[i][i] = 0; | ~~~~~~~~~~~^~~ a.cc:18:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 18 | time[i][j] = INF; | ^ a.cc:18:50: warning: pointer to a function used in arithmetic [-Wpointer-arith] 18 | time[i][j] = INF; | ^ a.cc:18:52: error: assignment of read-only location '*(time + (((sizetype)i) + ((sizetype)j)))' 18 | time[i][j] = INF; | ~~~~~~~~~~~^~~~~ a.cc:25:31: warning: pointer to a function used in arithmetic [-Wpointer-arith] 25 | time[a][b] = time[b][a] = itime; | ^ a.cc:25:34: warning: pointer to a function used in arithmetic [-Wpointer-arith] 25 | time[a][b] = time[b][a] = itime; | ^ a.cc:25:44: warning: pointer to a function used in arithmetic [-Wpointer-arith] 25 | time[a][b] = time[b][a] = itime; | ^ a.cc:25:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 25 | time[a][b] = time[b][a] = itime; | ^ a.cc:25:49: error: assignment of read-only location '*(time + (((sizetype)b) + ((sizetype)a)))' 25 | time[a][b] = time[b][a] = itime; | ~~~~~~~~~~~^~~~~~~ a.cc:33:66: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:33:69: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:33:83: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:33:86: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:33:94: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:33:97: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:33:107: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:33:110: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:33:99: error: invalid operands of types 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} and 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} to binary 'operator+' 33 | if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ~~~~~~~~~~ ^ ~~~~~~~~~~ | | | | | time_t(time_t*) noexcept {aka long int(long int*) noexcept} | time_t(time_t*) noexcept {aka long int(long int*) noexcept} a.cc:38:50: warning: pointer to a function used in arithmetic [-Wpointer-arith] 38 | if(r == 1) cout << time[a][b] << endl; | ^ a.cc:38:53: warning: pointer to a function used in arithmetic [-Wpointer-arith] 38 | if(r == 1) cout << time[a][b] << endl; | ^
s731175965
p00200
C++
#include <iostream> #include <algorithm> using namespace std; const int INF = 1000000; int cost[301][301],time[301][301]; int main(){ int n,m; while(cin >> n >> m,n || m){ int a,b,icost,itime,c,r; for(int i = 0;i <= m;++i){ for(int j = 0;j <= m;++j){ if(i == j) { cost[i][i] = 0; time[i][i] = 0; } else { cost[i][j] = INF; time[i][j] = INF; } } } for(int i = 0;i < n;++i){ cin >> a >> b >> icost >> itime; cost[a][b] = cost[b][a] = icost; time[a][b] = time[b][a] = itime; } cin >> c; for(int d = 0;d < c;++d){ cin >> a >> b >> r; for(int k = 0;k <= m;++k){ for(int i = 0;i <= m;++i){ for(int j = 0;j <= m;++j){ if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); else cost[i][j] = min(cost[i][j],cost[i][k] + cost[k][j]); } } } if(r == 1) cout << time[a][b] << endl; else cout << cost[a][b] << endl; } } return 0; }
a.cc:5:33: error: 'int time [301][301]' redeclared as different kind of entity 5 | int cost[301][301],time[301][301]; | ^ In file included from /usr/include/pthread.h:23, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157, from /usr/include/c++/14/ext/atomicity.h:35, from /usr/include/c++/14/bits/ios_base.h:39, 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/time.h:76:15: note: previous declaration 'time_t time(time_t*)' 76 | extern time_t time (time_t *__timer) __THROW; | ^~~~ a.cc: In function 'int main()': a.cc:14:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 14 | time[i][i] = 0; | ^ a.cc:14:50: warning: pointer to a function used in arithmetic [-Wpointer-arith] 14 | time[i][i] = 0; | ^ a.cc:14:52: error: assignment of read-only location '*(time + (((sizetype)i) * 2))' 14 | time[i][i] = 0; | ~~~~~~~~~~~^~~ a.cc:18:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 18 | time[i][j] = INF; | ^ a.cc:18:50: warning: pointer to a function used in arithmetic [-Wpointer-arith] 18 | time[i][j] = INF; | ^ a.cc:18:52: error: assignment of read-only location '*(time + (((sizetype)i) + ((sizetype)j)))' 18 | time[i][j] = INF; | ~~~~~~~~~~~^~~~~ a.cc:25:31: warning: pointer to a function used in arithmetic [-Wpointer-arith] 25 | time[a][b] = time[b][a] = itime; | ^ a.cc:25:34: warning: pointer to a function used in arithmetic [-Wpointer-arith] 25 | time[a][b] = time[b][a] = itime; | ^ a.cc:25:44: warning: pointer to a function used in arithmetic [-Wpointer-arith] 25 | time[a][b] = time[b][a] = itime; | ^ a.cc:25:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 25 | time[a][b] = time[b][a] = itime; | ^ a.cc:25:49: error: assignment of read-only location '*(time + (((sizetype)b) + ((sizetype)a)))' 25 | time[a][b] = time[b][a] = itime; | ~~~~~~~~~~~^~~~~~~ a.cc:33:66: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:33:69: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:33:83: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:33:86: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:33:94: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:33:97: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:33:107: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:33:110: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ^ a.cc:33:99: error: invalid operands of types 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} and 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} to binary 'operator+' 33 | if(r == 1) time[i][j] = min(time[i][j],time[i][k] + time[k][j]); | ~~~~~~~~~~ ^ ~~~~~~~~~~ | | | | | time_t(time_t*) noexcept {aka long int(long int*) noexcept} | time_t(time_t*) noexcept {aka long int(long int*) noexcept} a.cc:38:50: warning: pointer to a function used in arithmetic [-Wpointer-arith] 38 | if(r == 1) cout << time[a][b] << endl; | ^ a.cc:38:53: warning: pointer to a function used in arithmetic [-Wpointer-arith] 38 | if(r == 1) cout << time[a][b] << endl; | ^
s175429160
p00200
C++
#include<iostream> #include<algorithm> #include<queue> using namespace std; int cost[101][101]; int gtime[101][101]; struct tSta{ int val, sta; tSta( int s ){ val = 0; sta = s; } }; bool operator<( const tSta& l, const tSta& r ){ return l.val > r.val; } int main(){ priority_queue<tSta> que; int n, m, k; while( cin >> n >> m, n||m ){ memset( cost, 0, sizeof(cost) ); memset( gtime, 0, sizeof(gtime) ); for( int i=0; i<n; i++ ){ int a, b, c, t; cin >> a >> b >> c >> t; cost[a][b] = cost[b][a] = c; gtime[a][b] = gtime[b][a] = t; } cin >> k; for( int i=0; i<k; i++ ){ int p, q, r; cin >> p >> q >> r; while( !que.empty() ) que.pop(); que.push( tSta(p) ); while( !que.empty() ){ tSta ts = que.top(); if( ts.sta == q ) break; que.pop(); if( r==0 ){ // cost for( int j=1; j<=m; j++ ){ if( cost[ts.sta][j] > 0 ){ tSta next(j); next.val = ts.val + cost[ts.sta][j]; que.push( next ); } } }else if( r==1 ){ // time for( int j=1; j<=m; j++ ){ if( gtime[ts.sta][j] > 0 ){ tSta next(j); next.sta = j; next.val = ts.val + gtime[ts.sta][j]; que.push( next ); } } } } cout << que.top().val << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:25:17: error: 'memset' was not declared in this scope 25 | memset( cost, 0, sizeof(cost) ); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include<queue> +++ |+#include <cstring> 4 | using namespace std;
s820299892
p00200
C++
#include <iostream> #include <cstring> using namespace std; const int INF=100000; int cost[101][101]; int time[101][101]; int main(void){ int n,m,a,b,c; while(1){ for(a=0;a<=100;a++){ for(b=0;b<=100;b++){ cost[a][b]=INF; time[a][b]=INF; if(a==b)cost[a][b]=0,time[a][b]=0; } } cin >> n >> m; if(n==0 && m==0)break; for(a=0;a<n;a++){ int f,t,co,ti; scanf("%d%d%d%d",&f,&t,&co,&ti); if(cost[f][t]>co)cost[f][t]=co,cost[t][f]=co; if(time[f][t]>ti)time[f][t]=ti,time[t][f]=ti; } for(a=1;a<=m;a++){ for(b=1;b<=m;b++){ for(c=1;c<=m;c++){ cost[a][b]=min(cost[a][b],cost[a][c]+cost[c][b]); time[a][b]=min(time[a][b],time[a][c]+time[c][b]); } } } cin >> n; for(a=0;a<n;a++){ int d,f,t; scanf("%d%d%d",&f,&t,&d); if(d==0)printf("%d\n",cost[f][t]); if(d==1)printf("%d\n",time[f][t]); } } return 0; }
a.cc:8:18: error: 'int time [101][101]' redeclared as different kind of entity 8 | int time[101][101]; | ^ In file included from /usr/include/pthread.h:23, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157, from /usr/include/c++/14/ext/atomicity.h:35, from /usr/include/c++/14/bits/ios_base.h:39, 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/time.h:76:15: note: previous declaration 'time_t time(time_t*)' 76 | extern time_t time (time_t *__timer) __THROW; | ^~~~ a.cc: In function 'int main()': a.cc:16:39: warning: pointer to a function used in arithmetic [-Wpointer-arith] 16 | time[a][b]=INF; | ^ a.cc:16:42: warning: pointer to a function used in arithmetic [-Wpointer-arith] 16 | time[a][b]=INF; | ^ a.cc:16:43: error: assignment of read-only location '*(time + (((sizetype)a) + ((sizetype)b)))' 16 | time[a][b]=INF; | ~~~~~~~~~~^~~~ a.cc:17:60: warning: pointer to a function used in arithmetic [-Wpointer-arith] 17 | if(a==b)cost[a][b]=0,time[a][b]=0; | ^ a.cc:17:63: warning: pointer to a function used in arithmetic [-Wpointer-arith] 17 | if(a==b)cost[a][b]=0,time[a][b]=0; | ^ a.cc:17:64: error: assignment of read-only location '*(time + (((sizetype)a) + ((sizetype)b)))' 17 | if(a==b)cost[a][b]=0,time[a][b]=0; | ~~~~~~~~~~^~ a.cc:26:34: warning: pointer to a function used in arithmetic [-Wpointer-arith] 26 | if(time[f][t]>ti)time[f][t]=ti,time[t][f]=ti; | ^ a.cc:26:37: warning: pointer to a function used in arithmetic [-Wpointer-arith] 26 | if(time[f][t]>ti)time[f][t]=ti,time[t][f]=ti; | ^ a.cc:26:38: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 26 | if(time[f][t]>ti)time[f][t]=ti,time[t][f]=ti; | ~~~~~~~~~~^~~ a.cc:26:48: warning: pointer to a function used in arithmetic [-Wpointer-arith] 26 | if(time[f][t]>ti)time[f][t]=ti,time[t][f]=ti; | ^ a.cc:26:51: warning: pointer to a function used in arithmetic [-Wpointer-arith] 26 | if(time[f][t]>ti)time[f][t]=ti,time[t][f]=ti; | ^ a.cc:26:52: error: assignment of read-only location '*(time + (((sizetype)f) + ((sizetype)t)))' 26 | if(time[f][t]>ti)time[f][t]=ti,time[t][f]=ti; | ~~~~~~~~~~^~~ a.cc:26:62: warning: pointer to a function used in arithmetic [-Wpointer-arith] 26 | if(time[f][t]>ti)time[f][t]=ti,time[t][f]=ti; | ^ a.cc:26:65: warning: pointer to a function used in arithmetic [-Wpointer-arith] 26 | if(time[f][t]>ti)time[f][t]=ti,time[t][f]=ti; | ^ a.cc:26:66: error: assignment of read-only location '*(time + (((sizetype)t) + ((sizetype)f)))' 26 | if(time[f][t]>ti)time[f][t]=ti,time[t][f]=ti; | ~~~~~~~~~~^~~ a.cc:32:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 32 | time[a][b]=min(time[a][b],time[a][c]+time[c][b]); | ^ a.cc:32:50: warning: pointer to a function used in arithmetic [-Wpointer-arith] 32 | time[a][b]=min(time[a][b],time[a][c]+time[c][b]); | ^ a.cc:32:62: warning: pointer to a function used in arithmetic [-Wpointer-arith] 32 | time[a][b]=min(time[a][b],time[a][c]+time[c][b]); | ^ a.cc:32:65: warning: pointer to a function used in arithmetic [-Wpointer-arith] 32 | time[a][b]=min(time[a][b],time[a][c]+time[c][b]); | ^ a.cc:32:73: warning: pointer to a function used in arithmetic [-Wpointer-arith] 32 | time[a][b]=min(time[a][b],time[a][c]+time[c][b]); | ^ a.cc:32:76: warning: pointer to a function used in arithmetic [-Wpointer-arith] 32 | time[a][b]=min(time[a][b],time[a][c]+time[c][b]); | ^ a.cc:32:84: warning: pointer to a function used in arithmetic [-Wpointer-arith] 32 | time[a][b]=min(time[a][b],time[a][c]+time[c][b]); | ^ a.cc:32:87: warning: pointer to a function used in arithmetic [-Wpointer-arith] 32 | time[a][b]=min(time[a][b],time[a][c]+time[c][b]); | ^ a.cc:32:77: error: invalid operands of types 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} and 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} to binary 'operator+' 32 | time[a][b]=min(time[a][b],time[a][c]+time[c][b]); | ~~~~~~~~~~^~~~~~~~~~~ | | | | | time_t(time_t*) noexcept {aka long int(long int*) noexcept} | time_t(time_t*) noexcept {aka long int(long int*) noexcept} a.cc:41:53: warning: pointer to a function used in arithmetic [-Wpointer-arith] 41 | if(d==1)printf("%d\n",time[f][t]); | ^ a.cc:41:56: warning: pointer to a function used in arithmetic [-Wpointer-arith] 41 | if(d==1)printf("%d\n",time[f][t]); | ^
s897289440
p00200
C++
#include<iostream> #include<string> #include<algorithm> #include<vector> #include<cstring> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) #define REP(n) rep(i,n) const int INF = 1<<28, MAXM = 101, COST = 0, TIME = 1; int cost[2][MAXM][MAXM]; int main() { int n, m, a, b, c, t; while(cin >> n >> m) { REP(2)rep(j,m)rep(k,m)cost[i][j][k] = INF; //fill(cost, sizeof(cost), INF); REP(n) { cin >> a >> b >> c >> t; a--; b--; cost[TIME][a][b] = cost[TIME][b][a] = t; cost[COST][a][b] = cost[COST][b][a] = c; } int k; cin >> k; int p, q, r; rep(s,k) { cin >> p >> q >> r; p--; q--; memset(d, INF , sizeof(d)); //rep(i,m)rep(j,m) d[i][j] = cost[r][i][j]; rep(l,m)rep(i,m)rep(j,m) { cost[TIME][i][j] = min(cost[TIME][i][j], cost[TIME][i][l] + cost[TIME][l][j]); cost[COST][i][j] = min(cost[COST][i][j], cost[COST][i][l] + cost[COST][l][j]); } cout << cost[r][p][q] << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:37:20: error: 'd' was not declared in this scope 37 | memset(d, INF , sizeof(d)); | ^
s159917246
p00200
C++
#include<stdio.h> int dijkstra(short int,short int,short int,short int,short int**); int main(void) { short int f1, f2, n, m, a, b, ic, ti, k, p, q, r, out, **cost, **time; while(scanf("%d %d",&n,&m) && n > 0) { cost = new int *[m]; time = new int *[n]; //線路設計 for(f1 = 0; f1 < n; f1++) { cost[f1] = new int [m]; time[f1] = new int [m]; for(f2 = 0; f2 < m; f2++) { cost[f1][f2] = 0; time[f1][f2] = 0; } } //線路情報入力 for(f1 = 0; f1 < n; f1++) { scanf("%d %d %d %d",&a, &b, &ic, &ti); a--; b--; cost[a][b] = ic; cost[b][a] = ic; time[a][b] = ti; time[b][a] = ti; } //問い合わせ入力 scanf("%d",&k); for(f1 = 1; f1 <= k; f1++) { scanf("%d %d %d",&p, &q, &r); p--; q--; if(r == 0) out = dijkstra(n, m, p, q, cost); else out = dijkstra(n, m, p, q, time); printf("%d\n",out); } } return 0; } int dijkstra(int n, int m, int p, int q, int **temp) { int *C, *sum, f1, po = p, min; //Cの中身 0:出発していない 1:出発した C = new int [m]; sum = new int [m]; //初期化 for(f1 = 0; f1 < m; f1++) { C[f1] = 0; sum[f1] = 0; } //ダイクストラ探索 while(po != q) { //現在いる地点から次の駅までにかかるコストを計算し次に行く駅の現時点での最小コストを求める for(f1 = 0; f1 < m; f1++) { if(temp[po][f1] > 0) { if(C[f1] == 0 && (sum[f1] == 0 || temp[po][f1] + sum[po] < sum[f1])) sum[f1] = temp[po][f1] + sum[po]; } } //出発していない駅の中で最小コストを選択する min = 0; C[po] = 1; for(f1 = 0; f1 < m; f1++) { if(C[f1] == 0 && sum[f1] != 0 && (min == 0 || sum[f1] < min)) { min = sum[f1]; po = f1; } } } return sum[q]; }
a.cc: In function 'int main()': a.cc:12:24: error: cannot convert 'int**' to 'short int**' in assignment 12 | cost = new int *[m]; | ^~~~~~~~~~~~ | | | int** a.cc:13:24: error: cannot convert 'int**' to 'short int**' in assignment 13 | time = new int *[n]; | ^~~~~~~~~~~~ | | | int** a.cc:17:36: error: cannot convert 'int*' to 'short int*' in assignment 17 | cost[f1] = new int [m]; | ^~~~~~~~~~~ | | | int* a.cc:18:36: error: cannot convert 'int*' to 'short int*' in assignment 18 | time[f1] = new int [m]; | ^~~~~~~~~~~ | | | int*
s885472399
p00200
C++
#include<stdio.h> int dijkstra(short int,short int,short int,short int,short int**); int main(void) { short int f1, f2, n, m, a, b, ic, ti, k, p, q, r, out, **cost, **time; while(scanf("%d %d",&n,&m) && n > 0) { cost = new int *[m]; time = new int *[n]; //線路設計 for(f1 = 0; f1 < n; f1++) { cost[f1] = new int [m]; time[f1] = new int [m]; for(f2 = 0; f2 < m; f2++) { cost[f1][f2] = 0; time[f1][f2] = 0; } } //線路情報入力 for(f1 = 0; f1 < n; f1++) { scanf("%d %d %d %d",&a, &b, &ic, &ti); a--; b--; cost[a][b] = ic; cost[b][a] = ic; time[a][b] = ti; time[b][a] = ti; } //問い合わせ入力 scanf("%d",&k); for(f1 = 1; f1 <= k; f1++) { scanf("%d %d %d",&p, &q, &r); p--; q--; if(r == 0) out = dijkstra(n, m, p, q, cost); else out = dijkstra(n, m, p, q, time); printf("%d\n",out); } } return 0; } int dijkstra(short int n,short int m,short int p,short int q,short int **temp) { int *C, *sum, f1, po = p, min; //Cの中身 0:出発していない 1:出発した C = new int [m]; sum = new int [m]; //初期化 for(f1 = 0; f1 < m; f1++) { C[f1] = 0; sum[f1] = 0; } //ダイクストラ探索 while(po != q) { //現在いる地点から次の駅までにかかるコストを計算し次に行く駅の現時点での最小コストを求める for(f1 = 0; f1 < m; f1++) { if(temp[po][f1] > 0) { if(C[f1] == 0 && (sum[f1] == 0 || temp[po][f1] + sum[po] < sum[f1])) sum[f1] = temp[po][f1] + sum[po]; } } //出発していない駅の中で最小コストを選択する min = 0; C[po] = 1; for(f1 = 0; f1 < m; f1++) { if(C[f1] == 0 && sum[f1] != 0 && (min == 0 || sum[f1] < min)) { min = sum[f1]; po = f1; } } } return sum[q]; }
a.cc: In function 'int main()': a.cc:12:24: error: cannot convert 'int**' to 'short int**' in assignment 12 | cost = new int *[m]; | ^~~~~~~~~~~~ | | | int** a.cc:13:24: error: cannot convert 'int**' to 'short int**' in assignment 13 | time = new int *[n]; | ^~~~~~~~~~~~ | | | int** a.cc:17:36: error: cannot convert 'int*' to 'short int*' in assignment 17 | cost[f1] = new int [m]; | ^~~~~~~~~~~ | | | int* a.cc:18:36: error: cannot convert 'int*' to 'short int*' in assignment 18 | time[f1] = new int [m]; | ^~~~~~~~~~~ | | | int*
s085336671
p00200
C++
#include<stdio.h> short int dijkstra(short int,short int,short int,short int,short int**); int main(void) { short int f1, f2, n, m, a, b, ic, ti, k, p, q, r, out, **cost, **time; while(scanf("%d %d",&n,&m) && n > 0) { cost = new short int *[m]; time = new short int *[n]; //線路設計 for(f1 = 0; f1 < n; f1++) { cost[f1] = new short int [m]; time[f1] = new short int [m]; for(f2 = 0; f2 < m; f2++) { cost[f1][f2] = 0; time[f1][f2] = 0; } } //線路情報入力 for(f1 = 0; f1 < n; f1++) { scanf("%d %d %d %d",&a, &b, &ic, &ti); a--; b--; cost[a][b] = ic; cost[b][a] = ic; time[a][b] = ti; time[b][a] = ti; } //問い合わせ入力 scanf("%d",&k); for(f1 = 1; f1 <= k; f1++) { scanf("%d %d %d",&p, &q, &r); p--; q--; if(r == 0) out = dijkstra(n, m, p, q, cost); else out = dijkstra(n, m, p, q, time); printf("%d\n",out); } } return 0; } short int dijkstra(short int n,short int m,short int p,short int q,short int **temp) { short int *C, *sum, f1, po = p, min; //Cの中身 0:出発していない 1:出発した C = new int [m]; sum = new int [m]; //初期化 for(f1 = 0; f1 < m; f1++) { C[f1] = 0; sum[f1] = 0; } //ダイクストラ探索 while(po != q) { //現在いる地点から次の駅までにかかるコストを計算し次に行く駅の現時点での最小コストを求める for(f1 = 0; f1 < m; f1++) { if(temp[po][f1] > 0) { if(C[f1] == 0 && (sum[f1] == 0 || temp[po][f1] + sum[po] < sum[f1])) sum[f1] = temp[po][f1] + sum[po]; } } //出発していない駅の中で最小コストを選択する min = 0; C[po] = 1; for(f1 = 0; f1 < m; f1++) { if(C[f1] == 0 && sum[f1] != 0 && (min == 0 || sum[f1] < min)) { min = sum[f1]; po = f1; } } } return sum[q]; }
a.cc: In function 'short int dijkstra(short int, short int, short int, short int, short int**)': a.cc:58:13: error: cannot convert 'int*' to 'short int*' in assignment 58 | C = new int [m]; | ^~~~~~~~~~~ | | | int* a.cc:59:15: error: cannot convert 'int*' to 'short int*' in assignment 59 | sum = new int [m]; | ^~~~~~~~~~~ | | | int*
s515862889
p00200
C++
#include<cstdio> #include<algorithm> using namespace std; int main() { while(true) { int timedate[2][105][105]; int n,m; memset(timedate,0,sizeof(timedate)); scanf("%d%d",&n,&m); if(n==0&&m==0)break; int a, b, cost,time; for(int i=0;i<n;i++) { scanf("%d%d%d%d",&a,&b,&cost,&time); timedate[0][a][b]=cost; timedate[0][b][a]=cost; timedate[1][a][b]=time; timedate[1][b][a]=time; } int k; scanf("%d",&k); for(int i=0;i<k;i++) { int p,q,r; int date[105]; int omin=1000000,jmin; fill(date,date+100,-1); scanf("%d%d%d",&p,&q,&r); date[p]=0; for(int u=1;u<100;u++) { omin=1000000; jmin=0; for(int j=1;j<100;j++) { if(date[j]!=-1) { for(int o=1;o<101;o++) { if(timedate[r][j][o]!=0&&o!=-1&&omin>date[j]+timedate[r][j][o]&&date[o]==-1) { omin=date[j]+timedate[r][j][o]; jmin=o; } } } } date[jmin]=omin; } printf("%d\n",date[q]); } } return 0; }
a.cc: In function 'int main()': a.cc:15:5: error: 'memset' was not declared in this scope 15 | memset(timedate,0,sizeof(timedate)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include<algorithm> +++ |+#include <cstring> 3 |
s147567848
p00200
C++
#include <stdio.h> #include <queue> #include <vector> using namespace std; typedef pair<int,int> P;//P.first:最小コスト P.second:頂点番号 //cost[x][i][j]:iからjへの種類xのコスト //xが1なら時間,0なら金額をあらわす int cost[2][301][301]; //smore[x][i][j]:iからjへの最短距離 int smore[2][301][301]; //somerode[x][i]:iから移動できる頂点の番号を保持 queue <int> somerode[2][301]; //m:駅の数 int m; //seeked[i]:頂点iについてダイクストラしたかのフラグ bool seeked[2][301]; //dijkstra(int):ダイクストラ法をstartを始点に行う void dijkstra(int start,int type); int main() { int n,a,b,C,T,p,q,r,ans[300],k; scanf("%d%d",&n,&m); while(n != 0 && m != 0){ //フラグ、コスト、最小値の初期化 for(int i = 0;i <= 300; i++){ seeked[0][i] = false; seeked[1][i] = false; for(int j = 0;j <= 300; j++){ smore[0][i][j] = INT_MAX; smore[1][i][j] = INT_MAX; cost[0][i][j] = 10000; cost[1][i][j] = 10000; } } //路線情報入力 for(int i = 0;i < n; i++){ scanf("%d%d%d%d",&a,&b,&C,&T); if(cost[0][a][b] > C){ cost[0][a][b] = C; somerode[0][a].push(b); //printf("出発:%d 目的:%d コスト:%d 記録コスト:%d\n",a,b,C,cost[0][a][b]); } if(cost[0][b][a] > C){ cost[0][b][a] = C; somerode[0][b].push(a); //printf("出発:%d 目的:%d コスト:%d 記録コスト:%d\n",a,b,C,cost[0][b][a]); } if(cost[1][a][b] > T){ cost[1][a][b] = T; somerode[1][a].push(b); //printf("出発:%d 目的:%d 時間:%d 記録時間:%d\n",a,b,T,cost[1][a][b]); } if(cost[1][b][a] > T){ cost[1][b][a] = T; somerode[1][b].push(a); //printf("出発:%d 目的:%d 時間:%d 記録時間:%d\n",a,b,T,cost[1][b][a]); } } //問い合わせ scanf("%d",&k); //printf("問い合わせ個数:%d\n",k); for(int i = 0;i < k; i++){ scanf("%d%d%d",&p,&q,&r); //printf("p:%d q:%d r:%d",p,q,r); if(seeked[r][q]) ans[i] = smore[r][q][p]; else if (seeked[r][p]) ans[i] = smore[r][p][q]; else{ dijkstra(p,r); ans[i] = smore[r][p][q]; seeked[r][p] = true; } } for(int i = 0; i < k; i++){ printf("%d\n",ans[i]); } scanf("%d%d",&n,&m); } return 0; } void dijkstra(int start,int type){ //printf("キュー宣言前\n"); priority_queue< P,vector<P>,greater<P> > que; //printf("キュー宣言後 %d %d\n",type,start); smore[type][start][start] = 0; //printf("キュー代入前\n"); que.push(P(0,start)); //printf("while前\n"); while(!que.empty()){ P p = que.top(); que.pop(); //キューから最小コストの頂点の番号とコストを取り出す int v = p.second; //vにコストが最小の頂点の番号 int size = somerode[type][v].size(); //printf("最小頂点:%d\n",v); if(smore[type][start][v] < p.first)continue; //もし最小コストが取り出したコストより小さければ更新の必要がないので次のループへ for(int i = 0; i < size; i++){ //somerode[x][i]:iからいける頂点の番号をもつキュー //もし現在の(start-i間最小コスト)より(移動コスト+現在までかかったコスト)が小さければ更新 //printf("更新する点:%d 更新候補前:%d 更新候補後:%d\n",somerode[type][v].front(),smore[type][start][ somerode[type][v].front() ],smore[type][start][v] + cost[type][v][ somerode[type][v].front() ]); if(smore[type][start][ somerode[type][v].front() ] > smore[type][start][v] + cost[type][v][ somerode[type][v].front() ]){ smore[type][start][ somerode[type][v].front() ] = smore[type][start][v] + cost[type][v][ somerode[type][v].front() ]; //printf("更新したsmore:%d 更新した頂点:%d\n",smore[type][start][ somerode[type][v].front() ],somerode[type][v].front()); que.push(P(smore[type][start][ somerode[type][v].front() ],somerode[type][v].front())); //キュー更新 } somerode[type][v].push( somerode[type][v].front() ); somerode[type][v].pop(); } } }
a.cc: In function 'int main()': a.cc:39:50: error: 'INT_MAX' was not declared in this scope 39 | smore[0][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 <queue> +++ |+#include <climits> 3 | #include <vector>
s567193886
p00200
C++
#include <stdio.h> #include <queue> #include <vector> #include <iostream> using namespace std; typedef pair<int,int> P;//P.first:最小コスト P.second:頂点番号 //cost[x][i][j]:iからjへの種類xのコスト //xが1なら時間,0なら金額をあらわす int cost[2][301][301]; //smore[x][i][j]:iからjへの最短距離 int smore[2][301][301]; //somerode[x][i]:iから移動できる頂点の番号を保持 queue <int> somerode[2][301]; //m:駅の数 int m; //seeked[i]:頂点iについてダイクストラしたかのフラグ bool seeked[2][301]; //dijkstra(int):ダイクストラ法をstartを始点に行う void dijkstra(int start,int type); int main() { int n,a,b,C,T,p,q,r,ans[300],k; scanf("%d%d",&n,&m); while(n != 0 && m != 0){ //フラグ、コスト、最小値の初期化 for(int i = 0;i <= 300; i++){ seeked[0][i] = false; seeked[1][i] = false; for(int j = 0;j <= 300; j++){ smore[0][i][j] = INT_MAX; smore[1][i][j] = INT_MAX; cost[0][i][j] = 10000; cost[1][i][j] = 10000; } } //路線情報入力 for(int i = 0;i < n; i++){ scanf("%d%d%d%d",&a,&b,&C,&T); if(cost[0][a][b] > C){ cost[0][a][b] = C; somerode[0][a].push(b); //printf("出発:%d 目的:%d コスト:%d 記録コスト:%d\n",a,b,C,cost[0][a][b]); } if(cost[0][b][a] > C){ cost[0][b][a] = C; somerode[0][b].push(a); //printf("出発:%d 目的:%d コスト:%d 記録コスト:%d\n",a,b,C,cost[0][b][a]); } if(cost[1][a][b] > T){ cost[1][a][b] = T; somerode[1][a].push(b); //printf("出発:%d 目的:%d 時間:%d 記録時間:%d\n",a,b,T,cost[1][a][b]); } if(cost[1][b][a] > T){ cost[1][b][a] = T; somerode[1][b].push(a); //printf("出発:%d 目的:%d 時間:%d 記録時間:%d\n",a,b,T,cost[1][b][a]); } } //問い合わせ scanf("%d",&k); //printf("問い合わせ個数:%d\n",k); for(int i = 0;i < k; i++){ scanf("%d%d%d",&p,&q,&r); //printf("p:%d q:%d r:%d",p,q,r); if(seeked[r][q]) ans[i] = smore[r][q][p]; else if (seeked[r][p]) ans[i] = smore[r][p][q]; else{ dijkstra(p,r); ans[i] = smore[r][p][q]; seeked[r][p] = true; } } for(int i = 0; i < k; i++){ printf("%d\n",ans[i]); } scanf("%d%d",&n,&m); } return 0; } void dijkstra(int start,int type){ //printf("キュー宣言前\n"); priority_queue< P,vector<P>,greater<P> > que; //printf("キュー宣言後 %d %d\n",type,start); smore[type][start][start] = 0; //printf("キュー代入前\n"); que.push(P(0,start)); //printf("while前\n"); while(!que.empty()){ P p = que.top(); que.pop(); //キューから最小コストの頂点の番号とコストを取り出す int v = p.second; //vにコストが最小の頂点の番号 int size = somerode[type][v].size(); //printf("最小頂点:%d\n",v); if(smore[type][start][v] < p.first)continue; //もし最小コストが取り出したコストより小さければ更新の必要がないので次のループへ for(int i = 0; i < size; i++){ //somerode[x][i]:iからいける頂点の番号をもつキュー //もし現在の(start-i間最小コスト)より(移動コスト+現在までかかったコスト)が小さければ更新 //printf("更新する点:%d 更新候補前:%d 更新候補後:%d\n",somerode[type][v].front(),smore[type][start][ somerode[type][v].front() ],smore[type][start][v] + cost[type][v][ somerode[type][v].front() ]); if(smore[type][start][ somerode[type][v].front() ] > smore[type][start][v] + cost[type][v][ somerode[type][v].front() ]){ smore[type][start][ somerode[type][v].front() ] = smore[type][start][v] + cost[type][v][ somerode[type][v].front() ]; //printf("更新したsmore:%d 更新した頂点:%d\n",smore[type][start][ somerode[type][v].front() ],somerode[type][v].front()); que.push(P(smore[type][start][ somerode[type][v].front() ],somerode[type][v].front())); //キュー更新 } somerode[type][v].push( somerode[type][v].front() ); somerode[type][v].pop(); } } }
a.cc: In function 'int main()': a.cc:40:50: error: 'INT_MAX' was not declared in this scope 40 | smore[0][i][j] = INT_MAX; | ^~~~~~~ a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 4 | #include <iostream> +++ |+#include <climits> 5 | using namespace std;
s984536834
p00200
C++
#include<math.h> #include<iostream> #include<string> #include<vector> #include<algorithm> #define REP(i,a,b) for(i=a;i<b;i++) #define rep(i,n) REP(i,0,n) using namespace std; const int INF = (1<<30); int cost[200][200], time[200][200],dist[200]; int x[200][200]; bool vis[200]; int M,N; void dij(int p, int q, int r){ int i,j,k,l,m,n,mn; rep(i,M)rep(j,M)x[i][j]= (r==0)?cost[i][j]:time[i][j]; rep(i,M)vis[i]=false,dist[i]=INF; dist[p-1]=0; for(;;){ k=-1,mn=INF; rep(i,M)if(!vis[i]&&dist[i]<mn){mn=dist[i],k=i;} if(k==-1 || mn>=INF) break; if(k==q-1)break; vis[k]=true; rep(i,M)if(!vis[i])dist[i]=min(dist[i],dist[k]+x[k][i]); } cout<<dist[q-1]<<endl; } int main(){ int i,j,k,l,m,n; while(cin>>N>>M){ if((N|M)==0) break; rep(i,M){ dist[i]=INF; rep(j,M){ if(i==j) {cost[i][j]=time[i][j]=0; continue;} cost[i][j]=time[i][j]=INF; } } rep(i,N){//graph info int a,b,c,t; cin>>a>>b>>c>>t; a--; b--; cost[a][b]=cost[b][a]=c; time[a][b]=time[b][a]=t; } cin>>k; rep(i,k){//question int p,q,r; cin>>p>>q>>r; dij(p,q,r); } } }
a.cc:11:34: error: 'int time [200][200]' redeclared as different kind of entity 11 | int cost[200][200], time[200][200],dist[200]; | ^ In file included from /usr/include/pthread.h:23, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157, from /usr/include/c++/14/ext/atomicity.h:35, from /usr/include/c++/14/bits/ios_base.h:39, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)' 76 | extern time_t time (time_t *__timer) __THROW; | ^~~~ a.cc: In function 'void dij(int, int, int)': a.cc:18:58: warning: pointer to a function used in arithmetic [-Wpointer-arith] 18 | rep(i,M)rep(j,M)x[i][j]= (r==0)?cost[i][j]:time[i][j]; | ^ a.cc:18:61: warning: pointer to a function used in arithmetic [-Wpointer-arith] 18 | rep(i,M)rep(j,M)x[i][j]= (r==0)?cost[i][j]:time[i][j]; | ^ a.cc:18:40: error: operands to '?:' have different types 'int' and 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} 18 | rep(i,M)rep(j,M)x[i][j]= (r==0)?cost[i][j]:time[i][j]; | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~ a.cc: In function 'int main()': a.cc:41:54: warning: pointer to a function used in arithmetic [-Wpointer-arith] 41 | if(i==j) {cost[i][j]=time[i][j]=0; continue;} | ^ a.cc:41:57: warning: pointer to a function used in arithmetic [-Wpointer-arith] 41 | if(i==j) {cost[i][j]=time[i][j]=0; continue;} | ^ a.cc:41:58: error: assignment of read-only location '*(time + (((sizetype)i) + ((sizetype)j)))' 41 | if(i==j) {cost[i][j]=time[i][j]=0; continue;} | ~~~~~~~~~~^~ a.cc:42:44: warning: pointer to a function used in arithmetic [-Wpointer-arith] 42 | cost[i][j]=time[i][j]=INF; | ^ a.cc:42:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 42 | cost[i][j]=time[i][j]=INF; | ^ a.cc:42:48: error: assignment of read-only location '*(time + (((sizetype)i) + ((sizetype)j)))' 42 | cost[i][j]=time[i][j]=INF; | ~~~~~~~~~~^~~~ a.cc:49:56: warning: pointer to a function used in arithmetic [-Wpointer-arith] 49 | cost[a][b]=cost[b][a]=c; time[a][b]=time[b][a]=t; | ^ a.cc:49:59: warning: pointer to a function used in arithmetic [-Wpointer-arith] 49 | cost[a][b]=cost[b][a]=c; time[a][b]=time[b][a]=t; | ^ a.cc:49:67: warning: pointer to a function used in arithmetic [-Wpointer-arith] 49 | cost[a][b]=cost[b][a]=c; time[a][b]=time[b][a]=t; | ^ a.cc:49:70: warning: pointer to a function used in arithmetic [-Wpointer-arith] 49 | cost[a][b]=cost[b][a]=c; time[a][b]=time[b][a]=t; | ^ a.cc:49:71: error: assignment of read-only location '*(time + (((sizetype)b) + ((sizetype)a)))' 49 | cost[a][b]=cost[b][a]=c; time[a][b]=time[b][a]=t; | ~~~~~~~~~~^~
s701219479
p00200
C++
#include<math.h> #include<iostream> #include<string> #include<vector> #include<algorithm> #define REP(i,a,b) for(i=a;i<b;i++) #define rep(i,n) REP(i,0,n) using namespace std; #define INF (1<<30) int cost[200][200], time[200][200],dist[200]; int x[200][200]; bool vis[200]; int M,N; void dij(int p, int q, int r){ int i,j,k,l,m,n,mn; rep(i,M)rep(j,M)x[i][j]= (r==0)?cost[i][j]:time[i][j]; rep(i,M)vis[i]=false,dist[i]=INF; dist[p-1]=0; for(;;){ k=-1,mn=INF; rep(i,M)if(!vis[i]&&dist[i]<mn){mn=dist[i],k=i;} if(k==-1 || mn>=INF) break; if(k==q-1)break; vis[k]=true; rep(i,M)if(!vis[i])dist[i]=min(dist[i],dist[k]+x[k][i]); } cout<<dist[q-1]<<endl; } int main(){ int i,j,k,l,m,n; while(cin>>N>>M){ if((N|M)==0) break; rep(i,M){ dist[i]=INF; rep(j,M){ if(i==j) {cost[i][j]=time[i][j]=0; continue;} cost[i][j]=time[i][j]=INF; } } rep(i,N){//graph info int a,b,c,t; cin>>a>>b>>c>>t; a--; b--; cost[a][b]=cost[b][a]=c; time[a][b]=time[b][a]=t; } cin>>k; rep(i,k){//question int p,q,r; cin>>p>>q>>r; dij(p,q,r); } } }
a.cc:11:34: error: 'int time [200][200]' redeclared as different kind of entity 11 | int cost[200][200], time[200][200],dist[200]; | ^ In file included from /usr/include/pthread.h:23, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157, from /usr/include/c++/14/ext/atomicity.h:35, from /usr/include/c++/14/bits/ios_base.h:39, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)' 76 | extern time_t time (time_t *__timer) __THROW; | ^~~~ a.cc: In function 'void dij(int, int, int)': a.cc:18:58: warning: pointer to a function used in arithmetic [-Wpointer-arith] 18 | rep(i,M)rep(j,M)x[i][j]= (r==0)?cost[i][j]:time[i][j]; | ^ a.cc:18:61: warning: pointer to a function used in arithmetic [-Wpointer-arith] 18 | rep(i,M)rep(j,M)x[i][j]= (r==0)?cost[i][j]:time[i][j]; | ^ a.cc:18:40: error: operands to '?:' have different types 'int' and 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} 18 | rep(i,M)rep(j,M)x[i][j]= (r==0)?cost[i][j]:time[i][j]; | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~ a.cc: In function 'int main()': a.cc:41:54: warning: pointer to a function used in arithmetic [-Wpointer-arith] 41 | if(i==j) {cost[i][j]=time[i][j]=0; continue;} | ^ a.cc:41:57: warning: pointer to a function used in arithmetic [-Wpointer-arith] 41 | if(i==j) {cost[i][j]=time[i][j]=0; continue;} | ^ a.cc:41:58: error: assignment of read-only location '*(time + (((sizetype)i) + ((sizetype)j)))' 41 | if(i==j) {cost[i][j]=time[i][j]=0; continue;} | ~~~~~~~~~~^~ a.cc:42:44: warning: pointer to a function used in arithmetic [-Wpointer-arith] 42 | cost[i][j]=time[i][j]=INF; | ^ a.cc:42:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 42 | cost[i][j]=time[i][j]=INF; | ^ a.cc:42:48: error: assignment of read-only location '*(time + (((sizetype)i) + ((sizetype)j)))' 42 | cost[i][j]=time[i][j]=INF; | ^ a.cc:49:56: warning: pointer to a function used in arithmetic [-Wpointer-arith] 49 | cost[a][b]=cost[b][a]=c; time[a][b]=time[b][a]=t; | ^ a.cc:49:59: warning: pointer to a function used in arithmetic [-Wpointer-arith] 49 | cost[a][b]=cost[b][a]=c; time[a][b]=time[b][a]=t; | ^ a.cc:49:67: warning: pointer to a function used in arithmetic [-Wpointer-arith] 49 | cost[a][b]=cost[b][a]=c; time[a][b]=time[b][a]=t; | ^ a.cc:49:70: warning: pointer to a function used in arithmetic [-Wpointer-arith] 49 | cost[a][b]=cost[b][a]=c; time[a][b]=time[b][a]=t; | ^ a.cc:49:71: error: assignment of read-only location '*(time + (((sizetype)b) + ((sizetype)a)))' 49 | cost[a][b]=cost[b][a]=c; time[a][b]=time[b][a]=t; | ~~~~~~~~~~^~
s500660957
p00200
C++
#include<math.h> #include<iostream> #define REP(i,a,b) for(i=a;i<b;i++) #define rep(i,n) REP(i,0,n) #define INF (1<<30) using namespace std; int cost[200][200], time[200][200],dist[200]; int x[200][200]; bool vis[200]; int M,N; void dij(int p, int q, int r){ int i,j,k,l,m,n,mn; rep(i,M)rep(j,M)x[i][j]= ((r==0)?(cost[i][j]):(time[i][j])); rep(i,M)vis[i]=false,dist[i]=INF; dist[p-1]=0; for(;;){ k=-1,mn=INF; rep(i,M)if(!vis[i]&&dist[i]<mn){mn=dist[i],k=i;} if(k==-1 || mn>=INF) break; if(k==q-1)break; vis[k]=true; rep(i,M)if(!vis[i])dist[i]=min(dist[i],dist[k]+x[k][i]); } cout<<dist[q-1]<<endl; } int main(){ int i,j,k,l,m,n; while(cin>>N>>M){ if((N|M)==0) break; rep(i,M){ dist[i]=INF; rep(j,M){ if(i==j) {cost[i][j]=time[i][j]=0; continue;} cost[i][j]=time[i][j]=INF; } } rep(i,N){ int a,b,c,t; cin>>a>>b>>c>>t; a--; b--; cost[a][b]=cost[b][a]=c; time[a][b]=time[b][a]=t; } cin>>k; rep(i,k){ int p,q,r; cin>>p>>q>>r; dij(p,q,r); } } }
a.cc:9:34: error: 'int time [200][200]' redeclared as different kind of entity 9 | int cost[200][200], time[200][200],dist[200]; | ^ In file included from /usr/include/pthread.h:23, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157, from /usr/include/c++/14/ext/atomicity.h:35, from /usr/include/c++/14/bits/ios_base.h:39, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)' 76 | extern time_t time (time_t *__timer) __THROW; | ^~~~ a.cc: In function 'void dij(int, int, int)': a.cc:16:62: warning: pointer to a function used in arithmetic [-Wpointer-arith] 16 | rep(i,M)rep(j,M)x[i][j]= ((r==0)?(cost[i][j]):(time[i][j])); | ^ a.cc:16:65: warning: pointer to a function used in arithmetic [-Wpointer-arith] 16 | rep(i,M)rep(j,M)x[i][j]= ((r==0)?(cost[i][j]):(time[i][j])); | ^ a.cc:16:41: error: operands to '?:' have different types 'int' and 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} 16 | rep(i,M)rep(j,M)x[i][j]= ((r==0)?(cost[i][j]):(time[i][j])); | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc: In function 'int main()': a.cc:39:54: warning: pointer to a function used in arithmetic [-Wpointer-arith] 39 | if(i==j) {cost[i][j]=time[i][j]=0; continue;} | ^ a.cc:39:57: warning: pointer to a function used in arithmetic [-Wpointer-arith] 39 | if(i==j) {cost[i][j]=time[i][j]=0; continue;} | ^ a.cc:39:58: error: assignment of read-only location '*(time + (((sizetype)i) + ((sizetype)j)))' 39 | if(i==j) {cost[i][j]=time[i][j]=0; continue;} | ~~~~~~~~~~^~ a.cc:40:44: warning: pointer to a function used in arithmetic [-Wpointer-arith] 40 | cost[i][j]=time[i][j]=INF; | ^ a.cc:40:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 40 | cost[i][j]=time[i][j]=INF; | ^ a.cc:40:48: error: assignment of read-only location '*(time + (((sizetype)i) + ((sizetype)j)))' 40 | cost[i][j]=time[i][j]=INF; | ^ a.cc:47:56: warning: pointer to a function used in arithmetic [-Wpointer-arith] 47 | cost[a][b]=cost[b][a]=c; time[a][b]=time[b][a]=t; | ^ a.cc:47:59: warning: pointer to a function used in arithmetic [-Wpointer-arith] 47 | cost[a][b]=cost[b][a]=c; time[a][b]=time[b][a]=t; | ^ a.cc:47:67: warning: pointer to a function used in arithmetic [-Wpointer-arith] 47 | cost[a][b]=cost[b][a]=c; time[a][b]=time[b][a]=t; | ^ a.cc:47:70: warning: pointer to a function used in arithmetic [-Wpointer-arith] 47 | cost[a][b]=cost[b][a]=c; time[a][b]=time[b][a]=t; | ^ a.cc:47:71: error: assignment of read-only location '*(time + (((sizetype)b) + ((sizetype)a)))' 47 | cost[a][b]=cost[b][a]=c; time[a][b]=time[b][a]=t; | ~~~~~~~~~~^~
s844593955
p00200
C++
#include<iostream> #include<algorithm> using namespace std; int time[100][100]; int cost[100][100]; const int INF = 10000; int main(void){ while(1){ //init int rosen,eki,a,b,incost,intime; for(int i=0; i<100; i++){ for(int j=0; j<100; j++) time[i][j] = cost[i][j] = INF; } for(int i=0; i<100; i++) time[i][i] = cost[i][i] = 0; //in cin >> rosen >> eki; if(rosen==0&&eki==0)break; for(int i=0; i<rosen; i++){ cin >> a >> b >> incost >> intime; a--; b--; cost[a][b] = cost[b][a] = incost; time[a][b] = time[b][a] = intime; } //calc for(int k=0; k<eki; k++){ for(int i=0; i<eki; i++){ for(int j=0; j<eki; j++){ time[i][j] = min(time[i][j],time[i][k]+time[k][j]); cost[i][j] = min(cost[i][j],cost[i][k]+cost[k][j]); } } } //out int toi; cin >> toi; for(int i=0; i<toi; i++){ int a,b,r; cin >> a >> b >> r; a--; b--; if(r==0) cout << cost[a][b] << endl; else cout << time[a][b] << endl; } } return 0; }
a.cc:5:18: error: 'int time [100][100]' redeclared as different kind of entity 5 | int time[100][100]; | ^ In file included from /usr/include/pthread.h:23, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157, from /usr/include/c++/14/ext/atomicity.h:35, from /usr/include/c++/14/bits/ios_base.h:39, 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/time.h:76:15: note: previous declaration 'time_t time(time_t*)' 76 | extern time_t time (time_t *__timer) __THROW; | ^~~~ a.cc: In function 'int main()': a.cc:16:39: warning: pointer to a function used in arithmetic [-Wpointer-arith] 16 | time[i][j] = cost[i][j] = INF; | ^ a.cc:16:42: warning: pointer to a function used in arithmetic [-Wpointer-arith] 16 | time[i][j] = cost[i][j] = INF; | ^ a.cc:16:44: error: assignment of read-only location '*(time + (((sizetype)i) + ((sizetype)j)))' 16 | time[i][j] = cost[i][j] = INF; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ a.cc:19:31: warning: pointer to a function used in arithmetic [-Wpointer-arith] 19 | time[i][i] = cost[i][i] = 0; | ^ a.cc:19:34: warning: pointer to a function used in arithmetic [-Wpointer-arith] 19 | time[i][i] = cost[i][i] = 0; | ^ a.cc:19:36: error: assignment of read-only location '*(time + (((sizetype)i) * 2))' 19 | time[i][i] = cost[i][i] = 0; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~ a.cc:28:31: warning: pointer to a function used in arithmetic [-Wpointer-arith] 28 | time[a][b] = time[b][a] = intime; | ^ a.cc:28:34: warning: pointer to a function used in arithmetic [-Wpointer-arith] 28 | time[a][b] = time[b][a] = intime; | ^ a.cc:28:44: warning: pointer to a function used in arithmetic [-Wpointer-arith] 28 | time[a][b] = time[b][a] = intime; | ^ a.cc:28:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 28 | time[a][b] = time[b][a] = intime; | ^ a.cc:28:49: error: assignment of read-only location '*(time + (((sizetype)b) + ((sizetype)a)))' 28 | time[a][b] = time[b][a] = intime; | ~~~~~~~~~~~^~~~~~~~ a.cc:35:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 35 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:35:50: warning: pointer to a function used in arithmetic [-Wpointer-arith] 35 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:35:64: warning: pointer to a function used in arithmetic [-Wpointer-arith] 35 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:35:67: warning: pointer to a function used in arithmetic [-Wpointer-arith] 35 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:35:75: warning: pointer to a function used in arithmetic [-Wpointer-arith] 35 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:35:78: warning: pointer to a function used in arithmetic [-Wpointer-arith] 35 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:35:86: warning: pointer to a function used in arithmetic [-Wpointer-arith] 35 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:35:89: warning: pointer to a function used in arithmetic [-Wpointer-arith] 35 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:35:79: error: invalid operands of types 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} and 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} to binary 'operator+' 35 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ~~~~~~~~~~^~~~~~~~~~~ | | | | | time_t(time_t*) noexcept {aka long int(long int*) noexcept} | time_t(time_t*) noexcept {aka long int(long int*) noexcept} a.cc:51:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 51 | cout << time[a][b] << endl; | ^ a.cc:51:50: warning: pointer to a function used in arithmetic [-Wpointer-arith] 51 | cout << time[a][b] << endl; | ^
s926882419
p00200
C++
#include<iostream> #include<algorithm> using namespace std; const int LEN = 100; const int INF = 10000; int time[LEN][LEN]; int cost[LEN][LEN]; int main(void){ while(1){ //init int rosen,eki,a,b,incost,intime; for(int i=0; i<LEN; i++){ for(int j=0; j<LEN; j++) time[i][j] = cost[i][j] = INF; } for(int i=0; i<LEN; i++) time[i][i] = cost[i][i] = 0; //in cin >> rosen >> eki; if(rosen==0&&eki==0)break; for(int i=0; i<rosen; i++){ cin >> a >> b >> incost >> intime; a--; b--; cost[a][b] = cost[b][a] = incost; time[a][b] = time[b][a] = intime; } //calc for(int k=0; k<eki; k++){ for(int i=0; i<eki; i++){ for(int j=0; j<eki; j++){ time[i][j] = min(time[i][j],time[i][k]+time[k][j]); cost[i][j] = min(cost[i][j],cost[i][k]+cost[k][j]); } } } //out int toi; cin >> toi; for(int i=0; i<toi; i++){ int a,b,r; cin >> a >> b >> r; a--; b--; if(r==0) cout << cost[a][b] << endl; else cout << time[a][b] << endl; } } return 0; }
a.cc:7:18: error: 'int time [100][100]' redeclared as different kind of entity 7 | int time[LEN][LEN]; | ^ In file included from /usr/include/pthread.h:23, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157, from /usr/include/c++/14/ext/atomicity.h:35, from /usr/include/c++/14/bits/ios_base.h:39, 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/time.h:76:15: note: previous declaration 'time_t time(time_t*)' 76 | extern time_t time (time_t *__timer) __THROW; | ^~~~ a.cc: In function 'int main()': a.cc:17:39: warning: pointer to a function used in arithmetic [-Wpointer-arith] 17 | time[i][j] = cost[i][j] = INF; | ^ a.cc:17:42: warning: pointer to a function used in arithmetic [-Wpointer-arith] 17 | time[i][j] = cost[i][j] = INF; | ^ a.cc:17:44: error: assignment of read-only location '*(time + (((sizetype)i) + ((sizetype)j)))' 17 | time[i][j] = cost[i][j] = INF; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ a.cc:20:31: warning: pointer to a function used in arithmetic [-Wpointer-arith] 20 | time[i][i] = cost[i][i] = 0; | ^ a.cc:20:34: warning: pointer to a function used in arithmetic [-Wpointer-arith] 20 | time[i][i] = cost[i][i] = 0; | ^ a.cc:20:36: error: assignment of read-only location '*(time + (((sizetype)i) * 2))' 20 | time[i][i] = cost[i][i] = 0; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~ a.cc:29:31: warning: pointer to a function used in arithmetic [-Wpointer-arith] 29 | time[a][b] = time[b][a] = intime; | ^ a.cc:29:34: warning: pointer to a function used in arithmetic [-Wpointer-arith] 29 | time[a][b] = time[b][a] = intime; | ^ a.cc:29:44: warning: pointer to a function used in arithmetic [-Wpointer-arith] 29 | time[a][b] = time[b][a] = intime; | ^ a.cc:29:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 29 | time[a][b] = time[b][a] = intime; | ^ a.cc:29:49: error: assignment of read-only location '*(time + (((sizetype)b) + ((sizetype)a)))' 29 | time[a][b] = time[b][a] = intime; | ~~~~~~~~~~~^~~~~~~~ a.cc:36:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 36 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:36:50: warning: pointer to a function used in arithmetic [-Wpointer-arith] 36 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:36:64: warning: pointer to a function used in arithmetic [-Wpointer-arith] 36 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:36:67: warning: pointer to a function used in arithmetic [-Wpointer-arith] 36 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:36:75: warning: pointer to a function used in arithmetic [-Wpointer-arith] 36 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:36:78: warning: pointer to a function used in arithmetic [-Wpointer-arith] 36 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:36:86: warning: pointer to a function used in arithmetic [-Wpointer-arith] 36 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:36:89: warning: pointer to a function used in arithmetic [-Wpointer-arith] 36 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:36:79: error: invalid operands of types 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} and 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} to binary 'operator+' 36 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ~~~~~~~~~~^~~~~~~~~~~ | | | | | time_t(time_t*) noexcept {aka long int(long int*) noexcept} | time_t(time_t*) noexcept {aka long int(long int*) noexcept} a.cc:52:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 52 | cout << time[a][b] << endl; | ^ a.cc:52:50: warning: pointer to a function used in arithmetic [-Wpointer-arith] 52 | cout << time[a][b] << endl; | ^
s936933248
p00200
C++
#include<iostream> #include<algorithm> using namespace std; const int LEN = 100; const int INF = 10000; int time[LEN][LEN]; int cost[LEN][LEN]; int main(void){ while(1){ //init int rosen,eki,a,b,incost,intime; for(int i=0; i<LEN; i++){ for(int j=0; j<LEN; j++) time[i][j] = cost[i][j] = INF; } for(int i=0; i<LEN; i++) time[i][i] = cost[i][i] = 0; //in cin >> rosen >> eki; if(rosen==0&&eki==0)break; for(int i=0; i<rosen; i++){ cin >> a >> b >> incost >> intime; a--; b--; cost[a][b] = cost[b][a] = incost; time[a][b] = time[b][a] = intime; } //calc for(int k=0; k<eki; k++){ for(int i=0; i<eki; i++){ for(int j=0; j<eki; j++){ time[i][j] = min(time[i][j],time[i][k]+time[k][j]); cost[i][j] = min(cost[i][j],cost[i][k]+cost[k][j]); } } } //out int toi; cin >> toi; for(int i=0; i<toi; i++){ int a,b,r; cin >> a >> b >> r; a--; b--; if(r==0) cout << cost[a][b] << endl; else cout << time[a][b] << endl; } } return 0; }
a.cc:7:18: error: 'int time [100][100]' redeclared as different kind of entity 7 | int time[LEN][LEN]; | ^ In file included from /usr/include/pthread.h:23, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157, from /usr/include/c++/14/ext/atomicity.h:35, from /usr/include/c++/14/bits/ios_base.h:39, 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/time.h:76:15: note: previous declaration 'time_t time(time_t*)' 76 | extern time_t time (time_t *__timer) __THROW; | ^~~~ a.cc: In function 'int main()': a.cc:17:39: warning: pointer to a function used in arithmetic [-Wpointer-arith] 17 | time[i][j] = cost[i][j] = INF; | ^ a.cc:17:42: warning: pointer to a function used in arithmetic [-Wpointer-arith] 17 | time[i][j] = cost[i][j] = INF; | ^ a.cc:17:44: error: assignment of read-only location '*(time + (((sizetype)i) + ((sizetype)j)))' 17 | time[i][j] = cost[i][j] = INF; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ a.cc:20:31: warning: pointer to a function used in arithmetic [-Wpointer-arith] 20 | time[i][i] = cost[i][i] = 0; | ^ a.cc:20:34: warning: pointer to a function used in arithmetic [-Wpointer-arith] 20 | time[i][i] = cost[i][i] = 0; | ^ a.cc:20:36: error: assignment of read-only location '*(time + (((sizetype)i) * 2))' 20 | time[i][i] = cost[i][i] = 0; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~ a.cc:29:31: warning: pointer to a function used in arithmetic [-Wpointer-arith] 29 | time[a][b] = time[b][a] = intime; | ^ a.cc:29:34: warning: pointer to a function used in arithmetic [-Wpointer-arith] 29 | time[a][b] = time[b][a] = intime; | ^ a.cc:29:44: warning: pointer to a function used in arithmetic [-Wpointer-arith] 29 | time[a][b] = time[b][a] = intime; | ^ a.cc:29:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 29 | time[a][b] = time[b][a] = intime; | ^ a.cc:29:49: error: assignment of read-only location '*(time + (((sizetype)b) + ((sizetype)a)))' 29 | time[a][b] = time[b][a] = intime; | ~~~~~~~~~~~^~~~~~~~ a.cc:36:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 36 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:36:50: warning: pointer to a function used in arithmetic [-Wpointer-arith] 36 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:36:64: warning: pointer to a function used in arithmetic [-Wpointer-arith] 36 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:36:67: warning: pointer to a function used in arithmetic [-Wpointer-arith] 36 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:36:75: warning: pointer to a function used in arithmetic [-Wpointer-arith] 36 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:36:78: warning: pointer to a function used in arithmetic [-Wpointer-arith] 36 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:36:86: warning: pointer to a function used in arithmetic [-Wpointer-arith] 36 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:36:89: warning: pointer to a function used in arithmetic [-Wpointer-arith] 36 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:36:79: error: invalid operands of types 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} and 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} to binary 'operator+' 36 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ~~~~~~~~~~^~~~~~~~~~~ | | | | | time_t(time_t*) noexcept {aka long int(long int*) noexcept} | time_t(time_t*) noexcept {aka long int(long int*) noexcept} a.cc:52:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 52 | cout << time[a][b] << endl; | ^ a.cc:52:50: warning: pointer to a function used in arithmetic [-Wpointer-arith] 52 | cout << time[a][b] << endl; | ^
s731249967
p00200
C++
#include<iostream> #include<algorithm> using namespace std; const int LEN = 100; const int INF = 10000; int time[LEN][LEN]; int cost[LEN][LEN]; int main(void){ while(1){ //init int rosen,eki,a,b,incost,intime; for(int i=0; i<LEN; i++){ for(int j=0; j<LEN; j++) time[i][j] = cost[i][j] = INF; } for(int i=0; i<LEN; i++) time[i][i] = cost[i][i] = 0; //in cin >> rosen >> eki; if(rosen==0&&eki==0)break; for(int i=0; i<rosen; i++){ cin >> a >> b >> incost >> intime; a--; b--; cost[a][b] = cost[b][a] = incost; time[a][b] = time[b][a] = intime; } //calc for(int k=0; k<eki; k++){ for(int i=0; i<eki; i++){ for(int j=0; j<eki; j++){ time[i][j] = min(time[i][j],time[i][k]+time[k][j]); cost[i][j] = min(cost[i][j],cost[i][k]+cost[k][j]); } } } //out int toi; cin >> toi; for(int i=0; i<toi; i++){ int a,b,r; cin >> a >> b >> r; a--; b--; if(r==0) cout << cost[a][b] << endl; else cout << time[a][b] << endl; } } return 0; }
a.cc:7:18: error: 'int time [100][100]' redeclared as different kind of entity 7 | int time[LEN][LEN]; | ^ In file included from /usr/include/pthread.h:23, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157, from /usr/include/c++/14/ext/atomicity.h:35, from /usr/include/c++/14/bits/ios_base.h:39, 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/time.h:76:15: note: previous declaration 'time_t time(time_t*)' 76 | extern time_t time (time_t *__timer) __THROW; | ^~~~ a.cc: In function 'int main()': a.cc:17:39: warning: pointer to a function used in arithmetic [-Wpointer-arith] 17 | time[i][j] = cost[i][j] = INF; | ^ a.cc:17:42: warning: pointer to a function used in arithmetic [-Wpointer-arith] 17 | time[i][j] = cost[i][j] = INF; | ^ a.cc:17:44: error: assignment of read-only location '*(time + (((sizetype)i) + ((sizetype)j)))' 17 | time[i][j] = cost[i][j] = INF; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ a.cc:20:31: warning: pointer to a function used in arithmetic [-Wpointer-arith] 20 | time[i][i] = cost[i][i] = 0; | ^ a.cc:20:34: warning: pointer to a function used in arithmetic [-Wpointer-arith] 20 | time[i][i] = cost[i][i] = 0; | ^ a.cc:20:36: error: assignment of read-only location '*(time + (((sizetype)i) * 2))' 20 | time[i][i] = cost[i][i] = 0; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~ a.cc:29:31: warning: pointer to a function used in arithmetic [-Wpointer-arith] 29 | time[a][b] = time[b][a] = intime; | ^ a.cc:29:34: warning: pointer to a function used in arithmetic [-Wpointer-arith] 29 | time[a][b] = time[b][a] = intime; | ^ a.cc:29:44: warning: pointer to a function used in arithmetic [-Wpointer-arith] 29 | time[a][b] = time[b][a] = intime; | ^ a.cc:29:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 29 | time[a][b] = time[b][a] = intime; | ^ a.cc:29:49: error: assignment of read-only location '*(time + (((sizetype)b) + ((sizetype)a)))' 29 | time[a][b] = time[b][a] = intime; | ~~~~~~~~~~~^~~~~~~~ a.cc:36:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 36 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:36:50: warning: pointer to a function used in arithmetic [-Wpointer-arith] 36 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:36:64: warning: pointer to a function used in arithmetic [-Wpointer-arith] 36 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:36:67: warning: pointer to a function used in arithmetic [-Wpointer-arith] 36 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:36:75: warning: pointer to a function used in arithmetic [-Wpointer-arith] 36 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:36:78: warning: pointer to a function used in arithmetic [-Wpointer-arith] 36 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:36:86: warning: pointer to a function used in arithmetic [-Wpointer-arith] 36 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:36:89: warning: pointer to a function used in arithmetic [-Wpointer-arith] 36 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:36:79: error: invalid operands of types 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} and 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} to binary 'operator+' 36 | time[i][j] = min(time[i][j],time[i][k]+time[k][j]); | ~~~~~~~~~~^~~~~~~~~~~ | | | | | time_t(time_t*) noexcept {aka long int(long int*) noexcept} | time_t(time_t*) noexcept {aka long int(long int*) noexcept} a.cc:52:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 52 | cout << time[a][b] << endl; | ^ a.cc:52:50: warning: pointer to a function used in arithmetic [-Wpointer-arith] 52 | cout << time[a][b] << endl; | ^
s332328955
p00200
C++
#include<iostream> #include<queue> #include<vector> #include<functional> using namespace std; struct Edge{ int to,cost; Edge(){} Edge(int to,int cost):to(to),cost(cost){} }; int dijkstra(const vector< vector<Edge> > vve,int s,int t){ priority_queue<pair<int,int>, vector< pair<int,int> >, greater< pair<int,int> > > que; pair<int,int> pii; pii.first = 0; pii.second = s; que.push(pii); vector<int> dist(vve.size(), INT_MAX); while(!que.empty()){ int cost = que.top().first; int now = que.top().second; que.pop(); if(dist[now] <= cost){ continue; } dist[now] = cost; for(int i=0;i<vve[now].size();i++){ que.push( make_pair(vve[now][i].cost + cost, vve[now][i].to) ); } } return dist[t]; } int main(){ int n,m; while(true){ cin >> n >> m; if(n == 0 && m==0){ break; } vector< vector<Edge> > coin(m); vector< vector<Edge> > time(m); for(int i=0;i<n;i++){ int a,b,c,t; cin >> a >> b >> c >> t; coin[a-1].push_back(Edge(b-1,c)); coin[b-1].push_back(Edge(a-1,c)); time[a-1].push_back(Edge(b-1,t)); time[b-1].push_back(Edge(a-1,t)); } int k; cin >> k; for(int i=0;i<k;i++){ int p,q,r; cin >> p >> q >> r; int ans; if(r){ ans = dijkstra(time,p-1,q-1); }else{ ans = dijkstra(coin,p-1,q-1); } cout << ans << endl; } } }
a.cc: In function 'int dijkstra(std::vector<std::vector<Edge> >, int, int)': a.cc:21:38: error: 'INT_MAX' was not declared in this scope 21 | vector<int> dist(vve.size(), INT_MAX); | ^~~~~~~ a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 4 | #include<functional> +++ |+#include <climits> 5 |
s312319888
p00200
C++
#include <algorithm> #include <map> #include <vector> #include <iostream> #include <sstream> #include <cstdio> #include <cstring> #include <cctype> #include <cstdlib> #include <cmath> #include <string> #include <queue> #include <stack> #include <set> using namespace std; #define REP(i,n) for(int i=0; i<n; ++i) #define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it) #define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it) #define MP make_pair #define PB push_back #define ALL(x) (x).begin(),(x).end() const int INF = 1<<29; const double EPS = 1e-9; double zero(double d){ return d < EPS ? 0.0 : d; } typedef long long LL; typedef pair<int,int> P; int main() { cout.setf(ios::fixed, ios::floatfield); cout.precision(7); int n,m; cin >> n >> m; vector< vector<int> > cost(m+1, vector<int>(m+1,INF)), time(m+1, vector<int>(m+1,INF)); REP(i,cost.size()){ cost[i][i] = 0; time[i][i] = 0; } REP(i,n){ int a,b,c,t; cin >> a >> b >> c >> t; cost[a][b] = c; cost[b][a] = c; time[a][b] = t; time[b][a] = t; } int k; cin >> k; REP(_tmp,k){ int p,q,r; cin >> p >> q >> r; vector< vector<int> > data(m+1, 0); data = r ? time : cost; deque<bool> reached(m+1,0); vector<int> dis(m+1,INF); dis[p] = 0; while(true){ int minn = -1; REP(i,reached.size()){ if( ! reached[i] ){ if( minn==-1 || dis[minn] > dis[i] ){ minn = i; } } } if( minn == q ) break; reached[minn] = true; REP(i,data[minn].size()+1){ dis[i] = min( dis[minn] + data[minn][i], dis[i] ); } } cout << dis[q] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:66:38: error: no matching function for call to 'std::vector<std::vector<int> >::vector(int, int)' 66 | vector< vector<int> > data(m+1, 0); | ^ In file included from /usr/include/c++/14/vector:66, from a.cc:3: /usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with <template-parameter-2-2> = _InputIterator; _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]' 707 | vector(_InputIterator __first, _InputIterator __last, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:707:9: note: template argument deduction/substitution failed: In file included from /usr/include/c++/14/bits/stl_algobase.h:65, from /usr/include/c++/14/algorithm:60, from a.cc:1: /usr/include/c++/14/bits/stl_iterator_base_types.h: In substitution of 'template<class _InIter> using std::_RequireInputIter = std::__enable_if_t<((bool)std::is_convertible<typename std::iterator_traits< <template-parameter-1-1> >::iterator_category, std::input_iterator_tag>::value)> [with _InIter = int]': /usr/include/c++/14/bits/stl_vector.h:705:9: required from here 705 | typename = std::_RequireInputIter<_InputIterator>> | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_types.h:252:57: error: no type named 'iterator_category' in 'struct std::iterator_traits<int>' 252 | input_iterator_tag>::value>; | ^~~~~ /usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; allocator_type = std::allocator<std::vector<int> >]' 678 | vector(initializer_list<value_type> __l, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:678:43: note: no known conversion for argument 1 from 'int' to 'std::initializer_list<std::vector<int> >' 678 | vector(initializer_list<value_type> __l, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, std::__type_identity_t<_Alloc>&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::__type_identity_t<_Alloc> = std::allocator<std::vector<int> >]' 659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:659:23: note: no known conversion for argument 1 from 'int' to 'std::vector<std::vector<int> >&&' 659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m) | ~~~~~~~~~^~~~ /usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; allocator_type = std::allocator<std::vector<int> >; std::false_type = std::false_type]' 640 | vector(vector&& __rv, const allocator_type& __m, false_type) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; allocator_type = std::allocator<std::vector<int> >; std::true_type = std::true_type]' 635 | vector(vector&& __rv, const allocator_type& __m, true_type) noexcept | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, std::__type_identity_t<_Alloc>&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::__type_identity_t<_Alloc> = std::allocator<std::vector<int> >]' 624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:624:28: note: no known conversion for argument 1 from 'int' to 'const std::vector<std::vector<int> >&' 624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]' 620 | vector(vector&&) noexcept = default; | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]' 601 | vector(const vector& __x) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const value_type&, const allocator_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; size_type = long unsigned int; value_type = std::vector<int>; allocator_type = std::allocator<std::vector<int> >]' 569 | vector(size_type __n, const value_type& __value, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:569:47: note: no known conversion for argument 2 from 'int' to 'const std::vector<std::vector<int> >::value_type&' {aka 'const std::vector<int>&'} 569 | vector(size_type __n, const value_type& __value, | ~~~~~~~~~~~~~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; size_type = long unsigned int; allocator_type = std::allocator<std::vector<int> >]' 556 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:556:51: note: no known conversion for argument 2 from 'int' to 'const std::vector<std::vector<int> >::allocator_type&' {aka 'const std::allocator<std::vector<int> >&'} 556 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; allocator_type = std::allocator<std::vector<int> >]' 542 | vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]' 531 | vector() = default; | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate expects 0 arguments, 2 provided
s543928458
p00200
C++
#include<iostream> #include<queue> #include<algorithm> #include<utility> #include<vector> using namespace std; #define MAX_M 110 struct edge{int to,cost;}; typedef pair<int,int> P; vector<edge> c[2][MAX_M]; int dijkstra(int s,int e,bool r){ int d[MAX_M]; for(int i=0;i<MAX_M;i++){ d[i]=INT_MAX; } priority_queue<P,vector<P>,greater< P > > que; d[s]=0; que.push(P(0,s)); while(!que.empty()){ P p=que.top();que.pop(); int v=p.second; if(d[v]<p.first) continue; for(int i=0;i<c[r][v].size();i++){ edge e=c[r][v][i]; if(d[e.to]>d[v]+e.cost){ d[e.to]=d[v]+e.cost; que.push(P(d[e.to],e.to)); } } } return d[e]; } int main(){ int n,m; while(cin>>n>>m,n!=0||m!=0){ for(int i=0;i<n;i++){ int a,b,cos,tim; cin>>a>>b>>cos>>tim; edge co,t; co.to=b;co.cost=cos; t.to=b;t.cost=tim; c[0][a].push_back(co); c[1][a].push_back(t); } cin>>n; for(int i=0;i<n;i++){ int s,e; bool r; cin>>s>>e>>r; int ans=dijkstra(s,e,r); cout<<ans<<endl; } } }
a.cc: In function 'int dijkstra(int, int, bool)': a.cc:18:22: error: 'INT_MAX' was not declared in this scope 18 | d[i]=INT_MAX; | ^~~~~~~ a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 4 | #include<utility> +++ |+#include <climits> 5 | #include<vector>
s678381088
p00200
C++
#include<iostream> #include<queue> #include<algorithm> #include<utility> #include<vector> #include<climits> using namespace std; #define MAX_M 110 struct edge{int to,cost;}; typedef pair<int,int> P; vector<edge> c[2][MAX_M]; int dijkstra(int s,int e,bool r){ int d[MAX_M]; for(int i=0;i<MAX_M;i++){ d[i]=INT_MAX; } priority_queue<P,vector<P>,greater< P > > que; d[s]=0; que.push(P(0,s)); while(!que.empty()){ P p=que.top();que.pop(); int v=p.second; if(d[v]<p.first) continue; for(int i=0;i<c[r][v].size();i++){ edge e=c[r][v][i]; if(d[e.to]>d[v]+e.cost){ d[e.to]=d[v]+e.cost; que.push(P(d[e.to],e.to)); } } } return d[e]; } int main(){ int n,m; while(cin>>n>>m,n!=0||m!=0){ for(int r=0;r<2;r++){ for(int i=0;i<MAX_M;i++){ c[r][i].clear; } } for(int i=0;i<n;i++){ int a,b,cos,tim; cin>>a>>b>>cos>>tim; edge co,t; co.to=b;co.cost=cos; t.to=b;t.cost=tim; c[0][a].push_back(co); c[1][a].push_back(t); } cin>>n; for(int i=0;i<n;i++){ int s,e; bool r; cin>>s>>e>>r; int ans=dijkstra(s,e,r); cout<<ans<<endl; } } }
a.cc: In function 'int main()': a.cc:48:41: error: invalid use of non-static member function 'void std::vector<_Tp, _Alloc>::clear() [with _Tp = edge; _Alloc = std::allocator<edge>]' 48 | c[r][i].clear; | ~~~~~~~~^~~~~ In file included from /usr/include/c++/14/vector:66, from /usr/include/c++/14/queue:63, from a.cc:2: /usr/include/c++/14/bits/stl_vector.h:1607:7: note: declared here 1607 | clear() _GLIBCXX_NOEXCEPT | ^~~~~
s943109407
p00200
C++
#include <iostream> #define N 101 #define INF 1e+9 using namespace std; int cost[N][N],time[N][N]; int main(void){ int n,m; while(cin>>n>>m,n||m){ for(int i=0;i<n;++i)for(int j=0;j<n;++j){cost[i][j]=time[i][j]=INF;} for(int i=0,a,b,c,t;i<n;++i){ cin>>a>>b>>c>>t; cost[a][b]=cost[b][a]=c; time[a][b]=time[b][a]=t; } int k;cin>>k; for(int i=0,p,q,r;i<k;++i){ cin>>p>>q>>r; if(r){//time int d[N]; for(int j=0;j<n;++j) d[j]=INF; d[p]=0; bool f=false; for(;;){ for(int j=0;j<n;++j){//from for(int k=0;k<n;++k){//to if(d[j]!=INF && d[j] + time[j][k] < d[k]){ f==true; d[k] = d[j] + time[j][k]; } } } if(f==false) break; f=false; } cout<<d[q]<<endl; }else{//cost int d[N]; for(int j=0;j<n;++j) d[j]=INF; d[p]=0; bool f=false; for(;;){ for(int j=0;j<n;++j){//from for(int k=0;k<n;++k){//to if(d[j]!=INF && d[j] + cost[j][k] < d[k]){ f==true; d[k] = d[j] + cost[j][k]; } } } if(f==false) break; f=false; } cout<<d[q]<<endl; } } } return 0; }
a.cc:8:25: error: 'int time [101][101]' redeclared as different kind of entity 8 | int cost[N][N],time[N][N]; | ^ In file included from /usr/include/pthread.h:23, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157, from /usr/include/c++/14/ext/atomicity.h:35, from /usr/include/c++/14/bits/ios_base.h:39, 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/time.h:76:15: note: previous declaration 'time_t time(time_t*)' 76 | extern time_t time (time_t *__timer) __THROW; | ^~~~ a.cc: In function 'int main()': a.cc:13:75: warning: pointer to a function used in arithmetic [-Wpointer-arith] 13 | for(int i=0;i<n;++i)for(int j=0;j<n;++j){cost[i][j]=time[i][j]=INF;} | ^ a.cc:13:78: warning: pointer to a function used in arithmetic [-Wpointer-arith] 13 | for(int i=0;i<n;++i)for(int j=0;j<n;++j){cost[i][j]=time[i][j]=INF;} | ^ a.cc:13:79: error: assignment of read-only location '*(time + (((sizetype)i) + ((sizetype)j)))' 13 | for(int i=0;i<n;++i)for(int j=0;j<n;++j){cost[i][j]=time[i][j]=INF;} | ^ a.cc:17:31: warning: pointer to a function used in arithmetic [-Wpointer-arith] 17 | time[a][b]=time[b][a]=t; | ^ a.cc:17:34: warning: pointer to a function used in arithmetic [-Wpointer-arith] 17 | time[a][b]=time[b][a]=t; | ^ a.cc:17:42: warning: pointer to a function used in arithmetic [-Wpointer-arith] 17 | time[a][b]=time[b][a]=t; | ^ a.cc:17:45: warning: pointer to a function used in arithmetic [-Wpointer-arith] 17 | time[a][b]=time[b][a]=t; | ^ a.cc:17:46: error: assignment of read-only location '*(time + (((sizetype)b) + ((sizetype)a)))' 17 | time[a][b]=time[b][a]=t; | ~~~~~~~~~~^~ a.cc:30:86: warning: pointer to a function used in arithmetic [-Wpointer-arith] 30 | if(d[j]!=INF && d[j] + time[j][k] < d[k]){ | ^ a.cc:30:89: warning: pointer to a function used in arithmetic [-Wpointer-arith] 30 | if(d[j]!=INF && d[j] + time[j][k] < d[k]){ | ^ a.cc:30:78: warning: pointer to a function used in arithmetic [-Wpointer-arith] 30 | if(d[j]!=INF && d[j] + time[j][k] < d[k]){ | ~~~~~^~~~~~~~~~~~ a.cc:30:91: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 30 | if(d[j]!=INF && d[j] + time[j][k] < d[k]){ | ~~~~~~~~~~~~~~~~~~^~~~~~ a.cc:32:85: warning: pointer to a function used in arithmetic [-Wpointer-arith] 32 | d[k] = d[j] + time[j][k]; | ^ a.cc:32:88: warning: pointer to a function used in arithmetic [-Wpointer-arith] 32 | d[k] = d[j] + time[j][k]; | ^ a.cc:32:77: warning: pointer to a function used in arithmetic [-Wpointer-arith] 32 | d[k] = d[j] + time[j][k]; | ~~~~~^~~~~~~~~~~~ a.cc:32:77: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'int' [-fpermissive] 32 | d[k] = d[j] + time[j][k]; | ~~~~~^~~~~~~~~~~~ | | | time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept}
s417189218
p00200
C++
#include <iostream> #include <vector> #include <queue> #include <map> using namespace std; typedef pair<int,int> P; const int MAX_V = 101; const int INF = 1000000009; struct edge { int to, cost, time; }; vector<edge> G[MAX_V]; int dist[MAX_V]; int dijkstra(int s, int t, int type) { fill(dist, dist+MAX_V, INF); dist[s] = 0; priority_queue<P, vector<P>, greater<P> > que; que.push(P(0, s)); while(!que.empty()) { P n = que.top(); que.pop(); int v = n.second; if(v == t) return dist[v]; for(int i=0; i<G[v].size(); i++) { edge& e = G[v][i]; if(type == 0) { if(dist[e.to] > dist[v] + e.cost) { dist[e.to] = dist[v] + e.cost; que.push(P(dist[e.to], e.to)); } } else { if(dist[e.to] > dist[v] + e.time) { dist[e.to] = dist[v] + e.time; que.push(P(dist[e.to], e.to)); } } } } return INF; } int M, N, K; int a, b, c, time; int p, q, r; int main() { while(scanf("%d%d", &N, &M), N|M) { for(int i=0; i<MAX_V; i++) G[i].clear(); for(int i=0; i<N; i++) { scanf("%d%d%d%d", &a, &b, &c, &time); edge e = { b, c, time }; G[a].push_back(e); } scanf("%d", &K); for(int i=0; i<K; i++) { scanf("%d%d%d", &p, &q, &r); int d = dijkstra(p, q, r); printf("%d\n", d); } } }
a.cc:44:14: error: 'int time' redeclared as different kind of entity 44 | int a, b, c, time; | ^~~~ In file included from /usr/include/pthread.h:23, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157, from /usr/include/c++/14/ext/atomicity.h:35, from /usr/include/c++/14/bits/ios_base.h:39, 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/time.h:76:15: note: previous declaration 'time_t time(time_t*)' 76 | extern time_t time (time_t *__timer) __THROW; | ^~~~ a.cc: In function 'int main()': a.cc:54:47: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'int' [-fpermissive] 54 | edge e = { b, c, time }; | ^ | | | time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept}
s101403528
p00200
C++
#include <iostream> using namespace std; #define INF 1000000 int time[110][110]; int cost[110][110]; int main() { int n,m; while(cin>>n>>m,n){ for(int i=0;i<m;++i){ for(int j=0;j<m;++j){ int a; i==j?a=0:a=INF; time[i][j]=a; cost[i][j]=a; } } for(int i=0;i<n;++i){ int a,b,c,t; cin>>a>>b>>c>>t; a--;b--; cost[a][b]=c; cost[b][a]=c; time[a][b]=t; time[b][a]=t; } for(int k=0;k<m;++k){ for(int i=0;i<m;++i){ for(int j=0;j<m;++j){ cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]); time[i][j]=min(time[i][j],time[i][k]+time[k][j]); } } } int k; cin>>k; for(int i=0;i<k;++i){ int p,q,r; cin>>p>>q>>r; p--;q--; if(!r) cout<<cost[p][q]<<endl; else cout<<time[p][q]<<endl; } } return 0; }
a.cc:4:18: error: 'int time [110][110]' redeclared as different kind of entity 4 | int time[110][110]; | ^ In file included from /usr/include/pthread.h:23, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157, from /usr/include/c++/14/ext/atomicity.h:35, from /usr/include/c++/14/bits/ios_base.h:39, 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/time.h:76:15: note: previous declaration 'time_t time(time_t*)' 76 | extern time_t time (time_t *__timer) __THROW; | ^~~~ a.cc: In function 'int main()': a.cc:14:23: warning: pointer to a function used in arithmetic [-Wpointer-arith] 14 | time[i][j]=a; | ^ a.cc:14:26: warning: pointer to a function used in arithmetic [-Wpointer-arith] 14 | time[i][j]=a; | ^ a.cc:14:27: error: assignment of read-only location '*(time + (((sizetype)i) + ((sizetype)j)))' 14 | time[i][j]=a; | ~~~~~~~~~~^~ a.cc:24:19: warning: pointer to a function used in arithmetic [-Wpointer-arith] 24 | time[a][b]=t; | ^ a.cc:24:22: warning: pointer to a function used in arithmetic [-Wpointer-arith] 24 | time[a][b]=t; | ^ a.cc:24:23: error: assignment of read-only location '*(time + (((sizetype)a) + ((sizetype)b)))' 24 | time[a][b]=t; | ~~~~~~~~~~^~ a.cc:25:19: warning: pointer to a function used in arithmetic [-Wpointer-arith] 25 | time[b][a]=t; | ^ a.cc:25:22: warning: pointer to a function used in arithmetic [-Wpointer-arith] 25 | time[b][a]=t; | ^ a.cc:25:23: error: assignment of read-only location '*(time + (((sizetype)b) + ((sizetype)a)))' 25 | time[b][a]=t; | ~~~~~~~~~~^~ a.cc:31:27: warning: pointer to a function used in arithmetic [-Wpointer-arith] 31 | time[i][j]=min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:31:30: warning: pointer to a function used in arithmetic [-Wpointer-arith] 31 | time[i][j]=min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:31:42: warning: pointer to a function used in arithmetic [-Wpointer-arith] 31 | time[i][j]=min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:31:45: warning: pointer to a function used in arithmetic [-Wpointer-arith] 31 | time[i][j]=min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:31:53: warning: pointer to a function used in arithmetic [-Wpointer-arith] 31 | time[i][j]=min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:31:56: warning: pointer to a function used in arithmetic [-Wpointer-arith] 31 | time[i][j]=min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:31:64: warning: pointer to a function used in arithmetic [-Wpointer-arith] 31 | time[i][j]=min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:31:67: warning: pointer to a function used in arithmetic [-Wpointer-arith] 31 | time[i][j]=min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:31:57: error: invalid operands of types 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} and 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} to binary 'operator+' 31 | time[i][j]=min(time[i][j],time[i][k]+time[k][j]); | ~~~~~~~~~~^~~~~~~~~~~ | | | | | time_t(time_t*) noexcept {aka long int(long int*) noexcept} | time_t(time_t*) noexcept {aka long int(long int*) noexcept} a.cc:44:29: warning: pointer to a function used in arithmetic [-Wpointer-arith] 44 | cout<<time[p][q]<<endl; | ^ a.cc:44:32: warning: pointer to a function used in arithmetic [-Wpointer-arith] 44 | cout<<time[p][q]<<endl; | ^
s135149283
p00200
C++
#include <iostream> using namespace std; #define INF 1000000 int time[110][110]; int cost[110][110]; int main() { int n,m; while(cin>>n>>m,n){ for(int i=0;i<m;++i){ for(int j=0;j<m;++j){ if(i==j){ time[i][j]=0; cost[i][j]=0; }else{ time[i][j]=INF; cost[i][j]=INF; } } } for(int i=0;i<n;++i){ int a,b,c,t; cin>>a>>b>>c>>t; a--;b--; cost[a][b]=c; cost[b][a]=c; time[a][b]=t; time[b][a]=t; } for(int k=0;k<m;++k){ for(int i=0;i<m;++i){ for(int j=0;j<m;++j){ cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]); time[i][j]=min(time[i][j],time[i][k]+time[k][j]); } } } int k; cin>>k; for(int i=0;i<k;++i){ int p,q,r; cin>>p>>q>>r; p--;q--; if(!r) cout<<cost[p][q]<<endl; else cout<<time[p][q]<<endl; } } return 0; }
a.cc:4:18: error: 'int time [110][110]' redeclared as different kind of entity 4 | int time[110][110]; | ^ In file included from /usr/include/pthread.h:23, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157, from /usr/include/c++/14/ext/atomicity.h:35, from /usr/include/c++/14/bits/ios_base.h:39, 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/time.h:76:15: note: previous declaration 'time_t time(time_t*)' 76 | extern time_t time (time_t *__timer) __THROW; | ^~~~ a.cc: In function 'int main()': a.cc:13:27: warning: pointer to a function used in arithmetic [-Wpointer-arith] 13 | time[i][j]=0; | ^ a.cc:13:30: warning: pointer to a function used in arithmetic [-Wpointer-arith] 13 | time[i][j]=0; | ^ a.cc:13:31: error: assignment of read-only location '*(time + (((sizetype)i) + ((sizetype)j)))' 13 | time[i][j]=0; | ~~~~~~~~~~^~ a.cc:16:27: warning: pointer to a function used in arithmetic [-Wpointer-arith] 16 | time[i][j]=INF; | ^ a.cc:16:30: warning: pointer to a function used in arithmetic [-Wpointer-arith] 16 | time[i][j]=INF; | ^ a.cc:16:31: error: assignment of read-only location '*(time + (((sizetype)i) + ((sizetype)j)))' 16 | time[i][j]=INF; | ^ a.cc:27:19: warning: pointer to a function used in arithmetic [-Wpointer-arith] 27 | time[a][b]=t; | ^ a.cc:27:22: warning: pointer to a function used in arithmetic [-Wpointer-arith] 27 | time[a][b]=t; | ^ a.cc:27:23: error: assignment of read-only location '*(time + (((sizetype)a) + ((sizetype)b)))' 27 | time[a][b]=t; | ~~~~~~~~~~^~ a.cc:28:19: warning: pointer to a function used in arithmetic [-Wpointer-arith] 28 | time[b][a]=t; | ^ a.cc:28:22: warning: pointer to a function used in arithmetic [-Wpointer-arith] 28 | time[b][a]=t; | ^ a.cc:28:23: error: assignment of read-only location '*(time + (((sizetype)b) + ((sizetype)a)))' 28 | time[b][a]=t; | ~~~~~~~~~~^~ a.cc:34:27: warning: pointer to a function used in arithmetic [-Wpointer-arith] 34 | time[i][j]=min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:34:30: warning: pointer to a function used in arithmetic [-Wpointer-arith] 34 | time[i][j]=min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:34:42: warning: pointer to a function used in arithmetic [-Wpointer-arith] 34 | time[i][j]=min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:34:45: warning: pointer to a function used in arithmetic [-Wpointer-arith] 34 | time[i][j]=min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:34:53: warning: pointer to a function used in arithmetic [-Wpointer-arith] 34 | time[i][j]=min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:34:56: warning: pointer to a function used in arithmetic [-Wpointer-arith] 34 | time[i][j]=min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:34:64: warning: pointer to a function used in arithmetic [-Wpointer-arith] 34 | time[i][j]=min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:34:67: warning: pointer to a function used in arithmetic [-Wpointer-arith] 34 | time[i][j]=min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:34:57: error: invalid operands of types 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} and 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} to binary 'operator+' 34 | time[i][j]=min(time[i][j],time[i][k]+time[k][j]); | ~~~~~~~~~~^~~~~~~~~~~ | | | | | time_t(time_t*) noexcept {aka long int(long int*) noexcept} | time_t(time_t*) noexcept {aka long int(long int*) noexcept} a.cc:47:29: warning: pointer to a function used in arithmetic [-Wpointer-arith] 47 | cout<<time[p][q]<<endl; | ^ a.cc:47:32: warning: pointer to a function used in arithmetic [-Wpointer-arith] 47 | cout<<time[p][q]<<endl; | ^
s336457588
p00200
C++
#include <iostream> using namespace std; int time[110][110]; int cost[110][110]; int main() { int n,m; while(cin>>n>>m){ if(!n)return 0; for(int i=0;i<m;++i){ for(int j=0;j<m;++j){ if(i==j){ time[i][j]=0; cost[i][j]=0; }else{ time[i][j]=100000; cost[i][j]=100000; } } } for(int i=0;i<n;++i){ int a,b,c,t; cin>>a>>b>>c>>t; a--;b--; cost[a][b]=c; cost[b][a]=c; time[a][b]=t; time[b][a]=t; } for(int k=0;k<m;++k){ for(int i=0;i<m;++i){ for(int j=0;j<m;++j){ cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]); time[i][j]=min(time[i][j],time[i][k]+time[k][j]); } } } int k; cin>>k; for(int i=0;i<k;++i){ int p,q,r; cin>>p>>q>>r; p--;q--; if(!r) cout<<cost[p][q]<<endl; else cout<<time[p][q]<<endl; } } }
a.cc:3:18: error: 'int time [110][110]' redeclared as different kind of entity 3 | int time[110][110]; | ^ In file included from /usr/include/pthread.h:23, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157, from /usr/include/c++/14/ext/atomicity.h:35, from /usr/include/c++/14/bits/ios_base.h:39, 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/time.h:76:15: note: previous declaration 'time_t time(time_t*)' 76 | extern time_t time (time_t *__timer) __THROW; | ^~~~ a.cc: In function 'int main()': a.cc:13:27: warning: pointer to a function used in arithmetic [-Wpointer-arith] 13 | time[i][j]=0; | ^ a.cc:13:30: warning: pointer to a function used in arithmetic [-Wpointer-arith] 13 | time[i][j]=0; | ^ a.cc:13:31: error: assignment of read-only location '*(time + (((sizetype)i) + ((sizetype)j)))' 13 | time[i][j]=0; | ~~~~~~~~~~^~ a.cc:16:27: warning: pointer to a function used in arithmetic [-Wpointer-arith] 16 | time[i][j]=100000; | ^ a.cc:16:30: warning: pointer to a function used in arithmetic [-Wpointer-arith] 16 | time[i][j]=100000; | ^ a.cc:16:31: error: assignment of read-only location '*(time + (((sizetype)i) + ((sizetype)j)))' 16 | time[i][j]=100000; | ~~~~~~~~~~^~~~~~~ a.cc:27:19: warning: pointer to a function used in arithmetic [-Wpointer-arith] 27 | time[a][b]=t; | ^ a.cc:27:22: warning: pointer to a function used in arithmetic [-Wpointer-arith] 27 | time[a][b]=t; | ^ a.cc:27:23: error: assignment of read-only location '*(time + (((sizetype)a) + ((sizetype)b)))' 27 | time[a][b]=t; | ~~~~~~~~~~^~ a.cc:28:19: warning: pointer to a function used in arithmetic [-Wpointer-arith] 28 | time[b][a]=t; | ^ a.cc:28:22: warning: pointer to a function used in arithmetic [-Wpointer-arith] 28 | time[b][a]=t; | ^ a.cc:28:23: error: assignment of read-only location '*(time + (((sizetype)b) + ((sizetype)a)))' 28 | time[b][a]=t; | ~~~~~~~~~~^~ a.cc:34:27: warning: pointer to a function used in arithmetic [-Wpointer-arith] 34 | time[i][j]=min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:34:30: warning: pointer to a function used in arithmetic [-Wpointer-arith] 34 | time[i][j]=min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:34:42: warning: pointer to a function used in arithmetic [-Wpointer-arith] 34 | time[i][j]=min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:34:45: warning: pointer to a function used in arithmetic [-Wpointer-arith] 34 | time[i][j]=min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:34:53: warning: pointer to a function used in arithmetic [-Wpointer-arith] 34 | time[i][j]=min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:34:56: warning: pointer to a function used in arithmetic [-Wpointer-arith] 34 | time[i][j]=min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:34:64: warning: pointer to a function used in arithmetic [-Wpointer-arith] 34 | time[i][j]=min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:34:67: warning: pointer to a function used in arithmetic [-Wpointer-arith] 34 | time[i][j]=min(time[i][j],time[i][k]+time[k][j]); | ^ a.cc:34:57: error: invalid operands of types 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} and 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} to binary 'operator+' 34 | time[i][j]=min(time[i][j],time[i][k]+time[k][j]); | ~~~~~~~~~~^~~~~~~~~~~ | | | | | time_t(time_t*) noexcept {aka long int(long int*) noexcept} | time_t(time_t*) noexcept {aka long int(long int*) noexcept} a.cc:47:29: warning: pointer to a function used in arithmetic [-Wpointer-arith] 47 | cout<<time[p][q]<<endl; | ^ a.cc:47:32: warning: pointer to a function used in arithmetic [-Wpointer-arith] 47 | cout<<time[p][q]<<endl; | ^
s587469175
p00200
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int a, b, time, cost, querys; int i, j, k, p, q, r, n, m; int times[100][100], costs[100][100]; while (true) { cin >> n >> m; if (!n && !m) break; for (i = 0; i < m; i++) { for (j = 0; j < m; j++) { times[i][j] = (i == j) ? 0 : 1e9; costs[i][j] = (i == j) ? 0 : 1e9; } } for (i = 0; i < n; i++) { cin >> a >> b >> cost >> time; times[a - 1][b - 1] = time; costs[a - 1][b - 1] = cost; } for (k = 0; k < m; k++) { for (i = 0; i < m; i++) { for (j = 0; j < m; j++) { times[i][j] = min(times[i][j], times[i][k] + times[k][j]); costs[i][j] = min(costs[i][j], costs[i][k] + costs[k][j]); } } } cin >> querys; for (i = 0; i < querys; i++) { cin >> p >> q >> r; cout << r ? times[p - 1][q - 1] : costs[p - 1][q - 1] << endl; } } }
a.cc: In function 'int main()': a.cc:42:79: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<' 42 | cout << r ? times[p - 1][q - 1] : costs[p - 1][q - 1] << endl; | ~~~~~~~~~~~~~~~~~~~~^~~~~~~
s173708770
p00200
C++
#include<iostream> using namespace std; int line[3001][3001],c[3001][3001],t[3001][3001]; int stop[3001]={0}; int ls[3001]={0}; int route_cost(int p,int q){ int top = -1; for(int i=0;i<ls[p];i++){ cout << line[p][i] << endl; if(stop[line[p][i]]!=0) continue; stop[p]++; if(q==line[p][i]){ stop[p] = 0; return c[p][q]; } int h = route_cost(line[p][i],q)+c[p][line[p][i]]; else if(top<0||top>h){ top = h+c[p][line[p][i]]; } } stop[p] = 0; return top; } int route_time(int p,int q){ int top = -1; for(int i=0;i<ls[p];i++){ //cout << "P " << p << endl; cout << line[p][i] << endl; if(stop[line[p][i]]!=0) continue; stop[p]++; if(q==line[p][i]){ stop[p] = 0; return t[p][q]; } h = route_time(line[p][i],q)+t[p][line[p][i]]; else if(top<0||top>h){ top = h; //cout << 'O' << endl; } } stop[p] = 0; return top; } int main(){ int n,m; int a,b,cost,time; while(cin>>n>>m){ if(n==0&&m==0) break; for(int i=0;i<n;i++){ cin >> a >> b >> cost >> time; line[a][ls[a]] = b; ls[a]++; line[b][ls[b]] = a; ls[b]++; c[a][b] = cost; c[b][a] = cost; t[a][b] = time; t[b][a] = time; //cout << "line " << line[a][ls[a]-1] << ' ' << line[b][ls[b]-1] << endl; } int k; cin >> k; int p,q,r; for(int i=0;i<k;i++){ cin>>p>>q>>r; if(r==0) cout << route_cost(p,q) << endl; else if(r==1) cout << route_time(p,q) << endl; } } return 0; }
a.cc: In function 'int route_cost(int, int)': a.cc:17:5: error: 'else' without a previous 'if' 17 | else if(top<0||top>h){ | ^~~~ a.cc: In function 'int route_time(int, int)': a.cc:35:1: error: 'h' was not declared in this scope 35 | h = route_time(line[p][i],q)+t[p][line[p][i]]; | ^ a.cc:36:7: error: 'else' without a previous 'if' 36 | else if(top<0||top>h){ | ^~~~
s332709636
p00200
C++
#include<iostream> using namespace std; int line[3001][3001],c[3001][3001],t[3001][3001]; int stop[3001]={0}; int ls[3001]={0}; int route_cost(int p,int q){ int top = -1; for(int i=0;i<ls[p];i++){ //cout << line[p][i] << endl; if(stop[line[p][i]]!=0) continue; stop[p]++; if(q==line[p][i]){ stop[p] = 0; return c[p][q]; } int h = route_cost(line[p][i],q)+c[p][line[p][i]]; else if(top<0||top>h){ top = h+c[p][line[p][i]]; } } stop[p] = 0; return top; } int route_time(int p,int q){ int top = -1; for(int i=0;i<ls[p];i++){ //cout << "P " << p << endl; //cout << line[p][i] << endl; if(stop[line[p][i]]!=0) continue; stop[p]++; if(q==line[p][i]){ stop[p] = 0; return t[p][q]; } h = route_time(line[p][i],q)+t[p][line[p][i]]; else if(top<0||top>h){ top = h; //cout << 'O' << endl; } } stop[p] = 0; return top; } int main(){ int n,m; int a,b,cost,time; while(cin>>n>>m){ if(n==0&&m==0) break; for(int i=0;i<n;i++){ cin >> a >> b >> cost >> time; line[a][ls[a]] = b; ls[a]++; line[b][ls[b]] = a; ls[b]++; c[a][b] = cost; c[b][a] = cost; t[a][b] = time; t[b][a] = time; //cout << "line " << line[a][ls[a]-1] << ' ' << line[b][ls[b]-1] << endl; } int k; cin >> k; int p,q,r; for(int i=0;i<k;i++){ cin>>p>>q>>r; if(r==0) cout << route_cost(p,q) << endl; else if(r==1) cout << route_time(p,q) << endl; } } return 0; }
a.cc: In function 'int route_cost(int, int)': a.cc:17:5: error: 'else' without a previous 'if' 17 | else if(top<0||top>h){ | ^~~~ a.cc: In function 'int route_time(int, int)': a.cc:35:1: error: 'h' was not declared in this scope 35 | h = route_time(line[p][i],q)+t[p][line[p][i]]; | ^ a.cc:36:7: error: 'else' without a previous 'if' 36 | else if(top<0||top>h){ | ^~~~
s854499323
p00200
C++
#include <iostream> #include <cstring> using namespace std; const int INF = 1000000; const int MAX_V = 101; int cost[MAX_V][MAX_V]; int time[MAX_V][MAX_V]; int d[MAX_V]; bool used[MAX_V]; int V; int n,m; void dijkstra(int s,bool r){ fill(d,d+m,INF); memset(used,false,sizeof(used)); d[s]=0; while(1){ int v=-1; for(int u=0;u<m;u++){ if(used[u]) continue; if(v==-1||d[u]<d[v]){ v=u; } } if(v==-1) break; used[v]=true; for(int u=0;u<m;u++){ int c; if(r) c=cost[u][v]; else c=time[u][v]; d[u]=min(d[u],d[v]+c); } } } int main(){ while(cin >> n >> m,n+m){ for(int i=0;i<m+1; i++){ for(int j=0; j<m; j++){ cost[i][j]=INF; time[i][j]=INF; } } for (int i = 0; i < m+1; ++i) { cost[i][i]=0; time[i][i]=0; } for (int i = 0; i < n; ++i) { int to,from,c,t; cin >> to>>from>>c>>t; to--; from--; cost[to][from]=c; cost[from][to]=c; time[to][from]=t; time[from][to]=t; } int k; cin>>k; for (int i = 0; i < k; ++i) { int p,q,r; cin>>p>>q>>r; p--; q--; dijkstra(p,!r); cout<<d[q]<<endl; } } }
a.cc:9:22: error: 'int time [101][101]' redeclared as different kind of entity 9 | int time[MAX_V][MAX_V]; | ^ In file included from /usr/include/pthread.h:23, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157, from /usr/include/c++/14/ext/atomicity.h:35, from /usr/include/c++/14/bits/ios_base.h:39, 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/time.h:76:15: note: previous declaration 'time_t time(time_t*)' 76 | extern time_t time (time_t *__timer) __THROW; | ^~~~ a.cc: In function 'void dijkstra(int, bool)': a.cc:33:26: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | else c=time[u][v]; | ^ a.cc:33:29: warning: pointer to a function used in arithmetic [-Wpointer-arith] 33 | else c=time[u][v]; | ^ a.cc:33:29: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'int' [-fpermissive] 33 | else c=time[u][v]; | ~~~~~~~~~^ | | | time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept} a.cc: In function 'int main()': a.cc:43:23: warning: pointer to a function used in arithmetic [-Wpointer-arith] 43 | time[i][j]=INF; | ^ a.cc:43:26: warning: pointer to a function used in arithmetic [-Wpointer-arith] 43 | time[i][j]=INF; | ^ a.cc:43:27: error: assignment of read-only location '*(time + (((sizetype)i) + ((sizetype)j)))' 43 | time[i][j]=INF; | ~~~~~~~~~~^~~~ a.cc:48:19: warning: pointer to a function used in arithmetic [-Wpointer-arith] 48 | time[i][i]=0; | ^ a.cc:48:22: warning: pointer to a function used in arithmetic [-Wpointer-arith] 48 | time[i][i]=0; | ^ a.cc:48:23: error: assignment of read-only location '*(time + (((sizetype)i) * 2))' 48 | time[i][i]=0; | ~~~~~~~~~~^~ a.cc:56:20: warning: pointer to a function used in arithmetic [-Wpointer-arith] 56 | time[to][from]=t; | ^ a.cc:56:26: warning: pointer to a function used in arithmetic [-Wpointer-arith] 56 | time[to][from]=t; | ^ a.cc:56:27: error: assignment of read-only location '*(time + (((sizetype)to) + ((sizetype)from)))' 56 | time[to][from]=t; | ~~~~~~~~~~~~~~^~ a.cc:57:22: warning: pointer to a function used in arithmetic [-Wpointer-arith] 57 | time[from][to]=t; | ^ a.cc:57:26: warning: pointer to a function used in arithmetic [-Wpointer-arith] 57 | time[from][to]=t; | ^ a.cc:57:27: error: assignment of read-only location '*(time + (((sizetype)from) + ((sizetype)to)))' 57 | time[from][to]=t; | ~~~~~~~~~~~~~~^~
s535782451
p00200
C++
#include <iostream> #include <cstring> using namespace std; const int INF = 1000000; const int MAX_V = 101; const int MAX_E = 20000; int cost[MAX_V][MAX_V]; int time[MAX_V][MAX_V]; int d[MAX_V]; bool used[MAX_V]; int V; int n,m; void dijkstra(int s,bool r){ fill(d,d+m,INF); memset(used,false,sizeof(used)); d[s]=0; while(1){ int v=-1; for(int u=0;u<m;u++){ if(used[u]) continue; if(v==-1||d[u]<d[v]){ v=u; } } if(v==-1) break; used[v]=true; for(int u=0;u<m;u++){ int c; if(r) c=cost[u][v]; else c=time[u][v]; d[u]=min(d[u],d[v]+c); } } } int main(){ while(cin >> n >> m,n+m){ for(int i=0;i<m+1; i++){ for(int j=0; j<m; j++){ cost[i][j]=INF; time[i][j]=INF; } } for (int i = 0; i < m+1; ++i) { cost[i][i]=0; time[i][i]=0; } for (int i = 0; i < n; ++i) { int to,from,c,t; cin >> to>>from>>c>>t; to--; from--; cost[to][from]=c; cost[from][to]=c; time[to][from]=t; time[from][to]=t; } int k; cin>>k; for (int i = 0; i < k; ++i) { int p,q,r; cin>>p>>q>>r; p--; q--; dijkstra(p,!r); cout<<d[q]<<endl; } } }
a.cc:10:22: error: 'int time [101][101]' redeclared as different kind of entity 10 | int time[MAX_V][MAX_V]; | ^ In file included from /usr/include/pthread.h:23, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157, from /usr/include/c++/14/ext/atomicity.h:35, from /usr/include/c++/14/bits/ios_base.h:39, 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/time.h:76:15: note: previous declaration 'time_t time(time_t*)' 76 | extern time_t time (time_t *__timer) __THROW; | ^~~~ a.cc: In function 'void dijkstra(int, bool)': a.cc:34:26: warning: pointer to a function used in arithmetic [-Wpointer-arith] 34 | else c=time[u][v]; | ^ a.cc:34:29: warning: pointer to a function used in arithmetic [-Wpointer-arith] 34 | else c=time[u][v]; | ^ a.cc:34:29: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'int' [-fpermissive] 34 | else c=time[u][v]; | ~~~~~~~~~^ | | | time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept} a.cc: In function 'int main()': a.cc:44:23: warning: pointer to a function used in arithmetic [-Wpointer-arith] 44 | time[i][j]=INF; | ^ a.cc:44:26: warning: pointer to a function used in arithmetic [-Wpointer-arith] 44 | time[i][j]=INF; | ^ a.cc:44:27: error: assignment of read-only location '*(time + (((sizetype)i) + ((sizetype)j)))' 44 | time[i][j]=INF; | ~~~~~~~~~~^~~~ a.cc:49:19: warning: pointer to a function used in arithmetic [-Wpointer-arith] 49 | time[i][i]=0; | ^ a.cc:49:22: warning: pointer to a function used in arithmetic [-Wpointer-arith] 49 | time[i][i]=0; | ^ a.cc:49:23: error: assignment of read-only location '*(time + (((sizetype)i) * 2))' 49 | time[i][i]=0; | ~~~~~~~~~~^~ a.cc:57:20: warning: pointer to a function used in arithmetic [-Wpointer-arith] 57 | time[to][from]=t; | ^ a.cc:57:26: warning: pointer to a function used in arithmetic [-Wpointer-arith] 57 | time[to][from]=t; | ^ a.cc:57:27: error: assignment of read-only location '*(time + (((sizetype)to) + ((sizetype)from)))' 57 | time[to][from]=t; | ~~~~~~~~~~~~~~^~ a.cc:58:22: warning: pointer to a function used in arithmetic [-Wpointer-arith] 58 | time[from][to]=t; | ^ a.cc:58:26: warning: pointer to a function used in arithmetic [-Wpointer-arith] 58 | time[from][to]=t; | ^ a.cc:58:27: error: assignment of read-only location '*(time + (((sizetype)from) + ((sizetype)to)))' 58 | time[from][to]=t; | ~~~~~~~~~~~~~~^~
s600040887
p00200
C++
#include <iostream> #include <cstdio> #include <iomanip> #include <vector> #include <map> #include <set> #include <queue> #include <bitset> #include <stack> #include <utility> #include <numeric> #include <algorithm> #include <functional> #include <cctype> #include <complex> #include <string> #include <sstream> #include <cassert> using namespace std; //common typedef int i32; typedef long long i64,ll; #define BR "\n" #define ALL(c) (c).begin(),(c).end() #define REP(i,n) for(int i=0;i<(int)(n);++i) #define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it) #define IN(l,v,r) ((l)<=(v) && (v)<(r)) typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii; typedef long long ll; typedef vector<long long> vl; typedef pair<long long,long long> pll; typedef vector<pair<long long,long long> > vpll; typedef vector<string> vs; typedef long double ld; //config #define MODE_DEBUG //#define INF 1<<30 //#define EPS 1e-8 //const ll MOD =100000007; //debug //#ifdef MODE_DEBUG #define LINE() cerr<< " (L" << __LINE__ << ")" #define LINELN() LINE()<<endl #define DUMP(x) cerr << #x << " = " << (x) <<endl #define DEBUG(x) DUMP(x) << " (L" << __LINE__ << ")" << " " << __FILE__<<endl #define CHECK(exp,act) if(exp!=act){DUMP(exp);DEBUG(act);} #define STOP(e) CHECK(e,true);if(!(e)) exit(1); #else #define DUMP(x) #define DEBUG(x) #define CHECK(exp,act) #define STOP(e) #endif template<class T> inline string toString(const vector<T>& x) { stringstream ss; REP(i,x.size()){ if(i!=0)ss<<" "; ss<< x[i]; } return ss.str(); } template<class T> inline string toString(const vector<vector<T>>& map) { stringstream ss; REP(i,map.size()){ if(i!=0)ss<<BR; ss<< toString(map[i]); } return ss.str(); } template<class K,class V> string toString(map<K,V>& x) { string res;stringstream ss; for(auto& p:x)ss<< p.first<<":" << p.second<<" "; return ss.str(); } template<typename T,typename V> inline T mod(T v,V MOD){ return (v%MOD+MOD)%MOD; } typedef vector<vector<int>> Mat; void warshall_floyd(Mat& d){ const int V=d.size(); for(int k=0;k<V;k++) for(int i=0;i<V;i++)for(int j=0;j<V;j++) if(d[i][j]>d[i][k] + d[k][j]){ d[i][j]=d[i][k] + d[k][j]; //prev[i][j]=k; } } const int INF =1<<28; int main(){ while(true){ int N,M;cin >> N >> M; if(N==0 && M==0)return 0; Mat ds(M+1,vector<int>(M+1,INF)); Mat cs(M+1,vector<int>(M+1,INF)); REP(i,M+1)ds[i][i]=cs[i][i]=0; REP(i,N){ int a,b,c,t; cin >> a >> b >> c>>t; ds[a][b]=min(ds[a][b],t);ds[b][a]=min(ds[b][a],t); cs[a][b]=min(cs[a][b],c);cs[b][a]=min(cs[b][a],c); } warshall_floyd(ds);DUMP(toString(ds)); warshall_floyd(cs);DUMP(toString(cs)); int k;cin >> k; REP(i,k){ int p,q,r;cin >> p >> q >>r; if(r==0)cout<<cs[p][q]<<endl; else cout<<ds[p][q]<<endl; } } return 0; }
a.cc:50:2: error: #else without #if 50 | #else | ^~~~ a.cc:51:9: warning: "DUMP" redefined 51 | #define DUMP(x) | ^~~~ a.cc:46:10: note: this is the location of the previous definition 46 | #define DUMP(x) cerr << #x << " = " << (x) <<endl | ^~~~ a.cc:52:9: warning: "DEBUG" redefined 52 | #define DEBUG(x) | ^~~~~ a.cc:47:9: note: this is the location of the previous definition 47 | #define DEBUG(x) DUMP(x) << " (L" << __LINE__ << ")" << " " << __FILE__<<endl | ^~~~~ a.cc:53:9: warning: "CHECK" redefined 53 | #define CHECK(exp,act) | ^~~~~ a.cc:48:9: note: this is the location of the previous definition 48 | #define CHECK(exp,act) if(exp!=act){DUMP(exp);DEBUG(act);} | ^~~~~ a.cc:54:9: warning: "STOP" redefined 54 | #define STOP(e) | ^~~~ a.cc:49:9: note: this is the location of the previous definition 49 | #define STOP(e) CHECK(e,true);if(!(e)) exit(1); | ^~~~ a.cc:55:2: error: #endif without #if 55 | #endif | ^~~~~
s916768618
p00200
C++
#include<iostream> #include<algorithm> #include<vector> #include<map> #include<queue> #define INF (1<<30) #define COST 0 #define TIME 1 using namespace std; typedef pair<int, int> p; vector<p> costs[105], times[105]; int dist[105]; void dijkstra(vector<p> *edge, int s){ fill(dist, dist + 105, INF); dist[s] = 0; priority_queue<p, vector<p>, greater<p> > q; q.push(p(0, s)); while(!q.empty()){ p tmp = q.top();q.pop(); int d = tmp.first, from = tmp.second; if(dist[from] < d)continue; for(int i = 0; i < edge[from].size(); i++){ int to = edge[from][i].first, c = edge[from][i].second; if(dist[to] < dist[from] + c)continue; dist[to] = dist[from] + c; q.push(p(dist[to], to)); } } } int main(){ while(true){ int n, m; cin >> n >> m; if(!n && !m) break; costs.clear(); times.clear(); for(int i = 0; i < n; i++){ int a, b, c, t; cin >> a >> b >> c >> t; costs[a].push_back(p(b, c)); costs[b].push_back(p(a, c)); times[a].push_back(p(b, t)); times[b].push_back(p(a, t)); } int k; cin >> k; for(int i = 0; i < k; i++){ int p, q, r; cin >> p >> q >> r; if(r == COST){ dijkstra(costs, p); }else{ dijkstra(times, p); } cout << dist[q] << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:40:23: error: request for member 'clear' in 'costs', which is of non-class type 'std::vector<std::pair<int, int> > [105]' 40 | costs.clear(); | ^~~~~ a.cc:41:23: error: request for member 'clear' in 'times', which is of non-class type 'std::vector<std::pair<int, int> > [105]' 41 | times.clear(); | ^~~~~
s848307776
p00200
C++
#include <vector> #include <map> #include <stack> #include <queue> #include <cstring> #include <string> #include <sstream> #include <algorithm> #include <iomanip> #include <iostream> #define VARIABLE(x) cerr << #x << "=" << x << endl #define rep(i,n) for(int i=0;i<(int)(n);i++) #define REP(i,m,n) for (int i=m;i<(int)(n);i++) const int INF = 10000000; using namespace std; typedef long long ll; const int MAX = 10000; /** Problem0200 : Traveling Alone : One-way Ticket of Youth **/ int costG[100][100]; int timeG[100][100]; int main() { int n, m, a, b, c, t; while (cin >> n >> m, n!=0 && m!=0) { rep(i, 100) { rep(j, 100) { costG[i][j]=INF; timeG[i][j]=INF; } } rep(k, n) { cin >> a >> b >> c >> t; a--; b--; costG[a][b] = c; costG[b][a] = c; timeG[a][b] = t; timeG[b][a] = t; } rep(k, m) { rep(i, m) { rep(j, m) { costG[i][j] = min(costG[i][j], costG[i][k]+costG[k][j]); timeG[i][j] = min(timeG[i][j], timeG[i][k]+timeG[k][j]); } } } int k, p, q, r; cin >> k; rep(i, k) { cin >> p >> q >> r; p--; q--; if (r==0) { cout << costG[p][q] << endl; } else { cout << timeG[p][q] << endl; } } } re
a.cc: In function 'int main()': a.cc:67:9: error: 're' was not declared in this scope; did you mean 'rep'? 67 | re | ^~ | rep a.cc:67:11: error: expected '}' at end of input 67 | re | ^ a.cc:26:1: note: to match this '{' 26 | { | ^
s279658461
p00200
C++
//2013-5 #include <iostream> #include <fstream> #include <cstdio> #include <vector> #include <queue> #include <stack> #include <map> #include <algorithm> #include <time.h> #define mp make_pair #define INF 1e8 #define fs first #define sc second #define rep(x,n) for(int x = 0;x < n;x ++) #define Rep(x,n) for(int x = 1;x <= n;x ++) using namespace std; int d[2][105][105]; //行き先、cost...0 time...1 int main(){ int n,m; while(scanf("%d %d",&n,&m)&&(n!=0||m!=0){ rep(i,m){ rep(j,m){ d[0][i][j]=INF; d[1][i][j]=INF; } } rep(i,m){ d[0][i][i]=0; d[1][i][i]=0; } rep(i,n){ int a,b,cost,time; scanf("%d %d %d %d",&a,&b,&cost,&time); a--;b--; d[0][a][b]=cost; d[0][b][a]=cost; d[1][a][b]=time; d[1][b][a]=time; } rep(i,2){ rep(j,m){ rep(k,m){ rep(l,m){ d[i][k][l]=min(d[i][k][l],d[i][k][j]+d[i][j][l]); if(d[i][k][l]>INF) d[i][k][l]=INF; } } } } int k; scanf("%d",&k); rep(i,k){ int p,q,r; scanf("%d %d %d",&p,&q,&r); p--;q--; printf("%d\n",d[r][p][q]); } } }
a.cc: In function 'int main()': a.cc:24:45: error: expected ')' before '{' token 24 | while(scanf("%d %d",&n,&m)&&(n!=0||m!=0){ | ~ ^ | )
s490026003
p00201
Java
class Main{ public static void main(String args[]) { Scanner sc = new Scanner(System.in); while (true) { HashMap<String, Integer> data = new HashMap<String, Integer>(); int items = sc.nextInt(); if (items == 0) { break; } for (int i = 0; i < items; i++) { data.put(sc.next(), sc.nextInt()); } int craftrecipe = sc.nextInt(); for (int j = 0; j < craftrecipe; j++) { String item = sc.next(); int source = sc.nextInt(); int money = 0; for (int k = 0; k < source; k++) { String a = sc.next(); money += data.get(a); } if (data.get(item) > money) { data.put(item, money); } } String answer = sc.next(); System.out.println(data.get(answer)); } } }
Main.java:3: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:3: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:5: error: cannot find symbol HashMap<String, Integer> data = new HashMap<String, Integer>(); ^ symbol: class HashMap location: class Main Main.java:5: error: cannot find symbol HashMap<String, Integer> data = new HashMap<String, Integer>(); ^ symbol: class HashMap location: class Main 4 errors
s291445153
p00201
Java
8 wood 3000 string 800 rice 36 water 0 racket 5000 microphone 9800 onigiri 140 guitar 98000 3 racket 2 wood string onigiri 2 rice water guitar 3 racket microphone onigiri guitar 1 computer 300000 0 computer 0
Main.java:1: error: class, interface, enum, or record expected 8 ^ 1 error
s331042571
p00201
Java
import java.util.HashMap; import java.util.Scanner; public class Vol2_201 { void run() { Scanner in = new Scanner(System.in); HashMap<String, Integer> item = new HashMap<String, Integer>(); while(true) { int N = Integer.parseInt(in.next()); if (N == 0) break; for(int i = 0; i < N; i++) { item.put(in.next(), Integer.parseInt(in.next())); } int M = Integer.parseInt(in.next()); for(int i = 0; i < M; i++) { String item_name = in.next(); int item_cost = item.get(item_name); int X = Integer.parseInt(in.next()); int recipe_cost = 0; for(int j = 0; j < X; j++) { recipe_cost += item.get(in.next()); } if(item_cost > recipe_cost) { item.put(item_name, recipe_cost); } } System.out.println(item.get(in.next())); } } public static void main(String[] args) { new Vol2_201().run(); } }
Main.java:4: error: class Vol2_201 is public, should be declared in a file named Vol2_201.java public class Vol2_201 { ^ 1 error
s085613176
p00201
Java
import java.util.*; class P0200 { Scanner sc; HashMap<Integer, Integer> itemList; HashMap<String, Integer> key; LinkedList<Integer>[] itemComb; long solve(int item) { long sum = 0; if (itemComb[item].isEmpty()) { return itemList.get(item); } for (int str : itemComb[item]) { sum += solve(str); } return Math.min(itemList.get(item), sum); } void run() { sc = new Scanner(System.in); while (true) { int n = sc.nextInt(); if (n == 0) { break; } itemList = new HashMap<Integer, Integer>(); key = new HashMap<String, Integer>(); itemComb = new LinkedList[n]; for (int i = 0; i < n; i++) { String item = sc.next(); itemList.put(i, sc.nextInt()); key.put(item, i); itemComb[i] = new LinkedList<Integer>(); } int m = sc.nextInt(); for (int i = 0; i < m; i++) { String item = sc.next(); int num = sc.nextInt(); for (int j = 0; j < num; j++) { itemComb[key.get(item)].add( key.get(sc.next()) ); } } System.out.println(solve( key.get(sc.next()) ) ); } } public static void main(String[] args) { new P0200().run(); } }
Note: Main.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.
s869927393
p00201
Java
import java.util.*; class Main { Scanner sc; HashMap<String, Integer> itemList; HashMap<String, LinkedList<String>> itemComb; long solve(String item, long min) { long sum = 0; if ( !itemList.contains(item) )return min; if (itemComb.get(item).isEmpty()) { return itemList.get(item); } for (String str : itemComb.get(item)) { sum += solve(str, min); if (sum >= min) return min; } return sum; } void run() { sc = new Scanner(System.in); while (true) { int n = sc.nextInt(); if (n == 0) { break; } itemList = new HashMap<String, Integer>(); itemComb = new HashMap<String,LinkedList<String>>(); for (int i = 0; i < n; i++) { LinkedList<String> tmp = new LinkedList<String>(); String item = sc.next(); itemList.put(item, sc.nextInt()); itemComb.put(item,tmp); } int m = sc.nextInt(); for (int i = 0; i < m; i++) { String item = sc.next(); int num = sc.nextInt(); LinkedList<String> tmp = new LinkedList<String>(); for (int j = 0; j < num; j++) { tmp.add(sc.next()); } itemComb.put(item,tmp); } String q = sc.next(); System.out.println(solve( q, itemList.get(q) ) ); } } public static void main(String[] args) { new Main().run(); } }
Main.java:12: error: cannot find symbol if ( !itemList.contains(item) )return min; ^ symbol: method contains(String) location: variable itemList of type HashMap<String,Integer> 1 error
s643579830
p00201
Java
import java.util.Scanner; import java.util.ArrayList; public class AOJ0201 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); ArrayList<String> item = new ArrayList<String>(); ArrayList<Integer> itemMoney = new ArrayList<Integer>(); ArrayList<String> alcmy = new ArrayList<String>(); String ansStr,tmpStr1,tmpStr2; Integer oneItemMoney,alcmyItemMoney,alcmyFlg,ansInt; while(scan.hasNext()) { oneItemMoney=0; alcmyItemMoney=0; alcmyFlg=1; ansInt=0; //アイテムセット int n = scan.nextInt(); for(int i=0;i<n;i++) { item.add(scan.next()); itemMoney.add(scan.nextInt()); } //錬金レシピセット int m = scan.nextInt(); for(int i=0;i<m;i++) { alcmy.add(scan.next()); tmpStr1 = alcmy.get(i); //錬金するアイテムの値段を見る for(int j=0;j<n;j++) { if(tmpStr1.equals(item.get(j))) { oneItemMoney=itemMoney.get(j); break; } } //錬金レシピの素材の値段を見る int k = scan.nextInt(); alcmyItemMoney=0; for(int p=0;p<k;p++) { tmpStr2 = scan.next(); for(int j=0;j<n;j++) { if(tmpStr2.equals(item.get(j))) { alcmyItemMoney=alcmyItemMoney+itemMoney.get(j); break; } } //System.out.println(alcmyItemMoney +"alc"); //System.out.println(oneItemMoney + "oneItem"); //そのアイテムの値段と錬金された時の値段を比較 /*if(oneItemMoney<alcmyItemMoney) { alcmyFlg=0; break; }*/ } if(alcmyFlg==1) { for(int j=0;j<n;j++) { if(tmpStr1.equals(item.get(j))) { itemMoney.set(j,alcmyItemMoney); break; } } } } //指定されたアイテム ansStr = scan.next(); for(int i=0;i<n;i++) { if(ansStr.equals(item.get(i))) { ansInt=i; break; } } //System.out.println(itemMoney.get(5)); System.out.println(itemMoney.get(ansInt)); } } }
Main.java:5: error: class AOJ0201 is public, should be declared in a file named AOJ0201.java public class AOJ0201 ^ 1 error
s519791179
p00201
Java
import java.util.Scanner; import java.util.ArrayList; public class AOJ0201 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); ArrayList<String> item = new ArrayList<String>(); ArrayList<Integer> itemMoney = new ArrayList<Integer>(); ArrayList<String> alcmy = new ArrayList<String>(); String ansStr,tmpStr1,tmpStr2; Integer oneItemMoney,alcmyItemMoney,alcmyFlg,ansInt; while(scan.hasNext()) { item.clear(); itemMoney.clear(); alcmy.clear(); oneItemMoney=0; alcmyItemMoney=0; alcmyFlg=1; ansInt=0; //アイテムセット int n = scan.nextInt(); if(n==0) break; for(int i=0;i<n;i++) { item.add(scan.next()); itemMoney.add(scan.nextInt()); } //錬金レシピセット int m = scan.nextInt(); for(int i=0;i<m;i++) { alcmy.add(scan.next()); tmpStr1 = alcmy.get(i); //錬金するアイテムの値段を見る for(int j=0;j<n;j++) { if(tmpStr1.equals(item.get(j))) { oneItemMoney=itemMoney.get(j); break; } } //錬金レシピの素材の値段を見る int k = scan.nextInt(); alcmyItemMoney=0; for(int p=0;p<k;p++) { tmpStr2 = scan.next(); for(int j=0;j<n;j++) { if(tmpStr2.equals(item.get(j))) { alcmyItemMoney=alcmyItemMoney+itemMoney.get(j); break; } } //System.out.println(alcmyItemMoney +"alc"); //System.out.println(oneItemMoney + "oneItem"); //そのアイテムの値段と錬金された時の値段を比較 /*if(oneItemMoney<alcmyItemMoney) { alcmyFlg=0; break; }*/ } if(alcmyFlg==1) { for(int j=0;j<n;j++) { if(tmpStr1.equals(item.get(j))) { itemMoney.set(j,alcmyItemMoney); break; } } } } //指定されたアイテム ansStr = scan.next(); for(int i=0;i<n;i++) { if(ansStr.equals(item.get(i))) { ansInt=i; break; } } System.out.println(itemMoney.get(ansInt)); } } }
Main.java:5: error: class AOJ0201 is public, should be declared in a file named AOJ0201.java public class AOJ0201 ^ 1 error
s337949993
p00201
C
#include<iostream> #include<string> #include<map> using namespace std; int main(){ int n, price, m, sum; string item, ingre, wantMake; while(cin >> n, n){ sum = 0; map <string,int> itemPrice; while(n--){ cin >> item >> price; itemPrice.insert(map<string,int>::value_type(item,price)); } cin >> m; while(m--){ sum = 0; cin >> item >> price; while(price--){ cin >> ingre; if(itemPrice.find(ingre)!=itemPrice.end()){ sum += itemPrice[ingre]; } } if(itemPrice[item]>sum){ itemPrice[item] = sum; } } cin >> wantMake; cout << itemPrice[wantMake] <<endl; } }
main.c:1:9: fatal error: iostream: No such file or directory 1 | #include<iostream> | ^~~~~~~~~~ compilation terminated.
s910496159
p00201
C
#include<iostream> #include<string> #include<map> using namespace std; int main(){ int n, price, m, sum; string item, ingre, wantMake; while(cin >> n, n){ sum = 0; map <string,int> itemPrice; while(n--){ cin >> item >> price; itemPrice.insert(map<string,int>::value_type(item,price)); } cin >> m; while(m--){ sum = 0; cin >> item >> price; while(price--){ cin >> ingre; if(itemPrice.find(ingre)!=itemPrice.end()){ sum += itemPrice[ingre]; } } if(itemPrice[item]>sum){ itemPrice[item] = sum; } } cin >> wantMake; cout << itemPrice[wantMake] <<endl; } }
main.c:1:9: fatal error: iostream: No such file or directory 1 | #include<iostream> | ^~~~~~~~~~ compilation terminated.
s559643733
p00201
C
#include<stdio.h> #include<string.h> #include<stdlib.h> typedef struct{ char name[128]; unsigned int minprice; short fr_oth; } item; typedef struct{ char to[128]; unsigned int num; char from[100][128]; } gosei; item list[100]; gosei makelist[100]; unsigned int m,n; unsigned int makeans(int var); int main(void){ unsigned int i,j,k,ans; char tmpstr[128]; unsigned int inputs; while(scanf("%u%*c",&n) &&n){ for(i=0;i<n;i++) scanf("%s %u%*c",list[i].name,&(list[i].minprice)); scanf("%u%*c",&m); for(i=0;i<m;i++){ scanf("%s %u%*c",tmpstr,&inputs); for(j=0;j<n;j++){ if(strcmp(list[j].name,tmpstr))continue; list[j].fr_oth=1; break; } strcpy(makelist[i].to,tmpstr); makelist[i].num=inputs; for(j=0;j<makelist[i].num;j++) scanf("%s%*c",makelist[i].from[j]); } scanf("%s%*c",tmpstr); for(i=0;i<n;i++){ if(strcmp(list[i].name,tmpstr)) continue; k=i; break; } ans=makeans(k); printf("%u\n",ans); } return 0; } unsigned int makeans(int var){ unsigned int i,j,k,tmp; if(list[var].fr_oth==1){ tmp=0; for(i=0;i<m;i++){ if(strcmp(makelist[i].to,list[var].name)) continue; k=i; break; } for(i=0;i<makelist[k].num;i++){ for(j=0;j<n;j++){ if(strcmp(makelist[k].from[i],list[j].name)) continue; break; } tmp+=makeans(j); } if(var->minprice>tmp) list[var].minprice=tmp; list[var].fr_oth=0; } return list[var].minprice; }
main.c: In function 'makeans': main.c:73:11: error: invalid type argument of '->' (have 'int') 73 | if(var->minprice>tmp) list[var].minprice=tmp; | ^~
s868023763
p00201
C++
#include <cstdlib> #include <iostream> #include <unordered_map> #include <vector> using namespace std; template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; } typedef vector<vector<int>> graph; void dfs(int v, const graph &G, vector<bool> &visited, vector<int> &order) { visited[v] = true; for(const auto &to : G[v]) { if(!visited[to]) dfs(to, G, visited, order); } order.emplace_back(v); } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); for(int n; cin >> n && n;) { unordered_map<string, int> encoder; vector<int> price(n); for(int i = 0; i < n; ++i) { string name; cin >> name >> price[i]; encoder[name] = i; } int m; cin >> m; graph G(n); for(int i = 0; i < m; ++i) { string target; int k; cin >> target >> k; const int to = encoder[target]; for(int j = 0; j < k; ++j) { string from; cin >> from; G[encoder[from]].emplace_back(to); } } vector<bool> visited(n, false); vector<int> order; for(int v = 0; v < n; ++v) { if(!visited[v]) dfs(v, G, visited, order); } vector<int> sum(n, INT_MAX); for(int i = n - 1; i >= 0; --i) { const int v = order[i]; chmin(sum[v], price[v]); for(const auto &to : G[v]) { if(sum[to] == INT_MAX) sum[to] = 0; sum[to] += sum[v]; } } string want; cin >> want; cout << sum[encoder[want]] << endl; } return EXIT_SUCCESS; }
a.cc: In function 'int main()': a.cc:56:36: error: 'INT_MAX' was not declared in this scope 56 | vector<int> sum(n, 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 | using namespace std;
s502044986
p00201
C++
#include<iostream> #include<algorithm> #include<map> #include<vector> #include<string> using namespace std; typedef struct{ vector<string> sozai; long long money; }BUTU; pair<string,logn long> P[1002]; BUTU butu[1024]; long long n,p,m,a,b; string s,ss,mokuhyou; long long tansaku(string now){ for(int i=0;i<n;i++){ if(P[i].first==now){ return P[i].second; } } return -1; } long long check(string now){ long long banti=tansaku(now); long long f=butu[banti].sozai.size(); long long cnt=0; if(f==0){ return butu[banti].money; } else{ for(int i=0;i<f;i++){ if(tansaku(butu[banti].sozai[i])!=-1){ cnt+=check(butu[banti].sozai[i]); } else{ return butu[banti].money; } } return min(cnt,butu[banti].money); } return -1; } main(){ while(1){ cin>>n; if(n==0)break; for(int i=0;i<n;i++){ cin>>s>>p; butu[i].money=p; P[i].first=s; P[i].second=i; } cin>>m; for(int i=0;i<m;i++){ cin>>s>>a; b=tansaku(s); for(int j=0;j<a;j++){ cin>>ss; butu[b].sozai.push_back(ss); } } cin>>mokuhyou; cout<<check(mokuhyou)<<endl; } }
a.cc:11:13: error: 'logn' was not declared in this scope; did you mean 'long'? 11 | pair<string,logn long> P[1002]; | ^~~~ | long a.cc:11:22: error: template argument 2 is invalid 11 | pair<string,logn long> P[1002]; | ^ a.cc: In function 'long long int tansaku(std::string)': a.cc:17:13: error: request for member 'first' in 'P[i]', which is of non-class type 'int' 17 | if(P[i].first==now){ | ^~~~~ a.cc:18:19: error: request for member 'second' in 'P[i]', which is of non-class type 'int' 18 | return P[i].second; | ^~~~~~ a.cc: At global scope: a.cc:43:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 43 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:50:12: error: request for member 'first' in 'P[i]', which is of non-class type 'int' 50 | P[i].first=s; | ^~~~~ a.cc:51:12: error: request for member 'second' in 'P[i]', which is of non-class type 'int' 51 | P[i].second=i; | ^~~~~~
s410733807
p00201
C++
#include<iostream> #include <stdio.h> #include <vector> #include<string> using namespace std; int ha(string); void saga(void); struct L{ string name; int cost; }; struct R{ string name; string zairyo[101]; int size; }; int q,m,n; L list[101]; R resipi[101]; int main() { int i,j,k,b=0,s,a; string S; while((cin>> n)!="EOF"){ q=n; for(i=0;i<n;i++){ cin >> list[i].name>> list[i].cost; } cin>>m; for(i=0;i<m;i++){ cin>>resipi[i].name>>b; resipi[i].size=b; for(j=0;j<b;j++){ cin>>resipi[i].zairyo[j]; } } cin>>S; /*for(i=0;i<n;i++){ cout <<list[i].name<< list[i].cost<<endl; } for(i=0;i<m;i++){ cout<<resipi[i].name; for(j=0;j<resipi[i].size;j++){ cout<<resipi[i].zairyo[j]; } cout<<endl; } */ cout<<ha(S)<<endl; } return 0; } int ha(string S) { int i,j,f=0,sum=0; for(i=0;i<m;i++){ //cout<<S<<endl<<resipi[i].name; if(S==resipi[i].name){ f=1; break; } } if(f==1){ for(j=0;j<resipi[i].size;j++){ sum=sum+ha(resipi[i].zairyo[j]); } //printf("%d\n",sum); for(i=0;i<n;i++){ if(S==list[i].name){ if(sum<list[i].cost){ return sum; } else return list[i].cost; } } } for(i=0;i<n;i++){ if(S==list[i].name){ return list[i].cost; } } }
a.cc: In function 'int main()': a.cc:26:24: error: no match for 'operator!=' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'const char [4]') 26 | while((cin>> n)!="EOF"){ | ~~~~~~~~~^~~~~~~ | | | | | const char [4] | std::basic_istream<char>::__istream_type {aka std::basic_istream<char>} In file included from /usr/include/c++/14/iosfwd:42, from /usr/include/c++/14/ios:40, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/postypes.h:197:5: note: candidate: 'template<class _StateT> bool std::operator!=(const fpos<_StateT>&, const fpos<_StateT>&)' 197 | operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/postypes.h:197:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::fpos<_StateT>' 26 | while((cin>> n)!="EOF"){ | ^~~~~ In file included from /usr/include/c++/14/string:43, 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: /usr/include/c++/14/bits/allocator.h:243:5: note: candidate: 'template<class _T1, class _T2> bool std::operator!=(const allocator<_CharT>&, const allocator<_T2>&)' 243 | operator!=(const allocator<_T1>&, const allocator<_T2>&) | ^~~~~~~~ /usr/include/c++/14/bits/allocator.h:243:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::allocator<_CharT>' 26 | while((cin>> n)!="EOF"){ | ^~~~~ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:455:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 455 | operator!=(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:455:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 26 | while((cin>> n)!="EOF"){ | ^~~~~ /usr/include/c++/14/bits/stl_iterator.h:500:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 500 | operator!=(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:500:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 26 | while((cin>> n)!="EOF"){ | ^~~~~ /usr/include/c++/14/bits/stl_iterator.h:1686:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1686 | operator!=(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1686:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 26 | while((cin>> n)!="EOF"){ | ^~~~~ /usr/include/c++/14/bits/stl_iterator.h:1753:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1753 | operator!=(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1753:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 26 | while((cin>> n)!="EOF"){ | ^~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51: /usr/include/c++/14/bits/stl_pair.h:1052:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator!=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1052 | operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1052:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::pair<_T1, _T2>' 26 | while((cin>> n)!="EOF"){ | ^~~~~ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:651:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 651 | operator!=(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:651:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 26 | while((cin>> n)!="EOF"){ | ^~~~~ /usr/include/c++/14/string_view:658:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 658 | operator!=(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:658:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 26 | while((cin>> n)!="EOF"){ | ^~~~~ /usr/include/c++/14/string_view:666:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 666 | operator!=(__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:666:5: note: template argument deduction/substitution failed: a.cc:26:26: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'const char*' 26 | while((cin>> n)!="EOF"){ | ^~~~~ /usr/include/c++/14/bits/basic_string.h:3833:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3833 | operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3833:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 26 | while((cin>> n)!="EOF"){ | ^~~~~ /usr/include/c++/14/bits/basic_string.h:3847:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3847 | operator!=(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3847:5: note: template argument deduction/substitution failed: a.cc:26:26: note: mismatched types 'const _CharT*' and 'std::basic_istream<char>' 26 | while((cin>> n)!="EOF"){ | ^~~~~ /usr/include/c++/14/bits/basic_string.h:3860:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3860 | operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3860:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 26 | while((cin>> n)!="EOF"){ | ^~~~~ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68: /usr/include/c++/14/tuple:2613:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator!=(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)' 2613 | operator!=(const tuple<_TElements...>& __t, | ^~~~~~~~ /usr/include/c++/14/tuple:2613:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::tuple<_UTypes ...>' 26 | while((cin>> n)!="EOF"){ | ^~~~~ In file included from /usr/include/c++/14/bits/locale_facets.h:48, from /usr/include/c++/14/bits/basic_ios.h:37, from /usr/include/c++/14/ios:46: /usr/include/c++/14/bits/streambuf_iterator.h:242:5: note: candidate: 'template<class _CharT, class _Traits> bool std::operator!=(const istreambuf_iterator<_CharT, _Traits>&, cons
s194458067
p00201
C++
#include<iostream> #include <stdio.h> #include <vector> #include<string> using namespace std; int ha(string); void saga(void); struct L{ string name; int cost; }; struct R{ string name; string zairyo[101]; int size; }; int q,m,n; L list[101]; R resipi[101]; int main() { int i,j,k,b=0,s,a; string S; while((cin>> n)!=EOF){ q=n; for(i=0;i<n;i++){ cin >> list[i].name>> list[i].cost; } cin>>m; for(i=0;i<m;i++){ cin>>resipi[i].name>>b; resipi[i].size=b; for(j=0;j<b;j++){ cin>>resipi[i].zairyo[j]; } } cin>>S; /*for(i=0;i<n;i++){ cout <<list[i].name<< list[i].cost<<endl; } for(i=0;i<m;i++){ cout<<resipi[i].name; for(j=0;j<resipi[i].size;j++){ cout<<resipi[i].zairyo[j]; } cout<<endl; } */ cout<<ha(S)<<endl; } return 0; } int ha(string S) { int i,j,f=0,sum=0; for(i=0;i<m;i++){ //cout<<S<<endl<<resipi[i].name; if(S==resipi[i].name){ f=1; break; } } if(f==1){ for(j=0;j<resipi[i].size;j++){ sum=sum+ha(resipi[i].zairyo[j]); } //printf("%d\n",sum); for(i=0;i<n;i++){ if(S==list[i].name){ if(sum<list[i].cost){ return sum; } else return list[i].cost; } } } for(i=0;i<n;i++){ if(S==list[i].name){ return list[i].cost; } } }
a.cc: In function 'int main()': a.cc:26:24: error: no match for 'operator!=' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'int') 26 | while((cin>> n)!=EOF){ | ~~~~~~~~~^~ | | | std::basic_istream<char>::__istream_type {aka std::basic_istream<char>} a.cc:26:24: note: candidate: 'operator!=(int, int)' (built-in) 26 | while((cin>> n)!=EOF){ | ^ a.cc:26:24: note: no known conversion for argument 1 from 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} to 'int' In file included from /usr/include/c++/14/iosfwd:42, from /usr/include/c++/14/ios:40, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/postypes.h:197:5: note: candidate: 'template<class _StateT> bool std::operator!=(const fpos<_StateT>&, const fpos<_StateT>&)' 197 | operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/postypes.h:197:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/14/cstdio:42, from /usr/include/c++/14/ext/string_conversions.h:45, from /usr/include/c++/14/bits/basic_string.h:4154, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::fpos<_StateT>' 26 | while((cin>> n)!=EOF){ | ^~~ In file included from /usr/include/c++/14/string:43: /usr/include/c++/14/bits/allocator.h:243:5: note: candidate: 'template<class _T1, class _T2> bool std::operator!=(const allocator<_CharT>&, const allocator<_T2>&)' 243 | operator!=(const allocator<_T1>&, const allocator<_T2>&) | ^~~~~~~~ /usr/include/c++/14/bits/allocator.h:243:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::allocator<_CharT>' 26 | while((cin>> n)!=EOF){ | ^~~ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:455:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 455 | operator!=(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:455:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 26 | while((cin>> n)!=EOF){ | ^~~ /usr/include/c++/14/bits/stl_iterator.h:500:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 500 | operator!=(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:500:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 26 | while((cin>> n)!=EOF){ | ^~~ /usr/include/c++/14/bits/stl_iterator.h:1686:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1686 | operator!=(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1686:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 26 | while((cin>> n)!=EOF){ | ^~~ /usr/include/c++/14/bits/stl_iterator.h:1753:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1753 | operator!=(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1753:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 26 | while((cin>> n)!=EOF){ | ^~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51: /usr/include/c++/14/bits/stl_pair.h:1052:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator!=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1052 | operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1052:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::pair<_T1, _T2>' 26 | while((cin>> n)!=EOF){ | ^~~ In file included from /usr/include/c++/14/bits/basic_string.h:47: /usr/include/c++/14/string_view:651:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 651 | operator!=(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:651:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 26 | while((cin>> n)!=EOF){ | ^~~ /usr/include/c++/14/string_view:658:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 658 | operator!=(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:658:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 26 | while((cin>> n)!=EOF){ | ^~~ /usr/include/c++/14/string_view:666:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 666 | operator!=(__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:666:5: note: template argument deduction/substitution failed: a.cc:26:26: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int' 26 | while((cin>> n)!=EOF){ | ^~~ /usr/include/c++/14/bits/basic_string.h:3833:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3833 | operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3833:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 26 | while((cin>> n)!=EOF){ | ^~~ /usr/include/c++/14/bits/basic_string.h:3847:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3847 | operator!=(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3847:5: note: template argument deduction/substitution failed: a.cc:26:26: note: mismatched types 'const _CharT*' and 'std::basic_istream<char>' 26 | while((cin>> n)!=EOF){ | ^~~ /usr/include/c++/14/bits/basic_string.h:3860:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3860 | operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3860:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 26 | while((cin>> n)!=EOF){ | ^~~ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68: /usr/include/c++/14/tuple:2613:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator!=(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)' 2613 | operator!=(const tuple<_TElements...>& __t, | ^~~~~~~~ /usr/include/c++/14/tuple:2613:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::tuple<_UTypes ...>' 26 | while((cin>> n)!=EOF){ | ^~~ In file included from /u
s386041494
p00201
C++
#include<iostream> #include <stdio.h> #include <vector> #include<string> using namespace std; int ha(string); void saga(void); struct L{ string name; int cost; }; struct R{ string name; string zairyo[101]; int size; }; int q,m,n; L list[101]; R resipi[101]; int main() { int i,j,k,b=0,s,a; string S; while((cin>> n)!=EOF){ q=n; for(i=0;i<n;i++){ cin >> list[i].name>> list[i].cost; } cin>>m; for(i=0;i<m;i++){ cin>>resipi[i].name>>b; resipi[i].size=b; for(j=0;j<b;j++){ cin>>resipi[i].zairyo[j]; } } cin>>S; /*for(i=0;i<n;i++){ cout <<list[i].name<< list[i].cost<<endl; } for(i=0;i<m;i++){ cout<<resipi[i].name; for(j=0;j<resipi[i].size;j++){ cout<<resipi[i].zairyo[j]; } cout<<endl; } */ cout<<ha(S)<<endl; } return 0; } int ha(string S) { int i,j,f=0,sum=0; for(i=0;i<m;i++){ //cout<<S<<endl<<resipi[i].name; if(S==resipi[i].name){ f=1; break; } } if(f==1){ for(j=0;j<resipi[i].size;j++){ sum=sum+ha(resipi[i].zairyo[j]); } //printf("%d\n",sum); for(i=0;i<n;i++){ if(S==list[i].name){ if(sum<list[i].cost){ return sum; } else return list[i].cost; } } } for(i=0;i<n;i++){ if(S==list[i].name){ return list[i].cost; } } }
a.cc: In function 'int main()': a.cc:26:24: error: no match for 'operator!=' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'int') 26 | while((cin>> n)!=EOF){ | ~~~~~~~~~^~ | | | std::basic_istream<char>::__istream_type {aka std::basic_istream<char>} a.cc:26:24: note: candidate: 'operator!=(int, int)' (built-in) 26 | while((cin>> n)!=EOF){ | ^ a.cc:26:24: note: no known conversion for argument 1 from 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} to 'int' In file included from /usr/include/c++/14/iosfwd:42, from /usr/include/c++/14/ios:40, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/postypes.h:197:5: note: candidate: 'template<class _StateT> bool std::operator!=(const fpos<_StateT>&, const fpos<_StateT>&)' 197 | operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/postypes.h:197:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/14/cstdio:42, from /usr/include/c++/14/ext/string_conversions.h:45, from /usr/include/c++/14/bits/basic_string.h:4154, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::fpos<_StateT>' 26 | while((cin>> n)!=EOF){ | ^~~ In file included from /usr/include/c++/14/string:43: /usr/include/c++/14/bits/allocator.h:243:5: note: candidate: 'template<class _T1, class _T2> bool std::operator!=(const allocator<_CharT>&, const allocator<_T2>&)' 243 | operator!=(const allocator<_T1>&, const allocator<_T2>&) | ^~~~~~~~ /usr/include/c++/14/bits/allocator.h:243:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::allocator<_CharT>' 26 | while((cin>> n)!=EOF){ | ^~~ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:455:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 455 | operator!=(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:455:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 26 | while((cin>> n)!=EOF){ | ^~~ /usr/include/c++/14/bits/stl_iterator.h:500:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 500 | operator!=(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:500:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 26 | while((cin>> n)!=EOF){ | ^~~ /usr/include/c++/14/bits/stl_iterator.h:1686:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1686 | operator!=(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1686:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 26 | while((cin>> n)!=EOF){ | ^~~ /usr/include/c++/14/bits/stl_iterator.h:1753:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1753 | operator!=(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1753:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 26 | while((cin>> n)!=EOF){ | ^~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51: /usr/include/c++/14/bits/stl_pair.h:1052:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator!=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1052 | operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1052:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::pair<_T1, _T2>' 26 | while((cin>> n)!=EOF){ | ^~~ In file included from /usr/include/c++/14/bits/basic_string.h:47: /usr/include/c++/14/string_view:651:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 651 | operator!=(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:651:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 26 | while((cin>> n)!=EOF){ | ^~~ /usr/include/c++/14/string_view:658:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 658 | operator!=(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:658:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 26 | while((cin>> n)!=EOF){ | ^~~ /usr/include/c++/14/string_view:666:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 666 | operator!=(__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:666:5: note: template argument deduction/substitution failed: a.cc:26:26: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int' 26 | while((cin>> n)!=EOF){ | ^~~ /usr/include/c++/14/bits/basic_string.h:3833:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3833 | operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3833:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 26 | while((cin>> n)!=EOF){ | ^~~ /usr/include/c++/14/bits/basic_string.h:3847:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3847 | operator!=(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3847:5: note: template argument deduction/substitution failed: a.cc:26:26: note: mismatched types 'const _CharT*' and 'std::basic_istream<char>' 26 | while((cin>> n)!=EOF){ | ^~~ /usr/include/c++/14/bits/basic_string.h:3860:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3860 | operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3860:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 26 | while((cin>> n)!=EOF){ | ^~~ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68: /usr/include/c++/14/tuple:2613:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator!=(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)' 2613 | operator!=(const tuple<_TElements...>& __t, | ^~~~~~~~ /usr/include/c++/14/tuple:2613:5: note: template argument deduction/substitution failed: a.cc:26:26: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::tuple<_UTypes ...>' 26 | while((cin>> n)!=EOF){ | ^~~ In file included from /u
s869526480
p00201
C++
#include<iostream> #include<string> #include<algorithm> #include<utility> #include<vector> using namespace std; typedef pair<string, int>P; int main() { int n; while (cin >> n, n) { vector<P>v; for (int i = 0;i < n;i++) { string sa, int a; cin >> sa >> a; v.push_back(P(sa, a)); } int m; cin >> m; for (int i = 0;i < m;i++) { string s; cin >> s; int a; cin >> a; int it=-1; int mny = 0; for (int j = 0;j < a;j++) { string sb; cin >> sb; for (int k = 0;k < n;k++) { if (sb == v[k].first) { mny += v[k].second; } } } for (int j = 0;j < v.size();j++) { if (s == v[j].first)it = j; } if (it == -1)v.push_back(P(s, mny)); else v[it].second = mny; } string ans; cin >> ans; for (int i = 0;i < v.size();i++) { if (ans == v[i].first) { cout << v[i].second << endl; break; } } } return 0; }
a.cc: In function 'int main()': a.cc:14:36: error: expected unqualified-id before 'int' 14 | string sa, int a; | ^~~ a.cc:15:38: error: 'a' was not declared in this scope; did you mean 'sa'? 15 | cin >> sa >> a; | ^ | sa
s740158474
p00201
C++
#include <iostream> #include <vector> #include <map> #include <string> #define REP(i,n) for(int i = (int)(n) - 1; i >= 0; --i) using namespace std; int costs[101]; vector<int> recipe[101]; bool flags[101]; int getCost(int goal){ if(recipe[goal].empty()) return costs[goal]; flags[goal] = true; int sum = 0; REP(i, recipe[goal].size()){ if(flags[recipe[goal][i]]){ flags[goal] = false; return costs[goal]; } sum += getCost(recipe[goal][i]); } flags[goal] = false; if(sum < costs[goal]){ return sum; }else{ return costs[goal]; } } int main(){ int n, m; while(true){ cin >> n; if(n==0)break; memset(flags, 0, sizeof(flags)); map<string,int> hash; REP(i,n){ string name; cin >> name >> costs[i]; hash.insert(map<string,int>::value_type(name,i)); recipe[i].clear(); } cin >> m; REP(i, m){ string name; int item; int num; cin >> name >> num; item = hash[name]; recipe[item].reserve(num); REP(j, num){ string mate; int mat; cin >> mate; mat = hash[mate]; recipe[item].push_back(mat); } } string goalName; int goal; cin >> goalName; goal = hash[goalName]; cout << getCost(goal) << endl; } return 0; }
a.cc: In function 'int main()': a.cc:39:17: error: 'memset' was not declared in this scope 39 | memset(flags, 0, sizeof(flags)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <map> +++ |+#include <cstring> 4 | #include <string>
s590292472
p00201
C++
#include <stdio.h> #include <queue> #include <string.h> using namespace std; typedef pair<int,int> P; //howmuch[i]:i番のアイテムの最小の値段 int howmuch[100]; //itemname[i]:i番目のアイテムの名前 char itemname[100][101]; //n:アイテムの種類 m:レシピの数 int n,m; //resipeuseditem[i][k]:iをつくるためにkを用いたかどうかの判定 bool resipeuseditem[100][100]; //resipeN[i]:iを作るために用いたアイテムの番号を保存する queue <int> resipeN[100]; //allminseek作業用キュー priority_queue< P,vector<P>,greater<P> > que; //アイテム名を番号に変換する関数 int nameTOnonber(char *); //最小値を求める void allminseek(); int main() { int k,i,j,oTOi,o2; char o[101]; scanf("%d",&n); while(n != 0){ //初期化 for(i = 0; i < 100; i++){ for(j = 0; j < 100; j++){ resipeuseditem[i][j] = false; } } //入力 for(i = 0;i < n; i++){ fflush(stdin); scanf("%s %d",itemname[i],&howmuch[i]); int a = nameTOnonber(itemname[i]); que.push(P(howmuch[i],a)); } scanf("%d",&m); for(i = 0;i < m; i++){ scanf("%s %d",o,&k); oTOi = nameTOnonber(o); //printf("k:%d\n",k); for(j = 0; j < k; j++){ scanf("%s",o); o2 = nameTOnonber(o); resipeN[oTOi].push(o2); resipeuseditem[oTOi][o2] = true; //printf("作るもの:%d 素材[%d]:%d\n",oTOi,j,o2); } //printf("size:%d\n",resipeN[oTOi].size()); } //探索 allminseek(); scanf("%s",o); printf("%d\n",howmuch[ nameTOnonber(o) ]); scanf("%d",&n); } return 0; } int nameTOnonber(char *name){ for(int i = 0; i < n; i++){ if(strcmp(itemname[i],name) == 0){ //printf("アイテム名:%s 配列番号:%d\n",name,i); return i; } } printf("nameTOnonber変換ミス\n"); return INT_MAX; } void allminseek(){ //アイテムiを使用したかどうかのフラグ bool used[100]; int temp,minNO; //printf("min:配列%d 値段%d",min.first,min.second); for(int i = 0; i < n; i++) used[i] = false; while(!que.empty()){ minNO = que.top().second; que.pop(); //printf("最小値段アイテム:%s\n",itemname[minNO]); if(!used[ minNO ]){ //minNOを使用しているレシピの探索と実行 for(int i = 0;i < n; i++){ //printf("[%d][%d]%d\n",i,minNO,resipeuseditem[i][minNO]); if(resipeuseditem[i][minNO]){ temp = 0; for(int j = 0; j < resipeN[i].size(); j++){ temp += howmuch[ resipeN[i].front() ]; //printf("材料:%d 値段:%d 合計:%d\n",resipeN[i].front(),howmuch[ resipeN[i].front() ],temp); resipeN[i].push(resipeN[i].front()); resipeN[i].pop(); } if(howmuch[i] > temp){ howmuch[i] = temp; que.push(P(temp,i)); } } } used[ minNO ] = true; } } }
a.cc: In function 'int nameTOnonber(char*)': a.cc:89:16: error: 'INT_MAX' was not declared in this scope 89 | return INT_MAX; | ^~~~~~~ a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 3 | #include <string.h> +++ |+#include <climits> 4 | using namespace std;
s776360357
p00201
C++
#include <iostream> #include <string> #include <map> #include <vector> using namespace std; int n, m; map<string, int> items; map<string, vector<string> > alc; map<string, int> memo; int minPrice(const string& t) { vector<string>& mats = alc[t]; if (!mats.size()) return items[t]; map<string, int>::iterator it = memo.find(t); if (it != memo.end()) return it->second; i nt ap = 0; for (unsigned i = 0; i < mats.size(); i++) { ap += minPrice(mats[i]); } return memo[t] = min(items[t], ap); } int main () { while (cin >> n, n) { for (int i = 0; i < n; i++) { string name; int value; cin >> name >> value; items[name] = value; } cin >> m; for (int i = 0; i < m; i++) { string name; int k; cin >> name >> k; vector<string> mats; for (int j = 0; j < k; j++) { string mat; cin >> mat; mats.push_back(mat); } alc[name] = mats; } string target; cin >> target; cout << minPrice(target) << endl; } return 0; }
a.cc: In function 'int minPrice(const std::string&)': a.cc:16:9: error: 'i' was not declared in this scope; did you mean 'it'? 16 | i nt ap = 0; | ^ | it a.cc:18:17: error: 'ap' was not declared in this scope 18 | ap += minPrice(mats[i]); | ^~ a.cc:20:40: error: 'ap' was not declared in this scope 20 | return memo[t] = min(items[t], ap); | ^~
s940909959
p00201
C++
#include <cstdio> #include <cstring> #include <cstdlib> #include <string> #include <sstream> #include <algorithm> #include <vector> #include <queue> #include <stack> #include <functional> #include <iostream> #include <map> #include <set> using namespace std; typedef pair<int,int> P; #define pu push #define pb push_back #define mp make_pair #define eps 1e-7 #define INF 2000000000 #define EQ(a,b) (abs((a)-(b))<EPS) int n,m; struct item { string name; int cost,size; vector<string> le; }; item lis[100]; int memo[100]; int mysearch(string s) { for(int i=0;i<n;i++) { if(lis[i].name==s)return i; } } int getcost(int v) { if(memo[v]!=-1)return memo[v]; else { if(lis[v].size==0)return lis[v].cost; else { int ans=0; for(int i=0;i<lis[v].size;i++) { ans+=getcost(mysearch(lis[v].le[i])); } memo[v]= min(ans,lis[v].cost); list[v].cost=memo[v]; return memo[v]; } } } int main() { while(1) { fill(memo,memo+100,-1); cin >> n; if(n==0)break; string s; int c; for(int i=0;i<n;i++) { cin >> s >> c; lis[i].name=s; lis[i].cost=c; lis[i].size=0; } cin >> m; for(int i=0;i<m;i++) { int t,k; cin >> s; cin >> t; for(int j=0;j<t;j++) { string st; cin >> st; k=mysearch(s); lis[k].le.pb(st); } lis[k].size=t; } string str; cin >> str; cout << getcost(mysearch(str))<< endl; } return 0; }
a.cc: In function 'int getcost(int)': a.cc:52:25: error: 'list' was not declared in this scope 52 | list[v].cost=memo[v]; | ^~~~ a.cc:14:1: note: 'std::list' is defined in header '<list>'; this is probably fixable by adding '#include <list>' 13 | #include <set> +++ |+#include <list> 14 | using namespace std; a.cc: In function 'int mysearch(std::string)': a.cc:37:1: warning: control reaches end of non-void function [-Wreturn-type] 37 | } | ^
s696654358
p00201
C++
#include <stdio.h> #include <string.h> #include <string> #include <vector> #include <algorithm> int n; struct item{ string name[256]; int cost; vector<string> used; int size; } ; item list[100]; int memo[100]; int getCost(int v) { if(memo[v]!=-1)return memo[v]; int i, j; int ans; if (list[v].size == 0){ return (list[v].cost); } else { ans = 0; for (i = 0; i < list[v].size; i++){ for (j = 0; j < n; j++){ if (list[v].used[i]== list[j].name){ ans += getCost(j); } } } list[v].cost = min(list[v].cost,ans); } return (list[vertex].cost); } int main(void) { int i, j, k; int m, kk; char key[256], temp[256]; int look, sum; while (1){ scanf("%d", &n); if (n == 0){ break; } for(i=0;i<n;i++)memo[i]=-1; for (i = 0; i < n; i++){ scanf("%s%d", list[i].name, &list[i].cost); list[i].size = 0; } scanf("%d", &m); for (i = 0; i < m; i++){ scanf("%s", key); for (j = 0; j < n; j++){ if (strcmp(key, list[j].name) == 0){ look = j; } } scanf("%d", &kk); list[look].size = kk; for (j = 0; j < kk; j++){ scanf("%s", temp); for (k = 0; k < n; k++){ if (strcmp(temp, list[k].name) == 0){ strcpy(list[look].used[j], temp); } } } } scanf("%s", key); for (j = 0; j < n; j++){ if (strcmp(key, list[j].name) == 0){ look = j; } } printf("%d\n", getCost(look)); } return (0); }
a.cc:9:5: error: 'string' does not name a type; did you mean 'stdin'? 9 | string name[256]; | ^~~~~~ | stdin a.cc:11:5: error: 'vector' does not name a type 11 | vector<string> used; | ^~~~~~ a.cc: In function 'int getCost(int)': a.cc:31:29: error: 'struct item' has no member named 'used' 31 | if (list[v].used[i]== list[j].name){ | ^~~~ a.cc:31:47: error: 'struct item' has no member named 'name' 31 | if (list[v].used[i]== list[j].name){ | ^~~~ a.cc:36:24: error: 'min' was not declared in this scope; did you mean 'std::min'? 36 | list[v].cost = min(list[v].cost,ans); | ^~~ | std::min In file included from /usr/include/c++/14/algorithm:61, from a.cc:5: /usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ a.cc:38:18: error: 'vertex' was not declared in this scope 38 | return (list[vertex].cost); | ^~~~~~ a.cc: In function 'int main()': a.cc:56:35: error: 'struct item' has no member named 'name' 56 | scanf("%s%d", list[i].name, &list[i].cost); | ^~~~ a.cc:64:41: error: 'struct item' has no member named 'name' 64 | if (strcmp(key, list[j].name) == 0){ | ^~~~ a.cc:73:46: error: 'struct item' has no member named 'name' 73 | if (strcmp(temp, list[k].name) == 0){ | ^~~~ a.cc:74:43: error: 'struct item' has no member named 'used' 74 | strcpy(list[look].used[j], temp); | ^~~~ a.cc:81:37: error: 'struct item' has no member named 'name' 81 | if (strcmp(key, list[j].name) == 0){ | ^~~~
s183267143
p00201
C++
#include <cstdio> #include <algorithm> #include <string> #include <vector> #include <algorithm> int n; struct item{ string name[256]; int cost; vector<string> used; int size; } ; item list[100]; int memo[100]; int getCost(int v) { if(memo[v]!=-1)return memo[v]; int i, j; int ans; if (list[v].size == 0){ return (list[v].cost); } else { ans = 0; for (i = 0; i < list[v].size; i++){ for (j = 0; j < n; j++){ if (list[v].used[i]== list[j].name){ ans += getCost(j); } } } list[v].cost = min(list[v].cost,ans); } return (list[vertex].cost); } int main(void) { int i, j, k; int m, kk; string key, temp; int look, sum; while (1){ scanf("%d", &n); if (n == 0){ break; } for(i=0;i<n;i++)memo[i]=-1; for (i = 0; i < n; i++){ cin >> list[i].name >> list[i].cost; list[i].size = 0; } cin >> m; for (i = 0; i < m; i++){ cin >> key; for (j = 0; j < n; j++){ if (key==list[j].name){ look = j; } } cin >> kk; list[look].size = kk; for (j = 0; j < kk; j++){ cin >> temp; for (k = 0; k < n; k++){ if (temp==list[k].name){ list[look].used[j]=temp; } } } } cin >> key; for (j = 0; j < n; j++){ if (strcmp(key, list[j].name) == 0){ look = j; } } cout << getCost(look); } return (0); }
a.cc:9:5: error: 'string' does not name a type; did you mean 'stdin'? 9 | string name[256]; | ^~~~~~ | stdin a.cc:11:5: error: 'vector' does not name a type 11 | vector<string> used; | ^~~~~~ a.cc: In function 'int getCost(int)': a.cc:31:29: error: 'struct item' has no member named 'used' 31 | if (list[v].used[i]== list[j].name){ | ^~~~ a.cc:31:47: error: 'struct item' has no member named 'name' 31 | if (list[v].used[i]== list[j].name){ | ^~~~ a.cc:36:24: error: 'min' was not declared in this scope; did you mean 'std::min'? 36 | list[v].cost = min(list[v].cost,ans); | ^~~ | std::min In file included from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ a.cc:38:18: error: 'vertex' was not declared in this scope 38 | return (list[vertex].cost); | ^~~~~~ a.cc: In function 'int main()': a.cc:45:5: error: 'string' was not declared in this scope 45 | string key, temp; | ^~~~~~ a.cc:45:5: note: suggested alternatives: In file included from /usr/include/c++/14/string:41, from a.cc:3: /usr/include/c++/14/bits/stringfwd.h:77:33: note: 'std::string' 77 | typedef basic_string<char> string; | ^~~~~~ /usr/include/c++/14/string:76:11: note: 'std::pmr::string' 76 | using string = basic_string<char>; | ^~~~~~ a.cc:56:13: error: 'cin' was not declared in this scope 56 | cin >> list[i].name >> list[i].cost; | ^~~ a.cc:56:28: error: 'struct item' has no member named 'name' 56 | cin >> list[i].name >> list[i].cost; | ^~~~ a.cc:60:9: error: 'cin' was not declared in this scope 60 | cin >> m; | ^~~ a.cc:62:20: error: 'key' was not declared in this scope 62 | cin >> key; | ^~~ a.cc:64:34: error: 'struct item' has no member named 'name' 64 | if (key==list[j].name){ | ^~~~ a.cc:71:24: error: 'temp' was not declared in this scope; did you mean 'tm'? 71 | cin >> temp; | ^~~~ | tm a.cc:73:39: error: 'struct item' has no member named 'name' 73 | if (temp==list[k].name){ | ^~~~ a.cc:74:36: error: 'struct item' has no member named 'used' 74 | list[look].used[j]=temp; | ^~~~ a.cc:79:16: error: 'key' was not declared in this scope 79 | cin >> key; | ^~~ a.cc:81:37: error: 'struct item' has no member named 'name' 81 | if (strcmp(key, list[j].name) == 0){ | ^~~~ a.cc:81:17: error: 'strcmp' was not declared in this scope 81 | if (strcmp(key, list[j].name) == 0){ | ^~~~~~ a.cc:5:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 4 | #include <vector> +++ |+#include <cstring> 5 | #include <algorithm> a.cc:86:9: error: 'cout' was not declared in this scope 86 | cout << getCost(look); | ^~~~
s489385454
p00201
C++
#include <cstdio> #include <algorithm> #include <string> #include <vector> #include <algorithm> int n; struct item{ string name; int cost; vector<string> used; int size; } ; item list[100]; int memo[100]; int getCost(int v) { if(memo[v]!=-1)return memo[v]; int i, j; int ans; if (list[v].size == 0){ return (list[v].cost); } else { ans = 0; for (i = 0; i < list[v].size; i++){ for (j = 0; j < n; j++){ if (list[v].used[i]== list[j].name){ ans += getCost(j); } } } list[v].cost = min(list[v].cost,ans); } return (list[vertex].cost); } int main(void) { int i, j, k; int m, kk; string key, temp; int look, sum; while (1){ scanf("%d", &n); if (n == 0){ break; } for(i=0;i<n;i++)memo[i]=-1; for (i = 0; i < n; i++){ cin >> list[i].name >> list[i].cost; list[i].size = 0; } cin >> m; for (i = 0; i < m; i++){ cin >> key; for (j = 0; j < n; j++){ if (key==list[j].name){ look = j; } } cin >> kk; list[look].size = kk; for (j = 0; j < kk; j++){ cin >> temp; for (k = 0; k < n; k++){ if (temp==list[k].name){ list[look].used[j]=temp; } } } } cin >> key; for (j = 0; j < n; j++){ if (strcmp(key, list[j].name) == 0){ look = j; } } cout << getCost(look); } return (0); }
a.cc:9:5: error: 'string' does not name a type; did you mean 'stdin'? 9 | string name; | ^~~~~~ | stdin a.cc:11:5: error: 'vector' does not name a type 11 | vector<string> used; | ^~~~~~ a.cc: In function 'int getCost(int)': a.cc:31:29: error: 'struct item' has no member named 'used' 31 | if (list[v].used[i]== list[j].name){ | ^~~~ a.cc:31:47: error: 'struct item' has no member named 'name' 31 | if (list[v].used[i]== list[j].name){ | ^~~~ a.cc:36:24: error: 'min' was not declared in this scope; did you mean 'std::min'? 36 | list[v].cost = min(list[v].cost,ans); | ^~~ | std::min In file included from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ a.cc:38:18: error: 'vertex' was not declared in this scope 38 | return (list[vertex].cost); | ^~~~~~ a.cc: In function 'int main()': a.cc:45:5: error: 'string' was not declared in this scope 45 | string key, temp; | ^~~~~~ a.cc:45:5: note: suggested alternatives: In file included from /usr/include/c++/14/string:41, from a.cc:3: /usr/include/c++/14/bits/stringfwd.h:77:33: note: 'std::string' 77 | typedef basic_string<char> string; | ^~~~~~ /usr/include/c++/14/string:76:11: note: 'std::pmr::string' 76 | using string = basic_string<char>; | ^~~~~~ a.cc:56:13: error: 'cin' was not declared in this scope 56 | cin >> list[i].name >> list[i].cost; | ^~~ a.cc:56:28: error: 'struct item' has no member named 'name' 56 | cin >> list[i].name >> list[i].cost; | ^~~~ a.cc:60:9: error: 'cin' was not declared in this scope 60 | cin >> m; | ^~~ a.cc:62:20: error: 'key' was not declared in this scope 62 | cin >> key; | ^~~ a.cc:64:34: error: 'struct item' has no member named 'name' 64 | if (key==list[j].name){ | ^~~~ a.cc:71:24: error: 'temp' was not declared in this scope; did you mean 'tm'? 71 | cin >> temp; | ^~~~ | tm a.cc:73:39: error: 'struct item' has no member named 'name' 73 | if (temp==list[k].name){ | ^~~~ a.cc:74:36: error: 'struct item' has no member named 'used' 74 | list[look].used[j]=temp; | ^~~~ a.cc:79:16: error: 'key' was not declared in this scope 79 | cin >> key; | ^~~ a.cc:81:37: error: 'struct item' has no member named 'name' 81 | if (strcmp(key, list[j].name) == 0){ | ^~~~ a.cc:81:17: error: 'strcmp' was not declared in this scope 81 | if (strcmp(key, list[j].name) == 0){ | ^~~~~~ a.cc:5:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 4 | #include <vector> +++ |+#include <cstring> 5 | #include <algorithm> a.cc:86:9: error: 'cout' was not declared in this scope 86 | cout << getCost(look); | ^~~~
s743332618
p00201
C++
#include <cstdio> #include <algorithm> #include <string> #include <vector> #include <algorithm> int n; struct item{ string name; int cost; vector<string> used; int size; } ; item list[100]; int memo[100]; int getCost(int v) { if(memo[v]!=-1)return memo[v]; int i, j; int ans; if (list[v].size == 0){ return (list[v].cost); } else { ans = 0; for (i = 0; i < list[v].size; i++){ for (j = 0; j < n; j++){ if (list[v].used[i]== list[j].name){ ans += getCost(j); } } } list[v].cost = min(list[v].cost,ans); } return (list[v].cost); } int main(void) { int i, j, k; int m, kk; string key, temp; int look, sum; while (1){ scanf("%d", &n); if (n == 0){ break; } for(i=0;i<n;i++)memo[i]=-1; for (i = 0; i < n; i++){ cin >> list[i].name >> list[i].cost; list[i].size = 0; } cin >> m; for (i = 0; i < m; i++){ cin >> key; for (j = 0; j < n; j++){ if (key==list[j].name){ look = j; } } cin >> kk; list[look].size = kk; for (j = 0; j < kk; j++){ cin >> temp; for (k = 0; k < n; k++){ if (temp==list[k].name){ list[look].used[j]=temp; } } } } cin >> key; for (j = 0; j < n; j++){ if (strcmp(key, list[j].name) == 0){ look = j; } } cout << getCost(look); } return (0); }
a.cc:9:5: error: 'string' does not name a type; did you mean 'stdin'? 9 | string name; | ^~~~~~ | stdin a.cc:11:5: error: 'vector' does not name a type 11 | vector<string> used; | ^~~~~~ a.cc: In function 'int getCost(int)': a.cc:31:29: error: 'struct item' has no member named 'used' 31 | if (list[v].used[i]== list[j].name){ | ^~~~ a.cc:31:47: error: 'struct item' has no member named 'name' 31 | if (list[v].used[i]== list[j].name){ | ^~~~ a.cc:36:24: error: 'min' was not declared in this scope; did you mean 'std::min'? 36 | list[v].cost = min(list[v].cost,ans); | ^~~ | std::min In file included from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ a.cc: In function 'int main()': a.cc:45:5: error: 'string' was not declared in this scope 45 | string key, temp; | ^~~~~~ a.cc:45:5: note: suggested alternatives: In file included from /usr/include/c++/14/string:41, from a.cc:3: /usr/include/c++/14/bits/stringfwd.h:77:33: note: 'std::string' 77 | typedef basic_string<char> string; | ^~~~~~ /usr/include/c++/14/string:76:11: note: 'std::pmr::string' 76 | using string = basic_string<char>; | ^~~~~~ a.cc:56:13: error: 'cin' was not declared in this scope 56 | cin >> list[i].name >> list[i].cost; | ^~~ a.cc:56:28: error: 'struct item' has no member named 'name' 56 | cin >> list[i].name >> list[i].cost; | ^~~~ a.cc:60:9: error: 'cin' was not declared in this scope 60 | cin >> m; | ^~~ a.cc:62:20: error: 'key' was not declared in this scope 62 | cin >> key; | ^~~ a.cc:64:34: error: 'struct item' has no member named 'name' 64 | if (key==list[j].name){ | ^~~~ a.cc:71:24: error: 'temp' was not declared in this scope; did you mean 'tm'? 71 | cin >> temp; | ^~~~ | tm a.cc:73:39: error: 'struct item' has no member named 'name' 73 | if (temp==list[k].name){ | ^~~~ a.cc:74:36: error: 'struct item' has no member named 'used' 74 | list[look].used[j]=temp; | ^~~~ a.cc:79:16: error: 'key' was not declared in this scope 79 | cin >> key; | ^~~ a.cc:81:37: error: 'struct item' has no member named 'name' 81 | if (strcmp(key, list[j].name) == 0){ | ^~~~ a.cc:81:17: error: 'strcmp' was not declared in this scope 81 | if (strcmp(key, list[j].name) == 0){ | ^~~~~~ a.cc:5:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 4 | #include <vector> +++ |+#include <cstring> 5 | #include <algorithm> a.cc:86:9: error: 'cout' was not declared in this scope 86 | cout << getCost(look); | ^~~~
s681204851
p00201
C++
#include <cstdio> #include <algorithm> #include <string> #include <vector> #include <algorithm> int n; struct item{ string name; int cost; vector<string> used; int size; } ; item list[100]; int memo[100]; int getCost(int v) { if(memo[v]!=-1)return memo[v]; int i, j; int ans; if (list[v].size == 0){ return (list[v].cost); } else { ans = 0; for (i = 0; i < list[v].size; i++){ for (j = 0; j < n; j++){ if (list[v].used[i]== list[j].name){ ans += getCost(j); } } } list[v].cost = min(list[v].cost,ans); } return (list[v].cost); } int main(void) { int i, j, k; int m, kk; string key, temp; int look, sum; while (1){ scanf("%d", &n); if (n == 0){ break; } for(i=0;i<n;i++)memo[i]=-1; for (i = 0; i < n; i++){ cin >> list[i].name >> list[i].cost; list[i].size = 0; } cin >> m; for (i = 0; i < m; i++){ cin >> key; for (j = 0; j < n; j++){ if (key==list[j].name){ look = j; } } cin >> kk; list[look].size = kk; for (j = 0; j < kk; j++){ cin >> temp; for (k = 0; k < n; k++){ if (temp==list[k].name){ list[look].used[j]=temp; } } } } cin >> key; for (j = 0; j < n; j++){ if (strcmp(key, list[j].name) == 0){ look = j; } } cout << getCost(look); } return (0); }
a.cc:9:5: error: 'string' does not name a type; did you mean 'stdin'? 9 | string name; | ^~~~~~ | stdin a.cc:11:5: error: 'vector' does not name a type 11 | vector<string> used; | ^~~~~~ a.cc: In function 'int getCost(int)': a.cc:31:29: error: 'struct item' has no member named 'used' 31 | if (list[v].used[i]== list[j].name){ | ^~~~ a.cc:31:47: error: 'struct item' has no member named 'name' 31 | if (list[v].used[i]== list[j].name){ | ^~~~ a.cc:36:24: error: 'min' was not declared in this scope; did you mean 'std::min'? 36 | list[v].cost = min(list[v].cost,ans); | ^~~ | std::min In file included from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ a.cc: In function 'int main()': a.cc:45:5: error: 'string' was not declared in this scope 45 | string key, temp; | ^~~~~~ a.cc:45:5: note: suggested alternatives: In file included from /usr/include/c++/14/string:41, from a.cc:3: /usr/include/c++/14/bits/stringfwd.h:77:33: note: 'std::string' 77 | typedef basic_string<char> string; | ^~~~~~ /usr/include/c++/14/string:76:11: note: 'std::pmr::string' 76 | using string = basic_string<char>; | ^~~~~~ a.cc:56:13: error: 'cin' was not declared in this scope 56 | cin >> list[i].name >> list[i].cost; | ^~~ a.cc:56:28: error: 'struct item' has no member named 'name' 56 | cin >> list[i].name >> list[i].cost; | ^~~~ a.cc:60:9: error: 'cin' was not declared in this scope 60 | cin >> m; | ^~~ a.cc:62:20: error: 'key' was not declared in this scope 62 | cin >> key; | ^~~ a.cc:64:34: error: 'struct item' has no member named 'name' 64 | if (key==list[j].name){ | ^~~~ a.cc:71:24: error: 'temp' was not declared in this scope; did you mean 'tm'? 71 | cin >> temp; | ^~~~ | tm a.cc:73:39: error: 'struct item' has no member named 'name' 73 | if (temp==list[k].name){ | ^~~~ a.cc:74:36: error: 'struct item' has no member named 'used' 74 | list[look].used[j]=temp; | ^~~~ a.cc:79:16: error: 'key' was not declared in this scope 79 | cin >> key; | ^~~ a.cc:81:37: error: 'struct item' has no member named 'name' 81 | if (strcmp(key, list[j].name) == 0){ | ^~~~ a.cc:81:17: error: 'strcmp' was not declared in this scope 81 | if (strcmp(key, list[j].name) == 0){ | ^~~~~~ a.cc:5:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 4 | #include <vector> +++ |+#include <cstring> 5 | #include <algorithm> a.cc:86:9: error: 'cout' was not declared in this scope 86 | cout << getCost(look); | ^~~~
s954798374
p00201
C++
#include <cstdio> #include <algorithm> #include <string> #include <vector> #include <algorithm> using nameapace::std; int n; struct item{ string name; int cost; vector<string> used; int size; } ; item list[100]; int memo[100]; int getCost(int v) { if(memo[v]!=-1)return memo[v]; int i, j; int ans; if (list[v].size == 0){ return (list[v].cost); } else { ans = 0; for (i = 0; i < list[v].size; i++){ for (j = 0; j < n; j++){ if (list[v].used[i]== list[j].name){ ans += getCost(j); } } } list[v].cost = min(list[v].cost,ans); } return (list[v].cost); } int main(void) { int i, j, k; int m, kk; string key, temp; int look, sum; while (1){ scanf("%d", &n); if (n == 0){ break; } for(i=0;i<n;i++)memo[i]=-1; for (i = 0; i < n; i++){ cin >> list[i].name >> list[i].cost; list[i].size = 0; } cin >> m; for (i = 0; i < m; i++){ cin >> key; for (j = 0; j < n; j++){ if (key==list[j].name){ look = j; } } cin >> kk; list[look].size = kk; for (j = 0; j < kk; j++){ cin >> temp; for (k = 0; k < n; k++){ if (temp==list[k].name){ list[look].used[j]=temp; } } } } cin >> key; for (j = 0; j < n; j++){ if (strcmp(key, list[j].name) == 0){ look = j; } } cout << getCost(look); } return (0); }
a.cc:6:7: error: 'nameapace' has not been declared 6 | using nameapace::std; | ^~~~~~~~~ a.cc:10:5: error: 'string' does not name a type; did you mean 'stdin'? 10 | string name; | ^~~~~~ | stdin a.cc:12:5: error: 'vector' does not name a type 12 | vector<string> used; | ^~~~~~ a.cc: In function 'int getCost(int)': a.cc:32:29: error: 'struct item' has no member named 'used' 32 | if (list[v].used[i]== list[j].name){ | ^~~~ a.cc:32:47: error: 'struct item' has no member named 'name' 32 | if (list[v].used[i]== list[j].name){ | ^~~~ a.cc:37:24: error: 'min' was not declared in this scope; did you mean 'std::min'? 37 | list[v].cost = min(list[v].cost,ans); | ^~~ | std::min In file included from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ a.cc: In function 'int main()': a.cc:46:5: error: 'string' was not declared in this scope 46 | string key, temp; | ^~~~~~ a.cc:46:5: note: suggested alternatives: In file included from /usr/include/c++/14/string:41, from a.cc:3: /usr/include/c++/14/bits/stringfwd.h:77:33: note: 'std::string' 77 | typedef basic_string<char> string; | ^~~~~~ /usr/include/c++/14/string:76:11: note: 'std::pmr::string' 76 | using string = basic_string<char>; | ^~~~~~ a.cc:57:13: error: 'cin' was not declared in this scope 57 | cin >> list[i].name >> list[i].cost; | ^~~ a.cc:57:28: error: 'struct item' has no member named 'name' 57 | cin >> list[i].name >> list[i].cost; | ^~~~ a.cc:61:9: error: 'cin' was not declared in this scope 61 | cin >> m; | ^~~ a.cc:63:20: error: 'key' was not declared in this scope 63 | cin >> key; | ^~~ a.cc:65:34: error: 'struct item' has no member named 'name' 65 | if (key==list[j].name){ | ^~~~ a.cc:72:24: error: 'temp' was not declared in this scope; did you mean 'tm'? 72 | cin >> temp; | ^~~~ | tm a.cc:74:39: error: 'struct item' has no member named 'name' 74 | if (temp==list[k].name){ | ^~~~ a.cc:75:36: error: 'struct item' has no member named 'used' 75 | list[look].used[j]=temp; | ^~~~ a.cc:80:16: error: 'key' was not declared in this scope 80 | cin >> key; | ^~~ a.cc:82:37: error: 'struct item' has no member named 'name' 82 | if (strcmp(key, list[j].name) == 0){ | ^~~~ a.cc:82:17: error: 'strcmp' was not declared in this scope 82 | if (strcmp(key, list[j].name) == 0){ | ^~~~~~ a.cc:5:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 4 | #include <vector> +++ |+#include <cstring> 5 | #include <algorithm> a.cc:87:9: error: 'cout' was not declared in this scope 87 | cout << getCost(look); | ^~~~
s081751877
p00201
C++
#include <cstdio> #include <algorithm> #include <string> #include <vector> #include <algorithm> using namespace::std; int n; struct item{ string name; int cost; vector<string> used; int size; } ; item list[100]; int memo[100]; int getCost(int v) { if(memo[v]!=-1)return memo[v]; int i, j; int ans; if (list[v].size == 0){ return (list[v].cost); } else { ans = 0; for (i = 0; i < list[v].size; i++){ for (j = 0; j < n; j++){ if (list[v].used[i]== list[j].name){ ans += getCost(j); } } } list[v].cost = min(list[v].cost,ans); } return (list[v].cost); } int main(void) { int i, j, k; int m, kk; string key, temp; int look, sum; while (1){ scanf("%d", &n); if (n == 0){ break; } for(i=0;i<n;i++)memo[i]=-1; for (i = 0; i < n; i++){ cin >> list[i].name >> list[i].cost; list[i].size = 0; } cin >> m; for (i = 0; i < m; i++){ cin >> key; for (j = 0; j < n; j++){ if (key==list[j].name){ look = j; } } cin >> kk; list[look].size = kk; for (j = 0; j < kk; j++){ cin >> temp; for (k = 0; k < n; k++){ if (temp==list[k].name){ list[look].used[j]=temp; } } } } cin >> key; for (j = 0; j < n; j++){ if (strcmp(key, list[j].name) == 0){ look = j; } } cout << getCost(look); } return (0); }
a.cc: In function 'int main()': a.cc:57:13: error: 'cin' was not declared in this scope 57 | cin >> list[i].name >> list[i].cost; | ^~~ a.cc:5:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 4 | #include <vector> +++ |+#include <iostream> 5 | #include <algorithm> a.cc:61:9: error: 'cin' was not declared in this scope 61 | cin >> m; | ^~~ a.cc:61:9: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:82:17: error: 'strcmp' was not declared in this scope 82 | if (strcmp(key, list[j].name) == 0){ | ^~~~~~ a.cc:5:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 4 | #include <vector> +++ |+#include <cstring> 5 | #include <algorithm> a.cc:87:9: error: 'cout' was not declared in this scope 87 | cout << getCost(look); | ^~~~ a.cc:87:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
s983273773
p00202
Java
public class Main { public static void main(String[] args) throws IOException { new Main().run(); } private void run() throws IOException { Scanner scanner = new Scanner(System.in); int MAX = 1000000; boolean[] prime = new boolean[MAX + 1]; for (int i = 2; i <= MAX; i++) { if (!prime[i]) { for (int j = i * 2; j <= MAX; j += i) { prime[j] = true; } } } while (true) { int n = scanner.nextInt(); int m = scanner.nextInt(); if ((n | m) == 0) break; int[] a = new int[n]; int min = Integer.MAX_VALUE; boolean[] f = new boolean[m + 1]; f[0] = true; for (int i = 0; i < n; i++) { int s = scanner.nextInt(); min = Math.min(s, min); a[i] = s; for (int j = s * 2; j <= m; j += s) { f[j] = true; } } int max = 0; for (int i = min; i <= m; i++) { if (f[i]) continue; for (int j = 0; j < n; j++) { if (i - a[j] >= 0 && f[i - a[j]]) { f[i] = true; break; } } if (f[i] && !prime[i]) max = i; } System.out.println(max == 0 ? "NA" : max); } } }
Main.java:4: error: cannot find symbol public static void main(String[] args) throws IOException { ^ symbol: class IOException location: class Main Main.java:8: error: cannot find symbol private void run() throws IOException { ^ symbol: class IOException location: class Main Main.java:9: error: cannot find symbol Scanner scanner = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:9: error: cannot find symbol Scanner scanner = new Scanner(System.in); ^ symbol: class Scanner location: class Main 4 errors
s149735625
p00202
Java
import java.util.Arrays; import java.util.Scanner; public class A0202 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int prime[] = new int[1000010]; Arrays.fill(prime, 1); prime[0] = 0; prime[1] = 0; for (int i = 2; i < 1000010; i++) { for (int j = i * 2; j < 1000010; j += i) { prime[j] = 0; } } while (true) { int n = sc.nextInt(); int cost = sc.nextInt(); if ((n | cost) == 0) { break; } int price[] = new int[n]; int array[] = new int[cost + 1]; for (int i = 0; i < n; i++) { price[i] = sc.nextInt(); array[price[i]] = 1; } int id = 0; while (id < cost + 1) { while (id < cost + 1 && array[id] == 0) { id++; } if (cost + 1 <= id) { break; } for (int i = 0; i < n; i++) { if (id + price[i] < cost + 1) { array[id + price[i]] = 1; } } id++; } boolean flag = false; for (int i = cost; 0 <= i; i--) { if (array[i] == 1 && prime[i] == 1) { System.out.println(i); flag = true; } if (flag) { break; } } if (!flag) { System.out.println("NA"); } } } }
Main.java:4: error: class A0202 is public, should be declared in a file named A0202.java public class A0202 { ^ 1 error
s899131232
p00202
Java
import java.util.Scanner; public class AtBossExpense { public static void main(String[] args) { Scanner sc = new Scanner(System.in); //素数のメモ作成 int size = 1000001; boolean[] prime = new boolean[size]; for(int i=2; i<size; i++){ prime[i] = true; } for(int i=2; i*i<size; i++){ if(prime[i]){ for(int j=i*i; j<size; j+=i){ prime[j] = false; } } } while(true){ int set = sc.nextInt();//料理の種類 limit = sc.nextInt();//予算上限 if((set | limit)==0) break; int[] food = new int[set];//料理の値段 for(int i=0; i<set; i++){ food[i] = sc.nextInt(); } //公約数チェック int yaku = food[0]; for(int i=1; i<set; i++){ yaku = ch(food[i], yaku); if(yaku==1){ break; } }//2以上の公約数を持つ場合、素数を作れない if(yaku>1){ System.out.println("NA"); continue; } //組み合わせで選ぶことのできる価格をtrue memo = new boolean[limit+1]; memo[0] = true; for(int i=0; i<set; i++){ fx(food[i]); } //素数の最大金額を選択 int ans =0; for(int i=limit; 0<i; i--){ if(prime[i] && memo[i]){ ans = i; break; } } System.out.println((ans>0)?ans:"NA"); } } static int limit; static boolean[] memo; //公約数を求める式 static int ch(int x, int y){ x %= y; if(x>0) return ch(y,x); else return y; } //料理の組み合わせで選べる金額をtrue static void fx(int x){ for(int j=0; j+x<=limit; j++){ if(memo[j]==true){ memo[j+x] = true; } } } }
Main.java:3: error: class AtBossExpense is public, should be declared in a file named AtBossExpense.java public class AtBossExpense { ^ 1 error
s743112185
p00202
Java
import java.util.Scanner; public static void main(String[] args) { Scanner sc = new Scanner(System.in); //素数のメモ作成 int size = 1000001; boolean[] prime = new boolean[size]; for(int i=2; i<size; i++){ prime[i] = true; } for(int i=2; i*i<size; i++){ if(prime[i]){ for(int j=i*i; j<size; j+=i){ prime[j] = false; } } } while(true){ int set = sc.nextInt();//料理の種類 limit = sc.nextInt();//予算上限 if((set | limit)==0) break; int[] food = new int[set];//料理の値段 for(int i=0; i<set; i++){ food[i] = sc.nextInt(); } //公約数チェック int yaku = food[0]; for(int i=1; i<set; i++){ yaku = ch(food[i], yaku); if(yaku==1){ break; } }//2以上の公約数を持つ場合、素数を作れない if(yaku>1){ System.out.println("NA"); continue; } //組み合わせで選ぶことのできる価格をtrue memo = new boolean[limit+1]; memo[0] = true; for(int i=0; i<set; i++){ fx(food[i]); } //素数の最大金額を選択 int ans =0; for(int i=limit; 0<i; i--){ if(prime[i] && memo[i]){ ans = i; break; } } System.out.println((ans>0)?ans:"NA"); } } static int limit; static boolean[] memo; //公約数を求める式 static int ch(int x, int y){ x %= y; if(x>0) return ch(y,x); else return y; } //料理の組み合わせで選べる金額をtrue static void fx(int x){ for(int j=0; j+x<=limit; j++){ if(memo[j]==true){ memo[j+x] = true; } } }
Main.java:3: error: unnamed classes are a preview feature and are disabled by default. public static void main(String[] args) { ^ (use --enable-preview to enable unnamed classes) 1 error
s796972915
p00202
C
#include <stdio.h> #include <math.h> #include <string.h> ?? int is_prime(int a) { ????????int last = sqrt(a) + 1; ????????int i; ?? ????????for (i = 2; i <= last; i++){ ????????????????if (a % i == 0){ ????????????????????????if (a == i) return (1); ????????????????????????return (0); ????????????????} ????????} ????????return (1); } ?? int main(void) { ????????static char dp[10000001]; ????????int n, x; ????????int i, j; ?? ????????while (scanf("%d %d", &n, &x), n){ ????????????????memset(dp, 0, sizeof(dp)); ????????????????*dp = 1; ????????????????for (i = 0; i < n; i++){ ????????????????????????int cost; ????????????????????????scanf("%d", &cost); ?? ????????????????????????for (j = 0; j + cost <= x; j++){ ????????????????????????????????if (dp[j]) dp[j + cost] = 1; ????????????????????????} ????????????????} ????????????????for (i = x; i > 0; i--){ ????????????????????????if (dp[i] && is_prime(i)){ ????????????????????????????????printf("%d\n", i); ????????????????????????????????break; ????????????????????????} ????????????????} ????????????????if (!i) puts("NA"); ????????} ????????return (0); }
main.c:4:1: error: expected identifier or '(' before '?' token 4 | ?? | ^ main.c:18:1: error: expected identifier or '(' before '?' token 18 | ?? | ^
s752298189
p00202
C
p[' '];t[' '];n,x,j;main(i){for(;i++<1e6;)for(x=i;x<1e6;p[x+=i]=1);for(;scanf("%d%d",&n,&x),n;memset(t,!printf(x<2?"NA\n":"%d\n",x),4e6)){for(;n--;)for(i=-scanf("%d",t);++i<x;)t[i+*k]|=t[i];for(;p[x]|!t[x];x--);}}
main.c:1:3: warning: multi-character character constant [-Wmultichar] 1 | p[' '];t[' '];n,x,j;main(i){for(;i++<1e6;)for(x=i;x<1e6;p[x+=i]=1);for(;scanf("%d%d",&n,&x),n;memset(t,!printf(x<2?"NA\n":"%d\n",x),4e6)){for(;n--;)for(i=-scanf("%d",t);++i<x;)t[i+*k]|=t[i];for(;p[x]|!t[x];x--);}} | ^~~~~ main.c:1:1: warning: data definition has no type or storage class 1 | p[' '];t[' '];n,x,j;main(i){for(;i++<1e6;)for(x=i;x<1e6;p[x+=i]=1);for(;scanf("%d%d",&n,&x),n;memset(t,!printf(x<2?"NA\n":"%d\n",x),4e6)){for(;n--;)for(i=-scanf("%d",t);++i<x;)t[i+*k]|=t[i];for(;p[x]|!t[x];x--);}} | ^ main.c:1:1: error: type defaults to 'int' in declaration of 'p' [-Wimplicit-int] main.c:1:12: warning: multi-character character constant [-Wmultichar] 1 | p[' '];t[' '];n,x,j;main(i){for(;i++<1e6;)for(x=i;x<1e6;p[x+=i]=1);for(;scanf("%d%d",&n,&x),n;memset(t,!printf(x<2?"NA\n":"%d\n",x),4e6)){for(;n--;)for(i=-scanf("%d",t);++i<x;)t[i+*k]|=t[i];for(;p[x]|!t[x];x--);}} | ^~~~~ main.c:1:10: warning: data definition has no type or storage class 1 | p[' '];t[' '];n,x,j;main(i){for(;i++<1e6;)for(x=i;x<1e6;p[x+=i]=1);for(;scanf("%d%d",&n,&x),n;memset(t,!printf(x<2?"NA\n":"%d\n",x),4e6)){for(;n--;)for(i=-scanf("%d",t);++i<x;)t[i+*k]|=t[i];for(;p[x]|!t[x];x--);}} | ^ main.c:1:10: error: type defaults to 'int' in declaration of 't' [-Wimplicit-int] main.c:1:19: warning: data definition has no type or storage class 1 | p[' '];t[' '];n,x,j;main(i){for(;i++<1e6;)for(x=i;x<1e6;p[x+=i]=1);for(;scanf("%d%d",&n,&x),n;memset(t,!printf(x<2?"NA\n":"%d\n",x),4e6)){for(;n--;)for(i=-scanf("%d",t);++i<x;)t[i+*k]|=t[i];for(;p[x]|!t[x];x--);}} | ^ main.c:1:19: error: type defaults to 'int' in declaration of 'n' [-Wimplicit-int] main.c:1:21: error: type defaults to 'int' in declaration of 'x' [-Wimplicit-int] 1 | p[' '];t[' '];n,x,j;main(i){for(;i++<1e6;)for(x=i;x<1e6;p[x+=i]=1);for(;scanf("%d%d",&n,&x),n;memset(t,!printf(x<2?"NA\n":"%d\n",x),4e6)){for(;n--;)for(i=-scanf("%d",t);++i<x;)t[i+*k]|=t[i];for(;p[x]|!t[x];x--);}} | ^ main.c:1:23: error: type defaults to 'int' in declaration of 'j' [-Wimplicit-int] 1 | p[' '];t[' '];n,x,j;main(i){for(;i++<1e6;)for(x=i;x<1e6;p[x+=i]=1);for(;scanf("%d%d",&n,&x),n;memset(t,!printf(x<2?"NA\n":"%d\n",x),4e6)){for(;n--;)for(i=-scanf("%d",t);++i<x;)t[i+*k]|=t[i];for(;p[x]|!t[x];x--);}} | ^ main.c:1:25: error: return type defaults to 'int' [-Wimplicit-int] 1 | p[' '];t[' '];n,x,j;main(i){for(;i++<1e6;)for(x=i;x<1e6;p[x+=i]=1);for(;scanf("%d%d",&n,&x),n;memset(t,!printf(x<2?"NA\n":"%d\n",x),4e6)){for(;n--;)for(i=-scanf("%d",t);++i<x;)t[i+*k]|=t[i];for(;p[x]|!t[x];x--);}} | ^~~~ main.c: In function 'main': main.c:1:25: error: type of 'i' defaults to 'int' [-Wimplicit-int] main.c:1:77: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 1 | p[' '];t[' '];n,x,j;main(i){for(;i++<1e6;)for(x=i;x<1e6;p[x+=i]=1);for(;scanf("%d%d",&n,&x),n;memset(t,!printf(x<2?"NA\n":"%d\n",x),4e6)){for(;n--;)for(i=-scanf("%d",t);++i<x;)t[i+*k]|=t[i];for(;p[x]|!t[x];x--);}} | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | p[' '];t[' '];n,x,j;main(i){for(;i++<1e6;)for(x=i;x<1e6;p[x+=i]=1);for(;scanf("%d%d",&n,&x),n;memset(t,!printf(x<2?"NA\n":"%d\n",x),4e6)){for(;n--;)for(i=-scanf("%d",t);++i<x;)t[i+*k]|=t[i];for(;p[x]|!t[x];x--);}} main.c:1:77: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 1 | p[' '];t[' '];n,x,j;main(i){for(;i++<1e6;)for(x=i;x<1e6;p[x+=i]=1);for(;scanf("%d%d",&n,&x),n;memset(t,!printf(x<2?"NA\n":"%d\n",x),4e6)){for(;n--;)for(i=-scanf("%d",t);++i<x;)t[i+*k]|=t[i];for(;p[x]|!t[x];x--);}} | ^~~~~ main.c:1:77: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:1:99: error: implicit declaration of function 'memset' [-Wimplicit-function-declaration] 1 | p[' '];t[' '];n,x,j;main(i){for(;i++<1e6;)for(x=i;x<1e6;p[x+=i]=1);for(;scanf("%d%d",&n,&x),n;memset(t,!printf(x<2?"NA\n":"%d\n",x),4e6)){for(;n--;)for(i=-scanf("%d",t);++i<x;)t[i+*k]|=t[i];for(;p[x]|!t[x];x--);}} | ^~~~~~ main.c:1:1: note: include '<string.h>' or provide a declaration of 'memset' +++ |+#include <string.h> 1 | p[' '];t[' '];n,x,j;main(i){for(;i++<1e6;)for(x=i;x<1e6;p[x+=i]=1);for(;scanf("%d%d",&n,&x),n;memset(t,!printf(x<2?"NA\n":"%d\n",x),4e6)){for(;n--;)for(i=-scanf("%d",t);++i<x;)t[i+*k]|=t[i];for(;p[x]|!t[x];x--);}} main.c:1:99: warning: incompatible implicit declaration of built-in function 'memset' [-Wbuiltin-declaration-mismatch] 1 | p[' '];t[' '];n,x,j;main(i){for(;i++<1e6;)for(x=i;x<1e6;p[x+=i]=1);for(;scanf("%d%d",&n,&x),n;memset(t,!printf(x<2?"NA\n":"%d\n",x),4e6)){for(;n--;)for(i=-scanf("%d",t);++i<x;)t[i+*k]|=t[i];for(;p[x]|!t[x];x--);}} | ^~~~~~ main.c:1:99: note: include '<string.h>' or provide a declaration of 'memset' main.c:1:109: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 1 | p[' '];t[' '];n,x,j;main(i){for(;i++<1e6;)for(x=i;x<1e6;p[x+=i]=1);for(;scanf("%d%d",&n,&x),n;memset(t,!printf(x<2?"NA\n":"%d\n",x),4e6)){for(;n--;)for(i=-scanf("%d",t);++i<x;)t[i+*k]|=t[i];for(;p[x]|!t[x];x--);}} | ^~~~~~ main.c:1:109: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:1:109: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:1:109: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:1:186: error: 'k' undeclared (first use in this function) 1 | p[' '];t[' '];n,x,j;main(i){for(;i++<1e6;)for(x=i;x<1e6;p[x+=i]=1);for(;scanf("%d%d",&n,&x),n;memset(t,!printf(x<2?"NA\n":"%d\n",x),4e6)){for(;n--;)for(i=-scanf("%d",t);++i<x;)t[i+*k]|=t[i];for(;p[x]|!t[x];x--);}} | ^ main.c:1:186: note: each undeclared identifier is reported only once for each function it appears in
s895775622
p00202
C++
#include<iostream> #include<cstring> #include<algorithm> const int Max = 1000001; int dishes[31]; bool dish[Max]; bool isPrime[Max]; int main(){ for (int i = 2; i < Max; i++)isPrime[i] = true; for (int i = 2; i < std::sqrt(Max); i++){ if (isPrime[i]){ for (int j = i * 2; j < Max; j += i)isPrime[j] = false; } } int n, x; while (std::cin >> n, n){ std::cin >> x; memset(dish, 0, sizeof(dish)); for (int i = 0; i < n; i++){ std::cin >> dishes[i]; } dish[0] = true; for (int i = 0; i < x; i++){ if (dish[i]){ for (int j = 0; j < n; j++){ dish[i + dishes[j]] = true; } } } for (int i = x; i >= 0; i--){ if (dish[i] && isPrime[i]){ std::cout << i << std::endl; break; } if (i == 0)std::cout << "NA" << std::endl; } } return 0; }
a.cc: In function 'int main()': a.cc:14:34: error: 'sqrt' is not a member of 'std'; did you mean 'sort'? 14 | for (int i = 2; i < std::sqrt(Max); i++){ | ^~~~ | sort
s337322906
p00202
C++
using System; using System.Collections.Generic; using System.Linq; namespace AOJ { class Program { public static void Main(string[] args) { var pmax = 1000000; var primes = new bool[pmax+1]; var maxsq = (int)Math.Sqrt(pmax); for(var i=2;i<=pmax;i++) primes[i]=true; for(var i=2;i<=maxsq;i++) if(primes[i]) for(var j=i*2;j<pmax;j+=i) primes[j]=false; List<int> num; while((num = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToList())[0]>0){ var menu = new List<int>(); var order = new bool[num[1]+1]; var max = 0; for(var i=0;i<num[0];i++) menu.Add(int.Parse(Console.ReadLine())); order[0]=true; for(var i=0;i<=num[1];i++) if(order[i]){ menu.ForEach(x=>{if(i+x<=num[1])order[i+x]=true;}); if(primes[i]) max=i; } Console.WriteLine(max<1?"NA":"{0}",max); } } } }
a.cc:1:7: error: expected nested-name-specifier before 'System' 1 | using System; | ^~~~~~ 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.Linq; | ^~~~~~ a.cc:9:23: error: expected ':' before 'static' 9 | public static void Main(string[] args) | ^~~~~~~ | : a.cc:9:41: error: 'string' has not been declared 9 | public static void Main(string[] args) | ^~~~~~ a.cc:9:50: error: expected ',' or '...' before 'args' 9 | public static void Main(string[] args) | ^~~~ a.cc:38:10: error: expected ';' after class definition 38 | } | ^ | ; a.cc: In static member function 'static void AOJ::Program::Main(int*)': a.cc:11:25: error: 'var' was not declared in this scope 11 | var pmax = 1000000; | ^~~ a.cc:12:29: error: expected ';' before 'primes' 12 | var primes = new bool[pmax+1]; | ^~~~~~ a.cc:13:29: error: expected ';' before 'maxsq' 13 | var maxsq = (int)Math.Sqrt(pmax); | ^~~~~ a.cc:14:33: error: expected ';' before 'i' 14 | for(var i=2;i<=pmax;i++) | ^ a.cc:14:37: error: 'i' was not declared in this scope 14 | for(var i=2;i<=pmax;i++) | ^ a.cc:14:40: error: 'pmax' was not declared in this scope 14 | for(var i=2;i<=pmax;i++) | ^~~~ a.cc:15:33: error: 'primes' was not declared in this scope 15 | primes[i]=true; | ^~~~~~ a.cc:16:33: error: expected ';' before 'i' 16 | for(var i=2;i<=maxsq;i++) | ^ a.cc:16:37: error: 'i' was not declared in this scope 16 | for(var i=2;i<=maxsq;i++) | ^ a.cc:16:40: error: 'maxsq' was not declared in this scope 16 | for(var i=2;i<=maxsq;i++) | ^~~~~ a.cc:17:36: error: 'primes' was not declared in this scope 17 | if(primes[i]) | ^~~~~~ a.cc:18:49: error: expected ';' before 'j' 18 | for(var j=i*2;j<pmax;j+=i) | ^ a.cc:18:55: error: 'j' was not declared in this scope 18 | for(var j=i*2;j<pmax;j+=i) | ^ a.cc:18:57: error: 'pmax' was not declared in this scope 18 | for(var j=i*2;j<pmax;j+=i) | ^~~~ a.cc:20:25: error: 'List' was not declared in this scope 20 | List<int> num; | ^~~~ a.cc:20:30: error: expected primary-expression before 'int' 20 | List<int> num; | ^~~ a.cc:21:32: error: 'num' was not declared in this scope; did you mean 'enum'? 21 | while((num = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToList())[0]>0){ | ^~~ | enum a.cc:21:38: error: 'Console' was not declared in this scope 21 | while((num = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToList())[0]>0){ | ^~~~~~~ a.cc:21:75: error: 'x' was not declared in this scope 21 | while((num = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToList())[0]>0){ | ^ a.cc:21:77: error: expected primary-expression before '>' token 21 | while((num = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToList())[0]>0){ | ^ a.cc:21:78: error: expected primary-expression before 'int' 21 | while((num = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToList())[0]>0){ | ^~~ a.cc:22:37: error: expected ';' before 'menu' 22 | var menu = new List<int>(); | ^~~~ a.cc:23:37: error: expected ';' before 'order' 23 | var order = new bool[num[1]+1]; | ^~~~~ a.cc:24:37: error: expected ';' before 'max' 24 | var max = 0; | ^~~ a.cc:25:41: error: expected ';' before 'i' 25 | for(var i=0;i<num[0];i++) | ^ a.cc:25:45: error: 'i' was not declared in this scope 25 | for(var i=0;i<num[0];i++) | ^ a.cc:26:41: error: 'menu' was not declared in this scope 26 | menu.Add(int.Parse(Console.ReadLine())); | ^~~~ a.cc:26:50: error: expected primary-expression before 'int' 26 | menu.Add(int.Parse(Console.ReadLine())); | ^~~ a.cc:27:33: error: 'order' was not declared in this scope 27 | order[0]=true; | ^~~~~ a.cc:28:41: error: expected ';' before 'i' 28 | for(var i=0;i<=num[1];i++) | ^ a.cc:28:45: error: 'i' was not declared in this scope 28 | for(var i=0;i<=num[1];i++) | ^ a.cc:30:49: error: 'menu' was not declared in this scope 30 | menu.ForEach(x=>{if(i+x<=num[1])order[i+x]=true;}); | ^~~~ a.cc:30:64: error: expected primary-expression before '>' token 30 | menu.ForEach(x=>{if(i+x<=num[1])order[i+x]=true;}); | ^ a.cc:30:65: error: expected primary-expression before '{' token 30 | menu.ForEach(x=>{if(i+x<=num[1])order[i+x]=true;}); | ^ a.cc:31:52: error: 'primes' was not declared in this scope 31 | if(primes[i]) | ^~~~~~ a.cc:32:57: error: 'max' was not declared in this scope 32 | max=i; | ^~~ a.cc:34:51: error: 'max' was not declared in this scope 34 | Console.WriteLine(max<1?"NA":"{0}",max); | ^~~
s700155356
p00202
C++
#include <cstdio> #include <iostream> #include <vector> using namespace std; int main() { int n, m; while(cin >> n >> m && (n || m)) { int cnt=0;vector<int> primes; bool num[m]; memset(num, false, sizeof(num)); num[0] = true; for(int i=0;i < n;++i) {int hoge; cin>>hoge; if(!(hoge%2)){++cnt;}} if (cnt == n) {puts("NA"); continue;} for(int i=2,len=m/2;i<=len;++i) { if (num[i-1]) continue; for(int j=i+i;j <= m;j+=i) { num[j-1] = true; } } for(int i=0;i < m;++i) { if (!num[i]) { primes.push_back(i+1); } } cout << primes.back() << endl; } return 0; }
a.cc: In function 'int main()': a.cc:11:9: error: 'memset' was not declared in this scope 11 | memset(num, false, sizeof(num)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <vector> +++ |+#include <cstring> 4 | using namespace std;
s511079655
p00202
C++
#include <bits/stdc++.h> using namespace std; #define FOR(i, s, n) for(int i = s; i < (int)n; i++) #define per(i, n) for(int i = n; i >= 0; i--) #define ROF(i, s, n) for(int i = s; i >= (int)n; i--) #define FORIT(i, A) for (auto i : A) #define PRINT(x) cout << (x) << "\n" #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(), (a).rend() #define MP make_pair #define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i) #define SZ(a) int((a).size()) #define EXIST(s,e) ((s).find(e)!=(s).end()) #define SORT(c) sort((c).begin(),(c).end()) #define CLR(a) memset((a), 0 ,sizeof(a)) #define dump(x) cout << #x << " = " << (x) << "\n"; #define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n"; #define sq(n) (n) * (n) typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef long long LL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; typedef unsigned int uint; typedef unsigned long long ull; typedef priority_queue<int> maxpq; typedef priority_queue< int, vector<int>, greater<int> > minpq; static const double EPS = 1e-10; static const double PI = acos( -1.0 ); static const int mod = 10007; static const int INF = 1 << 25; static const LL LL_INF = 1152921504606846976; static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 }; static const int dy[] = { 0, -1, 0, 1 , 1, 1, -1, -1 }; static vector<bool> is_pm( 10000001, true );; static bool dp[ 31 ][ 10000001 ]; static int ans = 0, m; static char n; static VI ar; static void solve( static const char now, static const int how_much ) { if ( how_much > m ) { return; } if ( is_pm[ how_much ] ) { ans = max( ans, how_much ); } if ( now == n || dp[ now ][ how_much ] ) { return; } dp[ now ][ how_much ] = true; solve( now, how_much + ar[ now ] ); solve( now + 1, how_much ); } int main() { for ( int i = 2; i * i < 10000000; i++ ) { if ( is_pm[ i ] ) { for ( int j = i * i; j <= 10000000; j += i ) { is_pm[ j ] = false; } } } is_pm[ 3 ] = false; is_pm[ 2 ] = false; is_pm[ 1 ] = false; is_pm[ 0 ] = false; while ( ~scanf( "%d %d", &n, &m ) && n && m ) { ar.resize( n ); ar.reserve( n ); for ( int i = 0; i < n; i++ ) { scanf( "%d", &ar[ i ] ); } sort( ar.begin(), ar.end() ); memset( dp, false, sizeof( dp ) ); ans = 0; solve( 0, 0 ); if ( ans == 0 ) { printf( "NA\n" ); } else { printf( "%d\n", ans ); } } return 0; }
a.cc:44:20: error: storage class specified for parameter 'now' 44 | static void solve( static const char now, static const int how_much ) { | ^~~~~~ a.cc:44:41: error: expected ')' before ',' token 44 | static void solve( static const char now, static const int how_much ) { | ~ ^ | ) a.cc:44:43: error: expected unqualified-id before 'static' 44 | static void solve( static const char now, static const int how_much ) { | ^~~~~~ a.cc:44:13: warning: 'void solve(...)' used but never defined 44 | static void solve( static const char now, static const int how_much ) { | ^~~~~
s839959659
p00202
C++
#include <iostream> #include <algorithm> #include <cstring> using namespace std; const int XMAX = 1000000; constexpr int SQRTXMAX = sqrt(XMAX); bool is_prime[XMAX + 1]; bool dp[XMAX + 1]; int cost[30]; int main() { // prime memset(is_prime, true, sizeof(is_prime)); is_prime[0] = is_prime[1] = false for (int i = 2; i <= SQRTXMAX) { if (is_prime[i]) { int current = i * i; for (int j = i * i; j <= XMAX; j += i) { is_prime[j] = false; } } } int n, x; while (cin >> n >> x, n) { for (int i = 0; i < n; i++) cin >> cost[i]; // dp r = 0; dp[0] = true; for (int i = 1; i <= x; i++) { for (int j = 0; j < n; j++) { int k = i - cost[j]; if (k >= 0 && dp[k]) { dp[i] = true; if (is_prime[i]) r = i; break; } } } if (r == 0) { cout << "NA" << endl; } else { cout << r << endl; } } return 0; }
a.cc:6:26: error: 'sqrt' was not declared in this scope 6 | constexpr int SQRTXMAX = sqrt(XMAX); | ^~~~ a.cc: In function 'int main()': a.cc:15:36: error: expected ';' before 'for' 15 | is_prime[0] = is_prime[1] = false | ^ | ; 16 | for (int i = 2; i <= SQRTXMAX) { | ~~~ a.cc:16:19: error: 'i' was not declared in this scope 16 | for (int i = 2; i <= SQRTXMAX) { | ^ a.cc:30:5: error: 'r' was not declared in this scope 30 | r = 0; | ^
s989591149
p00202
C++
#include <iostream> #include <algorithm> #include <cstring> using namespace std; const int XMAX = 1000000; constexpr int SQRTXMAX = (int)sqrt(XMAX); bool is_prime[XMAX + 1]; bool dp[XMAX + 1]; int cost[30]; int main() { // prime memset(is_prime, true, sizeof(is_prime)); is_prime[0] = is_prime[1] = false for (int i = 2; i <= SQRTXMAX) { if (is_prime[i]) { int current = i * i; for (int j = i * i; j <= XMAX; j += i) { is_prime[j] = false; } } } int n, x; while (cin >> n >> x, n) { for (int i = 0; i < n; i++) cin >> cost[i]; // dp r = 0; dp[0] = true; for (int i = 1; i <= x; i++) { for (int j = 0; j < n; j++) { int k = i - cost[j]; if (k >= 0 && dp[k]) { dp[i] = true; if (is_prime[i]) r = i; break; } } } if (r == 0) { cout << "NA" << endl; } else { cout << r << endl; } } return 0; }
a.cc:6:31: error: 'sqrt' was not declared in this scope 6 | constexpr int SQRTXMAX = (int)sqrt(XMAX); | ^~~~ a.cc: In function 'int main()': a.cc:15:36: error: expected ';' before 'for' 15 | is_prime[0] = is_prime[1] = false | ^ | ; 16 | for (int i = 2; i <= SQRTXMAX) { | ~~~ a.cc:16:19: error: 'i' was not declared in this scope 16 | for (int i = 2; i <= SQRTXMAX) { | ^ a.cc:30:5: error: 'r' was not declared in this scope 30 | r = 0; | ^
s248997031
p00202
C++
#include <iostream> #include <algorithm> #include <cstring> using namespace std; const int XMAX = 1000000; const int SQRTXMAX = sqrt(XMAX); bool is_prime[XMAX + 1]; bool dp[XMAX + 1]; int cost[30]; int main() { // prime memset(is_prime, true, sizeof(is_prime)); is_prime[0] = is_prime[1] = false for (int i = 2; i <= SQRTXMAX) { if (is_prime[i]) { int current = i * i; for (int j = i * i; j <= XMAX; j += i) { is_prime[j] = false; } } } int n, x; while (cin >> n >> x, n) { for (int i = 0; i < n; i++) cin >> cost[i]; // dp r = 0; dp[0] = true; for (int i = 1; i <= x; i++) { for (int j = 0; j < n; j++) { int k = i - cost[j]; if (k >= 0 && dp[k]) { dp[i] = true; if (is_prime[i]) r = i; break; } } } if (r == 0) { cout << "NA" << endl; } else { cout << r << endl; } } return 0; }
a.cc:6:22: error: 'sqrt' was not declared in this scope 6 | const int SQRTXMAX = sqrt(XMAX); | ^~~~ a.cc: In function 'int main()': a.cc:15:36: error: expected ';' before 'for' 15 | is_prime[0] = is_prime[1] = false | ^ | ; 16 | for (int i = 2; i <= SQRTXMAX) { | ~~~ a.cc:16:19: error: 'i' was not declared in this scope 16 | for (int i = 2; i <= SQRTXMAX) { | ^ a.cc:30:5: error: 'r' was not declared in this scope 30 | r = 0; | ^
s707531168
p00202
C++
#include <iostream> #include <algorithm> #include <cstring> using namespace std; const int XMAX = 1000000; constexpr int SQRTXMAX = sqrt(XMAX); bool is_prime[XMAX + 1]; bool dp[XMAX + 1]; int cost[30]; int main() { // prime memset(is_prime, true, sizeof(is_prime)); is_prime[0] = is_prime[1] = false; for (int i = 2; i <= SQRTXMAX; i++) { if (is_prime[i]) { int current = i * i; for (int j = i * i; j <= XMAX; j += i) { is_prime[j] = false; } } } int n, x; while (cin >> n >> x, n) { for (int i = 0; i < n; i++) cin >> cost[i]; // dp int r = 0; dp[0] = true; for (int i = 1; i <= x; i++) { dp[i] = false; for (int j = 0; j < n; j++) { int k = i - cost[j]; if (k >= 0 && dp[k]) { dp[i] = true; if (is_prime[i]) r = i; break; } } } if (r == 0) { cout << "NA" << endl; } else { cout << r << endl; } } return 0; }
a.cc:6:26: error: 'sqrt' was not declared in this scope 6 | constexpr int SQRTXMAX = sqrt(XMAX); | ^~~~
s220384923
p00202
C++
#include <bits/stdc++.h> #ifndef INCLUDE_BOOL_ARRAY_HPP #define INCLUDE_BOOL_ARRAY_HPP #include <cstring> #include <limits> #include <cassert> namespace orliv { template<unsigned int CAP> struct BoolArray { typename int memory_t; memory_t K; memory_t data[CAP]; BoolArray() { clear_deep(); } void clear_deep(){ std::memset(data, sizeof(data), 0); K = 1; } void clear(){ K++; } bool within_k(int x, int k){ return data[x] + k >= K; } inline bool get(int x){ return data[x] == K; } inline void set(int x){ data[x] = K; } }; } #endif using namespace std; typedef long long ll; typedef long double ld; typedef tuple<int, int> duo; const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1}; const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1}; const int Mod = 1000000000 + 0; //{{{ templates #define TT_ template<typename T>inline #define TTF_ template<typename T,typename F>inline TT_ T sq(T x){return x*x;} TT_ T In(){T x;cin>>x;return x;} TT_ void Out(T&x){cout<<x;} TT_ void sort(T&v){sort(begin(v),end(v));} TT_ void revs(T&v){reverse(begin(v),end(v));} TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));} TT_ int ubnd(T&v,typename T::value_type x){return upper_bound(begin(v),end(v),x)-begin(v);} TT_ int lbnd(T&v,typename T::value_type x){return lower_bound(begin(v),end(v),x)-begin(v);} TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));} TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;} TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));} TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));} inline void fast_io(){ios_base::sync_with_stdio(0);cin.tie(0);} inline int in(){int x;scanf("%d",&x);return x;} inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;} inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);} //}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple const int MAX_N = 10100100; BoolArray<MAX_N> dp; bool sieve[MAX_N]; int main() { for (int i = 2; i * i <= MAX_N; i++){ if (sieve[i]) continue; for (int j = i * i; j <= MAX_N; j += i){ sieve[j] = true; } } int n, x; while (n = in(), x = in(), n){ dp.set(0); for (int i = 0; i < n; i++){ int cost = in(); for (int j = j + cost <= x; j++){ if (dp.get(j)) dp.set(j + cost); } } for (int i = x; i > 0; i--){ if (sieve[i] && dp.get(i)){ printf("%d\n", i); goto END; } } puts("NA"); END:; dp.clear(); } return 0; }
a.cc:13:12: error: expected nested-name-specifier before 'int' 13 | typename int memory_t; | ^~~ a.cc:13:3: error: two or more data types in declaration of 'memory_t' 13 | typename int memory_t; | ^~~~~~~~ a.cc:14:3: error: 'memory_t' does not name a type 14 | memory_t K; | ^~~~~~~~ a.cc:15:3: error: 'memory_t' does not name a type 15 | memory_t data[CAP]; | ^~~~~~~~ a.cc: In member function 'void orliv::BoolArray<CAP>::clear_deep()': a.cc:17:34: error: 'data' was not declared in this scope; did you mean 'std::data'? 17 | void clear_deep(){ std::memset(data, sizeof(data), 0); K = 1; } | ^~~~ | std::data In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:1: /usr/include/c++/14/bits/range_access.h:344:5: note: 'std::data' declared here 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ a.cc:17:58: error: 'K' was not declared in this scope 17 | void clear_deep(){ std::memset(data, sizeof(data), 0); K = 1; } | ^ a.cc: In member function 'void orliv::BoolArray<CAP>::clear()': a.cc:18:17: error: 'K' was not declared in this scope 18 | void clear(){ K++; } | ^ a.cc: In member function 'bool orliv::BoolArray<CAP>::within_k(int, int)': a.cc:19:39: error: 'data' was not declared in this scope; did you mean 'std::data'? 19 | bool within_k(int x, int k){ return data[x] + k >= K; } | ^~~~ | std::data /usr/include/c++/14/bits/range_access.h:344:5: note: 'std::data' declared here 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ a.cc:19:54: error: 'K' was not declared in this scope 19 | bool within_k(int x, int k){ return data[x] + k >= K; } | ^ a.cc: In member function 'bool orliv::BoolArray<CAP>::get(int)': a.cc:20:34: error: 'data' was not declared in this scope; did you mean 'std::data'? 20 | inline bool get(int x){ return data[x] == K; } | ^~~~ | std::data /usr/include/c++/14/bits/range_access.h:344:5: note: 'std::data' declared here 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ a.cc:20:45: error: 'K' was not declared in this scope 20 | inline bool get(int x){ return data[x] == K; } | ^ a.cc: In member function 'void orliv::BoolArray<CAP>::set(int)': a.cc:21:27: error: 'data' was not declared in this scope; did you mean 'std::data'? 21 | inline void set(int x){ data[x] = K; } | ^~~~ | std::data /usr/include/c++/14/bits/range_access.h:344:5: note: 'std::data' declared here 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ a.cc:21:37: error: 'K' was not declared in this scope 21 | inline void set(int x){ data[x] = K; } | ^ a.cc: At global scope: a.cc:58:1: error: 'BoolArray' does not name a type 58 | BoolArray<MAX_N> dp; | ^~~~~~~~~ a.cc: In function 'int main()': a.cc:72:5: error: 'dp' was not declared in this scope; did you mean 'dy'? 72 | dp.set(0); | ^~ | dy a.cc:75:38: error: expected ';' before ')' token 75 | for (int j = j + cost <= x; j++){ | ^ | ;
s187877333
p00202
C++
#include <vector> #include <iostream> std::vector<bool> cul_prime(const int &n) { std::vector<bool> prime(n + 1, true); prime.at(0) = false; prime.at(1) = false; double root = sqrt(n) + 1; for (auto i = 2; i <= n >> 1; ++i) { prime.at(i << 1) = false; } for (auto i = 3; i < root; i += 2) { if (prime.at(i)) { for (auto j = 2; j <= n / i; ++j) { prime.at(i * j) = false; } } } return prime; } double sqrt(const int &n) { double a = n, b = 1; while ((a - b) * (a - b) < 0.1) { double min = (a + b) / 2; if (min * min > n) { a = min; } else { b = min; } } return a; } int main() { int n, x; std::cin >> n >> x; while (n != 0) { std::vector<bool> num(x + 1, false); std::vector<int> menu; for (auto i = 0; i < n; ++i) { int price; std::cin >> price; menu.push_back(price); } int max = 0; auto prime = cul_prime(x); num.at(0) = true; for (const auto &i : menu) { for (auto j = 0; j <= x - i; ++j) { if (num.at(j)) { if (j + i <= x) { num.at(j + i) = true; if (max < j + i && prime.at(j + i)) { max = j + i; } } } } } if (max == 0) { std::cout << "NA\n"; } else { std::cout << max << "\n"; } std::cin >> n >> x; } return 0; }
a.cc: In function 'std::vector<bool> cul_prime(const int&)': a.cc:8:23: error: 'sqrt' was not declared in this scope 8 | double root = sqrt(n) + 1; | ^~~~
s363884150
p00202
C++
#include <cstdio> #include <vector> #include <algorithm> using namespace std; int n, x, a[30]; bool dp[1000001], prime[1000001]; vector<int> p; int main() { for(int i = 2; i <= 1000000; i++) prime[i] = true; for(int i = 2; i <= 1000; i++) { if(!prime[i]) continue; for(int j = i * i; j <= 1000000; j += i) prime[j] = false; } p = {0}; for(int i = 2; i <= 1000000; i++) { if(prime[i]) p.push_back(i); } while(scanf("%d%d", &n, &x), n) { for(int i = 0; i < n; i++) scanf("%d", &a[i]); sort(a, a + n); for(int i = 0; i < x; i++) dp[i + 1] = false; dp[0] = true; for(int i = 1; i <= x; i++) { for(int j = 0; j < n && i >= a[j]; j++) { if(dp[i - a[j]]) { dp[i] = true; break; } } } int pos = upper_bound(p.begin(), p.end(), x); for(int i = pos - 1; i >= 0; i--) { if(dp[p[i]]) { printf(i ? "%d\n" : "NA\n", p[i]); break; } } } }
a.cc: In function 'int main()': a.cc:26:38: error: cannot convert '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'int' in initialization 26 | int pos = upper_bound(p.begin(), p.end(), x); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ | | | __gnu_cxx::__normal_iterator<int*, std::vector<int> >
s097828922
p00202
C++
#include<iostream> #include<iomanip> #include<algorithm> #include<bitset> #include<cctype> #include<climits> #include<cmath> #include<cstdio> #include<deque> #include<list> #include<map> #include<queue> #include<set> #include<stack> #include<string> #include<sstream> #include<vector> using namespace std; #define M 1000001 int main() { static char gosei[M] = {}; //????????°???1??? for (int i = 2; i <= sqrt(M); i++) if (gosei[i] == 0) { for (int j = 2, k = 0; (k = i*j) <= M; j++) gosei[k] = 1; } static char dp[M]; for (int n, x; cin >> n >> x&&n&&x;) { memset(dp, 0, sizeof(dp)); dp[0] = 1; for (int i = 0; i < n; i++) { int b; cin >> b; for (int j = 0; j + b <= x; j++) if (dp[j]) dp[j + b] = 1; } bool NA = true; for (int i = x; i >= 1; i--) { if (dp[i] && !gosei[i]) { cout << i << endl; NA = false; break; } } if (NA)cout << "NA" << endl; } return 0; }
a.cc: In function 'int main()': a.cc:34:17: error: 'memset' was not declared in this scope 34 | memset(dp, 0, sizeof(dp)); | ^~~~~~ a.cc:15:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 14 | #include<stack> +++ |+#include <cstring> 15 | #include<string>
s947146702
p00202
C++
import java.util.*; class Main { static Scanner scan = new Scanner(System.in); public static void main(String[] args) { while (scan.hasNext()) { int n = scan.nextInt(); int money = scan.nextInt(); boolean[] dp = new boolean[money+1]; if (n == 0) { break; } int[] menu = new int[30]; for (int i = 0; i < n; i++) { menu[i] = scan.nextInt(); } solve(dp, menu); int i; for (i = dp.length-1; i >= 0; i--) { if (dp[i] && prime(i)) { break; } } if (i < 0) { System.out.println("NA"); } else { System.out.println(i); } } } public static void solve(boolean dp[], int menu[]) { for (int i = 0; i < menu.length; i++) { if (menu[i] > dp.length) { continue; } dp[menu[i]] = true; for (int j = 1; j < dp.length; j++) { if (dp[j] && j + menu[i] < dp.length) { dp[j+menu[i]] = true; } } } } public static boolean prime(int a) { if (a <= 3) { return true; } else { for (int i = 2; i * i <= a; i++) { if (a % i == 0) { return false; } } } return true; } }
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:5:12: error: 'Scanner' does not name a type 5 | static Scanner scan = new Scanner(System.in); | ^~~~~~~ a.cc:7:11: error: expected ':' before 'static' 7 | public static void main(String[] args) { | ^~~~~~~ | : a.cc:7:29: error: 'String' has not been declared 7 | public static void main(String[] args) { | ^~~~~~ a.cc:7:38: error: expected ',' or '...' before 'args' 7 | public static void main(String[] args) { | ^~~~ a.cc:35:11: error: expected ':' before 'static' 35 | public static void solve(boolean dp[], int menu[]) { | ^~~~~~~ | : a.cc:35:30: error: 'boolean' has not been declared 35 | public static void solve(boolean dp[], int menu[]) { | ^~~~~~~ a.cc:51:11: error: expected ':' before 'static' 51 | public static boolean prime(int a) { | ^~~~~~~ | : a.cc:51:19: error: 'boolean' does not name a type; did you mean 'bool'? 51 | public static boolean prime(int a) { | ^~~~~~~ | bool a.cc:63:2: error: expected ';' after class definition 63 | } | ^ | ; a.cc: In static member function 'static void Main::main(int*)': a.cc:9:16: error: 'scan' was not declared in this scope 9 | while (scan.hasNext()) { | ^~~~ a.cc:12:13: error: 'boolean' was not declared in this scope; did you mean 'bool'? 12 | boolean[] dp = new boolean[money+1]; | ^~~~~~~ | bool a.cc:12:21: error: expected primary-expression before ']' token 12 | boolean[] dp = new boolean[money+1]; | ^ a.cc:16:16: error: structured binding declaration cannot have type 'int' 16 | int[] menu = new int[30]; | ^~ a.cc:16:16: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:16:16: error: empty structured binding declaration a.cc:16:19: error: expected initializer before 'menu' 16 | int[] menu = new int[30]; | ^~~~ a.cc:18:17: error: 'menu' was not declared in this scope 18 | menu[i] = scan.nextInt(); | ^~~~ a.cc:20:19: error: 'dp' was not declared in this scope 20 | solve(dp, menu); | ^~ a.cc:20:23: error: 'menu' was not declared in this scope 20 | solve(dp, menu); | ^~~~ a.cc:23:30: error: 'prime' was not declared in this scope 23 | if (dp[i] && prime(i)) { | ^~~~~ a.cc:28:17: error: 'System' was not declared in this scope 28 | System.out.println("NA"); | ^~~~~~ a.cc:30:17: error: 'System' was not declared in this scope 30 | System.out.println(i); | ^~~~~~ a.cc: In static member function 'static void Main::solve(int*, int*)': a.cc:36:34: error: request for member 'length' in 'menu', which is of non-class type 'int*' 36 | for (int i = 0; i < menu.length; i++) { | ^~~~~~ a.cc:37:30: error: request for member 'length' in 'dp', which is of non-class type 'int*' 37 | if (menu[i] > dp.length) { | ^~~~~~ a.cc:41:36: error: request for member 'length' in 'dp', which is of non-class type 'int*' 41 | for (int j = 1; j < dp.length; j++) { | ^~~~~~ a.cc:42:47: error: request for member 'length' in 'dp', which is of non-class type 'int*' 42 | if (dp[j] && j + menu[i] < dp.length) { | ^~~~~~
s303025260
p00202
C++
#include <iostream> #include <algorithm> #include <cstring> constexpr int MAX_N = 31, MAX_C = 1000001; int n, max; int cost[MAX_N]; bool dp[MAX_C]; bool prime_num[MAX_C]; int main() { while (1) { std::cin >> n >> max; if (n + max == 0) break; std::memset(prime_num, false, sizeof(prime_num)); std::memset(dp, false, sizeof(dp)); for (int i = 0; i < n; ++i) std::cin >> cost[i]; for (int i = 2; i * i <= max; ++i) { if (!prime_num[i]) { for (int j = 2; i*j <= max; ++j) prime_num[i*j] = true; } } int ans = 0; for (int i = 0; i < n; ++i) dp[cost[i]] = true; for (int i = 1; i <= max; ++i) { for (int j = 0; j < n; ++j) { if (i + cost[j] <= max&&dp[i]) dp[i + cost[j]] = true; else if(!d[i]) goto a; } } a:; for (int i = max; i >= 0; --i) { if (dp[i] && !prime_num[i]) { ans = i; break; } } if (!ans) std::cout << "NA" <<std::endl; else std::cout << ans << std::endl; } return 0; }
a.cc: In function 'int main()': a.cc:34:42: error: 'd' was not declared in this scope 34 | else if(!d[i]) | ^
s624186915
p00202
C++
#include<iostream> #include <cstdio> #include<string> using namespace std; int ha(string); int saga(int); int q,m,n=1000000,List[1000]; bool slist[1000001]; bool klist[1000001]; int main() { int i,j,k,b=0,s,a=2,f=0,c=0; for( i = 0; i <n;i++ ){ slist[i]=true; klist[i]=false; } i=0; while(i<sqrt((double)n)){ for(i=a+a;i<n;i=i+a){ slist[i]=false; } for(i=a+1;i<sqrt((double)n);i++){ if(slist[i]==true){ a=i; break; } } } cin>>m>>n; while(m!=0||n!=0){ for( i = 0; i <n;i++ ){ klist[i]=false; } for(i=0;i<m;i++){ cin>>List[i]; klist[List[i]]=true; } for(i=0;i<n;i++){ if(klist[i]){ for(j=0;j<m;j++){ klist[i+List[j]]=true; } } } for(i=n;i>0;i--){ if(klist[i]&&slist[i]){ break; } } if(i==0){ printf("NA\n"); } else{ printf("%d\n",i); } cin>>m>>n; } return 0; }
a.cc: In function 'int main()': a.cc:20:17: error: 'sqrt' was not declared in this scope 20 | while(i<sqrt((double)n)){ | ^~~~
s626405945
p00202
C++
#include<iostream> #include <cstdio> #include<string> using namespace std; int ha(string); int saga(int); int q,m,n=1000000,List[1000]; bool slist[1000001]; bool klist[1000001]; int main() { int i,j,k,b=0,s,a=2,f=0,c=0; for( i = 0; i <n;i++ ){ slist[i]=true; klist[i]=false; } i=0; while(i<sqrt((double)n)){ for(i=a+a;i<n;i=i+a){ slist[i]=false; } for(i=a+1;i<sqrt((double)n);i++){ if(slist[i]==true){ a=i; break; } } } cin>>m>>n; while(m!=0||n!=0){ for( i = 0; i <n;i++ ){ klist[i]=false; } for(i=0;i<m;i++){ cin>>List[i]; klist[List[i]]=true; } for(i=0;i<n;i++){ if(klist[i]){ for(j=0;j<m;j++){ klist[i+List[j]]=true; } } } for(i=n;i>0;i--){ if(klist[i]&&slist[i]){ break; } } if(i==0){ printf("NA\n"); } else{ printf("%d\n",i); } cin>>m>>n; } return 0; }
a.cc: In function 'int main()': a.cc:20:17: error: 'sqrt' was not declared in this scope 20 | while(i<sqrt((double)n)){ | ^~~~
s719207740
p00202
C++
#include <iostream> #include <algorithm> #include <string> #include <vector> #include <queue> #include <bitset> #include <set> #include <map> #include <stack> #include <list> #define rep(i,n) for(int i=0;i<n;i++) #define REP(i,b,n) for(int i=b;i<n;i++) #define SORT(c) sort((c).begin(),(c).end()) #define DESCSORT(c) sort(c.begin(), c.end(), greater<int>()) const float PI = 3.1415926; static const int INFTY = (1<<30); using namespace std; typedef long long ll; typedef long double ld; int n; ll V[31], x; ll dp[32][1LL<<32]; ll maxn; bool sosu(ll t){ if(t == 1) return false; if(t == 2) return true; if(t%2 == 0) return false; for(ll i=3; i*i<=t; i+=2){ if(t%i == 0) return false; } return true; } void solve(ll now) { if(now > x) return; if(sosu(now) && now > maxn) maxn = now; rep(i, n) { solve(now + V[i]); } return; } int main() { while(cin >> n >> x, n) { maxn = 0; rep(i, n) { cin >> V[i]; } solve(0); if(maxn == 0) { cout << "NA" << endl; } else { cout << maxn << endl; } } return 0; }
/tmp/ccFLgUB9.o: in function `solve(long long)': a.cc:(.text+0xa0): relocation truncated to fit: R_X86_64_PC32 against symbol `maxn' defined in .bss section in /tmp/ccFLgUB9.o a.cc:(.text+0xc1): relocation truncated to fit: R_X86_64_PC32 against symbol `maxn' defined in .bss section in /tmp/ccFLgUB9.o /tmp/ccFLgUB9.o: in function `main': a.cc:(.text+0x119): relocation truncated to fit: R_X86_64_PC32 against symbol `maxn' defined in .bss section in /tmp/ccFLgUB9.o a.cc:(.text+0x16f): relocation truncated to fit: R_X86_64_PC32 against symbol `maxn' defined in .bss section in /tmp/ccFLgUB9.o a.cc:(.text+0x1a8): relocation truncated to fit: R_X86_64_PC32 against symbol `maxn' defined in .bss section in /tmp/ccFLgUB9.o collect2: error: ld returned 1 exit status
s593711058
p00202
C++
#include <iostream> #include <algorithm> #include <string> #include <vector> #include <queue> #include <bitset> #include <set> #include <map> #include <stack> #include <list> #define rep(i,n) for(int i=0;i<n;i++) #define REP(i,b,n) for(int i=b;i<n;i++) #define SORT(c) sort((c).begin(),(c).end()) #define DESCSORT(c) sort(c.begin(), c.end(), greater<int>()) const float PI = 3.1415926; static const int INFTY = (1<<30); using namespace std; typedef long long ll; typedef long double ld; int n; ll V[31], x; ll dp[32][1LL<<32]; ll maxn; bool sosu(ll t){ if(t == 1) return false; if(t == 2) return true; if(t%2 == 0) return false; for(ll i=3; i*i<=t; i+=2){ if(t%i == 0) return false; } return true; } void solve(ll now) { if(now > x) return; if(sosu(now) && now > maxn) maxn = now; rep(i, n) { solve(now + V[i]); } return; } int main() { while(cin >> n >> x, n) { maxn = 0; rep(i, n) { cin >> V[i]; } solve(0); if(maxn == 0) { cout << "NA" << endl; } else { cout << maxn << endl; } } return 0; }
/tmp/cc4zClI3.o: in function `solve(long long)': a.cc:(.text+0xa0): relocation truncated to fit: R_X86_64_PC32 against symbol `maxn' defined in .bss section in /tmp/cc4zClI3.o a.cc:(.text+0xc1): relocation truncated to fit: R_X86_64_PC32 against symbol `maxn' defined in .bss section in /tmp/cc4zClI3.o /tmp/cc4zClI3.o: in function `main': a.cc:(.text+0x119): relocation truncated to fit: R_X86_64_PC32 against symbol `maxn' defined in .bss section in /tmp/cc4zClI3.o a.cc:(.text+0x16f): relocation truncated to fit: R_X86_64_PC32 against symbol `maxn' defined in .bss section in /tmp/cc4zClI3.o a.cc:(.text+0x1a8): relocation truncated to fit: R_X86_64_PC32 against symbol `maxn' defined in .bss section in /tmp/cc4zClI3.o collect2: error: ld returned 1 exit status
s789120981
p00202
C++
#include <iostream> #include <algorithm> #include <string> #include <vector> #include <queue> #include <bitset> #include <set> #include <map> #include <stack> #include <list> #define rep(i,n) for(int i=0;i<n;i++) #define REP(i,b,n) for(int i=b;i<n;i++) #define SORT(c) sort((c).begin(),(c).end()) #define DESCSORT(c) sort(c.begin(), c.end(), greater<int>()) const float PI = 3.1415926; static const int INFTY = (1<<30); using namespace std; typedef long long ll; typedef long double ld; int n; ll V[31], x; ll dp[32][1LL<<32]; ll maxn; bool sosu(ll t){ if(t == 1) return false; if(t == 2) return true; if(t%2 == 0) return false; for(ll i=3; i*i<=t; i+=2){ if(t%i == 0) return false; } return true; } void solve(ll now) { if(now > x) return; if(sosu(now) && now > maxn) maxn = now; rep(i, n) { solve(now + V[i]); } return; } int main() { while(cin >> n >> x, n) { maxn = 0; rep(i, n) { cin >> V[i]; } solve(0); if(maxn == 0) { cout << "NA" << endl; } else { cout << maxn << endl; } } return 0; }
/tmp/ccraDUYE.o: in function `solve(long long)': a.cc:(.text+0xa0): relocation truncated to fit: R_X86_64_PC32 against symbol `maxn' defined in .bss section in /tmp/ccraDUYE.o a.cc:(.text+0xc1): relocation truncated to fit: R_X86_64_PC32 against symbol `maxn' defined in .bss section in /tmp/ccraDUYE.o /tmp/ccraDUYE.o: in function `main': a.cc:(.text+0x119): relocation truncated to fit: R_X86_64_PC32 against symbol `maxn' defined in .bss section in /tmp/ccraDUYE.o a.cc:(.text+0x16f): relocation truncated to fit: R_X86_64_PC32 against symbol `maxn' defined in .bss section in /tmp/ccraDUYE.o a.cc:(.text+0x1a8): relocation truncated to fit: R_X86_64_PC32 against symbol `maxn' defined in .bss section in /tmp/ccraDUYE.o collect2: error: ld returned 1 exit status
s560778675
p00202
C++
#include<iostream> using namespace std ; void ans( int cnt ,int dp[] ) { int a = cnt + 1 ; LOOK : a-- ; while( dp[ a ] != 1 ) { a-- ; if( a < 2 ) { END : cout << "NA" << endl ; return ; } } if( a < 2 ) { goto END ; } if( a % 2 == 0 ) { goto LOOK ; } if( a == 2 ) { cout << a << endl ; return ; } for( int i = 3 ; i * i <= a ; i += 2 ) { if( a % i == 0 ) { goto LOOK ; } } cout << a << endl ; return ; } int main() { int n ,m ; int dmon[ 30 ] ; int j ; while( cin >> n >> m ) { if( n== 0 && m == 0 ) { break ; } int cnt = m ; long long dp[ 1000000 + 1 ] = { 0 } ; for( int i = 0 ; i < n ; i++ ) { cin >> dmon[ i ] ; } for( int i = 0 ; i + dmon[ 0 ] <= m ; ) { for( j = 0 ; j < n && i + dmon[ j ] <= m ; j++ ) { dp[ i + dmon[ j ] ] = 1 ; } i++ ; while( dp[ i ] != 1 ) { i++ ; } } ans( cnt ,dp ) ; } return 0 ; }
a.cc: In function 'int main()': a.cc:70:27: error: cannot convert 'long long int*' to 'int*' 70 | ans( cnt ,dp ) ; | ^~ | | | long long int* a.cc:3:24: note: initializing argument 2 of 'void ans(int, int*)' 3 | void ans( int cnt ,int dp[] ) | ~~~~^~~~
s696753071
p00202
C++
#include<stdio.h> int isPrime(int x){ int i; if(x<2) return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3;i*i<=x;i+=2){ if(x%i==0) return 0; } return 1; } int main() { long x,cnt,cnt2,food; int n,d=0,g,kakaku[31],youso[1000001]={0}; scanf("%d %d",&n,&x); while(n!=0&&x!=0){ for(cnt=1;cnt<=n;cnt++){ scanf("%ld",&food); youso[food]=1; kakaku[cnt]=food; } for(cnt=1;cnt<=x;cnt++){ if(youso[cnt]==1){ for(cnt2=1;cnt2<=n;cnt2++){ youso[cnt+kakaku[cnt2]]=1; if(cnt+kakaku[cnt2]>x){ break; } } } } for(cnt=x;cnt>0;cnt--){ if(youso[cnt]==1){ g=cnt; d=isPrime(g); if(d==1){ d=cnt; flag=1; printf("%d\n",d); break; } } } if(flag==0){ printf("NA\n"); } flag=0; d=0; for(cnt=1;cnt<=x;cnt++){ youso[cnt]=0; } scanf("%d %d",&n,&x); } return 0; }
a.cc: In function 'int main()': a.cc:39:41: error: 'flag' was not declared in this scope 39 | flag=1; | ^~~~ a.cc:45:20: error: 'flag' was not declared in this scope 45 | if(flag==0){ | ^~~~ a.cc:48:17: error: 'flag' was not declared in this scope 48 | flag=0; | ^~~~
s097217710
p00202
C++
#include<stdio.h> int isPrime(int x){ int i; if(x<2) return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3;i*i<=x;i+=2){ if(x%i==0) return 0; } return 1; } int main() { long x,cnt,cnt2,food; int n,d=0,g,kakaku[31],youso[1000001]={0}; scanf("%d %d",&n,&lx); while(n!=0&&x!=0){ for(cnt=1;cnt<=n;cnt++){ scanf("%ld",&food); youso[food]=1; kakaku[cnt]=food; } for(cnt=1;cnt<=x;cnt++){ if(youso[cnt]==1){ for(cnt2=1;cnt2<=n;cnt2++){ youso[cnt+kakaku[cnt2]]=1; if(cnt+kakaku[cnt2]>x){ break; } } } } for(cnt=x;cnt>0;cnt--){ if(youso[cnt]==1){ g=cnt; d=isPrime(g); if(d==1){ d=cnt; flag=1; printf("%d\n",d); break; } } } if(flag==0){ printf("NA\n"); } flag=0; d=0; for(cnt=1;cnt<=x;cnt++){ youso[cnt]=0; } scanf("%d %d",&n,&lx); } return 0; }
a.cc: In function 'int main()': a.cc:16:27: error: 'lx' was not declared in this scope; did you mean 'x'? 16 | scanf("%d %d",&n,&lx); | ^~ | x a.cc:39:41: error: 'flag' was not declared in this scope 39 | flag=1; | ^~~~ a.cc:45:20: error: 'flag' was not declared in this scope 45 | if(flag==0){ | ^~~~ a.cc:48:17: error: 'flag' was not declared in this scope 48 | flag=0; | ^~~~
s880195396
p00202
C++
#include<stdio.h> int isPrime(int x){ int i; if(x<2) return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3;i*i<=x;i+=2){ if(x%i==0) return 0; } return 1; } int main() { long x,cnt,cnt2,food; int n,d=0,g,kakaku[31],youso[1000001]={0}; scanf("%d %ld",&n,&x); while(n!=0&&x!=0){ for(cnt=1;cnt<=n;cnt++){ scanf("%ld",&food); youso[food]=1; kakaku[cnt]=food; } for(cnt=1;cnt<=x;cnt++){ if(youso[cnt]==1){ for(cnt2=1;cnt2<=n;cnt2++){ youso[cnt+kakaku[cnt2]]=1; if(cnt+kakaku[cnt2]>x){ break; } } } } for(cnt=x;cnt>0;cnt--){ if(youso[cnt]==1){ g=cnt; d=isPrime(g); if(d==1){ d=cnt; flag=1; printf("%d\n",d); break; } } } if(flag==0){ printf("NA\n"); } flag=0; d=0; for(cnt=1;cnt<=x;cnt++){ youso[cnt]=0; } scanf("%d %ld",&n,&x); } return 0; }
a.cc: In function 'int main()': a.cc:39:41: error: 'flag' was not declared in this scope 39 | flag=1; | ^~~~ a.cc:45:20: error: 'flag' was not declared in this scope 45 | if(flag==0){ | ^~~~ a.cc:48:17: error: 'flag' was not declared in this scope 48 | flag=0; | ^~~~
s934896251
p00202
C++
#include<iostream> #include<cstring> using namespace std; ?? bool dp[1000010]; int n,x; int cook[33]; int solve(); bool prime(int now); ?? int main(){ ????????while(1){ ????????????????cin >> n >> x; ????????????????if(n == 0 && x == 0) break; ????????????????memset(dp,false,x+2); ????????????????dp[0] = true; ????????????????for(int i=0;i<n;i++){ ????????????????????????cin >> cook[i]; ????????????????????????for(int k=cook[i];k<=x;k++){ ????????????????????????????????if(dp[k-cook[i]]){ ????????????????????????????????????????dp[k] = true; ????????????????????????????????} ????????????????????????} ????????????????} ????????????????int ans = solve(); ????????????????if(ans) cout << ans << endl; ????????????????else cout << "NA" << endl; ????????} } ?? int solve (){ ????????int now = x; ????????while(1){ ????????????????if(dp[now] && !(prime(now))) return now; ????????????????now--; ????????} } ?? bool prime(int now) { ????????for(int i=2;i*i<=now;i++){ ????????????????if(now%i == 0) return true; ????????} ????????return false; }
a.cc:4:1: error: expected unqualified-id before '?' token 4 | ?? | ^ a.cc:10:1: error: expected unqualified-id before '?' token 10 | ?? | ^ a.cc:30:1: error: expected unqualified-id before '?' token 30 | ?? | ^ a.cc:38:1: error: expected unqualified-id before '?' token 38 | ?? | ^
s561008673
p00202
C++
#include<bits/stdc++.h> using namespace std; bool sosu[1000005]={0}; bool check[1000005]; main(){ ????int n,k; ????int shop; ????sosu[1]=1; ????for(int i=2;i<(int)sqrt(1000005);i++){ ????????if(sosu[i]==0){ ????????????for(int j=i;j<1000005;j+=i){ ????????sosu[j]=true; ????????????} ????????} ????} ????while(1){ ????????bool a=true; ????????cin>>n>>k; ????????if(n==0&&k==0)break; ????????memset(check,false,sizeof(check)); ????????for(int i=1;i<=n;i++){ ????????????scanf("%d",&shop); ????????????check[shop]=true; ????????????for(int j=shop;j<=k;j++){ ????????if(check[j-shop]==true){ ????????????check[j]=true; ????????} ????????????}?? ????????} ????????for(int i=k;i>0;i--){ ????????????if(sosu[i]==false&&check[i]==true){ ????????cout<<i<<endl; ????????i=0; ????????a=false; ????????????} ????????} ????????if(a){ ????????????cout<<"NA"<<endl; ????????} ????} }
a.cc:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 5 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:6:1: error: expected primary-expression before '?' token 6 | ????int n,k; | ^ a.cc:6:2: error: expected primary-expression before '?' token 6 | ????int n,k; | ^ a.cc:6:3: error: expected primary-expression before '?' token 6 | ????int n,k; | ^ a.cc:6:4: error: expected primary-expression before '?' token 6 | ????int n,k; | ^ a.cc:6:5: error: expected primary-expression before 'int' 6 | ????int n,k; | ^~~ a.cc:6:5: error: expected ':' before 'int' 6 | ????int n,k; | ^~~ | : a.cc:6:5: error: expected primary-expression before 'int' 6 | ????int n,k; | ^~~ a.cc:6:5: error: expected ':' before 'int' 6 | ????int n,k; | ^~~ | : a.cc:6:5: error: expected primary-expression before 'int' 6 | ????int n,k; | ^~~ a.cc:6:5: error: expected ':' before 'int' 6 | ????int n,k; | ^~~ | : a.cc:6:5: error: expected primary-expression before 'int' 6 | ????int n,k; | ^~~ a.cc:6:5: error: expected ':' before 'int' 6 | ????int n,k; | ^~~ | : a.cc:6:5: error: expected primary-expression before 'int' 6 | ????int n,k; | ^~~ a.cc:7:1: error: expected primary-expression before '?' token 7 | ????int shop; | ^ a.cc:7:2: error: expected primary-expression before '?' token 7 | ????int shop; | ^ a.cc:7:3: error: expected primary-expression before '?' token 7 | ????int shop; | ^ a.cc:7:4: error: expected primary-expression before '?' token 7 | ????int shop; | ^ a.cc:7:5: error: expected primary-expression before 'int' 7 | ????int shop; | ^~~ a.cc:7:5: error: expected ':' before 'int' 7 | ????int shop; | ^~~ | : a.cc:7:5: error: expected primary-expression before 'int' 7 | ????int shop; | ^~~ a.cc:7:5: error: expected ':' before 'int' 7 | ????int shop; | ^~~ | : a.cc:7:5: error: expected primary-expression before 'int' 7 | ????int shop; | ^~~ a.cc:7:5: error: expected ':' before 'int' 7 | ????int shop; | ^~~ | : a.cc:7:5: error: expected primary-expression before 'int' 7 | ????int shop; | ^~~ a.cc:7:5: error: expected ':' before 'int' 7 | ????int shop; | ^~~ | : a.cc:7:5: error: expected primary-expression before 'int' 7 | ????int shop; | ^~~ a.cc:8:1: error: expected primary-expression before '?' token 8 | ????sosu[1]=1; | ^ a.cc:8:2: error: expected primary-expression before '?' token 8 | ????sosu[1]=1; | ^ a.cc:8:3: error: expected primary-expression before '?' token 8 | ????sosu[1]=1; | ^ a.cc:8:4: error: expected primary-expression before '?' token 8 | ????sosu[1]=1; | ^ a.cc:8:14: error: expected ':' before ';' token 8 | ????sosu[1]=1; | ^ | : a.cc:8:14: error: expected primary-expression before ';' token a.cc:8:14: error: expected ':' before ';' token 8 | ????sosu[1]=1; | ^ | : a.cc:8:14: error: expected primary-expression before ';' token a.cc:8:14: error: expected ':' before ';' token 8 | ????sosu[1]=1; | ^ | : a.cc:8:14: error: expected primary-expression before ';' token a.cc:8:14: error: expected ':' before ';' token 8 | ????sosu[1]=1; | ^ | : a.cc:8:14: error: expected primary-expression before ';' token a.cc:9:1: error: expected primary-expression before '?' token 9 | ????for(int i=2;i<(int)sqrt(1000005);i++){ | ^ a.cc:9:2: error: expected primary-expression before '?' token 9 | ????for(int i=2;i<(int)sqrt(1000005);i++){ | ^ a.cc:9:3: error: expected primary-expression before '?' token 9 | ????for(int i=2;i<(int)sqrt(1000005);i++){ | ^ a.cc:9:4: error: expected primary-expression before '?' token 9 | ????for(int i=2;i<(int)sqrt(1000005);i++){ | ^ a.cc:9:5: error: expected primary-expression before 'for' 9 | ????for(int i=2;i<(int)sqrt(1000005);i++){ | ^~~ a.cc:9:5: error: expected ':' before 'for' 9 | ????for(int i=2;i<(int)sqrt(1000005);i++){ | ^~~ | : a.cc:9:5: error: expected primary-expression before 'for' 9 | ????for(int i=2;i<(int)sqrt(1000005);i++){ | ^~~ a.cc:9:5: error: expected ':' before 'for' 9 | ????for(int i=2;i<(int)sqrt(1000005);i++){ | ^~~ | : a.cc:9:5: error: expected primary-expression before 'for' 9 | ????for(int i=2;i<(int)sqrt(1000005);i++){ | ^~~ a.cc:9:5: error: expected ':' before 'for' 9 | ????for(int i=2;i<(int)sqrt(1000005);i++){ | ^~~ | : a.cc:9:5: error: expected primary-expression before 'for' 9 | ????for(int i=2;i<(int)sqrt(1000005);i++){ | ^~~ a.cc:9:5: error: expected ':' before 'for' 9 | ????for(int i=2;i<(int)sqrt(1000005);i++){ | ^~~ | : a.cc:9:5: error: expected primary-expression before 'for' 9 | ????for(int i=2;i<(int)sqrt(1000005);i++){ | ^~~ a.cc:9:17: error: 'i' was not declared in this scope 9 | ????for(int i=2;i<(int)sqrt(1000005);i++){ | ^ a.cc:16:1: error: expected primary-expression before '?' token 16 | ????while(1){ | ^ a.cc:16:2: error: expected primary-expression before '?' token 16 | ????while(1){ | ^ a.cc:16:3: error: expected primary-expression before '?' token 16 | ????while(1){ | ^ a.cc:16:4: error: expected primary-expression before '?' token 16 | ????while(1){ | ^ a.cc:16:5: error: expected primary-expression before 'while' 16 | ????while(1){ | ^~~~~ a.cc:16:5: error: expected ':' before 'while' 16 | ????while(1){ | ^~~~~ | : a.cc:16:5: error: expected primary-expression before 'while' 16 | ????while(1){ | ^~~~~ a.cc:16:5: error: expected ':' before 'while' 16 | ????while(1){ | ^~~~~ | : a.cc:16:5: error: expected primary-expression before 'while' 16 | ????while(1){ | ^~~~~ a.cc:16:5: error: expected ':' before 'while' 16 | ????while(1){ | ^~~~~ | : a.cc:16:5: error: expected primary-expression before 'while' 16 | ????while(1){ | ^~~~~ a.cc:16:5: error: expected ':' before 'while' 16 | ????while(1){ | ^~~~~ | : a.cc:16:5: error: expected primary-expression before 'while' 16 | ????while(1){ | ^~~~~
s441496287
p00202
C++
#include <stdio.h> #include <math.h> #include <string.h> ?? int is_prime(int a) { ????????int last = sqrt(a) + 1; ????????int i; ?? ????????for (i = 2; i <= last; i++){ ????????????????if (a % i == 0){ ????????????????????????if (a == i) return (1); ????????????????????????return (0); ????????????????} ????????} ????????return (1); } ?? int main(void) { ????????static char dp[10000001]; ????????int n, x,i,j; ?? ????????while (scanf("%d %d", &n, &x), n){ ????????????????memset(dp, 0, sizeof(dp)); ????????????????*dp = 1; ????????????????for (i = 0; i < n; i++){ ????????????????????????int cost; ????????????????????????scanf("%d", &cost); ?? ????????????????????????for (j = 0; j + cost <= x; j++){ ????????????????????????????????if (dp[j]) dp[j + cost] = 1; ????????????????????????} ????????????????} ????????????????for (i = x; i > 0; i--){ ????????????????????????if (dp[i] && is_prime(i)){ ????????????????????????????????printf("%d\n", i); ????????????????????????????????break; ????????????????????????} ????????????????} ????????????????if (!i) puts("NA"); ????????} ????????return (0); }
a.cc:4:1: error: expected unqualified-id before '?' token 4 | ?? | ^ a.cc:18:1: error: expected unqualified-id before '?' token 18 | ?? | ^
s421620668
p00202
C++
#include <cstdio> #include <iostream> #include <cstring> #include <algorithm> #include <vector> using namespace std; bool prime[1000001],dp[1000001]; void make_prime(){ for(int i=0;i<1000001;i++) prime[i]=true; prime[0]=prime[1]=false; for(int i=2;i<=1000000;i++){ if(prime[i]){ for(int j=i*2;j<1000001;j+=i){ prime[j]=false; } } } } int n,x; vector<int> price; int main(){ make_prime(); while(1){ cin>>n>>x; if(!n && !x)break; while(price.size())price.pop(); for(int i=0;i<1000001;i++){ dp[i]=false; } for(int i=0;i<n;i++){ int tmp; cin>>tmp; price.push_back(tmp); dp[tmp]=true; } sort(price.begin(),price.end()); for(int i=0;i<n;i++){ for(int j=0;j+price[i]<=x;j++){ if(dp[j]) dp[j+price[i]]=true; } } int ans=0; for(int i=x;i>=1;i--){ if(dp[i] && prime[i]){ ans=i; break; } } if(ans==0){ cout<<"NA"<<endl; }else{ cout<<ans<<endl; } } return 0; }
a.cc: In function 'int main()': a.cc:32:30: error: 'class std::vector<int>' has no member named 'pop' 32 | while(price.size())price.pop(); | ^~~
s408108197
p00202
C++
#include<cstdio> #include<iostream> #include<algorithm> #include<string> #include<queue> #include<vector> #include<functional> #include<cmath> #include<map> #include<stack> #include<set> #include<numeric> #include<limits> #include<iterator> #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define rep(i,n) for(int i=0; i<n; i++) #define INF (1<<20) using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef pair<ll, ll> pl; typedef pair<ll, char> plc; ll arr[1000010]; void Eratosthenes(int n) { rep(i, n+1)arr[i] = 1; for (int i = 2; i <= sqrt(n); i++) { if (arr[i]) { for (int j = 0; i*(j + 2) <= n; j++) arr[i*(j + 2)] = 0; } } } int dp[1000001]; int a[31], c[31]; int main() { int n,x; cin >> n >> x; Eratosthenes(x); for (int i = 0; i < n; i++) { cin >> a[i]; c[i] = 1000000 / a[i]; } memset(dp,-1,sizeof(dp)); dp[0] = 0; for (int i = 0; i < n; i++) { for (int j = 0; j <= x; j++) { if (dp[j] >= 0) { dp[j] = c[i]; } else if (j < a[i] || dp[j - a[i]] <= 0) { dp[j] = -1; } else { dp[j] = dp[j - a[i]] - 1; } } } for (int i = x; i >= 2; i--) { if (dp[i] >= 0) { if (arr[i]) { cout << i << endl; return 0; } } } cout << "NA" << endl; return 0; }
a.cc: In function 'int main()': a.cc:56:9: error: 'memset' was not declared in this scope 56 | memset(dp,-1,sizeof(dp)); | ^~~~~~ a.cc:16:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 15 | #include<iterator> +++ |+#include <cstring> 16 |