submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s381327559
p00458
C++
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> #include <cmath> #include <algorithm> #include <vector> #include <queue> #include <stack> #include <map> #include <set> typedef long long ll; using namespace std; bool kaku[90][90],kouri[90][90]; int dfs(int a,int b){ int re=0; if(!kaku[a-1][b] && kouri[a-1][b]){ kaku[a-1][b]=true; re=max(re,dfs(a-1,b)); } if(!kaku[a][b-1] && kouri[a][b-1]){ kaku[a][b-1]=true; re=max(re,dfs(a,b-1)); } if(!kaku[a+1][b] && kouri[a+1][b]){ kaku[a+1][b]=true; re=max(re,dfs(a+1,b)); } if(!kaku[a][b+1] && kouri[a][b+1]){ kaku[a][b+1]=true; re=max(re,dfs(a,b+1)); } kaku[a][b]=false; return re+1; } void solve(int m,int n){ int a,ans=0; for(int i=0;i<n;i++) for(int j=0;j<m;j++){ scanf("%d",&a); if(a==1) kouri[i][j]=true; } for(int i=0;i<n;i++) for(int j=0;j<m;j++){ ans=max(ans,dfs(i,j)); } printf("%d\n",ans-1); return 0; } int main(){ int m,n; while(1){ scanf("%d%d",&m,&n); if(m+n==0)break; solve(m,n); } }
a.cc: In function 'void solve(int, int)': a.cc:61:12: error: return-statement with a value, in function returning 'void' [-fpermissive] 61 | return 0; | ^
s397081669
p00458
C++
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> #include <cmath> #include <algorithm> #include <vector> #include <queue> #include <stack> #include <map> #include <set> typedef long long ll; using namespace std; int dfs(int a,int b){ int re=0; bool kaku[90][90]={0},kouri[90][90]={0}; if(!kaku[a-1][b] && kouri[a-1][b]){ kaku[a-1][b]=true; re=max(re,dfs(a-1,b)); } if(!kaku[a][b-1] && kouri[a][b-1]){ kaku[a][b-1]=true; re=max(re,dfs(a,b-1)); } if(!kaku[a+1][b] && kouri[a+1][b]){ kaku[a+1][b]=true; re=max(re,dfs(a+1,b)); } if(!kaku[a][b+1] && kouri[a][b+1]){ kaku[a][b+1]=true; re=max(re,dfs(a,b+1)); } kaku[a][b]=false; return re+1; } void solve(int m,int n){ int a,ans=0; for(int i=0;i<n;i++) for(int j=0;j<m;j++){ scanf("%d",&a); if(a==1) kouri[i][j]=true; } for(int i=0;i<n;i++) for(int j=0;j<m;j++){ ans=max(ans,dfs(i,j)); } printf("%d\n",ans-1); return; } int main(){ int m,n; while(1){ scanf("%d%d",&m,&n); if(m+n==0)break; solve(m,n); } return 0; }
a.cc: In function 'void solve(int, int)': a.cc:50:17: error: 'kouri' was not declared in this scope 50 | kouri[i][j]=true; | ^~~~~
s340937317
p00458
C++
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> #include <cmath> #include <algorithm> #include <vector> #include <queue> #include <stack> #include <map> #include <set> typedef long long ll; using namespace std; bool kaku[90][90],kouri[90][90]; int dfs(int a,int b){ int re=0; if(kaku[a-1][b] || !kouri[a-1][b]) return 0; kaku[a][b]=true; me=dfs(a-1,b); re=max(re,me); me=dfs(a,b-1) re=max(re,me); me=dfs(a,b+1) re=max(re,me); me=dfs(a+1,b) re=max(re,me); kaku[a][b]=false; return re+1; } int main(){ int m,n,a,ans,me; while(1){ ans=0; scanf("%d%d",&m,&n); if(m+n==0)break; for(int i=0;i<n;i++) for(int j=0;j<m;j++){ scanf("%d",&a); kouri[i][j]=(a==1); } for(int i=0;i<n;i++) for(int j=0;j<m;j++){ me=dfs(i,j); ans=max(ans,me); } printf("%d\n",ans-1); } return 0; }
a.cc: In function 'int dfs(int, int)': a.cc:26:5: error: 'me' was not declared in this scope; did you mean 're'? 26 | me=dfs(a-1,b); | ^~ | re
s645843971
p00458
C++
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> #include <cmath> #include <algorithm> #include <vector> #include <queue> #include <stack> #include <map> #include <set> typedef long long ll; using namespace std; bool kaku[90][90],kouri[90][90]; int dfs(int a,int b){ int re=0; if(kaku[a-1][b] || !kouri[a-1][b]) return 0; kaku[a][b]=true; me=dfs(a-1,b); re=max(re,me); me=dfs(a,b-1); re=max(re,me); me=dfs(a,b+1); re=max(re,me); me=dfs(a+1,b); re=max(re,me); kaku[a][b]=false; return re+1; } int main(){ int m,n,a,ans,me; while(1){ ans=0; scanf("%d%d",&m,&n); if(m+n==0)break; for(int i=0;i<n;i++) for(int j=0;j<m;j++){ scanf("%d",&a); kouri[i][j]=(a==1); } for(int i=0;i<n;i++) for(int j=0;j<m;j++){ me=dfs(i,j); ans=max(ans,me); } printf("%d\n",ans-1); } return 0; }
a.cc: In function 'int dfs(int, int)': a.cc:26:5: error: 'me' was not declared in this scope; did you mean 're'? 26 | me=dfs(a-1,b); | ^~ | re
s807659881
p00458
C++
#include <stdio.h> #include <stdlib.h> int d0,d1,d2,d3,dmax,x,y; int board[92][92]; int Search(x, y){ if(board[x][y]==0) return 0; board[x][y]=0; d0=Search((x-1),y); dmax=d0; d1=Search((x+1),y); if(dmax<d1) dmax=d1; d2=Search(x,(y-1)); if(dmax<d2) dmax=d2; d3=Search(x,(y+1)); if(dmax<d3) dmax=d3; board[x][y]=1; return dmax+1; } int main(void) { int max=0,m,n,i,j; scanf("%d\n%d",&m,&n); for (i=1;i<=m;i++){ for(j=1;j<=n;j++){ scanf("%d",&board[i][j]); } } for (i=1;i<=m;i++){ for(j=1;j<=n;j++){ int r=Search(i,j); if (max<r) max=r; } } printf("%d\n",max); return EXIT_SUCCESS; }
a.cc:8:16: error: expression list treated as compound expression in initializer [-fpermissive] 8 | int Search(x, y){ | ^ a.cc:8:17: error: expected ',' or ';' before '{' token 8 | int Search(x, y){ | ^ a.cc: In function 'int main()': a.cc:40:41: error: 'Search' cannot be used as a function 40 | int r=Search(i,j); | ~~~~~~^~~~~
s843674235
p00458
C++
// JOI4.cpp : ??????????????? ??¢????????±????????§????????¨????????? ????????????????????????????????? // #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stack> using namespace std; stack<int> st_i, st_j; int m, n, lake[90][90], come, max = 0; bool visit[90][90]; void search(int y, int x) { st_i.push(y); st_j.push(x); if ((x < m && lake[y][x + 1] == 1) && visit[y][x + 1] == false) { come++; visit[y][x + 1] = true; search(y, x + 1); } if ((x > 0 && lake[y][x - 1] == 1) && visit[y][x - 1] == false) { come++; visit[y][x - 1] = true; search(y, x - 1); } if ((y < n && lake[y + 1][x] == 1) && visit[y + 1][x] == false) { come++; visit[y + 1][x] = true; search(y + 1, x); } if ((y > 0 && lake[y - 1][x] == 1) && visit[y - 1][x] == false) { come++; visit[y - 1][x] = true; search(y - 1, x); } if (max < come) { max = come; } come--; visit[st_i.top()][st_j.top()] = false; st_i.pop(); st_j.pop(); } int main() { scanf("%d", &m); scanf("%d", &n); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { scanf("%d", &lake[i][j]); } } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (lake[i][j] == 1) { while (st_i.empty() == false) { st_i.pop(); st_j.pop(); } for (int a = 0; a < n; a++) { for (int b = 0; b < m; b++) { visit[a][b] = false; } } come = 1; visit[i][j] = true; search(i, j); } } } printf("%d\n", max); return 0; }
a.cc: In function 'void search(int, int)': a.cc:40:13: error: reference to 'max' is ambiguous 40 | if (max < come) { | ^~~ In file included from /usr/include/c++/14/deque:62, from /usr/include/c++/14/stack:62, from a.cc:5: /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:9:31: note: 'int max' 9 | int m, n, lake[90][90], come, max = 0; | ^~~ a.cc:41:17: error: reference to 'max' is ambiguous 41 | max = come; | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:9:31: note: 'int max' 9 | int m, n, lake[90][90], come, max = 0; | ^~~ a.cc: In function 'int main()': a.cc:82:24: error: reference to 'max' is ambiguous 82 | printf("%d\n", max); | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:9:31: note: 'int max' 9 | int m, n, lake[90][90], come, max = 0; | ^~~
s375799825
p00458
C++
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stack> using namespace std; stack<int> st_i, st_j; int m, n, lake[90][90], come, max = 0; bool visit[90][90]; void search(int y, int x) { st_i.push(y); st_j.push(x); if ((x < m && lake[y][x + 1] == 1) && visit[y][x + 1] == false) { come++; visit[y][x + 1] = true; search(y, x + 1); } if ((x > 0 && lake[y][x - 1] == 1) && visit[y][x - 1] == false) { come++; visit[y][x - 1] = true; search(y, x - 1); } if ((y < n && lake[y + 1][x] == 1) && visit[y + 1][x] == false) { come++; visit[y + 1][x] = true; search(y + 1, x); } if ((y > 0 && lake[y - 1][x] == 1) && visit[y - 1][x] == false) { come++; visit[y - 1][x] = true; search(y - 1, x); } if (max < come) { max = come; } come--; visit[st_i.top()][st_j.top()] = false; st_i.pop(); st_j.pop(); } int main() { scanf("%d", &m); scanf("%d", &n); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { scanf("%d", &lake[i][j]); } } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (lake[i][j] == 1) { while (st_i.empty() == false) { st_i.pop(); st_j.pop(); } for (int a = 0; a < n; a++) { for (int b = 0; b < m; b++) { visit[a][b] = false; } } come = 1; visit[i][j] = true; search(i, j); } } } printf("%d\n", max); return 0; }
a.cc: In function 'void search(int, int)': a.cc:38:13: error: reference to 'max' is ambiguous 38 | if (max < come) { | ^~~ In file included from /usr/include/c++/14/deque:62, from /usr/include/c++/14/stack:62, from a.cc:3: /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:7:31: note: 'int max' 7 | int m, n, lake[90][90], come, max = 0; | ^~~ a.cc:39:17: error: reference to 'max' is ambiguous 39 | max = come; | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:7:31: note: 'int max' 7 | int m, n, lake[90][90], come, max = 0; | ^~~ a.cc: In function 'int main()': a.cc:80:24: error: reference to 'max' is ambiguous 80 | printf("%d\n", max); | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:7:31: note: 'int max' 7 | int m, n, lake[90][90], come, max = 0; | ^~~
s389432678
p00458
C++
10 10 1 1 0 0 0 1 0 0 1 1 1 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 1 0 1 0 0 1 1 0 0 0 1 1 1 0 1 1 0 1 0 1 0 0 0 0 1 1 1 0 0 0 1 1 0 1 0 1 0 1 1 0 1 1 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 1
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 10 | ^~
s316820291
p00458
C++
#include <queue> #include <vector> #include <iostream> #include <algorithm> using namespace std; // ------ Class ------ // class Graph1 { public: // ------ Variables ------ // static const int INF = 1000000000; int V, E; vector<vector<int> > G; // ------ Constructors ------ // Graph1() : V(0), E(0), G(vector<vector<int> >()) {} Graph1(int v) : V(v), E(0), G(vector<vector<int> >(v)) {} Graph1(vector<vector<int> > g) : V(g.size()), G(g) { for (int i = 0; i < g.size(); i++) E += g[i].size(); } // ------ Basic Functions ------ // int size() { return V; } void add1(int v1, int v2) { G[v1].push_back(v2); E++; } void add2(int v1, int v2) { add1(v1, v2); add1(v2, v1); } // ------ Operators ------ // friend bool operator==(const Graph1& g1, const Graph1& g2) { return g1.G == g2.G; } friend bool operator!=(const Graph1& g1, const Graph1& g2) { return g1.G != g2.G; } vector<int> operator[](int x) { return G[x]; } // ------ Algorithms ------ // vector<int> dist(int s) { queue<int> que; que.push(s); vector<int> d(V, INF); d[s] = 0; while (!que.empty()) { int u = que.front(); que.pop(); for (int i = 0; i < G[u].size(); i++) { if (d[G[u][i]] == INF) { d[G[u][i]] = d[u] + 1; que.push(G[u][i]); } } } return d; } }; // ------ Main ------ // int H, W, x[91][91]; int main() { while(cin >> W >> H, W) { for(int i = 0; i < H; i++) { for(int j = 0; j < W; j++) cin >> x[i][j]; } Graph1 G(H * W); for(int i = 1; i < H; i++) { for(int j = 0; j < W; j++) { int v = i * W + j; if(x[i - 1][j] && x[i][j]) G.add2(v, v - W); } } for(int i = 0; i < H; i++) { for(int j = 1; j < W; j++) { int v = i * W + j; if(x[i][j - 1] && x[i][j]) G.add2(v, v - 1); } } int ret = 0; for(int i = 0; i < H * W; i++) vector<int> v = G.dist(i), ret = max(ret, *max_element(v.begin(), v.end())); cout << ret << endl; } }
a.cc: In function 'int main()': a.cc:67:84: error: no matching function for call to 'max(std::vector<int>&, int&)' 67 | for(int i = 0; i < H * W; i++) vector<int> v = G.dist(i), ret = max(ret, *max_element(v.begin(), v.end())); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/deque:62, from /usr/include/c++/14/queue:62, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:67:84: note: deduced conflicting types for parameter 'const _Tp' ('std::vector<int>' and 'int') 67 | for(int i = 0; i < H * W; i++) vector<int> v = G.dist(i), ret = max(ret, *max_element(v.begin(), v.end())); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:4: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:67:84: note: 'std::vector<int>' is not derived from 'std::initializer_list<_Tp>' 67 | for(int i = 0; i < H * W; i++) vector<int> v = G.dist(i), ret = max(ret, *max_element(v.begin(), v.end())); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s208663999
p00458
C++
#include <iostream> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) int m, n; bool tront[90][90]; int dfs(int y, int x) { int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0}; int rep = 0; tront[ny][nx] = false; REP(i, 4) { int nx = x + dx[i], ny = y + dy[i]; if (! (nx >= 0 && nx < m && ny >= 0 && ny < n)) continue; if (! tront[ny][nx]) continue; tront[ny][nx] = false; rep = max(rep, dfs(ny, nx)); tront[ny][nx] = true; } return rep + 1; } int main() { while (true) { int ans = 0; cin >> m >> n; if (n == 0 && m == 0) break; REP(i, n) REP(j, m) cin >> tront[i][j]; REP(i, n) REP(j, m) if (tront[i][j]) ans = max(ans, dfs(i, j)); cout << ans << endl; } return 0; }
a.cc: In function 'int dfs(int, int)': a.cc:15:15: error: 'ny' was not declared in this scope; did you mean 'dy'? 15 | tront[ny][nx] = false; | ^~ | dy a.cc:15:19: error: 'nx' was not declared in this scope; did you mean 'dx'? 15 | tront[ny][nx] = false; | ^~ | dx
s122842760
p00458
C++
3 3 1 1 0 1 0 1 1 1 0 5 3 1 1 1 0 1 1 1 0 0 0 1 0 0 0 1 0 0
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 3 | ^
s727673571
p00458
C++
#include <iostream> #include <algorithm> #include <queue> #include <stack> #include <utility> #define INF 1000000000 using namespace std; typedef pair<int, int> pa; typedef pair<int, pa> pp; int M, N; int ary[100][100], dp[100][100]; bool tay[100][100]; int dxy[5] = { 0,1,0,-1,0 }; int dfs(int dis,int y, int x) { tay[y][x] = true; int res = dis; for (int i = 0; i < 4; i++) { int yy = y + dxy[i]; int xx = x + dxy[i + 1]; if (1 <= yy&&yy <= N && 1 <= xx&&axx <= M && (!tay[yy][xx]) && (ary[yy][xx])) { res = max(res, dfs(dis + 1, yy, xx)); } } tay[y][x] = false; return res; } int solve(int y, int x) { if (ary[y][x] == 0) { return 0; } for (int i = 1; i <= N; i++) fill(tay[i], tay[i] + M + 1, false); return dfs(1, y, x); } int main() { while (true) { cin >> M >> N; if (M == 0 && N == 0) break; for (int i = 1; i <= N; i++) { for (int j = 1; j <= M; j++) { cin >> ary[i][j]; dp[i][j] = INF; } } int res = 0; for (int i = 1; i <= N; i++) { for (int j = 1; j <= M; j++) { res = max(res,solve(i, j)); } } cout << res << endl; } return 0; }
a.cc: In function 'int dfs(int, int, int)': a.cc:22:50: error: 'axx' was not declared in this scope; did you mean 'xx'? 22 | if (1 <= yy&&yy <= N && 1 <= xx&&axx <= M && (!tay[yy][xx]) && (ary[yy][xx])) { | ^~~ | xx
s784305507
p00458
C++
#include<stdio.h> #include<string.h> #include<stdlib.h> int InputIce[90][90]; int Ice[92][92]; int way=0; int height; //??? int width; //??¨? int count=0,count_z=0; void Check(int a,int b,int count_z){ //a:height,b:width //?????????count++?????? count_z++; //???????????? Ice[a][b]=0; if(Ice[a-1][b]==1 && a-1>=0){ Check(a-1,b,count_z); } if(Ice[a+1][b]==1 && a+1<=height+1){ Check(a+1,b,count_z); } if(Ice[a][b-1]==1 && b-1>=0){ Check(a,b-1,count_z); } if(Ice[a][b+1]==1 && b+1<=width+1){ Check(a,b+1,count_z); } //??????£?????°??????????????????? Ice[a][b]=1; //?????????§?????????°???count?????\?????? if(count<count_z) count=count_z; } int main(void){ int i,j,n,m; //??????¨??¨???????°?????????????????? scanf("%d",&width); scanf("%d",&height); if(width==0 && height==0) break; //??°???????¶?????????????????? for(i=0;i<height;i++){ for(j=0;j<width;j++){ scanf("%d",&InputIce[i][j]); } } //?????????????????????????????????????????????0????????????§?????? for(m=0;m<=width+1;m++) Ice[0][m]=0; for(n=0;n<=width+1;n++) Ice[height+1][n]=0; for(i=1;i<=height;i++){ for(j=0;j<=width+1;j++){ if(j==0 || j==width+1) Ice[i][j]=0; else Ice[i][j]=InputIce[i-1][j-1]; } } //??????1??????¨???,Check????????????????????????????????????????????? for(i=1;i<=height;i++){ for(j=1;j<=width;j++){ if(Ice[i][j]==1) Check(i,j,0); } } //?????????count????????? printf("%d\n",count); return 0; }
a.cc: In function 'int main()': a.cc:46:31: error: break statement not within loop or switch 46 | if(width==0 && height==0) break; | ^~~~~
s366043097
p00458
C++
#include <iostream> #include <algorithm> #include<cstdio> #include<string> #include<vector> #include<map> #include<stack> #include<queue> using namespace std; int check(int b[92][92], int x, int y, int s); int max; int main() { int m,n; max = 0; cin >> m >> n; int a[92][92] = { 0 }; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> a[i][j]; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { check(a, j, i, 0); } } cout << max << endl; return 0; } int check(int b[92][92], int x, int y, int s) { b[x][y] = 0; if (b[x - 1][y] == 1) { check(b, x - 1, y, s + 1); } if (b[x + 1][y] == 1) { check(b, x + 1, y, s + 1); } if (b[x][y - 1] == 1) { check(b, x, y - 1, s + 1); } if (b[x][y + 1] == 1) { check(b, x, y + 1, s + 1); } b[x][y] = 1; if ((b[x - 1][y] || b[x + 1][y] || b[x][y - 1] || b[x][y + 1]) == 0) { if (s + 1 > max) { max = s + 1; } return 0; } }
a.cc: In function 'int main()': a.cc:14:9: error: reference to 'max' is ambiguous 14 | max = 0; | ^~~ In file included from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:11:5: note: 'int max' 11 | int max; | ^~~ a.cc:27:17: error: reference to 'max' is ambiguous 27 | cout << max << endl; | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:11:5: note: 'int max' 11 | int max; | ^~~ a.cc: In function 'int check(int (*)[92], int, int, int)': a.cc:46:29: error: reference to 'max' is ambiguous 46 | if (s + 1 > max) { | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:11:5: note: 'int max' 11 | int max; | ^~~ a.cc:47:25: error: reference to 'max' is ambiguous 47 | max = s + 1; | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:11:5: note: 'int max' 11 | int max; | ^~~ a.cc:52:1: warning: control reaches end of non-void function [-Wreturn-type] 52 | } | ^
s234256555
p00458
C++
# include <iostream> # include <algorithm> # include <vector> # include <string> # include <set> # include <map> # include <cmath> # include <iomanip> # include <functional> # include <utility> # include <stack> # include <queue> # include <list> # include <tuple> # include <unordered_map> # include <numeric> # include <complex> using namespace std; using LL = long long; using ULL = unsigned long long; constexpr int INF = 2000000000; constexpr int HINF = INF / 2; constexpr double DINF = 100000000000000000.0; constexpr long long LINF = 9223372036854775807; constexpr long long HLINF = 4500000000000000000; const double PI = acos(-1); int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 }; # define ALL(x) (x).begin(),(x).end() # define UNIQ(c) (c).erase(unique(ALL((c))), end((c))) # define mp make_pair # define eb emplace_back # define FOR(i,a,b) for(int i=(a);i<(b);++i) # define REP(i,n) FOR(i,0,n) # define INIT std::ios::sync_with_stdio(false);std::cin.tie(0); int d[90][90], dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 }, h, w; int dfs(int x, int y) { int res = 0; for (int i = 0; i < 4; i++) { int nx = x + dx[i], ny = y + dy[i]; if (0 <= nx&&nx < h && 0 <= ny&&ny < w&&d[nx][ny]) { d[nx][ny] = 0; res = max(res, dfs(nx, ny) + 1); d[nx][ny] = 1; } } return res; } int main() { while (cin >> w >> h&&w&&h) { for (int i = 0; i < 90; i++)for (int j = 0; j < 90; j++)d[i][j] = 0; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { cin >> d[i][j]; } } int ans = 0; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (d[i][j] == 1) { d[i][j] = 0; ans = max(ans, dfs(i, j) + 1); d[i][j] = 1; } } } cout << ans << endl; } }
a.cc:37:16: error: redefinition of 'int dx [4]' 37 | int d[90][90], dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 }, h, w; | ^~ a.cc:27:5: note: 'int dx [4]' previously defined here 27 | int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 }; | ^~ a.cc:37:38: error: redefinition of 'int dy [4]' 37 | int d[90][90], dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 }, h, w; | ^~ a.cc:27:27: note: 'int dy [4]' previously defined here 27 | int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 }; | ^~
s010741706
p00458
C++
#include<stdio.h> #include<iostream> #include<algorithm> #include<stack> #include<string.h> using namespace std; struct DDD{ int x,y,c; }; int main(){ while(1) int i,j,n,m,p[92][92]={0},ans=0,xm[4]={1,-1,0,0},ym[4]={0,0,1,-1},l; DDD d; stack<DDD> zect; scanf("%d%d",&m,&n); if(n==0&&m==0)break; for(i=1;i<=n;i++){ for(j=1;j<=m;j++)scanf("%d",&p[i][j]); } for(i=1;i<=n;i++){ for(j=1;j<=m;j++){ if(p[i][j]==1){ int up[92][92]; memset(up,0x7f,sizeof(up)); d.x=i; d.y=j; d.c=1; zect.push(d); while(!zect.empty()){ d=zect.top(); up[d.x][d.y]=d.c; zect.pop(); ans=max(d.c,ans); for(l=0;l<4;l++){ if(p[d.x+xm[l]][d.y+ym[l]]==1&&up[d.x+xm[l]][d.y+ym[l]]>=d.c){ d.x+=xm[l]; d.y+=ym[l]; d.c++; up[d.x][d.y]=d.c; zect.push(d); d.x-=xm[l]; d.y-=ym[l]; d.c--; } } } } } } printf("%d\n",ans); } return 0; }
a.cc: In function 'int main()': a.cc:15:15: error: 'm' was not declared in this scope 15 | scanf("%d%d",&m,&n); | ^ a.cc:15:18: error: 'n' was not declared in this scope 15 | scanf("%d%d",&m,&n); | ^ a.cc:16:15: error: break statement not within loop or switch 16 | if(n==0&&m==0)break; | ^~~~~ a.cc:17:5: error: 'i' was not declared in this scope 17 | for(i=1;i<=n;i++){ | ^ a.cc:18:5: error: 'j' was not declared in this scope 18 | for(j=1;j<=m;j++)scanf("%d",&p[i][j]); | ^ a.cc:18:30: error: 'p' was not declared in this scope 18 | for(j=1;j<=m;j++)scanf("%d",&p[i][j]); | ^ a.cc:20:5: error: 'i' was not declared in this scope 20 | for(i=1;i<=n;i++){ | ^ a.cc:21:13: error: 'j' was not declared in this scope 21 | for(j=1;j<=m;j++){ | ^ a.cc:22:20: error: 'p' was not declared in this scope 22 | if(p[i][j]==1){ | ^ a.cc:33:33: error: 'ans' was not declared in this scope; did you mean 'abs'? 33 | ans=max(d.c,ans); | ^~~ | abs a.cc:34:37: error: 'l' was not declared in this scope 34 | for(l=0;l<4;l++){ | ^ a.cc:35:50: error: 'xm' was not declared in this scope; did you mean 'tm'? 35 | if(p[d.x+xm[l]][d.y+ym[l]]==1&&up[d.x+xm[l]][d.y+ym[l]]>=d.c){ | ^~ | tm a.cc:35:61: error: 'ym' was not declared in this scope; did you mean 'tm'? 35 | if(p[d.x+xm[l]][d.y+ym[l]]==1&&up[d.x+xm[l]][d.y+ym[l]]>=d.c){ | ^~ | tm a.cc:51:15: error: 'ans' was not declared in this scope; did you mean 'abs'? 51 | printf("%d\n",ans); | ^~~ | abs a.cc: At global scope: a.cc:53:1: error: expected unqualified-id before 'return' 53 | return 0; | ^~~~~~ a.cc:54:1: error: expected declaration before '}' token 54 | } | ^
s706020547
p00458
C++
#include <stdio.h> #include <stdlib.h> int d0,d1,d2,d3,dmax,x,y; int board[92][92]; int Search(x,y){ if(board[x][y]==0) return 0; board[x][y]=0; d0=Search((x-1),y); dmax=d0; d1=Search((x+1),y); if(dmax<d1) dmax=d1; d2=Search(x,(y-1)); if(dmax<d2) dmax=d2; d3=Search(x,(y+1)); if(dmax<d3) dmax=d3; board[x][y]=1; return dmax+1; } int main(void) { int max=0,m,n,i,j; scanf("%d\n%d",&m,&n); for (i=1;i<=m;i++){ for(j=1;j<=n;j++){ scanf("%d",&board[i][j]); } } for (i=1;i<=m;i++){ for(j=1;j<=n;j++){ int r=Search(i,j); if (max<r) max=r; } } printf("%d\n",max); return EXIT_SUCCESS; }
a.cc:8:15: error: expression list treated as compound expression in initializer [-fpermissive] 8 | int Search(x,y){ | ^ a.cc:8:16: error: expected ',' or ';' before '{' token 8 | int Search(x,y){ | ^ a.cc: In function 'int main()': a.cc:41:41: error: 'Search' cannot be used as a function 41 | int r=Search(i,j); | ~~~~~~^~~~~
s590738014
p00458
C++
#include <stdio.h> #include <stdlib.h> int d0,d1,d2,d3,dmax,x,y; int board[92][92]; int Search(x,y){ if(board[x][y]==0) return 0; board[x][y]=0; d0=Search((x-1),y); dmax=d0; d1=Search((x+1),y); if(dmax<d1) dmax=d1; d2=Search(x,(y-1)); if(dmax<d2) dmax=d2; d3=Search(x,(y+1)); if(dmax<d3) dmax=d3; board[x][y]=1; return dmax+1; } int main(void) { int max=0,m,n,i,j; scanf("%d\n%d",&m,&n); for (i=1;i<=m;i++){ for(j=1;j<=n;j++){ scanf("%d",&board[i][j]); } } for (i=1;i<=m;i++){ for(j=1;j<=n;j++){ int r=Search(i,j); if (max<r) max=r; } } printf("%d\n",max); return EXIT_SUCCESS; }
a.cc:8:15: error: expression list treated as compound expression in initializer [-fpermissive] 8 | int Search(x,y){ | ^ a.cc:8:16: error: expected ',' or ';' before '{' token 8 | int Search(x,y){ | ^ a.cc: In function 'int main()': a.cc:41:41: error: 'Search' cannot be used as a function 41 | int r=Search(i,j); | ~~~~~~^~~~~
s106141616
p00458
C++
import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class Main { int INF = 1 << 28; int w, h; boolean[][] map; int cnt; int max; void run() { Scanner sc = new Scanner(System.in); for(;;) { int w = sc.nextInt(); int h = sc.nextInt(); if( (w|h) == 0 ) break; map = new boolean[h+2][w+2]; for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) map[i][j] = sc.nextInt() == 1; max = 0; for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) { cnt = 0; if(map[i][j]) dfs(i, j); } System.out.println(max); } } int dx[] = {-1, 0, 1, 0}; int dy[] = {0, -1, 0, 1}; void dfs(int x, int y) { cnt++; max = max(cnt, max); map[x][y] = false; for(int i=0;i<4;i++) { if(map[ x+dx[i] ][y+dy[i]]) dfs(x+dx[i], y+dy[i]); } map[x][y] = true; cnt--; } public static void main(String[] args) { new Main().run(); } void debug(Object... os) { System.err.println(Arrays.deepToString(os)); } }
a.cc:2:1: error: 'import' does not name a type 2 | import java.util.*; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import static java.lang.Math.*; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: 'import' does not name a type 4 | import static java.util.Arrays.*; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:6:1: error: expected unqualified-id before 'public' 6 | public class Main { | ^~~~~~
s551482955
p00458
C++
#include<cstdio> #include<stack> #include<queue> #include<cstdlib> #include<algorithm> #include<string> #include<cstring> using namespace std; int cell[100][100]; int dx[] = {1, 0, 0, -1}; int dy[] = {0, 1, -1, 0}; int n,m; int ans; void debug(){ puts(""); for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ printf("%s",cell[i][j]?"□":"■"); }puts(""); } } void func(int c, int x, int y){ if(c>ans)ans=c; // debug(); // printf("%d\n", &c); for(int i = 0; i < 4; i++){ if(x+dx[i] = 0 && x+dx[i] =< n && y+dy[i] > 0 && y+dy[i]<=m && cell[x+dx[i]][y+dy[i]]){ cell[x][y]=0; func(c+1,x+dx[i], y+dy[i]); cell[x][y]=1; } } } int main(void){ while(scanf("%d%d", &m, &n),m){ for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ scanf("%d", &cell[i][j]); } } for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ if(cell[i][j])func(1, i, j); } } printf("%d\n", ans); ans=0; } return 0; }
a.cc: In function 'void func(int, int, int)': a.cc:31:44: error: expected primary-expression before '<' token 31 | if(x+dx[i] = 0 && x+dx[i] =< n && y+dy[i] > 0 && y+dy[i]<=m && cell[x+dx[i]][y+dy[i]]){ | ^
s873307667
p00458
C++
/*****include*****/ #include <iostream> #include <fstream> /*****デバッグ定義*****/ //#define DEBUG /*****マクロ定義*****/ /*****名前空間*****/ using namespace std; /*****グローバル変数置き場*****/ int Field[91][91]; bool Visited[91][91]; static int g_num = 0; static int g_max_num = 0; /*****その他関数置き場*****/ void dfs(int sx,int sy){ const int dx[] = {0,1,0,-1}; const int dy[] = {-1,0,1,0}; if(!Visited[sy][sx] && Field[sy][sx]){ Visited[sy][sx] = true; for(int i=0;i<4;i++){ g_num++; dfs(sx+dx[i],sy+dy[i]); } } g_num--; if(g_num > g_max_num) g_max_num = g_num; return; } /*****main関数*****/ void main(){ /*****ファイルオープン*****/ #ifdef DEBUG ofstream fout("output.txt"); ifstream fin("input.txt"); if(!fout || !fin){ cout << "Can't open the file.\n"; return; } #endif /*****変数置き場*****/ int height; int width; /*****処理部*****/ while(1){ g_max_num = 0; for(int k=0;k<91;k++){ for(int r=0;r<91;r++){ Visited[k][r] = false; Field[k][r] = 0; } } cin >> width >> height; if(width == 0 && height == 0) break; for(int i=0;i<height;i++){ for(int j=0;j<width;j++){ cin >> Field[i+1][j+1]; } } for(int i=0;i<=height;i++){ for(int j=0;j<=width;j++){ if(Field[i][j] == 1){ for(int k=0;k<=height;k++){ for(int r=0;r<=width;r++){ Visited[k][r] = false; } } g_num = 1; dfs(j,i); } } } cout << g_max_num << endl; } /*****処理終了後*****/ #ifdef DEBUG fout.close(); fin.close(); #endif }
a.cc:33:1: error: '::main' must return 'int' 33 | void main(){ | ^~~~
s805062963
p00458
C++
#include <cstdio> #include <algorithm> #include <queue> using namespace std; typedef pair<int,int> p; int main(){ int x[90][90]; int y[90][90]={},max=0,themax=0,ax,ay,m,n; int dx[4]={1,0,-1,0}; int dy[4]={0,1,0,-1}; queue<p>que; scanf("%d%d",&m,&n); for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ scanf("%d",&x[i][j]); }} for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if(x[i][j]==1){ que.clear(); for(int f=0;i<n;i++){ for(int g=0;j<m;j++){ y[f][g]=10000; }} que.push(p(i,j)); y[i][j]=0; while(que.size()){ p w=que.front(); que.pop(); for(int q=0;q<4;i++){ ax=w.first+dx[q]; ay=w.second+dy[q]; if(ax>=1 && ax<=n && ay>=1 &&ay<=m && y[ax][ay]==10000 && x[ax][ay]!=0){ y[ax][ay]=y[w.first][w.second]+1; que.push(p(ax,ay)); } } } if(themax<y[ax][ay]){themax=y[ax][ay];} }}} printf("%d\n",themax-10000); return 0; }
a.cc: In function 'int main()': a.cc:20:13: error: 'class std::queue<std::pair<int, int> >' has no member named 'clear' 20 | que.clear(); | ^~~~~
s489850590
p00458
C++
#include <cstdio> #include <algorithm> #include <queue> using namespace std; typedef pair<int,int> p; int main(){ while(1){ int x[90][90]; int y[90][90]={},max=0,themax=0,ax,ay,m,n; int dx[4]={1,0,-1,0}; int dy[4]={0,1,0,-1}; queue<p>que; scanf("%d%d",&m,&n); if(m==0) break; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ scanf("%d",&x[i][j]); }} for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if(x[i][j]==1){ for(int f=0;i<n;i++){ for(int g=0;j<m;j++){ y[f][g]=10000; }} que.push(p(i,j)); y[i][j]=0; while(que.size()){ p w=que.front(); que.pop(); for(int q=0;q<4;i++){ ax=w.first+dx[q]; ay=w.second+dy[q]; if(ax>=1 && ax<=n && ay>=1 &&ay<=m && y[ax][ay]==10000 && x[ax][ay]!=0){ y[ax][ay]=y[w.first][w.second]+1; que.push(p(ax,ay)); } } } if(themax<y[ax][ay]){themax=y[ax][ay];} }}} printf("%d\n",themax); return 0; }
a.cc: In function 'int main()': a.cc:44:2: error: expected '}' at end of input 44 | } | ^ a.cc:6:11: note: to match this '{' 6 | int main(){ | ^
s474425676
p00458
C++
#include <cstdio> #include <algorithm> #include <queue> using namespace std; typedef pair<int,int> p; int main(){ int x[90][90]; int y[90][90]={},max=0,themax=0,ax,ay,m,n; int dx[4]={1,0,-1,0}; int dy[4]={0,1,0,-1}; queue<p>que; fscanf(infile,"%d%d",&m,&n); for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ scanf("%d",&x[i][j]); }} for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if(x[i][j]==1){ for(int f=0;f<n;f++){ for(int g=0;g<m;g++){ y[f][g]=10000; }} que.push(p(i,j)); y[i][j]=0; while(que.size()){ p w=que.front(); que.pop(); for(int q=0;q<4;q++){ ax=w.first+dx[q]; ay=w.second+dy[q]; if(ax>=1 && ax<=n && ay>=1 &&ay<=m && y[ax][ay]==10000 && x[ax][ay]!=0){ y[ax][ay]=y[w.first][w.second]+1; que.push(p(ax,ay)); } } } if(themax<y[ax][ay]){themax=y[ax][ay];} }}} printf("%d\n",themax); return 0; }
a.cc: In function 'int main()': a.cc:13:8: error: 'infile' was not declared in this scope; did you mean 'inline'? 13 | fscanf(infile,"%d%d",&m,&n); | ^~~~~~ | inline
s478512660
p00458
C++
#include <cstdio> #include <algorithm> #include <queue> using namespace std; typedef pair<int,int> p; int main(){ int x[90][90]; int y[90][90]={},max=0,themax=0,ax,ay,m,n; int dx[4]={1,0,-1,0}; int dy[4]={0,1,0,-1}; queue<p>que; fscanf(infile,"%d%d",&m,&n); for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ scanf("%d",&x[i][j]); }} for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if(x[i][j]==1){ for(int f=0;f<n;f++){ for(int g=0;g<m;g++){ y[f][g]=-10000; }} que.push(p(i,j)); y[i][j]=0; while(que.size()){ p w=que.front(); que.pop(); for(int q=0;q<4;q++){ ax=w.first+dx[q]; ay=w.second+dy[q]; if(ax>=1 && ax<=n && ay>=1 &&ay<=m && y[ax][ay]==-10000 && x[ax][ay]!=0){ y[ax][ay]=y[w.first][w.second]+1; que.push(p(ax,ay)); } } } if(themax<y[ax][ay]){themax=y[ax][ay];} }}} printf("%d\n",themax); return 0; }
a.cc: In function 'int main()': a.cc:13:8: error: 'infile' was not declared in this scope; did you mean 'inline'? 13 | fscanf(infile,"%d%d",&m,&n); | ^~~~~~ | inline
s664511819
p00458
C++
#include<cstdio> #include<cctype> #include<iostream> #include<algorithm> using namespace std; bool ice[100][100]; int dx[4]={0,1,0,-1}; int dy[4]={-1,0,1,0}; int n,m; int bre(int x,int y,int c); int main(){ int i,j; while(1){ scanf("%d %d",&m,&n); if(!m && !n) break; memset(ice,false,sizeof(ice)); for(i=1;i<=n;i++){ for(j=1;j<=m;j++){ int a; scanf("%d", &a); if(a) ice[i][j] = true; } } int ans = 0; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ if(ice[i][j]){ ice[i][j] = false; ans = max(ans,bre(i,j,1)); ice[i][j] = true; } } } cout << ans << endl; } } int bre(int x,int y,int c){ int ret = c; for(int i = 0; i < 4; i++){ int nx = x + dx[i]; int ny = y + dy[i]; if(ice[nx][ny]){ ice[nx][ny] = false; ret = max(ret,bre(nx,ny,c+1)); ice[nx][ny] = true; } } return ret; }
a.cc: In function 'int main()': a.cc:20:5: error: 'memset' was not declared in this scope 20 | memset(ice,false,sizeof(ice)); | ^~~~~~ a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 4 | #include<algorithm> +++ |+#include <cstring> 5 |
s916328586
p00458
C++
#include<cstdio> #include<cctype> #include<iostream> #include<algorithm> using namespace std; bool ice[100][100]; int dx[4]={0,1,0,-1}; int dy[4]={-1,0,1,0}; int n,m; int bre(int x,int y,int c){ int ret = c; for(int i = 0; i < 4; i++){ int nx = x + dx[i]; int ny = y + dy[i]; if(ice[nx][ny]){ ice[nx][ny] = false; ret = max(ret,bre(nx,ny,c+1)); ice[nx][ny] = true; } } return ret; } int main(){ int i,j; while(1){ scanf("%d %d",&m,&n); if(!m && !n) break; memset(ice,false,sizeof(ice)); for(i=1;i<=n;i++){ for(j=1;j<=m;j++){ int a; scanf("%d", &a); if(a) ice[i][j] = true; } } int ans = 0; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ if(ice[i][j]){ ice[i][j] = false; ans = max(ans,bre(i,j,1)); ice[i][j] = true; } } } cout << ans << endl; } }
a.cc: In function 'int main()': a.cc:32:5: error: 'memset' was not declared in this scope 32 | memset(ice,false,sizeof(ice)); | ^~~~~~ a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 4 | #include<algorithm> +++ |+#include <cstring> 5 |
s894752699
p00458
C++
#include<cstdio> #include<iostream> #include<algorithm> using namespace std; bool ice[100][100]; int dx[4]={0,1,0,-1}; int dy[4]={-1,0,1,0}; int n,m; int bre(int x,int y,int c){ int ret = c; for(int i = 0; i < 4; i++){ int nx = x + dx[i]; int ny = y + dy[i]; if(ice[nx][ny]){ ice[nx][ny] = false; ret = max(ret,bre(nx,ny,c+1)); ice[nx][ny] = true; } } return ret; } int main(void){ int i,j; while(1){ scanf("%d %d",&m,&n); if(!m && !n) break; memset(ice,false,sizeof(ice)); for(i=1;i<=n;i++){ for(j=1;j<=m;j++){ int a; scanf("%d", &a); if(a) ice[i][j] = true; } } int ans = 0; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ if(ice[i][j]){ ice[i][j] = false; ans = max(ans,bre(i,j,1)); ice[i][j] = true; } } } cout << ans << endl; } }
a.cc: In function 'int main()': a.cc:31:5: error: 'memset' was not declared in this scope 31 | memset(ice,false,sizeof(ice)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include<algorithm> +++ |+#include <cstring> 4 |
s344008607
p00458
C++
#include <iostream> #include <stack> using namespace std; int main(){ int m; int n; int b; int c; int h;//現在の割った氷 int i;//割った氷の最高 int j; int k; while(cin >>m>>n){ if(m==0&&n==0){break;} int a[n][m]; int g[n][m];//氷が残っているか b=0; while(b<n){ c=0; while(c<m){ cin >>a[b][c]; g[b][c]=a[b][c]; c=c+1;} b=b+1;} stack<int> d;//nの値 stack<int> e;//mの値 stack<int> f;//次進む経路0上1下2左3右 i=0; b=0; while(b<n){ c=0; while(c<m){ d.push(b); e.push(c); f.push(1); h=1; k=0; while(h!=0){ if(f.top()==0&&d.top()!=0&&g[d.top()-1][e.top()]==1&&k==0){d.push(d.top()-1); e.push(e.top()); f.push(0); g[d.top()][e.top()]=0; h=h+1;} else if(f.top()==1&&d.top()!=n&&g[d.top()+1][e.top()]==1&&k==0){d.push(d.top()+1); e.push(e.top()); f.push(0); g[d.top()][e.top()]=0; h=h+1;} else if(f.top()==2&&d.top()!=0&&g[d.top()][e.top()-1]==1&&k==0){d.push(d.top()); e.push(e.top()-1); f.push(0); g[d.top()][e.top()]=0; h=h+1;} else if(f.top()==3&&d.top()!=m&&g[d.top()][e.top()+1]==1&&k==0){d.push(d.top()); e.push(e.top()+1); f.push(0); g[d.top()][e.top()]=0; h=h+1;} k=0; else if(f.top()!=3){j=f.top(); f.pop(); f.push(j+1);} else{g[d.top()][e.top()]=1; h=h-1; d.pop(); e.pop(); f.pop(); k=1;} if(h>i){i=h;} } c=c+1;} b=b+1;} cout <<i<<endl;}}
a.cc: In function 'int main()': a.cc:44:1: error: 'else' without a previous 'if' 44 | else if(f.top()!=3){j=f.top(); f.pop(); f.push(j+1);} | ^~~~
s496485808
p00458
C++
#include <stdio.h> #include <stdlib.h> int d0,d1,d2,d3,dmax,x,y; int board[92][92]; int Search(x, y){ if(board[x][y]==0) return 0; board[x][y]=0; d0=Search((x-1),y); dmax=d0; d1=Search((x+1),y); if(dmax<d1) dmax=d1; d2=Search(x,(y-1)); if(dmax<d2) dmax=d2; d3=Search(x,(y+1)); if(dmax<d3) dmax=d3; board[x][y]=1; return dmax+1; } int main(void) { int max=0,m,n,i,j; scanf("%d\n%d",&m,&n); for (i=1;i<=m;i++){ for(j=1;j<=n;j++){ scanf("%d",&board[i][j]); } } for (i=1;i<=m;i++){ for(j=1;j<=n;j++){ int r=Search(i,j); if (max<r) max=r; } } printf("%d\n",max); return EXIT_SUCCESS; }
a.cc:8:16: error: expression list treated as compound expression in initializer [-fpermissive] 8 | int Search(x, y){ | ^ a.cc:8:17: error: expected ',' or ';' before '{' token 8 | int Search(x, y){ | ^ a.cc: In function 'int main()': a.cc:40:41: error: 'Search' cannot be used as a function 40 | int r=Search(i,j); | ~~~~~~^~~~~
s444990693
p00458
C++
#include <cstdio> #include <vector> #include <algorithm> using namespace std; int solve(int x, int y, int w, int h, vector<vector<int> > f) { int ans = 0; if(f[x][y] == 0) return 0; f[x][y] = 0; int dx[] = {-1, 0, 0, 1}; int dy[] = {0, -1, 1, 0}; for(int i = 0; i < 4; ++i) { int nx = dx[i] + x; int ny = dy[i] + y; if(nx < 0 || ny < 0 || nx >= w || ny >= h) continue; int tmp = solve(nx, ny, w, h, f); ans = max(ans, tmp); } f[x][y] = 1; return ans + 1; } int main() { while(true) { int w, h; vector<vector<int> f; scanf("%d%d", &w, &h); if(w == 0) break; f.resize(w); for(int i = 0; i < w; ++i) f[i].resize(h); for(int y = 0; y < h; ++y) { for(int x = 0; x < w; ++x) scanf("%d", &f[x][y]); } int ans = 0; for(int x = 0; x < w; ++x) { for(int y = 0; y < h; ++y) ans = max(ans, solve(x, y, w, h, f)); } printf("%d\n", ans); } return 0; }
a.cc: In function 'int main()': a.cc:36:20: error: template argument 1 is invalid 36 | vector<vector<int> f; | ^ a.cc:36:20: error: template argument 2 is invalid a.cc:40:1: error: 'f' was not declared in this scope 40 | f.resize(w); | ^
s989175912
p00458
C++
#include <cstdio> #include <vector> #include <algorithm> using namespace std; int solve(int x, int y, int w, int h, vector<vector<int> > &f) { int ans = 0; if(f[x][y] == 0) return 0; f[x][y] = 0; int dx[] = {-1, 0, 0, 1}; int dy[] = {0, -1, 1, 0}; for(int i = 0; i < 4; ++i) { int nx = dx[i] + x; int ny = dy[i] + y; if(nx < 0 || ny < 0 || nx >= w || ny >= h) continue; int tmp = solve(nx, ny, w, h, f); ans = max(ans, tmp); } f[x][y] = 1; return ans + 1; } int main() { while(true) { int w, h; vector<vector<int> f; scanf("%d%d", &w, &h); if(w == 0) break; f.resize(w); for(int i = 0; i < w; ++i) f[i].resize(h); for(int y = 0; y < h; ++y) { for(int x = 0; x < w; ++x) scanf("%d", &f[x][y]); } int ans = 0; for(int x = 0; x < w; ++x) { for(int y = 0; y < h; ++y) ans = max(ans, solve(x, y, w, h, f)); } printf("%d\n", ans); } return 0; }
a.cc: In function 'int main()': a.cc:36:20: error: template argument 1 is invalid 36 | vector<vector<int> f; | ^ a.cc:36:20: error: template argument 2 is invalid a.cc:40:1: error: 'f' was not declared in this scope 40 | f.resize(w); | ^
s297976441
p00458
C++
#include <stdio.h> #include <string.h> int map[90][90],m,n; int main(){ int x,max = 0,i,j; memset(map,0,sizeof(map)); scanf("%d",&m); scanf("%d",&n); for(i=0;i<m;i++){ for(j=0;j<n;j++)scanf("%d",&map[i][j]); } for(i=0;i<m;i++){ for(j=0;j<n;j++){ x = rec(i,j); if(max < x)max = x; } } printf("%d\n",max); } int rec(i,j){ int max = 0,x; if(map[i][j] == 0)return 0; map[i][j] = 0; if(i > 0){ x = rec(i-1,j); if(max < x)max = x; } if(i+1 < m){ x = rec(i+1,j); if(max < x)max = x; } if(j > 0){ x = rec(i,j-1); if(max < x)max = x; } if(j+1 < n){ x = rec(i,j+1); if(max < x)max = x; } map[i][j] = 1; return max + 1; }
a.cc: In function 'int main()': a.cc:16:17: error: 'rec' was not declared in this scope 16 | x = rec(i,j); | ^~~ a.cc: At global scope: a.cc:23:9: error: 'i' was not declared in this scope 23 | int rec(i,j){ | ^ a.cc:23:11: error: 'j' was not declared in this scope 23 | int rec(i,j){ | ^ a.cc:23:12: error: expression list treated as compound expression in initializer [-fpermissive] 23 | int rec(i,j){ | ^
s181005665
p00458
C++
#include <stdio.h> #include <string.h> int map[90][90],m,n; int rec(i,j); int main(){ int x,max = 0,i,j; memset(map,0,sizeof(map)); scanf("%d",&m); scanf("%d",&n); for(i=0;i<m;i++){ for(j=0;j<n;j++)scanf("%d",&map[i][j]); } for(i=0;i<m;i++){ for(j=0;j<n;j++){ x = rec(i,j); if(max < x)max = x; } } printf("%d\n",max); } int rec(i,j){ int max = 0,x; if(map[i][j] == 0)return 0; map[i][j] = 0; if(i > 0){ x = rec(i-1,j); if(max < x)max = x; } if(i+1 < m){ x = rec(i+1,j); if(max < x)max = x; } if(j > 0){ x = rec(i,j-1); if(max < x)max = x; } if(j+1 < n){ x = rec(i,j+1); if(max < x)max = x; } map[i][j] = 1; return max + 1; }
a.cc:5:9: error: 'i' was not declared in this scope 5 | int rec(i,j); | ^ a.cc:5:11: error: 'j' was not declared in this scope 5 | int rec(i,j); | ^ a.cc:5:12: error: expression list treated as compound expression in initializer [-fpermissive] 5 | int rec(i,j); | ^ a.cc: In function 'int main()': a.cc:17:20: error: 'rec' cannot be used as a function 17 | x = rec(i,j); | ~~~^~~~~ a.cc: At global scope: a.cc:24:5: error: redefinition of 'int rec' 24 | int rec(i,j){ | ^~~ a.cc:5:5: note: 'int rec' previously defined here 5 | int rec(i,j); | ^~~ a.cc:24:9: error: 'i' was not declared in this scope 24 | int rec(i,j){ | ^ a.cc:24:11: error: 'j' was not declared in this scope 24 | int rec(i,j){ | ^
s377303736
p00458
C++
#include<cstdio> #include<algorithm> using namespace std; int w[100][100]; int a,b; int ans(int a,int b){ int num=0; w[a][b]=0; if(a>0 && w[a-1][b]==1){ num=max(num,solve(a-1,b)); } if(b>0 && w[a][b-1]==1){ num=max(num,solve(a,b-1)); } if(a<b-1 && w[a+1][b]==1){ num=max(num,solve(a+1,b)); } if(b<a-1 && w[a][b+1]==1){ num=max(num,solve(a,b+1)); } w[a][b]=1; return num++; } int main(){ while(1){ scanf("%d %d",&a,&b); if(!a) break; for(int i=0;i<b;i++){ for(int j=0;j<a;j++){ scanf("%d",&w[i][j]); } } int aaa=0; for(int i=0;i<b;i++){ for(int j=0;j<a;j++){ if(w[i][j]==1) aaa=max(aaa,ans(i,j)); } } printf("%d\n",aaa); } }
a.cc: In function 'int ans(int, int)': a.cc:10:21: error: 'solve' was not declared in this scope 10 | num=max(num,solve(a-1,b)); | ^~~~~ a.cc:13:21: error: 'solve' was not declared in this scope 13 | num=max(num,solve(a,b-1)); | ^~~~~ a.cc:16:21: error: 'solve' was not declared in this scope 16 | num=max(num,solve(a+1,b)); | ^~~~~ a.cc:19:20: error: 'solve' was not declared in this scope 19 | num=max(num,solve(a,b+1)); | ^~~~~
s081017897
p00458
C++
#include<cstdio> #include<algorithm> using namespace std; int w[100][100]; int a,b; int ans(int a,int b){ int num=0; w[a][b]=0; if(a>0 && w[a-1][b]==1){ num=max(num,solve(a-1,b)); } if(b>0 && w[a][b-1]==1){ num=max(num,solve(a,b-1)); } if(a<b-1 && w[a+1][b]==1){ num=max(num,solve(a+1,b)); } if(b<a-1 && w[a][b+1]==1){ num=max(num,solve(a,b+1)); } w[a][b]=1; return num+1; } int main(){ while(1){ scanf("%d %d",&a,&b); if(!a) break; for(int i=0;i<b;i++){ for(int j=0;j<a;j++){ scanf("%d",&w[i][j]); } } int aaa=0; for(int i=0;i<b;i++){ for(int j=0;j<a;j++){ if(w[i][j]==1) aaa=max(aaa,ans(i,j)); } } printf("%d\n",aaa); } }
a.cc: In function 'int ans(int, int)': a.cc:10:21: error: 'solve' was not declared in this scope 10 | num=max(num,solve(a-1,b)); | ^~~~~ a.cc:13:21: error: 'solve' was not declared in this scope 13 | num=max(num,solve(a,b-1)); | ^~~~~ a.cc:16:21: error: 'solve' was not declared in this scope 16 | num=max(num,solve(a+1,b)); | ^~~~~ a.cc:19:20: error: 'solve' was not declared in this scope 19 | num=max(num,solve(a,b+1)); | ^~~~~
s052471575
p00458
C++
#include<cstdio> int e[100][100],n,m; int ax[4]={0, 1, 0, -1},ay[4]={1, 0, -1, 0}; int dfs(int x, int y){ int i,w=1; for(int i=0;i<4;i++){ int nx = x + ax[i]; int ny = y + ay[i]; if(nx < 0 || nx >= n || ny < 0 || ny >= m){ continue; } e[x][y] = 0; if(e[nx][ny] == 1){ int num=dfs(nx, ny) + 1; if(num>w){ w=num; } } e[x][y] = 1; } return w; } int main(){ while(1){ int ans=0; scanf("%d %d",&m,&n); if(!m){ break; } for(inti = 0;i < n;i++){ for(int j=0;j<m;j++){ scanf("%d",e[i]+j); } } for(i = 0;i < n;i++){ for(j = 0;j < m;j++){ if(e[i][j]){ int num=dfs(i, j); if(num>ans){ ans=num; } } } } printf("%d\n",ans); } return 0; }
a.cc: In function 'int main()': a.cc:30:8: error: 'inti' was not declared in this scope; did you mean 'int'? 30 | for(inti = 0;i < n;i++){ | ^~~~ | int a.cc:30:17: error: 'i' was not declared in this scope 30 | for(inti = 0;i < n;i++){ | ^ a.cc:35:6: error: 'i' was not declared in this scope 35 | for(i = 0;i < n;i++){ | ^ a.cc:36:7: error: 'j' was not declared in this scope 36 | for(j = 0;j < m;j++){ | ^
s452317272
p00458
C++
/********************** aoj_0535 Crossing Black Ice ***********************/ #include <iostream> #include <stack> using namespace std; struct pos{ int x; //座標 int y; int count; //進んだ数 int after_move[100][100]; //今まで進んだ配列を記憶する }; int main(){ while(1){ int m, n; cin >> m >> n; if(m == 0 || n == 0) break; /*入力*/ int ice[100][100]; //与えられる配列(外壁あり) for(int i = 0; i < 100; i++){ //配列の初期か for(int j = 0; j < 100; j++){ ice[i][j] = 0; } } for(int i = 1; i <= n; i++){ //配列をもらう for(int j = 1; j <= m; j++){ cin >> ice[i][j]; } } /*最大移動数を数える(深さ優先探索)*/ stack<pos> sta; //スタック int ans = 0; //回答する移動数の数 for(int i = 1; i <= n; i++){ //与えられた配列分まわす for(int j = 1; j <= m; j++){ /*深さ優先探索*/ if(ice[i][j]){ //氷だったらそこをスタート地点にする pos p; //スタックに入れるpを作りスタート地点の情報を入れていく p.x = j; p.y = i; p.count = 1; memcpy(p.after_move, ice, sizeof(p.after_move)); p.after_move[i][j] = 0; //スタート地点の氷を割っておく sta.push(p); /*全パターン探す*/ while(!sta.empty()){ //stackが空になったら終了 int x1[] = {-1, 0, 1, 0}, y1[] = {0, 1, 0, -1}; //移動先 p = sta.top(); //スタックを取り出す sta.pop(); //スタックの先頭を削除 ans = max(ans, p.count); //進んだ数が最大なら記憶する for(int k = 0; k < 4; k++){ //上下左右の4カ所分まわす pos p1 = p; //移動 p1.x += x1[k]; p1.y += y1[k]; //移動先 if(p1.after_move[p1.y][p1.x]){ //異動先が氷なら p1.after_move[p1.y][p1.x] = 0; //氷を割る p1.count++; //進んだ数を増やす sta.push(p1); //スタックにいれる } } } } } } /*出力*/ cout << ans << endl; } return 0; }
a.cc: In function 'int main()': a.cc:44:41: error: 'memcpy' was not declared in this scope 44 | memcpy(p.after_move, ice, sizeof(p.after_move)); | ^~~~~~ a.cc:7:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 6 | #include <stack> +++ |+#include <cstring> 7 | using namespace std;
s501723918
p00458
C++
/********************** aoj_0535 Crossing Black Ice ***********************/ #include <iostream> #include <stack> #include <cstdio> using namespace std; struct pos{ int x; //座標 int y; int count; //進んだ数 int after_move[100][100]; //今まで進んだ配列を記憶する }; int main(){ while(1){ int m, n; cin >> m >> n; if(m == 0 || n == 0) break; /*入力*/ int ice[100][100]; //与えられる配列(外壁あり) for(int i = 0; i < 100; i++){ //配列の初期か for(int j = 0; j < 100; j++){ ice[i][j] = 0; } } for(int i = 1; i <= n; i++){ //配列をもらう for(int j = 1; j <= m; j++){ cin >> ice[i][j]; } } /*最大移動数を数える(深さ優先探索)*/ stack<pos> sta; //スタック int ans = 0; //回答する移動数の数 for(int i = 1; i <= n; i++){ //与えられた配列分まわす for(int j = 1; j <= m; j++){ /*深さ優先探索*/ if(ice[i][j]){ //氷だったらそこをスタート地点にする pos p; //スタックに入れるpを作りスタート地点の情報を入れていく p.x = j; p.y = i; p.count = 1; memcpy(p.after_move, ice, sizeof(p.after_move)); p.after_move[i][j] = 0; //スタート地点の氷を割っておく sta.push(p); /*全パターン探す*/ while(!sta.empty()){ //stackが空になったら終了 int x1[] = {-1, 0, 1, 0}, y1[] = {0, 1, 0, -1}; //移動先 p = sta.top(); //スタックを取り出す sta.pop(); //スタックの先頭を削除 ans = max(ans, p.count); //進んだ数が最大なら記憶する for(int k = 0; k < 4; k++){ //上下左右の4カ所分まわす pos p1 = p; //移動 p1.x += x1[k]; p1.y += y1[k]; //移動先 if(p1.after_move[p1.y][p1.x]){ //異動先が氷なら p1.after_move[p1.y][p1.x] = 0; //氷を割る p1.count++; //進んだ数を増やす sta.push(p1); //スタックにいれる } } } } } } /*出力*/ cout << ans << endl; } return 0; }
a.cc: In function 'int main()': a.cc:45:41: error: 'memcpy' was not declared in this scope 45 | memcpy(p.after_move, ice, sizeof(p.after_move)); | ^~~~~~ a.cc:8:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 7 | #include <cstdio> +++ |+#include <cstring> 8 | using namespace std;
s108662576
p00458
C++
/********************** aoj_0535 Crossing Black Ice ***********************/ #include <iostream> #include <stack> using namespace std; struct pos{ int x; //座標 int y; int count; //進んだ数 int after_move[100][100]; //今まで進んだ配列を記憶する }; int main(){ while(1){ int m, n; cin >> m >> n; if(m == 0 || n == 0) break; /*入力*/ int ice[100][100]; //与えられる配列(外壁あり) for(int i = 0; i < 100; i++){ //配列の初期か for(int j = 0; j < 100; j++){ ice[i][j] = 0; } } for(int i = 1; i <= n; i++){ //配列をもらう for(int j = 1; j <= m; j++){ cin >> ice[i][j]; } } /*最大移動数を数える(深さ優先探索)*/ stack<pos> sta; //スタック int ans = 0; //回答する移動数の数 for(int i = 1; i <= n; i++){ //与えられた配列分まわす for(int j = 1; j <= m; j++){ /*深さ優先探索*/ if(ice[i][j]){ //氷だったらそこをスタート地点にする pos p; //スタックに入れるpを作りスタート地点の情報を入れていく p.x = j; p.y = i; p.count = 1; memcpy(p.after_move, ice, sizeof(p.after_move)); p.after_move[i][j] = 0; //スタート地点の氷を割っておく sta.push(p); /*全パターン探す*/ while(!sta.empty()){ //stackが空になったら終了 int x1[] = {-1, 0, 1, 0}, y1[] = {0, 1, 0, -1}; //移動先 p = sta.top(); //スタックを取り出す sta.pop(); //スタックの先頭を削除 ans = max(ans, p.count); //進んだ数が最大なら記憶する for(int k = 0; k < 4; k++){ //上下左右の4カ所分まわす pos p1 = p; //移動 p1.x += x1[k]; p1.y += y1[k]; //移動先 if(p1.after_move[p1.y][p1.x]){ //異動先が氷なら p1.after_move[p1.y][p1.x] = 0; //氷を割る p1.count++; //進んだ数を増やす sta.push(p1); //スタックにいれる } } } } } } /*出力*/ cout << ans << endl; } return 0; }
a.cc: In function 'int main()': a.cc:44:41: error: 'memcpy' was not declared in this scope 44 | memcpy(p.after_move, ice, sizeof(p.after_move)); | ^~~~~~ a.cc:7:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 6 | #include <stack> +++ |+#include <cstring> 7 | using namespace std;
s386705266
p00458
C++
/********************** aoj_0535 Crossing Black Ice ***********************/ #include <iostream> #include <stack> #include <string> using namespace std; struct pos{ int x; //座標 int y; int count; //進んだ数 int after_move[100][100]; //今まで進んだ配列を記憶する }; int main(){ while(1){ int m, n; cin >> m >> n; if(m == 0 || n == 0) break; /*入力*/ int ice[100][100]; //与えられる配列(外壁あり) for(int i = 0; i < 100; i++){ //配列の初期か for(int j = 0; j < 100; j++){ ice[i][j] = 0; } } for(int i = 1; i <= n; i++){ //配列をもらう for(int j = 1; j <= m; j++){ cin >> ice[i][j]; } } /*最大移動数を数える(深さ優先探索)*/ stack<pos> sta; //スタック int ans = 0; //回答する移動数の数 for(int i = 1; i <= n; i++){ //与えられた配列分まわす for(int j = 1; j <= m; j++){ /*深さ優先探索*/ if(ice[i][j]){ //氷だったらそこをスタート地点にする pos p; //スタックに入れるpを作りスタート地点の情報を入れていく p.x = j; p.y = i; p.count = 1; memcpy(p.after_move, ice, sizeof(p.after_move)); p.after_move[i][j] = 0; //スタート地点の氷を割っておく sta.push(p); /*全パターン探す*/ while(!sta.empty()){ //stackが空になったら終了 int x1[] = {-1, 0, 1, 0}, y1[] = {0, 1, 0, -1}; //移動先 p = sta.top(); //スタックを取り出す sta.pop(); //スタックの先頭を削除 ans = max(ans, p.count); //進んだ数が最大なら記憶する for(int k = 0; k < 4; k++){ //上下左右の4カ所分まわす pos p1 = p; //移動 p1.x += x1[k]; p1.y += y1[k]; //移動先 if(p1.after_move[p1.y][p1.x]){ //異動先が氷なら p1.after_move[p1.y][p1.x] = 0; //氷を割る p1.count++; //進んだ数を増やす sta.push(p1); //スタックにいれる } } } } } } /*出力*/ cout << ans << endl; } return 0; }
a.cc: In function 'int main()': a.cc:45:41: error: 'memcpy' was not declared in this scope 45 | memcpy(p.after_move, ice, sizeof(p.after_move)); | ^~~~~~ a.cc:7:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 6 | #include <stack> +++ |+#include <cstring> 7 | #include <string>
s216174119
p00458
C++
#include <iostream> #include <algorithm> #include <vector> #include <queue> #include <map> #include <stack> #define FOR(i, a, b) for(int i = (a); i < (b); i++) #define rep(i, n) for(int i = 0; i < (n); i++) #define MP make_pair #define X first #define Y second using namespace std; typedef vector<int> vi; typedef pair<int, int> P; const int INF = 1<<29; int field[100][100]; int visit[100][100]; int dx[] = {0, 1, 0, -1}; int dy[] = {1, 0, -1, 0}; int w, h; int dfs(int x, int y){ int res = 0; rep(i, 4){ int nx = x+dx[i], ny = y+dy[i]; if(nx < 0 || nx >= w || ny < 0 || ny >= h) continue; if(!field[ny][nx]) continue; if(visit[ny][nx]) continue; visit[ny][nx] = 1; res = max(res, dfs(nx, ny)); visit[ny][nx] = 0; } return res+1; } int main(){ while(cin >> w >> h, w|h){ rep(i, h) rep(j, w) cin >> field[i][j]; int ans = 0; rep(i, h) rep(j, w){ if(field[i][j]){ memset(visit, 0, sizeof(visit)); visit[i][j] = 1; ans = max(ans, dfs(j, i)); } } cout << ans << endl; } return 0; }
a.cc: In function 'int main()': a.cc:49:33: error: 'memset' was not declared in this scope 49 | memset(visit, 0, sizeof(visit)); | ^~~~~~ a.cc:7:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 6 | #include <stack> +++ |+#include <cstring> 7 |
s674902535
p00458
C++
#include "stdio.h" int ido(int x,int y,int a[90][90]) { a[x][y] = 0; int max = 0; if(x + 1 < 90) { if(a[x + 1][y] == 1) { int w = ido(x + 1,y,a) if(max < w) { max = w; } } } if(0 <= x - 1) { int w = ido(x - 1,y,a); if(max < w) { max = w; } } if(y + 1 < 90) { int w = ido(x,y + 1,a); if(max < w) { max = w; } } if(0 <= y - 1) { int w = ido(x ,y - 1,a); if(max < w) { max = w; } } return max + 1; } int main() { while(1) { int m,n; scanf("%d",&m); scanf("%d",&n); if(n == 0 && m == 0) { break; } int aw[90][90]; for(int i = 0; i < n; i++) { for(int ii = 0; ii < m; ii++) { scanf("%d",&aw[i][ii]); } } int h1,h2; for(int i = 0; i < n; i++) { for(int ii = 0; ii < m; ii++) { if(aw[i][ii] == 1) { h1 = i; h2 = ii; goto aa; } } } aa: printf("%d\n",ido(h1,h2,aw)); } return 0; }
a.cc: In function 'int ido(int, int, int (*)[90])': a.cc:12:1: error: expected ',' or ';' before 'if' 12 | if(max < w) | ^~
s830427393
p00458
C++
#include "stdio.h" int ido(int x,int y,int aw[90][90]) { a[x][y] = 0; int a[90][90]; for(int i = 0; i < 90; i++) { for(int ii = 0; ii < 90; ii++) { a[i][ii] = aw[i][ii]; } } int max = 0; if(x + 1 < 90) { if(a[x + 1][y] == 1) { int w = ido(x + 1,y,a); if(max < w) { max = w; } } } if(0 <= x - 1) { if(a[x - 1][y] == 1) { int w = ido(x - 1,y,a); if(max < w) { max = w; } } } if(y + 1 < 90) { if(a[x][y + 1] == 1) { int w = ido(x,y + 1,a); if(max < w) { max = w; } } } if(0 <= y - 1) { if(a[x][y - 1] == 1) { int w = ido(x ,y - 1,a); if(max < w) { max = w; } } } return max + 1; } int main() { while(1) { int m,n; scanf("%d",&m); scanf("%d",&n); if(n == 0 && m == 0) { break; } int aw[90][90]; for(int i = 0; i < 90; i++) { for(int ii = 0; ii < 90; ii++) { aw[i][ii] = 0; } } for(int i = 0; i < n; i++) { for(int ii = 0; ii < m; ii++) { scanf("%d",&aw[i][ii]); } } int h1,h2; for(int i = 0; i < n; i++) { for(int ii = 0; ii < m; ii++) { if(aw[i][ii] == 1) { h1 = i; h2 = ii; goto aa; } } } aa: printf("%d\n",ido(h1,h2,aw)); } return 0; }
a.cc: In function 'int ido(int, int, int (*)[90])': a.cc:5:1: error: 'a' was not declared in this scope 5 | a[x][y] = 0; | ^
s855806380
p00458
C++
/********************** aoj_0535 Crossing Black Ice ***********************/ #include <iostream> #include <stack> using namespace std; struct pos{ int x; //座標 int y; int count; //進んだ数 int field[100][100]; //今まで進んだ配列を記憶する }; int main(){ while(1){ int m, n; cin >> m >> n; if(m == 0 || n == 0) break; /*入力*/ int ice[100][100] = {{0}}; //与えられる配列(外壁あり) for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ cin >> ice[i][j]; } } /*最大移動数を数える(深さ優先探索)*/ stack<pos> sta; //スタック int ans = 0; //回答する移動数の数 for(int i = 1; i <= n; i++){ //与えられた配列分まわす for(int j = 1; j <= m; j++){ /*深さ優先探索*/ if(ice[i][j]){ //氷だったらそこをスタート地点にする pos p; //スタックに入れるpを作りスタート地点の情報を入れていく p.x = j; p.y = i; p.count = 1; memcpy(p.field, ice, sizeof(p.field)); p.field[i][j] = 0; //スタート地点の氷を割っておく sta.push(p); /*全パターン探す*/ while(!sta.empty()){ //stackが空になったら終了 int x1[] = {-1, 0, 1, 0}, y1[] = {0, 1, 0, -1}; //移動先 p = sta.top(); //スタックを取り出す sta.pop(); //スタックの先頭を削除 ans = max(ans, p.count); //進んだ数が最大なら記憶する for(int k = 0; k < 4; k++){ //上下左右の4カ所分まわす pos p1 = p; //移動 p1.x += x1[k]; p1.y += y1[k]; //移動先 if(p1.field[p1.y][p1.x]){ //異動先が氷なら p1.field[p1.y][p1.x] = 0; //氷を割る p1.count++; //進んだ数を増やす sta.push(p1); //スタックにいれる } } } } } } /*出力*/ cout << ans << endl; } return 0; }
a.cc: In function 'int main()': a.cc:40:41: error: 'memcpy' was not declared in this scope 40 | memcpy(p.field, ice, sizeof(p.field)); | ^~~~~~ a.cc:7:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 6 | #include <stack> +++ |+#include <cstring> 7 | using namespace std;
s128822730
p00458
C++
/********************** aoj_0535 Crossing Black Ice ***********************/ #include <iostream> #include <stack> #include <cstdlib> using namespace std; struct pos{ int x; //座標 int y; int count; //進んだ数 int field[100][100]; //今まで進んだ配列を記憶する }; int main(){ while(1){ int m, n; cin >> m >> n; if(m == 0 || n == 0) break; /*入力*/ int ice[100][100] = {{0}}; //与えられる配列(外壁あり) for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ cin >> ice[i][j]; } } /*最大移動数を数える(深さ優先探索)*/ stack<pos> sta; //スタック int ans = 0; //回答する移動数の数 for(int i = 1; i <= n; i++){ //与えられた配列分まわす for(int j = 1; j <= m; j++){ /*深さ優先探索*/ if(ice[i][j]){ //氷だったらそこをスタート地点にする pos p; //スタックに入れるpを作りスタート地点の情報を入れていく p.x = j; p.y = i; p.count = 1; memcpy(p.field, ice, sizeof(p.field)); p.field[i][j] = 0; //スタート地点の氷を割っておく sta.push(p); /*全パターン探す*/ while(!sta.empty()){ //stackが空になったら終了 int x1[] = {-1, 0, 1, 0}, y1[] = {0, 1, 0, -1}; //移動先 p = sta.top(); //スタックを取り出す sta.pop(); //スタックの先頭を削除 ans = max(ans, p.count); //進んだ数が最大なら記憶する for(int k = 0; k < 4; k++){ //上下左右の4カ所分まわす pos p1 = p; //移動 p1.x += x1[k]; p1.y += y1[k]; //移動先 if(p1.field[p1.y][p1.x]){ //異動先が氷なら p1.field[p1.y][p1.x] = 0; //氷を割る p1.count++; //進んだ数を増やす sta.push(p1); //スタックにいれる } } } } } } /*出力*/ cout << ans << endl; } return 0; }
a.cc: In function 'int main()': a.cc:41:41: error: 'memcpy' was not declared in this scope 41 | memcpy(p.field, ice, sizeof(p.field)); | ^~~~~~ a.cc:8:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 7 | #include <cstdlib> +++ |+#include <cstring> 8 | using namespace std;
s427531440
p00459
C
#include <stdio.h> #include <string.h> unsigned int a[1000000000]; unsigned int s[1000000000]; unsigned int t[1000000000]; unsigned int u[1000000000]; int main() { int n,m,p,q,r,i,x,y; for(;;){ scanf("%d",&n); if(n == 0) break; for(i=0;i<n;i++){ a[i] = i+1; } scanf("%d",&m); scanf("%d%d%d",&p,&q,&r); for(i=0;i<m;i++){ scanf("%d%d",&x,&y); memcpy(s,a,sizeof(int)*x); memcpy(t,a+x,sizeof(int)*(y-x)); memcpy(u,a+y,sizeof(int)*(n-y)); memcpy(a,u,sizeof(int)*(n-y)); memcpy(a+(n-y),t,sizeof(int)*(y-x)); memcpy(a+(n-x),s,sizeof(int)*x); } x = 0; for(i=p-1;i<q;i++){ if(a[i] <= r) x++; } printf("%d\n",x); } return 0; }
/tmp/ccUGPDGx.o: in function `main': main.c:(.text+0xe4): relocation truncated to fit: R_X86_64_PC32 against symbol `s' defined in .bss section in /tmp/ccUGPDGx.o main.c:(.text+0x120): relocation truncated to fit: R_X86_64_PC32 against symbol `t' defined in .bss section in /tmp/ccUGPDGx.o main.c:(.text+0x15c): relocation truncated to fit: R_X86_64_PC32 against symbol `u' defined in .bss section in /tmp/ccUGPDGx.o main.c:(.text+0x17d): relocation truncated to fit: R_X86_64_PC32 against symbol `u' defined in .bss section in /tmp/ccUGPDGx.o main.c:(.text+0x1c6): relocation truncated to fit: R_X86_64_PC32 against symbol `t' defined in .bss section in /tmp/ccUGPDGx.o main.c:(.text+0x202): relocation truncated to fit: R_X86_64_PC32 against symbol `s' defined in .bss section in /tmp/ccUGPDGx.o collect2: error: ld returned 1 exit status
s661075634
p00459
C
#include<stdio.h> #include<string.h> #define Max(x,y) ((x>y)?x:y) typedef struct card{ int s,t,n; }card; card x[10500],y[10500]; int main(){ int i,j,n,m,p,q,r,a,b,c,d;//(a,b)cut c,d:absolute point int xn,yn,e,f,g;//f:flag g: while(1){ scanf("%d",&n); if(n==0)break; scanf("%d%d%d%d",&m,&p,&q,&r); xn=1; x[0]=(card){1,n+1,n}; while(m--){ scanf("%d%d",&a,&b); d=n+1;c=d-x[xn-1].n; f=0;yn=0; //for(i=0;i<xn;i++)printf("(%d-%d)",x[i].s,x[i].t); //printf("\n"); for(i=xn-1;i>=0;){ //printf("c:%d d:%d\n",c,d); if(f==0){ if(c==b+1){ for(j=i;j<xn;j++)y[yn++]=x[j]; f=1;g=i-1;i--; }else if(c<b+1 && b+1<d){ y[yn++]=(card){x[i].s+b+1-c,x[i].t,x[i].t-x[i].s-b-1+c}; for(j=i+1;j<xn;j++)y[yn++]=x[j]; x[i]=(card){x[i].s,x[i].s+b+1-c,b+1-c}; //for(j=0;j<=i;j++)printf("(%d-%d)",x[j].s,x[j].t); //printf("\n"); f=1;g=i;d=c+x[i].n; continue; }else i--; }else{ if(c==a+1){ for(j=i;j<=g;j++)y[yn++]=x[j]; for(j=0;j<i;j++)y[yn++]=x[j]; break; }else if(c<a+1 && a+1<d){ y[yn++]=(card){x[i].s+a+1-c,x[i].t,x[i].t-x[i].s-a-1+c}; for(j=i+1;j<=g;j++)y[yn++]=x[j]; x[i]=(card){x[i].s,x[i].s+a+1-c,a+1-c}; for(j=0;j<=i;j++)y[yn++]=x[j]; break; }else i--; } d=c; c=d-x[i].n; } //for(i=0;i<yn;i++)printf("(%d-%d)",y[i].s,y[i].t); //printf("\n"); memcpy(x,y,sizeof(card)*yn); xn=yn; } //printf("\n"); //for(i=0;i<xn;i++)printf("(%d - %d)",x[i].s,x[i].t); //printf("\n\n"); a=0;b=1; for(i=0;i<xn;i++){ /*if(b<p){ if(q>=b){ if(q<b+x[i].n){ a+=(x[i].s>r)?0:( (r<=x[i].s+q-b)?(r-x[i].s+1):(q-b+1) ); break; } else a+=(x[i].s>r)?0:( (r<x[i].t)?(r-x[i].s+1):(x[i].n) ); } }else if(b==p){ if(q<b+x[i].n){ a+=(x[i].s>r)?0:( (r<=x[i].s+q-p)?(r-x[i].s+1):(q-b+1) ); break; } else a+=(x[i].s>r)?0:( (r<x[i].t)?(r-x[i].s+1):(x[i].n) ); }else if(b<p && p<b+x[i].n){ if(q<b+x[i].n){ a+=(x[i].s+p-b>r)?0:( (r<=x[i].s+q-b)?(r-x[i].s-p+b+1):(q-p+1) ); } else a+=(x[i].s+p-b>r)?0:( (r<x[i].t)?(r-x[i].s-p+b+1):(x[i].n-p+b) ); }*/ //printf("%d ",b); if(p<b+x[i].n && b<=q){ c=x[i].s; d=x[i].t; if(b<p)c+=p-b; if(b+x[i].n>q)d+=q-b-x[i].n+1; if(d>r)d=r+1; if(c>r)c=d+1; //printf("%d %d",c,d); > printf("%d %d",c,d); > a+=Max(0,d-c); } //printf("\n"); b+=x[i].n; } printf("%d\n",a); } return 0; }
main.c: In function 'main': main.c:96:33: error: expected expression before '>' token 96 | > printf("%d %d",c,d); | ^ main.c:97:1: error: expected expression before '>' token 97 | > | ^
s897595717
p00459
C
#include <stdio.h> int main(){ int i, j, n, m, p, q, r; while(1){ scanf("%d",&n); if(n == 0) break; scanf("%d",&m); scanf("%d%d%d",&p,&q,&r); int d[n], a[n], b[n], c[n], x[m][2], count = 0; for(i = 0 ; i < n ; i++){ d[i] = i + 1; } for(i = 0 ; i < m ; i++){ for(j = 0 ; j < 2 ; j++){ scanf("%d",&x[i][j]); } } for(j = 0 ; j < m ; j++){ for(i = 0 ; i < x[j][0] ; i++){ a[i] = d[i]; } for(i = 0 ; i < x[j][1]-x[j][0] ; i++){ b[i] = d[x[k][0]]; } for(i = 0 ; i < n-x[j][1] ; i++){ c[i] = d[x[j][1]-x[j][0]]; } for(i = 0 ; i < n-x[j][1] ; i++){ d[i] = c[i]; } for(i = 0 ; i < x[j][1]-x[j][0] ; i++){ d[n-x[j][1]] = b[i]; } for(i = 0 ; i < x[j][0] ; i++){ d[x[j][1]-x[j][0]] = a[i]; } } for(i = 0 ; i < q-p+1 ; i++){ if(d[i+p] <= r) count++; } printf("%d\n",count); } return 0; }
main.c: In function 'main': main.c:25:20: error: 'k' undeclared (first use in this function) 25 | b[i] = d[x[k][0]]; | ^ main.c:25:20: note: each undeclared identifier is reported only once for each function it appears in
s287507936
p00459
C
#include <stdio.h> #include <stdlib.h> //Impossibly large number #define ILN 1000000002 typedef struct tag_node{ int num; struct tag_node *next_series; struct tag_node *next_one; }NODE; NODE *createNode(int i); NODE *retNode(NODE *START,int i); void shuffle(int x,int y,NODE *HEAD,NODE *TAIL,int n); int countCard(NODE *P,int p,int q,int r); void dbgPrint(NODE *P); void freeNode(NODE *P); int main(){ int n,m; int p,q,r; int x,y; NODE *HEAD,*TAIL,*Pnode; int i; int ans; while(1){ scanf("%d\n",&n); if(!n)break; scanf("%d\n",&m); scanf("%d %d %d\n",&p,&q,&r); HEAD=createNode(0); TAIL=createNode(ILN); Pnode=createNode(1); HEAD->next_one=Pnode; Pnode=createNode(n); HEAD->next_one->next_series=Pnode; Pnode->next_one=TAIL; //dbgPrint(HEAD); for(i=0;i<m;i++){ scanf("%d %d\n",&x,&y); shuffle(x,y,HEAD,TAIL,n); //dbgPrint(HEAD); } ans=countCard(HEAD,p,q,r); printf("%d\n",ans); freeNode(HEAD); } return 0; } NODE *createNode(int i){ NODE *P; P=(NODE *)malloc(sizeof(NODE)); if(!P){printf("malloc error");exit(1);} P->num=i; P->next_series=NULL; P->next_one=NULL; return P; } void dbgPrint(NODE *P){ printf(P->num==ILN?"E":"%d",P->num); if(P->next_series!=NULL){printf("=>");dbgPrint(P->next_series);} if(P->next_one!=NULL){printf("->");dbgPrint(P->next_one);} if(P->next_series==NULL && P->next_one==NULL )printf("-*\n"); return; } void freeNode(NODE *P){ if(P->next_series!=NULL)freeNode(P->next_series); if(P->next_one!=NULL )free(P->next_one); if(P->next_series==NULL && P->next_one==NULL )free(P); } NODE *retNode(NODE *START,int i){ // return i-th pointer from START; // if not exists :add Node & connect next_one(->) // (a) 0->1=>9->ILN 5th? // 0->1=>5->6=>9->ILN-* return ( 5-> ) // (b) 0->1=>9->ILN 8th? // 0->1=>8->9->ILN-* return ( 8-> ) NODE *P; int d; if(i==0){ if(START->next_series==NULL)return START; P=createNode(START->num+1); P->next_series=START->next_series; START->next_series=NULL; START->next_one=P; return START; } if(START->num==ILN)return START; if(START->next_one!=NULL){ return retNode(START->next_one,i-1); } if(START->next_series!=NULL){ d=START->next_series->num - START->num; if(i>=d){ return retNode(START->next_series,i-d); }else if(i==d-1){ //case(b) P=createNode(START->num+i); P->next_one=START->next_series; START->next_series=P; return retNode(P,0); }else if(i<d-1){ //case(a) P=createNode(START->num+i+1); P->next_series=START->next_series; START->next_series=P; P=createNode(START->num+i); P->next_one=START->next_series; START->next_series=P; return retNode(P,0); } } } return START; } void shuffle(int x,int y,NODE *HEAD,NODE *TAIL,int n){ NODE *Px,*Py,*Pend; NODE *Ptmp; Px=retNode(HEAD,x); Py=retNode(HEAD,y); Pend=retNode(HEAD,n); Ptmp=HEAD->next_one;//bak HEAD->next_one=Py->next_one; Pend->next_one=Px->next_one; Py->next_one=Ptmp; Px->next_one=TAIL; return; } int countCard(NODE *P,int p,int q,int r){ //printf("p=%d,q=%d,r=%d\t",p,q,r);dbgPrint(P); static int cnt; NODE *Pp,*Pq; int d,p0,q0; if(P->num==0){ cnt=0; Pp=retNode(P,p); Pq=retNode(P,q); countCard(Pp,0,q-p,r); } if(p==0){ if(q==0){ if(P->num<=r)cnt++; return cnt; } if(P->next_one!=NULL){ if(P->num<=r)cnt++; countCard(P->next_one,0,q-1,r); } if(P->next_series!=NULL){ p0=P->num; q0=P->next_series->num; d=q0-p0; if(r<p0){cnt=cnt; }else if(q0<=r){cnt+=d; }else if(p0<=r && r<q0){cnt+=r-p0+1;} countCard(P->next_series,0,q-d,r); } } return cnt; }
main.c:127:9: error: expected identifier or '(' before 'return' 127 | return START; | ^~~~~~ main.c:128:1: error: expected identifier or '(' before '}' token 128 | } | ^
s974796700
p00459
C++
#include<iostream> using namespace std; long long int main() { long long int size; long long int *card; long long int *dommy; long long int search[3]; long long int shuffle[2]; long long int time; while (cin >> size&&size) { card = new long long int[size]; for (long long int i = 0; i < size; ++i) { card[i] = i + 1; } cin >> time; for (long long int i = 0; i < 3; ++i) { cin >> search[i]; } for (long long int i = 0; i < time; ++i) { for (long long int j = 0; j < 2; ++j) { cin>>shuffle[j]; } dommy = new long long int[size]; for (long long int j = shuffle[1]; j < size; ++j) { dommy[j - shuffle[1]] = card[j]; } for (long long int j = shuffle[0]; j < shuffle[1]; ++j) { dommy[size - shuffle[1] + j - shuffle[0]] = card[j]; } for (long long int j = 0; j < shuffle[0]; ++j) { dommy[size - shuffle[0] + j] = card[j]; } card = dommy; } long long int answer = 0; for (long long int i = search[0] - 1; i < search[1]; ++i) { if (card[i] <= search[2]) { ++answer; } } cout << answer << endl; } return 0; }
a.cc:3:11: error: '::main' must return 'int' 3 | long long int main() { | ^~~
s413105426
p00459
C++
#define _CRT_SECURE_NO_WARNINGS #include "bits/stdc++.h" using namespace std; #define int int64_t #define CHOOSE(a) CHOOSE2 a #define CHOOSE2(a0,a1,a2,a3,x,...) x #define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal) #define REP2(i, s, n) REP1(i, s, < signed(n), ++) #define REP3(i, n) REP2(i, 0, n) #define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__) #define rrep(i, s) rep(i, s, >= 0, --) #define all(c) begin(c), end(c) #define maxup(ans, x) (ans = (ans < x ? x : ans)) #define minup(ans, x) (ans = (ans > x ? x : ans)) #define breakif(cond) if(cond) break; else using VV = vector<vector<int>>; using V = vector<int>; using P = pair<int, int>; using IP = pair<int, P>; template<typename T> inline void input(vector<T>& v) { for (auto& x : v) cin >> x; } signed main() { int n, m, p, q, r; vector<vector<P>> v(5001, vector<P>(5000)); while (cin >> n && n) { cin >> m >> p >> q >> r; v[0].clear(); v[0].push_back(P(1, n)); vector<P> a(m), b(m), c(m); rep(i, m) { a.clear(); b.clear(); c.clear(); v[i + 1].clear(); int x, y; cin >> x >> y; int sum = 0; for (P p : v[i]) { int tmp = p.second - p.first + 1; if (sum + tmp <= x) { a.push_back(p); } else if (y <= sum) { c.push_back(p); } else if (x <= sum && sum + tmp <= y) { b.push_back(p); } else if (sum < x && y < sum + tmp) { P fst = P(p.first, p.first + (x - sum) - 1); P snd = P(fst.second + 1, fst.second + (y - x)); P trd = P(snd.second + 1, p.second); a.push_back(fst); b.push_back(snd); c.push_back(trd); } else if (sum < x && x < sum + tmp) { P fst = P(p.first, p.first + (x - sum) - 1); P snd = P(fst.second + 1, p.second); a.push_back(fst); b.push_back(snd); } else if (sum < y && y < sum + tmp) { P fst = P(p.first, p.first + (y - sum) - 1); P snd = P(fst.second + 1, p.second); b.push_back(fst); c.push_back(snd); } sum += tmp; } v[i + 1].insert(v[i + 1].end(), all(c)); v[i + 1].insert(v[i + 1].end(), all(b)); v[i + 1].insert(v[i + 1].end(), all(a)); } int sum = 0; int ans = 0; p--; for (P item : v[m]) { int tmp = item.second - item.first + 1; P ra = P(1ll << 60, 1ll << 60); if (sum + tmp <= p) { //skip } else if (q <= sum) { //skip } else if (p <= sum && sum + tmp <= q) { ra = item; } else if (sum < p && q < sum + tmp) { int l = item.first + (p - sum); int r = l + (q - p); ra = P(l, r); } else if (sum < p && p < sum + tmp) { int l = item.first + (p - sum); int r = item.second; ra = P(l, r); } else if (sum < q && q < sum + tmp) { ra = P(item.first, item.first + (q - sum) - 1); } ans += max(0ll, min(r, ra.second) - ra.first + 1); sum += tmp; } cout << ans << endl; } }
a.cc: In function 'int main()': a.cc:99:35: error: no matching function for call to 'max(long long int, long int)' 99 | ans += max(0ll, min(r, ra.second) - ra.first + 1); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:2: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:99:35: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long int') 99 | ans += max(0ll, min(r, ra.second) - ra.first + 1); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:99:35: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 99 | ans += max(0ll, min(r, ra.second) - ra.first + 1); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s777128165
p00459
C++
#if 1 #include <fstream> #include <string> #include <sstream> #include <iostream> #include <locale> #include <codecvt> #include <memory> #include <iostream> #include <fstream> #include <string> #include <locale> #include <iomanip> #include <utility> #include <algorithm> int32_t N; int32_t p, q, r; int32_t M; int32_t X[5000]; int32_t Y[5000]; int32_t K[2][5000 * 3][2];//0: s 1: ?????° auto K_end = K[0]; inline void insert(decltype(K_end) pos, int32_t ns, int32_t nn) { for (auto iter = K_end; iter != pos; --iter) { (*iter)[0] = (*(iter - 1))[0]; (*iter)[1] = (*(iter - 1))[1]; } (*pos)[0] = ns; (*pos)[1] = nn; ++K_end; } int main() { std::cin >> N; while (N != 0) { std::cin >> M >> p >> q >> r; for (int32_t i = 0; i < M; ++i) { std::cin >> X[i] >> Y[i]; } K_end = K[0]; (*K_end)[0] = 1; (*K_end)[1] = N; ++K_end; for (int32_t i = 0; i < M; ++i) { //?????? int num_buf = 0; decltype(K_end) x_end_pos = nullptr; for (auto iter = K[i & 1]; iter != K_end; ++iter) { num_buf += (*iter)[1]; if (X[i] <= num_buf) { auto nn = (num_buf - X[i]); (*iter)[1] -= nn; insert(iter + 1, (*iter)[0] + (*iter)[1], nn); x_end_pos = iter + 1; break; } } num_buf = X[i]; decltype(K_end) y_end_pos = nullptr; for (auto iter = x_end_pos; iter != K_end; ++iter) { num_buf += (*iter)[1]; if (Y[i] <= num_buf) { auto nn = (num_buf - Y[i]); (*iter)[1] -= nn; insert(iter + 1, (*iter)[0] + (*iter)[1], nn); y_end_pos = iter + 1; break; } } //???????????? auto iter_out = K[(i + 1) & 1]; for (auto iter = y_end_pos; iter != K_end; ++iter) { (*iter_out)[0] = (*iter)[0]; (*iter_out)[1] = (*iter)[1]; ++iter_out; } for (auto iter = x_end_pos; iter != y_end_pos; ++iter) { (*iter_out)[0] = (*iter)[0]; (*iter_out)[1] = (*iter)[1]; ++iter_out; } for (auto iter = K[i & 1]; iter != x_end_pos; ++iter) { (*iter_out)[0] = (*iter)[0]; (*iter_out)[1] = (*iter)[1]; ++iter_out; } K_end = iter_out; } //?????? int32_t num_buf = 0; int32_t count = 0; for (auto iter = K[M & 1]; iter != K_end; ++iter) { auto n_numbuf = num_buf + (*iter)[1]; auto add = std::min(r - ((*iter)[0] - 1), (*iter)[1]); if (num_buf < p) { add -= (p - 1 - num_buf); } if (q < n_numbuf) { add = std::min(add, q - num_buf); } count += std::max(0, add); num_buf = n_numbuf; } std::cout << count << '\n'; std::cin >> N; } }
a.cc:2: error: unterminated #if 2 | #if 1
s027427103
p00459
C++
#include <algorithm> #include <climits> #include <iostream> #include <string> #include <vector> #include<queue> #include<queue> #define P pair<int,int> using namespace std; queue<P>operator +(queue<P>a, queue<P>b) { while (b.size()) { a.push(b.front()); b.pop(); } return a; } queue<P>L; int main() { int a; while (cin >> a, a) { int b, c, d, e; scanf("%d%d%d%d", &b, &c, &d, &e); queue<P>tmp; swap(L, tmp); L.push(P(1, a)); for (int f = 0; f < b; f++) { int g, h; scanf("%d%d", &g, &h); queue<P>A, B, C; int sum = 0, j = 0; while (L.size()) { P i = L.front(); L.pop(); sum += i.second - i.first + 1; if (j < g&&sum > g) { if (j < h&&sum > h) { A.push(P(i.first, i.first + (g - j) - 1)); B.push(P(i.first + (g - j), i.first + (h - j) - 1)); C.push(P(i.first + (h - j), i.second)); } else { A.push(P(i.first, i.first + (g - j) - 1)); B.push(P(i.first + (g - j), i.second)); } } else { if (j < h&&sum > h) { B.push(P(i.first, i.first + (h - j) - 1)); C.push(P(i.first + (h - j), i.second)); } else { if (sum > h) { C.push(i); } else if (sum > g) { B.push(i); } else { A.push(i); } } } j += i.second - i.first + 1; } L = C + B + A; } }
a.cc: In function 'int main()': a.cc:64:2: error: expected '}' at end of input 64 | } | ^ a.cc:18:12: note: to match this '{' 18 | int main() { | ^
s269535700
p00459
C++
#include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <vector> #include <string> #include <map> #include <set> #include <queue> #include <stack> #include <algorithm> #include <deque> using namespace std; #define rep(i,j) REP((i), 0, (j)) #define REP(i,j,k) for(int i=(j);(i)<(k);++i) #define BW(a,x,b) ((a)<=(x)&&(x)<=(b)) #define ALL(v) (v).begin(), (v).end() #define LENGTHOF(x) (sizeof(x) / sizeof(*(x))) #define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b) #define SQ(x) ((x)*(x)) #define Mod(x, mod) (((x)+(mod)%(mod)) #define MP make_pair #define PB push_back #define F first #define S second #define INF 1 << 30 #define EPS 1e-10 #define MOD 1000000007 typedef pair<int, int> pi; typedef pair<int, pi> pii; typedef vector<int> vi; typedef queue<int> qi; typedef long long ll; deque<pi>vec, a, b, c; int N, M, P, Q, R; int cnt(int p, int q, int r){ if(p > r) return 0; if(r >= q) return q-p+1; return r-p+1; } int countR(int p, int q, int r){ int n = 1, vp, res = 0; for(vp=0;vp<vec.size();vp++){ int f = vec[vp].F, l = vec[vp].S; int c = l-f+1; if(n <= p){ if(n+c < p){ } else if(n + c > q){ res += cnt(f+p-n, f+q-n, r); }else{ res += cnt(f+p-n, l, r); } n += c; }else if(n <= q){ if(n+c<=q){ res += cnt(f, l, r); }else{ res += cnt(f, f+q-n, r); } n += c; } } return res; } int main(){ while(1){ cin >> N; if(!N) break; cin >> M >> P >> Q >> R; vec.clear(); vec.push_back(MP(1,N)); int x, y; rep(i, M){ cin >> x >> y; a.clear(); b.clear(); int p=1; while(p<=x){ int f = vec[0].F, s = vec[0].S; if(p+s-f<=x){ a.push_back(MP(f,s)); p += s-f+1; vec.pop_front(); }else if(p+s-f>x){ a.push_back(MP(f, f+x-p)); vec[0].F = f+x-p+1; p = x+1; } } while(p<=y){ int f = vec[0].F, s = vec[0].S; if(p+s-f<=y){ b.push_back(MP(f, s)); p += s-f+1; vec.pop_front(); }else if(p+s-f>y){ b.push_back(MP(f, f+y-p)); vec[0].F = f+y-p+1; p = y+1; } } vec.insert(vec.end(), b.begin(), b.end()); vec.insert(vec.end(), a.begin(), a.end()); } /* rep(i, vec.size()){ for(int j=vec[i].F;j<=vec[i].S;j++) cout << j << endl;; }*/ cout << countR(P, Q, R) << endl; }
a.cc: In function 'int main()': a.cc:122:4: error: expected '}' at end of input 122 | } | ^ a.cc:75:11: note: to match this '{' 75 | int main(){ | ^
s525187907
p00459
C++
#include <iostream> #include <algorithm> #include <vector> using namespace std; int main(){ int n,m,p,q,r,x,y; vector<int>::iterator itx,ity,it; for(;cin>>n>>m>>p>>q>>r;cout<<x<<endl){ vector<int> v1(1),v2; for(v1.push_back(r);m--;v2.clear()){ cin>>x>>y; itx=upper_bound(v1.begin(),v1.end(),x); ity=upper_bound(v1.begin(),v1.end(),y); if( ity-v1.begin()+1 & 1 )v2.push_back(0); v2.push_back(0); // v2.insert(v2.end(),ity-v1.begin()&1?1:2,0); for(it=ity;it!=v1.end();++it) v2.push_back(*it - y); if(v1.end()-itx & 1)v2.push_back(n-y); for(it=itx;it!=ity;++it) v2.push_back(*it-x+n-y); it = v1.begin(); if(ity-v1.begin() & 1)++it; if(!it[1])it+=2; if(*it+n-x==v2.back())++it,v2.pop_back(); for(;it!=itx;++it) v2.push_back(*it+n-x); v1.swap(v2); } v1.insert( upper_bound(v1.begin(),v1.end(),p-1), 2, p-1); v1.insert( lower_bound(v1.begin(),v1.end(),q), q ); v1.push_back(n); it = upper_bound(v1.begin(),v1.end(),p-1); if(it-v1.begin() & 1) --it; for(x=0;*it<q;++it){ m=*it,++it x+=*it-m; } } }
a.cc: In function 'int main()': a.cc:41:35: error: expected ';' before 'x' 41 | m=*it,++it | ^ | ; 42 | x+=*it-m; | ~
s824298377
p00459
C++
#include <iostream> #include <algorithm> #include <vector> using namespace std; int main(){ int n,m,p,q,r,x,y; vector<int>::iterator itx,ity,it; for(;cin>>n>>m>>p>>q>>r;cout<<x<<endl){ vector<int> v1,v2; v1.push_back(0); for(v1.push_back(r);m--;v2.clear()){ cin>>x>>y; itx=upper_bound(v1.begin(),v1.end(),x); ity=upper_bound(v1.begin(),v1.end(),y); // if( ity-v1.begin()+1 & 1 )v2.push_back(0); // v2.push_back(0); v2.insert(v2.end(),ity-v1.begin()&1?1:2,0); for(it=ity;it!=v1.end();++it) v2.push_back(*it - y); if(v1.end()-itx & 1)v2.push_back(n-y); for(it=itx;it!=ity;++it) v2.push_back(*it-x+n-y); it = v1.begin(); if(ity-v1.begin() & 1)++it; if(!it[1])it+=2; if(*it+n-x==v2.back()){++it;v2.pop_back();} for(;it!=itx;++it) v2.push_back(*it+n-x); v1.swap(v2); } v1.insert( upper_bound(v1.begin(),v1.end(),p-1), 2, p-1); v1.insert( lower_bound(v1.begin(),v1.end(),q), q ); v1.push_back(n); it = upper_bound(v1.begin(),v1.end(),p-1); if(it-v1.begin() & 1) --it; for(x=0;*it<q; x+=*it++-m) m=*it++ } }
a.cc: In function 'int main()': a.cc:42:32: error: expected ';' before '}' token 42 | m=*it++ | ^ | ; 43 | } | ~
s776696430
p00459
C++
#include <iostream> #include <algorithm> #include <vector> using namespace std; int main(){ int n,m,p,q,r,x,y; vector<int>::iterator itx,ity,it; for(;cin>>n>>m>>p>>q>>r;cout<<x<<endl){ vector<int> v1,v2; v1.push_back(0); for(v1.push_back(r);m--;v2.clear()){ cin>>x>>y; itx=upper_bound(v1.begin(),v1.end(),x); ity=upper_bound(v1.begin(),v1.end(),y); // if( ity-v1.begin()+1 & 1 )v2.push_back(0); // v2.push_back(0); v2.insert(v2.end(),ity-v1.begin()&1?1:2,0); for(it=ity;it!=v1.end();++it) v2.push_back(*it - y); if(v1.end()-itx & 1)v2.push_back(n-y); for(it=itx;it!=ity;++it) v2.push_back(*it-x+n-y); it = v1.begin(); if(ity-v1.begin() & 1)++it; if(!it[1])it+=2; if(*it+n-x==v2.back()){++it;v2.pop_back();} for(;it!=itx;++it) v2.push_back(*it+n-x); v1.swap(v2); } v1.insert( upper_bound(v1.begin(),v1.end(),p-1), 2, p-1); v1.insert( lower_bound(v1.begin(),v1.end(),q), q ); v1.push_back(n); it = upper_bound(v1.begin(),v1.end(),p-1); if(it-v1.begin() & 1) --it; for(x=0;*it<q;it+=2) x+=it[1]-*it } }
a.cc: In function 'int main()': a.cc:41:37: error: expected ';' before '}' token 41 | x+=it[1]-*it | ^ | ; 42 | } | ~
s409781547
p00459
C++
#include <cstdio> #include <algorthm> #include <queue> using namespace std; typedef pair<int,int> P; #define mp make_pair #define f first #define s second int main(){ while(1){ int n,m,p,q,r; queue<P>que; scanf("%d",&n); if(!n) break; scanf("%d",&m); scanf("%d %d %d",&p,&q,&r); que.push(mp(1,r)); for(int i=0;i<m;i++){ int x,y; scanf("%d %d",&x,&y); int e=que.size(); for(int j=0;j<e;j++){ P pp=que.front(); que.pop(); int a=pp.f,b=pp.s; if(b<=x){ que.push(mp(n-x+a,n-x+b)); }else if(b>x && b<=y){ if(a<=x){ que.push(mp(n-x+a,n)); que.push(mp(n-y+1,n+b-x-y)); }else{ que.push(mp(n-y+a-x,n+b-x-y)); } }else{ if(a<=x){ que.push(mp(1,b-y)); que.push(mp(n-x+a,n)); que.push(mp(n-y+1,n-x)); }else if(a>x && a<=y){ que.push(mp(1,b-y)); que.push(mp(n-y-x+a,n-x)); }else{ que.push(mp(a-y,b-y)); } } } } int ans=0; while(que.size()){ P pp=que.front(); que.pop(); if(pp.s<p || pp.f>q){ continue; }else if(pp.f<q){ ans+=q-pp.f+1; }else{ ans+=pp.s-p+1; } } printf("%d\n",ans); } return 0; }
a.cc:2:10: fatal error: algorthm: No such file or directory 2 | #include <algorthm> | ^~~~~~~~~~ compilation terminated.
s192817711
p00459
C++
#include<iostream> #include<vector> #include<algorithm> using namespace std; class Deck { public: int start, end; Deck(int s, int e) { start = s; end = e; } vector<Deck> divide(int a, int b = -1) { vector<Deck> v; v.push_back(Deck(start, a)); if(b == -1) v.push_back(Deck(a 1, end)); else v.push_back(Deck(a 1, b)); v.push_back(Deck(b 1, end)); return v; } int get_ans(int n, int p, int q, int r) { int s = max(n, p); int res = min(min(q - s 1, end - start n - s 1), r - start); if(res < 0) res = 0; cout << start << " " << end << ":" << s << " " << res << endl; return res; } int size() { return end - start 1; } }; int main() { vector<Deck> vp; vector<Deck> *v =
a.cc: In member function 'std::vector<Deck> Deck::divide(int, int)': a.cc:22:23: error: expected primary-expression before '(' token 22 | v.push_back(Deck(a 1, end)); | ^ a.cc:22:28: error: expected ')' before numeric constant 22 | v.push_back(Deck(a 1, end)); | ^ a.cc:22:23: note: to match this '(' 22 | v.push_back(Deck(a 1, end)); | ^ a.cc:24:23: error: expected primary-expression before '(' token 24 | v.push_back(Deck(a 1, b)); | ^ a.cc:24:28: error: expected ')' before numeric constant 24 | v.push_back(Deck(a 1, b)); | ^ a.cc:24:23: note: to match this '(' 24 | v.push_back(Deck(a 1, b)); | ^ a.cc:25:23: error: expected primary-expression before '(' token 25 | v.push_back(Deck(b 1, end)); | ^ a.cc:25:28: error: expected ')' before numeric constant 25 | v.push_back(Deck(b 1, end)); | ^ a.cc:25:23: note: to match this '(' 25 | v.push_back(Deck(b 1, end)); | ^ a.cc: In member function 'int Deck::get_ans(int, int, int, int)': a.cc:32:31: error: expected ')' before numeric constant 32 | int res = min(min(q - s 1, end - start n - s 1), r - start); | ^ a.cc:32:22: note: to match this '(' 32 | int res = min(min(q - s 1, end - start n - s 1), r - start); | ^ a.cc:32:48: error: expected ')' before 'n' 32 | int res = min(min(q - s 1, end - start n - s 1), r - start); | ^ a.cc:32:22: note: to match this '(' 32 | int res = min(min(q - s 1, end - start n - s 1), r - start); | ^ a.cc: In member function 'int Deck::size()': a.cc:41:26: error: expected ';' before numeric constant 41 | return end - start 1; | ^ a.cc: In function 'int main()': a.cc:48:20: error: expected primary-expression at end of input 48 | vector<Deck> *v = | ^ a.cc:48:20: error: expected '}' at end of input a.cc:46:1: note: to match this '{' 46 | { | ^
s557538446
p00460
C
#include"bits/stdc++.h" main(){for(int n,m,s,i,j,d[50][3500],M=1e5;std::cin>>n>>m>>s,n*=n;){std::fill(d[0],d[50],M);d[0][0]=1;for(i=1;i<=n;++i)for(j=0;j<=s;++j){if(j>=i)d[i][j]+=d[i-1][j-i]+d[i][j-i];if(j>m)d[i][j]-=d[i-1][j-m-1];d[i][j]%=M;}printf("%d\n",d[n][s]);}}
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory 1 | #include"bits/stdc++.h" | ^~~~~~~~~~~~~~~ compilation terminated.
s883150726
p00460
C++
#include "bits/stdc++.h" using namespace std; typedef long long ll; int main(){ int n,m,s; while(cin>>n>>m>>s){ if(n==0&&m==0&&s==0)break; int dp[2][2300][3300]; rep(i,2)rep(j,2300)rep(k,3300)dp[i][j][k]=0; dp[0][0][0] = 1; for(int i=1;i<=n*n;i++){ for(int j=0;j<2300;j++) for(int k=0;k<3300;k++) dp[i%2][j][k] = 0; for(int j=1;j<=m;j++){ for(int k=1;k<=s;k++){ if(k-j>=0){ dp[i%2][j][k] += dp[i%2][j-1][k-1] + dp[(i-1)%2][j-1][k-j]; dp[i%2][j][k] %= 100000; } } } } ll ans = 0; for(int i=0;i<=m;i++){ ans+=dp[(n*n)%2][i][s]; ans%=100000; } cout<<ans<<endl; } }
a.cc: In function 'int main()': a.cc:14:13: error: 'i' was not declared in this scope 14 | rep(i,2)rep(j,2300)rep(k,3300)dp[i][j][k]=0; | ^ a.cc:14:9: error: 'rep' was not declared in this scope 14 | rep(i,2)rep(j,2300)rep(k,3300)dp[i][j][k]=0; | ^~~
s851976525
p00460
C++
#include <iostream> using namespace std; const int MAX_N = 7; const int MAX_S = 3000; int dp[MAX_N * MAX_N + 1][MAX_S + 1]; int main() { int N, M, S; while (cin >> N >> M >> S, N) { memset(dp, 0, sizeof dp); N *= N; dp[0][0] = 1; for (int i = 1; i <= M; ++i) { for (int j = N; j >= 1; --j) { for (int k = S; k >= i; --k) { dp[j][k] += dp[j - 1][k - i]; dp[j][k] %= 100000; } } } cout << dp[N][S] << endl; } }
a.cc: In function 'int main()': a.cc:15:17: error: 'memset' was not declared in this scope 15 | memset(dp, 0, sizeof dp); | ^~~~~~ a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 |
s309044418
p00460
C++
#include<bits/stdc++.h> using namespace std; int dp[2200][3200],_prev[2200][3200],n,m,s; int main(){ while(true){ cin>>n>>s>>m;if(n==0)return 0;n*=n; for(int i=0;i<2200;i++){fill(dp[i],dp[i]+3200);fill(_prev[i],_prev[i]+3200);} for(int i=0;i<=s;i++)_prev[i][0]=1; for(int i=0;i<n;i++){ for(int j=1;j<=s;j++){ for(int k=j;k<=m;k++){ dp[j][k]+=_prev[j-1][k-j];dp[j][k]%=100000; } } for(int j=0;j<=s;j++){ for(int k=0;k<=m;k++){ _prev[j][k]=dp[j][k];dp[j][k]=0; } } for(int j=1;j<=s;j++){ for(int k=1;k<=m;k++){ _prev[j][k]+=_prev[j-1][k]; } } } cout<<_prev[s][m]%100000<<endl; } }
a.cc: In function 'int main()': a.cc:7:45: error: no matching function for call to 'fill(int [3200], int*)' 7 | for(int i=0;i<2200;i++){fill(dp[i],dp[i]+3200);fill(_prev[i],_prev[i]+3200);} | ~~~~^~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:1022:5: note: candidate: 'template<class _ForwardIterator, class _Tp> void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&)' 1022 | fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:1022:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:86: /usr/include/c++/14/pstl/glue_algorithm_defs.h:191:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::fill(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' 191 | fill(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:191:1: note: candidate expects 4 arguments, 2 provided a.cc:7:68: error: no matching function for call to 'fill(int [3200], int*)' 7 | for(int i=0;i<2200;i++){fill(dp[i],dp[i]+3200);fill(_prev[i],_prev[i]+3200);} | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1022:5: note: candidate: 'template<class _ForwardIterator, class _Tp> void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&)' 1022 | fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:1022:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/pstl/glue_algorithm_defs.h:191:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::fill(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' 191 | fill(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:191:1: note: candidate expects 4 arguments, 2 provided
s150856437
p00460
C++
#include<bits/stdc++.h> using namespace std; int dp[2200][3200],_prev[2200][3200],n,m,s; int main(){ while(true){ cin>>n>>s>>m;if(n==0)return 0;n*=n; for(int i=0;i<2200;i++){fill(dp[i],dp[i]+3180);fill(_prev[i],_prev[i]+3180);} for(int i=0;i<=s;i++)_prev[i][0]=1; for(int i=0;i<n;i++){ for(int j=1;j<=s;j++){ for(int k=j;k<=m;k++){ dp[j][k]+=_prev[j-1][k-j];dp[j][k]%=100000; } } for(int j=0;j<=s;j++){ for(int k=0;k<=m;k++){ _prev[j][k]=dp[j][k];dp[j][k]=0; } } for(int j=1;j<=s;j++){ for(int k=1;k<=m;k++){ _prev[j][k]+=_prev[j-1][k]; } } } cout<<_prev[s][m]%100000<<endl; } }
a.cc: In function 'int main()': a.cc:7:45: error: no matching function for call to 'fill(int [3200], int*)' 7 | for(int i=0;i<2200;i++){fill(dp[i],dp[i]+3180);fill(_prev[i],_prev[i]+3180);} | ~~~~^~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:1022:5: note: candidate: 'template<class _ForwardIterator, class _Tp> void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&)' 1022 | fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:1022:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:86: /usr/include/c++/14/pstl/glue_algorithm_defs.h:191:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::fill(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' 191 | fill(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:191:1: note: candidate expects 4 arguments, 2 provided a.cc:7:68: error: no matching function for call to 'fill(int [3200], int*)' 7 | for(int i=0;i<2200;i++){fill(dp[i],dp[i]+3180);fill(_prev[i],_prev[i]+3180);} | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1022:5: note: candidate: 'template<class _ForwardIterator, class _Tp> void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&)' 1022 | fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:1022:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/pstl/glue_algorithm_defs.h:191:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::fill(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' 191 | fill(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:191:1: note: candidate expects 4 arguments, 2 provided
s262336171
p00460
C++
#include<iostream> #include<cstdio> #include<string> #include<set> #include<vector> #include<algorithm> #include<functional> using namespace std; int dp[49][2999][1999]{}; int main() { memset(dp, -1, sizeof(dp)); }
a.cc: In function 'int main()': a.cc:12:9: error: 'memset' was not declared in this scope 12 | memset(dp, -1, sizeof(dp)); | ^~~~~~ a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 7 | #include<functional> +++ |+#include <cstring> 8 | using namespace std;
s243457850
p00460
C++
#include<iostream> #include<map> #include<string> #include<vector> #include<algorithm> #include<queue> #include<set> #include<map> #define int long long using namespace std; int dp[2][2000][3000]; signed main() { int a, b, c; while (cin >> a >> b >> c, a || b || c) { a *= a; c -= a*(a + 1) / 2; b -= a; memset(dp, 0, sizeof(dp)); dp[0][0][0] = 1; for (int d = 1; d <= a; d++) { memset(dp[d & 1], 0, sizeof(dp[d & 1])); for (int e = 0; e <= b; e++) { for (int f = 0; f <= c; f++) { dp[d & 1][e][f] = dp[(d + 1) & 1][e][f]; if (e >= 1 && f >= (a - d + 1)) { dp[d & 1][e][f] = (dp[d & 1][e][f] + dp[d & 1][e - 1][f - (a - d + 1)])%100000; } } } } int sum = 0; for (int i = 0; i <= b; i++) { sum += dp[a & 1][i][c]%100000; } cout << sum << endl; } }
a.cc: In function 'int main()': a.cc:19:17: error: 'memset' was not declared in this scope 19 | memset(dp, 0, sizeof(dp)); | ^~~~~~ a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 7 | #include<set> +++ |+#include <cstring> 8 | #include<map>
s588551955
p00460
C++
#include<iostream> #include<map> #include<string> #include<vector> #include<algorithm> #include<queue> #include<set> #include<map> using namespace std; int dp[2][2000][3000]; signed main() { int a, b, c; while (cin >> a >> b >> c, a || b || c) { a *= a; c -= a*(a + 1) / 2; b -= a; memset(dp, 0, sizeof(dp)); dp[0][0][0] = 1; for (int d = 1; d <= a; d++) { memset(dp[d & 1], 0, sizeof(dp[d & 1])); for (int e = 0; e <= b; e++) { for (int f = 0; f <= c; f++) { dp[d & 1][e][f] = dp[(d + 1) & 1][e][f]; if (e >= 1 && f >= (a - d + 1)) { dp[d & 1][e][f] = (dp[d & 1][e][f] + dp[d & 1][e - 1][f - (a - d + 1)])%100000; } } } } int sum = 0; for (int i = 0; i <= b; i++) { sum = (sum+dp[a & 1][i][c])%100000; } cout << sum << endl; } }
a.cc: In function 'int main()': a.cc:18:17: error: 'memset' was not declared in this scope 18 | memset(dp, 0, sizeof(dp)); | ^~~~~~ a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 7 | #include<set> +++ |+#include <cstring> 8 | #include<map>
s311468596
p00460
C++
#include <cstdio> using namespace std; int n, m, s; int dp[49][2001][3001]; int main(){ while(1){ scanf("%d %d %d", &n, &m, &s); if(n == 0) break; dp = {{{}}}; for(int i=1; i<s+1; i++){ dp[0][i][i] = 1; } for(int i=1; i<n*n; i++){ for(int j=1; j<s+1; j++){ for(int k=1; k<m+1; k++){ for(int l=1; l<k; l++){ dp[i][j][k] += dp[i-1][j-k][l]; dp[i][j][k] %= 100000; } } } } for(int i=1; i<m+1; i++){ ans += dp[n*n-1][s][i]; ans %= 100000; } printf("%d\n", ans); } }
a.cc: In function 'int main()': a.cc:11:20: error: assigning to an array from an initializer list 11 | dp = {{{}}}; | ~~~^~~~~~~~ a.cc:29:25: error: 'ans' was not declared in this scope 29 | ans += dp[n*n-1][s][i]; | ^~~ a.cc:33:32: error: 'ans' was not declared in this scope 33 | printf("%d\n", ans); | ^~~
s609840484
p00460
C++
#include<iostream> using namespace std;int d[51][3210],n,m,s,i,j,k;int main(){while(cin>>n>>m>>s&&n){n*=n;memset(d,0,sizeof(d));d[0][0]=1;for(k=1;k<=m;k++)for(i=n;i;i--)for(j=k;j<=s;j++)d[i][j]=(d[i][j]+d[i-1][j-k])%100000;cout<<d[n][s]<<endl;}return 0;}
a.cc: In function 'int main()': a.cc:2:88: error: 'memset' was not declared in this scope 2 | using namespace std;int d[51][3210],n,m,s,i,j,k;int main(){while(cin>>n>>m>>s&&n){n*=n;memset(d,0,sizeof(d));d[0][0]=1;for(k=1;k<=m;k++)for(i=n;i;i--)for(j=k;j<=s;j++)d[i][j]=(d[i][j]+d[i-1][j-k])%100000;cout<<d[n][s]<<endl;}return 0;} | ^~~~~~ a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include<iostream> +++ |+#include <cstring> 2 | using namespace std;int d[51][3210],n,m,s,i,j,k;int main(){while(cin>>n>>m>>s&&n){n*=n;memset(d,0,sizeof(d));d[0][0]=1;for(k=1;k<=m;k++)for(i=n;i;i--)for(j=k;j<=s;j++)d[i][j]=(d[i][j]+d[i-1][j-k])%100000;cout<<d[n][s]<<endl;}return 0;}
s704654844
p00460
C++
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; int main(){ int dp1[50][3001]; int dp2[50][3001]; // x?????????, ?????¨???????¨???????y int mod=100000; int n,m,s; while(scanf("%d%d%d",&n,&m,&s)){ if(n==0&&m==0&&s==0) break; memset(dp1,0,sizeof(dp1)); dp1[0][0]=1; for(int i=1;i<=m;i++){ memset(dp2,0,sizeof(dp2)); for(int j=0;j<n*n+1;j++){ for(int k=0;k<s+1;k++){ //i???????????´??? if(j<n*n&&k+i<=s){ dp2[j+1][k+i]+=dp1[j][k]; dp2[j+1][k+i]%=mod; } //??????????????´??? dp2[j][k]+=dp1[j][k]; dp2[j][k]%=mod; } } //dp2???dp1???????????? for(int j=0;j<n*n+1;j++){ for(int k=0;k<s+1;k++){ dp1[j][k]=dp2[j][k]; } } } printf("%d\n",dp1[n*n][s]); } }
a.cc: In function 'int main()': a.cc:17:17: error: 'memset' was not declared in this scope 17 | memset(dp1,0,sizeof(dp1)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include<algorithm> +++ |+#include <cstring> 4 |
s496746957
p00460
C++
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; int main(){ int dp1[50][3001]; int dp2[50][3001]; // x?????????, ?????¨???????¨???????y int mod=100000; int n,m,s; while(scanf("%d%d%d",&n,&m,&s)){ if(n==0&&m==0&&s==0) break; memset(dp1,0,sizeof(dp1)); dp1[0][0]=1; for(int i=1;i<=m;i++){ memset(dp2,0,sizeof(dp2)); for(int j=0;j<n*n+1;j++){ for(int k=0;k<s+1;k++){ //i???????????´??? if(j<n*n&&k+i<=s){ dp2[j+1][k+i]+=dp1[j][k]; dp2[j+1][k+i]%=mod; } //??????????????´??? dp2[j][k]+=dp1[j][k]; dp2[j][k]%=mod; } } //dp2???dp1???????????? for(int j=0;j<n*n+1;j++){ for(int k=0;k<s+1;k++){ dp1[j][k]=dp2[j][k]; } } } printf("%d\n",dp1[n*n][s]); } }
a.cc: In function 'int main()': a.cc:17:17: error: 'memset' was not declared in this scope 17 | memset(dp1,0,sizeof(dp1)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include<algorithm> +++ |+#include <cstring> 4 |
s719862055
p00460
C++
#include<iostream> #include<cstdio> #include<cstdlib> #include<algorithm> using namespace std; int main(){ int dp1[50][3001]; int dp2[50][3001]; // x?????????, ?????¨???????¨???????y int mod=100000; int n,m,s; while(scanf("%d%d%d",&n,&m,&s)){ if(n==0&&m==0&&s==0) break; memset(dp1,0,sizeof(dp1)); dp1[0][0]=1; for(int i=1;i<=m;i++){ memset(dp2,0,sizeof(dp2)); for(int j=0;j<n*n+1;j++){ for(int k=0;k<s+1;k++){ //i???????????´??? if(j<n*n&&k+i<=s){ dp2[j+1][k+i]+=dp1[j][k]; dp2[j+1][k+i]%=mod; } //??????????????´??? dp2[j][k]+=dp1[j][k]; dp2[j][k]%=mod; } } //dp2???dp1???????????? for(int j=0;j<n*n+1;j++){ for(int k=0;k<s+1;k++){ dp1[j][k]=dp2[j][k]; } } } printf("%d\n",dp1[n*n][s]); } }
a.cc: In function 'int main()': a.cc:18:17: error: 'memset' was not declared in this scope 18 | memset(dp1,0,sizeof(dp1)); | ^~~~~~ a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 4 | #include<algorithm> +++ |+#include <cstring> 5 |
s061925700
p00460
C++
#include<cstdio> #include<algorithm> #define mod 100000 using namespace std; int dp[50][3001]; int main(){ int n,m,s; while(scanf("%d %d %d",&n,&m,&s)){ if(n==0&&m==0&&s==0) break; memset(dp,0,sizeof(dp)); dp[0][0]=1; for(int i=1;i<=m;i++){ for(int j=n*n;j>0;j--){ for(int k=i;k<=s;k++){ dp[j][k]=(dp[j][k]+dp[j-1][k-i])%mod; } } } printf("%d\n",dp[n*n][s]); } }
a.cc: In function 'int main()': a.cc:15:17: error: 'memset' was not declared in this scope 15 | memset(dp,0,sizeof(dp)); | ^~~~~~ 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 |
s871220397
p00460
C++
#include<cstdio> #include<algorithm> #include<string> #define mod 100000 using namespace std; int dp[50][3001]; int main(){ int n,m,s; while(scanf("%d %d %d",&n,&m,&s)){ if(n==0&&m==0&&s==0) break; memset(dp,0,sizeof(dp)); dp[0][0]=1; for(int i=1;i<=m;i++){ for(int j=n*n;j>0;j--){ for(int k=i;k<=s;k++){ dp[j][k]=(dp[j][k]+dp[j-1][k-i])%mod; } } } printf("%d\n",dp[n*n][s]); } }
a.cc: In function 'int main()': a.cc:16:17: error: 'memset' was not declared in this scope 16 | memset(dp,0,sizeof(dp)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include<string> +++ |+#include <cstring> 4 |
s054463111
p00460
C++
//y09-6 ビンゴ(2回目) #include <iostream> #include <fstream> #include <stdio.h> #include <math.h> #include <time.h> #include <string> #include <vector> #include <map> #include <list> #include <set> #include <stack> #include <queue> #include <cstdlib> #include <algorithm> #include <random> #include <cassert> using namespace std; #define LL long long #undef INT_MIN #undef INT_MAX #define INT_MIN -2147483648 #define INT_MAX 2147483647 #define LL_MIN -9223372036854775808 #define LL_MAX 9223372036854775807 #define segment_size 65536 #define ROOP() while (true) int main(){ ROOP(){ int N,M,S; cin >> N >> M >> S; if(N==0) return 0; int dp[50][3001]; for(int i=0; i<50; i++){ for(int j=0; j<3001; j++){ dp[i][j] = 0; } } dp[0][0] = 1; for(int i=1; i<=N*N; i++){ for(int j=i; j<=S; j++){ if(j>=i) dp[i][j] = dp[i-1][j-i] + dp[i][j-i]; if(j>m) dp[i][j] -= dp[i-1][j-m-1]; dp[i][j] %= 100000; } } cout << dp[N*N][S] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:47:22: error: 'm' was not declared in this scope 47 | if(j>m) dp[i][j] -= dp[i-1][j-m-1]; | ^
s515752749
p00460
C++
//y09-6 ビンゴ(2回目) #include <iostream> #include <fstream> #include <stdio.h> #include <math.h> #include <time.h> #include <string> #include <vector> #include <map> #include <list> #include <set> #include <stack> #include <queue> #include <cstdlib> #include <algorithm> #include <random> #include <cassert> using namespace std; #define LL long long #undef INT_MIN #undef INT_MAX #define INT_MIN -2147483648 #define INT_MAX 2147483647 #define LL_MIN -9223372036854775808 #define LL_MAX 9223372036854775807 #define segment_size 65536 #define ROOP() while (true) int main(){ ROOP(){ int N,M,S; cin >> N >> M >> S; if(N==0) return 0; int dp[50][3001]; for(int i=0; i<50; i++){ for(int j=0; j<3001; j++){ dp[i][j] = 0; } } dp[0][0] = 1; for(int i=1; i<=N*N; i++){ for(int j=i; j<=S; j++){ if(j>=i) dp[i][j] = dp[i-1][j-i] + dp[i][j-i]; if(j>m) dp[i][j] -= dp[i-1][j-M-1]; dp[i][j] %= 100000; } } cout << dp[N*N][S] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:47:22: error: 'm' was not declared in this scope 47 | if(j>m) dp[i][j] -= dp[i-1][j-M-1]; | ^
s881862988
p00460
C++
#include<stdio.h> #include<stdlib.h> #include<string.h> #define REP(i,n) for(i=0; i<(int)(n); i++) #define rep(i,s,n) for(i=(s); i<(int)(n); i++) typedef unsigned int uint; int getInt(){ int ret = 0,c; c = getchar(); while(!isdigit(c)) c = getchar(); while(isdigit(c)){ ret *= 10; ret += c - '0'; c = getchar(); } return ret; } #define MOD 100000 int n,m,s; uint memo[2001][3001]; uint prevs[2][3001]; uint *prev, *prev2; int main(){ int i,j,k,x,y; while(1){ n = getInt(); m = getInt(); s = getInt(); if(n+m+s == 0) break; n = n * n; prev = prevs[0]; prev2 = prevs[1]; REP(i,n){ if(i == 0){ REP(k,m+1) REP(j,s+1) memo[k][j] = 0; rep(x,1,m+1){ int xx = x * n; if(xx > s) break; memo[x][xx] = 1; } }else{ memset(prev,0,sizeof(int)*s); if(i % 5 == 0){ rep(x,1,m+1){ //memcpy(prev2,memo[x],sizeof(int)*s); rep(y,0,s+1-n+i){ prev2[y+(n-i)] = memo[x][y+(n-i)]; memo[x][y+(n-i)] = (memo[x-1][y] + prev[y]) % MOD; } uint *tmp = prev; prev = prev2; prev2 = tmp; } }else{ rep(x,1,m+1){ //memcpy(prev2,memo[x],sizeof(int)*s); rep(y,0,s+1-n+i){ prev2[y+(n-i)] = memo[x][y+(n-i)]; memo[x][y+(n-i)] = (memo[x-1][y] + prev[y]); } uint *tmp = prev; prev = prev2; prev2 = tmp; } } } } int ans = 0; REP(i,m+1) ans = (ans + memo[i][s]) % MOD; printf("%d\n",ans); } return 0; }
a.cc: In function 'int getInt()': a.cc:13:10: error: 'isdigit' was not declared in this scope 13 | while(!isdigit(c)) c = getchar(); | ^~~~~~~ a.cc:14:9: error: 'isdigit' was not declared in this scope 14 | while(isdigit(c)){ | ^~~~~~~
s226085570
p00460
C++
#include <iostream> using namespace std; int dp[59][3001]; int main(void) { while(1) { int num,max,sum; cin >> num >> max >> sum; if(num+max+sum == 0) return 0; memset(dp,0,sizeof(dp)); dp[0][0] = 1; for(int m=1;m<=max;++m)//その数を使ッた時のあれ { for(int n=num*num;n>=1;--n)//どの数が使う?(num { for(int i=m;i<=sum;++i){//どの数が使う?(sum dp[n][i] += dp[n-1][i-m];//mを使った時の通り数を足す dp[n][i] %= 100000; } } } cout << dp[num*num][sum] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:14:17: error: 'memset' was not declared in this scope 14 | memset(dp,0,sizeof(dp)); | ^~~~~~ a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 | using namespace std;
s895423525
p00460
C++
#include <iostream> #include <cstring> using namespace std; int dp[59][3001]; int main(void) { while(1) { int num,max,sum; cin >> num >> max >> sum; if(num+max+sum == 0) return 0; memset(dp,0,sizeof(dp)); dp[0][0] = 1; for(int m=1;m<=max;++m)//その数を使ッた時のあれ { for(int n=num*num;n>=1;--n)//どの数が使う?(num { for(int i=m;i<=sum;++i){//どの数が使う?(sum dp[n][i] += dp[n-1][i-m];//mを使った時の通り数を足す dp[n][i] %= 100000; } } } cout << dp[num*num][sum] << endl; } return 0; } #include <iostream> #include <cstring> using namespace std; int dp[59][3001]; int main(void) { while(1) { int num,max,sum; cin >> num >> max >> sum; if(num+max+sum == 0) return 0; memset(dp,0,sizeof(dp)); dp[0][0] = 1; for(int m=1;m<=max;++m)//その数を使ッた時のあれ { for(int n=num*num;n>=1;--n)//どの数が使う?(num { for(int i=m;i<=sum;++i){//どの数が使う?(sum dp[n][i] += dp[n-1][i-m];//mを使った時の通り数を足す dp[n][i] %= 100000; } } } cout << dp[num*num][sum] << endl; } return 0; }
a.cc:38:5: error: redefinition of 'int dp [59][3001]' 38 | int dp[59][3001]; | ^~ a.cc:5:5: note: 'int dp [59][3001]' previously declared here 5 | int dp[59][3001]; | ^~ a.cc:40:5: error: redefinition of 'int main()' 40 | int main(void) | ^~~~ a.cc:7:5: note: 'int main()' previously defined here 7 | int main(void) | ^~~~
s641339210
p00461
C
#include<stdio.h> #include<string.h> #pragma warning(disable:4996) int main(void){ int n, m; char s[100002]; int count; int i,ps; char *p; for (;;){ scanf("%d", &n); if (n == EOF)break; scanf("%d", &m); scanf("%s", s); ps = m; p = s; while (ps > 0){ p = strstr(p, "IOI"); for (i = 3; p[i] = 'O' && p[i + 1] = 'I' && i <= 1 + 2 * n ; i+=2){ if (i >= 1 + 2 * n){ count++; } } p += 2; ps -= 2; } printf("%d\n", count); } return 0; }
main.c: In function 'main': main.c:23:60: error: lvalue required as left operand of assignment 23 | for (i = 3; p[i] = 'O' && p[i + 1] = 'I' && i <= 1 + 2 * n ; i+=2){ | ^
s064308552
p00461
C
#include<stdio.h> #include<string.h> int main() { int n,m,i,j,ans; char str[1000000]; while(1) { scanf("%d %d",&n,&m); if(n==0&&m==0)break; scanf("%s",str); i=2*n; ans=0; while(str[i]!='\0') { for(j=0;j<2*i+1;j++) { if(j%2==0 && str[i-j]!='J') { i++; break; } if(j%2==1 && str[i-j]!='O') { i+=2; break; } if(j==2*i){ ans++; } } printf("%d\n",ans); } return 0; }
main.c: In function 'main': main.c:36:1: error: expected declaration or statement at end of input 36 | } | ^
s695006193
p00461
C
c,n;main(x){for(;t=scanf("%d%*d ",&n),n;printf("%d\n",c))for(c=0;x=getchar()%5;)t=x-4?t%2?c+=t>2*n,t+1:2:t%2?1:t+1;}
main.c:1:1: warning: data definition has no type or storage class 1 | c,n;main(x){for(;t=scanf("%d%*d ",&n),n;printf("%d\n",c))for(c=0;x=getchar()%5;)t=x-4?t%2?c+=t>2*n,t+1:2:t%2?1:t+1;} | ^ main.c:1:1: error: type defaults to 'int' in declaration of 'c' [-Wimplicit-int] main.c:1:3: error: type defaults to 'int' in declaration of 'n' [-Wimplicit-int] 1 | c,n;main(x){for(;t=scanf("%d%*d ",&n),n;printf("%d\n",c))for(c=0;x=getchar()%5;)t=x-4?t%2?c+=t>2*n,t+1:2:t%2?1:t+1;} | ^ main.c:1:5: error: return type defaults to 'int' [-Wimplicit-int] 1 | c,n;main(x){for(;t=scanf("%d%*d ",&n),n;printf("%d\n",c))for(c=0;x=getchar()%5;)t=x-4?t%2?c+=t>2*n,t+1:2:t%2?1:t+1;} | ^~~~ main.c: In function 'main': main.c:1:5: error: type of 'x' defaults to 'int' [-Wimplicit-int] main.c:1:18: error: 't' undeclared (first use in this function) 1 | c,n;main(x){for(;t=scanf("%d%*d ",&n),n;printf("%d\n",c))for(c=0;x=getchar()%5;)t=x-4?t%2?c+=t>2*n,t+1:2:t%2?1:t+1;} | ^ main.c:1:18: note: each undeclared identifier is reported only once for each function it appears in main.c:1:20: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 1 | c,n;main(x){for(;t=scanf("%d%*d ",&n),n;printf("%d\n",c))for(c=0;x=getchar()%5;)t=x-4?t%2?c+=t>2*n,t+1:2:t%2?1:t+1;} | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | c,n;main(x){for(;t=scanf("%d%*d ",&n),n;printf("%d\n",c))for(c=0;x=getchar()%5;)t=x-4?t%2?c+=t>2*n,t+1:2:t%2?1:t+1;} main.c:1:20: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 1 | c,n;main(x){for(;t=scanf("%d%*d ",&n),n;printf("%d\n",c))for(c=0;x=getchar()%5;)t=x-4?t%2?c+=t>2*n,t+1:2:t%2?1:t+1;} | ^~~~~ main.c:1:20: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:1:41: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 1 | c,n;main(x){for(;t=scanf("%d%*d ",&n),n;printf("%d\n",c))for(c=0;x=getchar()%5;)t=x-4?t%2?c+=t>2*n,t+1:2:t%2?1:t+1;} | ^~~~~~ main.c:1:41: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:1:41: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:1:41: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:1:68: error: implicit declaration of function 'getchar' [-Wimplicit-function-declaration] 1 | c,n;main(x){for(;t=scanf("%d%*d ",&n),n;printf("%d\n",c))for(c=0;x=getchar()%5;)t=x-4?t%2?c+=t>2*n,t+1:2:t%2?1:t+1;} | ^~~~~~~ main.c:1:68: note: 'getchar' is defined in header '<stdio.h>'; this is probably fixable by adding '#include <stdio.h>'
s070939521
p00461
C
char s[1000001];c[1000001]; main(n,m,i,r){for(;scanf("%d",&n),n;printf("%d\n",r)){ for(memset(c,0,sizeof(c)),scanf("%d%s",&m,s),i=2;i<m;i++)if(s[i-2]=='I'&&s[i-1]=='O'&&s[i]=='I')c[i]=c[i-2]+1; for(i=r=0;i<m;i++)if(c[i]>=n)r++; }
main.c:1:17: warning: data definition has no type or storage class 1 | char s[1000001];c[1000001]; | ^ main.c:1:17: error: type defaults to 'int' in declaration of 'c' [-Wimplicit-int] main.c:2:1: error: return type defaults to 'int' [-Wimplicit-int] 2 | main(n,m,i,r){for(;scanf("%d",&n),n;printf("%d\n",r)){ | ^~~~ main.c: In function 'main': main.c:2:1: error: type of 'n' defaults to 'int' [-Wimplicit-int] main.c:2:1: error: type of 'm' defaults to 'int' [-Wimplicit-int] main.c:2:1: error: type of 'i' defaults to 'int' [-Wimplicit-int] main.c:2:1: error: type of 'r' defaults to 'int' [-Wimplicit-int] main.c:2:20: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 2 | main(n,m,i,r){for(;scanf("%d",&n),n;printf("%d\n",r)){ | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | char s[1000001];c[1000001]; main.c:2:20: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 2 | main(n,m,i,r){for(;scanf("%d",&n),n;printf("%d\n",r)){ | ^~~~~ main.c:2:20: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:2:37: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 2 | main(n,m,i,r){for(;scanf("%d",&n),n;printf("%d\n",r)){ | ^~~~~~ main.c:2:37: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:2:37: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:2:37: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:3:13: error: implicit declaration of function 'memset' [-Wimplicit-function-declaration] 3 | for(memset(c,0,sizeof(c)),scanf("%d%s",&m,s),i=2;i<m;i++)if(s[i-2]=='I'&&s[i-1]=='O'&&s[i]=='I')c[i]=c[i-2]+1; | ^~~~~~ main.c:1:1: note: include '<string.h>' or provide a declaration of 'memset' +++ |+#include <string.h> 1 | char s[1000001];c[1000001]; main.c:3:13: warning: incompatible implicit declaration of built-in function 'memset' [-Wbuiltin-declaration-mismatch] 3 | for(memset(c,0,sizeof(c)),scanf("%d%s",&m,s),i=2;i<m;i++)if(s[i-2]=='I'&&s[i-1]=='O'&&s[i]=='I')c[i]=c[i-2]+1; | ^~~~~~ main.c:3:13: note: include '<string.h>' or provide a declaration of 'memset' main.c:5:1: error: expected declaration or statement at end of input 5 | } | ^
s732186300
p00461
C
#include<stdio.h> int main(){ while(1){ char ch; bool con=true; int cou=0; int m,n; int i,j; int ans=0; scanf("%d",&n); if(n==0)return 0; scanf("%d",&m); for(i=0;i<m;i++){ scanf(" %c",&ch); if(ch=='I'){ if(!con){ cou++; if(cou==n+1){ ans++; cou--; } } else cou=1; con=true; } if(ch=='O'){ if(!con)cou=0; con=false; } } printf("%d\n",ans); } }
main.c: In function 'main': main.c:6:17: error: unknown type name 'bool' 6 | bool con=true; | ^~~~ main.c:2:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' 1 | #include<stdio.h> +++ |+#include <stdbool.h> 2 | main.c:6:26: error: 'true' undeclared (first use in this function) 6 | bool con=true; | ^~~~ main.c:6:26: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' main.c:6:26: note: each undeclared identifier is reported only once for each function it appears in main.c:29:37: error: 'false' undeclared (first use in this function) 29 | con=false; | ^~~~~ main.c:29:37: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
s996457512
p00461
C++
#include<iostream> #include<string> #include<cstring> #include<algorithm> using namespace std; char P[2000002],str[1000000]; int main(){ int n,f=1; for(int i=0;i<2000001;i++){ if(f==1)P[i]='I'; else P[i]='O'; f*=-1; } while(cin>>n,n){ int len; cin>>len; cin>>str; int cnt=0; for(int i=0;i<len;i++){ if(i+1+2*n>m)break; if(!strncmp(str+i,P,n*2+1))cnt++; } cout<<cnt<<endl; } }
a.cc: In function 'int main()': a.cc:20:24: error: 'm' was not declared in this scope 20 | if(i+1+2*n>m)break; | ^
s168521290
p00461
C++
#include <iostream> #include <string> using namespace std; int main(){ int n, k; while (cin >> n){ int ans=0,size=0; string p = "I", s; cin >> k; for (int i = 0; i < n; i++){ p += "OI"; } cin >> s; for (int i = 0; i < s.size(); i++){ if (s[i] == p[0]){ if(s[i+1]==p[1]){ size = 2; for (int j = 2; j < p.size(); j++){ if (s[i + j] == p[j]){ size++; if (size == p.size()){ ans++; } } } else{ break; } } } } cout << ans << endl; } return 0; }
a.cc: In function 'int main()': a.cc:26:41: error: expected '}' before 'else' 26 | else{ | ^~~~ a.cc:16:49: note: to match this '{' 16 | if(s[i+1]==p[1]){ | ^ a.cc:32:25: error: 'ans' was not declared in this scope; did you mean 'abs'? 32 | cout << ans << endl; | ^~~ | abs a.cc: At global scope: a.cc:34:9: error: expected unqualified-id before 'return' 34 | return 0; | ^~~~~~ a.cc:35:1: error: expected declaration before '}' token 35 | } | ^
s872769321
p00461
C++
int main() { int n = 1; while (1){ int m = 0; int count = 0; std::string str; std::string check; std::cin >> n; if (n == 0) { break; } for (int i = 0; i < n; i++) { check += "I"; check += "O"; if (i == n - 1) { check += "I"; } } //std::cout << check << std::endl; std::cin >> m; std::cin >> str; std::string current; for (int i = 0; i < m; i++) { if (i >= m - 2 * n) { break; } for (int j = i; j < i + 2 * n + 1; j++) { if (j >= m) { continue; } current += str[j]; } if (current == check) { count += 1; } current = ""; } std::cout << count << std::endl; } return 0; }
a.cc: In function 'int main()': a.cc:9:14: error: 'string' is not a member of 'std' 9 | std::string str; | ^~~~~~ a.cc:1:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>' +++ |+#include <string> 1 | a.cc:11:14: error: 'string' is not a member of 'std' 11 | std::string check; | ^~~~~~ a.cc:11:14: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>' a.cc:13:14: error: 'cin' is not a member of 'std' 13 | std::cin >> n; | ^~~ a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' +++ |+#include <iostream> 1 | a.cc:20:13: error: 'check' was not declared in this scope 20 | check += "I"; | ^~~~~ a.cc:29:14: error: 'cin' is not a member of 'std' 29 | std::cin >> m; | ^~~ a.cc:29:14: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:31:14: error: 'cin' is not a member of 'std' 31 | std::cin >> str; | ^~~ a.cc:31:14: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:31:21: error: 'str' was not declared in this scope; did you mean 'std'? 31 | std::cin >> str; | ^~~ | std a.cc:33:14: error: 'string' is not a member of 'std' 33 | std::string current; | ^~~~~~ a.cc:33:14: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>' a.cc:43:17: error: 'current' was not declared in this scope 43 | current += str[j]; | ^~~~~~~ a.cc:46:17: error: 'current' was not declared in this scope 46 | if (current == check) { | ^~~~~~~ a.cc:46:28: error: 'check' was not declared in this scope 46 | if (current == check) { | ^~~~~ a.cc:50:13: error: 'current' was not declared in this scope 50 | current = ""; | ^~~~~~~ a.cc:56:14: error: 'cout' is not a member of 'std' 56 | std::cout << count << std::endl; | ^~~~ a.cc:56:14: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:56:36: error: 'endl' is not a member of 'std' 56 | std::cout << count << std::endl; | ^~~~ a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' +++ |+#include <ostream> 1 |
s297530966
p00461
C++
#include <iostream> #include <string> long main() { while (1){ long n = 0; long m = 0; long count = 0; std::string str = ""; std::string check = ""; std::cin >> n; if (n == 0) { break; } for (long i = 0; i < n; i++) { check += "I"; check += "O"; if (i == n - 1) { check += "I"; } } std::cin >> m; std::cin >> str; std::string current; for (long i = 0; i < m; i++) { if (i >= m - 2 * n) { break; } for (long j = i; j < i + 2 * n + 1; j++) { if (j >= m) { break; } current += str[j]; } if (current == check) { count += 1; } current = ""; } std::cout << count << std::endl; } return 0; }
cc1plus: error: '::main' must return 'int'
s399176055
p00461
C++
#include <iostream> #include <string> long main() { while (1){ long n = 0; long m = 0; long count = 0; std::string str = ""; std::string check = ""; std::cin >> n; if (n == 0) { break; } for (long i = 0; i < n; i++) { check += "I"; check += "O"; if (i == n - 1) { check += "I"; } } std::cin >> m; std::cin >> str; std::string current; int next = 0; for (long i = 0; i < m; i++) { if (i >= m - 2 * n) { next +=1; break; } for (long j = i; j < i + 2 * n + 1; j++) { if (j >= m) { next += 1; break; } current += str[j]; } if (next != 0) { break; } if (current == check) { count += 1; } current = ""; } std::cout << count << std::endl; } return 0; }
cc1plus: error: '::main' must return 'int'
s929795740
p00461
C++
#include<iostream> #include<vector> #include<string> #include<cstdio> using namespace std; char c[1000000]; int main() { int a, b; while (scanf("%d", &a), a) { scanf("%d%s",&b, c); int d = strlen(c); int s = 0; for (int e = 0; e < d; e++) { if (c[e] == 'I') { int k = 1; for (int f = e + 1; f < d; f++) { if (c[f - 1] == c[f]) { e = f - 1; break; } k++; } k++; k /= 2; if (k > a)s += k - a; } } printf("%d\n", s); } }
a.cc: In function 'int main()': a.cc:12:25: error: 'strlen' was not declared in this scope 12 | int d = strlen(c); | ^~~~~~ a.cc:5:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 4 | #include<cstdio> +++ |+#include <cstring> 5 | using namespace std;
s063098939
p00461
C++
#include <bits/stdc++.h> using namespace std; int main(){ int n,m,c=0,i; string s; while(cin>>n,n){ cin>>m>>s; for(i=0;i<m-2;i++){ if(s[i]=='l'&&s[i+1]=='O'&&s[i+2]=='l')c++; } cout<<c<<endl; }
a.cc: In function 'int main()': a.cc:12:4: error: expected '}' at end of input 12 | } | ^ a.cc:3:11: note: to match this '{' 3 | int main(){ | ^
s452927739
p00461
C++
int main(){ int n; while(cin>>n,n){ int len; cin>>len; string str; cin>>str; int ans=0; for(int i=0;i<len-2;i++) if(str[i]=='I'&&str[i+1]=='O'&&str[i+2]=='I') ans++,i++; cout <<ans<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:3:9: error: 'cin' was not declared in this scope 3 | while(cin>>n,n){ | ^~~ a.cc:6:5: error: 'string' was not declared in this scope 6 | string str; | ^~~~~~ a.cc:7:10: error: 'str' was not declared in this scope; did you mean 'std'? 7 | cin>>str; | ^~~ | std a.cc:11:5: error: 'cout' was not declared in this scope 11 | cout <<ans<<endl; | ^~~~ a.cc:11:17: error: 'endl' was not declared in this scope 11 | cout <<ans<<endl; | ^~~~
s283940330
p00461
C++
#include<bits/stdc++.h> using namespace std; #define int long long struct SuffixArray{ int n,k; string S; vector<int> r,r2,t,sa,lcp; SuffixArray(){} SuffixArray(string S):S(S){init();} void init(){ n=S.size(); r.resize(n+1,0); r2.resize(n+1,0); t.resize(n+1,0); sa.resize(n+1,0); lcp.resize(n+1,0); build_sa(); build_lcp(); build_rmq(); } bool compare_sa(int i,int j){ if(r[i]!=r[j]) return r[i]<r[j]; else{ int ri=i+k<=n?r[i+k]:-1; int rj=j+k<=n?r[j+k]:-1; return ri<rj; } } void build_sa(){ n=S.length(); for(int i=0;i<=n;i++){ sa[i]=i; r[i]=i<n?S[i]:-1; } for(k=1;k<=n;k*=2){ sort(sa.begin(),sa.end(),[&](const int &i, const int &j){ if(r[i]!=r[j]) return r[i]<r[j]; else{ int ri=i+k<=n?r[i+k]:-1; int rj=j+k<=n?r[j+k]:-1; return ri<rj; } }); t[sa[0]]=0; for(int i=1;i<=n;i++){ t[sa[i]]=t[sa[i-1]]+(compare_sa(sa[i-1],sa[i])?1:0); } for(int i=0;i<=n;i++){ r[i]=t[i]; } } } bool contains(string T){ int a=0,b=S.length()+1; while(a+1<b){ int c=(a+b)/2; if(S.compare(sa[c],T.length(),T)<0) a=c; else b=c; } if(b==(int)S.length()+1) b--; return S.compare(sa[b],T.length(),T)==0; } // O(|T|*log|S|) int count(string T){ int sl=S.length(),tl=T.length(); int a[2],b[2]; for(int i=0;i<2;i++){ a[i]=0; b[i]=sl; while(a[i]+1<b[i]){ int c=(a[i]+b[i])/2; if(S.compare(sa[c],tl,T)<0|| (i&&S.compare(sa[c],tl,T)==0)) a[i]=c; else b[i]=c; } } if(S.compare(sa[b[0]],tl,T)!=0) return 0; if(a[1]<sl&&S.compare(sa[a[1]+1],tl,T)==0) a[1]++; if(b[0]> 0&&S.compare(sa[b[0]-1],tl,T)==0) b[0]--; return a[1]-b[0]+1; } void build_lcp(){ for(int i=0;i<=n;i++) r2[sa[i]]=i; int h=0; lcp[0]=0; for(int i=0;i<n;i++){ int j=sa[r2[i]-1]; if(h>0) h--; for(;j+h<n&&i+h<n;h++){ if(S[j+h]!=S[i+h]) break; } lcp[r2[i]-1]=h; } } int getlcp(int p,string &T,int d){ int i=0; int len=min((int)T.length()-d,(int)S.length()-p-d); while(i<len&&S[p+d+i]==T[d+i]) i++; return i; } struct RMQ{ int n; vector<int> dat; const int def=INT_MAX; RMQ(){} RMQ(int n_){init(n_);} RMQ(int n_,vector<int>& a){init(n_);build(n_,a);} void init(int n_){ n=1; while(n<n_) n*=2; dat.clear(); dat.resize(2*n-1,def); } void build(int n_, vector<int>& a){ for(int i=0;i<n_;i++) dat[i+n-1]=a[i]; for(int i=n-2;i>=0;i--) dat[i]=min(dat[i*2+1],dat[i*2+2]); } void update(int k,int a){ k+=n-1; dat[k]=a; while(k>0){ k=(k-1)/2; dat[k]=min(dat[k*2+1],dat[k*2+2]); } } int query(int a,int b,int k,int l,int r){ if(r<=a||b<=l) return def; if(a<=l&&r<=b) return dat[k]; else{ int vl=query(a,b,k*2+1,l,(l+r)/2); int vr=query(a,b,k*2+2,(l+r)/2,r); return min(vl,vr); } } int query(int a,int b){ return query(a,b,0,0,n); } }; RMQ rmq; void build_rmq(){ rmq.init(n); rmq.build(n,lcp); } // O(|T|+log|S|) int count2(string T){ int a[2],b[2]; int sl=S.length(),tl=T.length(); for(int i=0;i<2;i++){ int p,l,r; p=tl; a[i]=0; b[i]=sl; l=getlcp(sa[a[i]],T,0); r=getlcp(sa[b[i]],T,0); while(a[i]+1<b[i]){ int c=(a[i]+b[i])/2; //cout<<a[i]<<" "<<b[i]<<" "<<c<<endl; if(l>=r){ int m=rmq.query(a[i],c); if(m<l) b[i]=c,r=m; else{ int k=l+getlcp(sa[c],T,l); if(i){ if(k==p||S[sa[c]+k]<T[k]) a[i]=c,l=k; else b[i]=c,r=k; }else{ if(k==p) b[i]=c,r=k; else if(S[sa[c]+k]<T[k]) a[i]=c,l=k; else b[i]=c,r=k; } } }else{ int m=rmq.query(c,b[i]); if(m<r) a[i]=c,l=m; else{ int k=r+getlcp(sa[c],T,r); if(i){ if(k==p||S[sa[c]+k]<T[k]) a[i]=c,l=k; else b[i]=c,r=k; }else{ if(k==p) b[i]=c,r=k; else if(S[sa[c]+k]<T[k]) a[i]=c,l=k; else b[i]=c,r=k; } } } } } if(a[1]<sl&&getlcp(sa[a[1]+1],T,0)==tl) a[1]++; if(b[0]> 0&&getlcp(sa[b[0]-1],T,0)==tl) b[0]--; if(getlcp(sa[b[0]],T,0)!=tl) return 0; return a[1]-b[0]+1; } }; char buf[1145141]; signed main(){ //cin.tie(0); //ios::sync_with_stdio(0); int n; while(scanf("%lld",&n),n){ int m; scanf("%lld\n",&m); gets(buf); string s(buf); SuffixArray sa(s); string t="I"; for(int i=0;i<n;i++) t=t+"OI"; cout<<sa.count2(t)<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:213:5: error: 'gets' was not declared in this scope; did you mean 'getw'? 213 | gets(buf); | ^~~~ | getw
s455671267
p00461
C++
#include<iostream> #include<vector> #include<string.h> #include<string> #include<windows.h> using namespace std; void make_pn(int n); int find_IOI(char pn[], char str[]); char func_pn[1000000]; char str[1000000]; char IO[] = "IO"; int n, m, total; bool isKisu; int main() { for(;;){ total = 0; cin >> n; if(n == 0){ break; } cin >> m; vector<char> str2(m); vector<char> Pn(n); if(n % 2 == 0){ isKisu = 0; } else{ isKisu = 1; } scanf("%s",str); make_pn(n); strcpy(&str2[0], &str[0]); strcpy(&Pn[0], &func_pn[0]); find_IOI(&Pn[0], &str2[0]); cout << total << endl; } } void make_pn(int n) { int i, cont = 0; for(int i = 0; i < n; i++){ strcpy(&func_pn[cont], IO); cont += 2; } func_pn[cont] = 'I'; func_pn[cont+1] = '\0'; } int find_IOI(char pn[], char str[]){ int cont = 0, i; int len; bool flg = 1; /* for(int i = 0;str[i] != '\0' ; i++){ cout << str[i]; } cout << endl; */ len = strlen(str); for(i = 0; i < len; i++){ //i”Ô–Ú‚ÅŒ©‚‚¯‚½ if(str[i] == 'I'){ break; } } // cout << i << "”Ô–Ú‚¶‚á‚Ë"<< endl; vector<char> sub(2*n+1); for(int j = i;; j++){ sub[cont] = str[j]; // printf("sub[%d] = %c\n",cont,sub[cont]); if(cont+1 == 2*n+1){ break; } cont++; } for(int j = 0; j < 2*n+1; j++){ /* cout << strcmp(&pn[j], &sub[j]) <<endl; if(strcmp(&pn[j], &sub[j]) != 0){ cout << strcmp(&pn[j], &sub[j]) << endl; flg = 0; break; } cout<< "*"<<endl; */ if(pn[j] != sub[j]){ flg = 0; break; } } if(flg == 1){ total++; } /* else{ cout << "ˆá‚Á‚½c" << endl; } */ if(len == 0){ return 0; } else{ // cout << "strlen = "<< len<<"\n" << endl; return find_IOI(&pn[0],&str[i+1]); } }
a.cc:5:9: fatal error: windows.h: No such file or directory 5 | #include<windows.h> | ^~~~~~~~~~~ compilation terminated.
s965008080
p00461
C++
#include <iostream> #include <algorithm> #include <string> using namespace std; int *buildFail(char *p) { int m = strlen(p); int *fail = new int[m+1]; int j = fail[0] = -1; for (int i = 1; i <= m; ++i) { while (j >= 0 && p[j] != p[i-1]) j = fail[j]; fail[i] = ++j; } return fail; } int match(char *t, char *p, int *fail) { int n = strlen(t), m = strlen(p); int count = 0; for (int i = 0, k = 0; i < n; ++i) { while (k >= 0 && p[k] != t[i]) k = fail[k]; if (++k >= m) { ++count; // match at t[i-m+1 .. i] k = fail[k]; } } return count; } int main(){ int n,m; char in[1000010]; char str[1000010]; while(scanf("%d",&n),n!=0){ scanf("%d %s",&m,in); for(int i=1; i<=2*n+1; i+=2){ str[i-1] = 'I'; str[i] = 'O'; } str[2*n+1] = 0; //puts(str); printf("%d\n",match(in,str,buildFail(str))); } return 0; }
a.cc: In function 'int* buildFail(char*)': a.cc:7:11: error: 'strlen' was not declared in this scope 7 | int m = strlen(p); | ^~~~~~ a.cc:3:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include <algorithm> +++ |+#include <cstring> 3 | #include <string> a.cc: In function 'int match(char*, char*, int*)': a.cc:17:11: error: 'strlen' was not declared in this scope 17 | int n = strlen(t), m = strlen(p); | ^~~~~~ a.cc:17:11: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' a.cc:21:16: error: 'm' was not declared in this scope 21 | if (++k >= m) { | ^
s666654285
p00461
C++
1 13 OOIOIOIOIIOII 2 13 OOIOIOIOIIOII 0
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 1 | ^
s860827093
p00461
C++
#include<iostream> #include<string> using namespace std; int main() { int n,m,ans,c[1000001]; string s; while(cin>>n>>m>>s,n){ memset(c,0,sizeof(c)); for(int i=m-3;i>=0;i--){ if(s.substr(i,3)=="IOI")c[i]=c[i+2]+1; } ans=0; for(int i=0;i<m;i++)cout<<c[i]<<", "; puts(""); for(int i=0;i<m;i++)if(c[i]>=n)ans++; cout<<ans<<endl; } }
a.cc: In function 'int main()': a.cc:9:5: error: 'memset' was not declared in this scope 9 | memset(c,0,sizeof(c)); | ^~~~~~ a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include<iostream> +++ |+#include <cstring> 2 | #include<string>
s932653743
p00461
C++
#include<iostream> #include<string> #include<cmemory> using namespace std; int main() { int n,m,ans,c[1000001]; string s; while(cin>>n>>m>>s,n){ memset(c,0,sizeof(c)); for(int i=m-3;i>=0;i--){ if(s.substr(i,3)=="IOI")c[i]=c[i+2]+1; } ans=0; for(int i=0;i<m;i++)cout<<c[i]<<", "; puts(""); for(int i=0;i<m;i++)if(c[i]>=n)ans++; cout<<ans<<endl; } }
a.cc:3:9: fatal error: cmemory: No such file or directory 3 | #include<cmemory> | ^~~~~~~~~ compilation terminated.
s460891184
p00461
C++
#include<iostream> main(){ int n,m,i,a,c[1000001]; for(std::string s;std::cin>>n>>m>>s,n;printf("%d\n",a)) for(a=0,i=m;--i;a+=c[i]>=n)c[i]=s.substr(i,3)-"IOI"?0:c[i+2]+1; }
a.cc:2:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 2 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:5:46: error: no match for 'operator-' (operand types are 'std::__cxx11::basic_string<char>' and 'const char [4]') 5 | for(a=0,i=m;--i;a+=c[i]>=n)c[i]=s.substr(i,3)-"IOI"?0:c[i+2]+1; | ~~~~~~~~~~~~~^~~~~~ | | | | | const char [4] | std::__cxx11::basic_string<char> In file included from /usr/include/c++/14/string:48, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 618 | operator-(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:618:5: note: template argument deduction/substitution failed: a.cc:5:47: note: 'std::__cxx11::basic_string<char>' is not derived from 'const std::reverse_iterator<_Iterator>' 5 | for(a=0,i=m;--i;a+=c[i]>=n)c[i]=s.substr(i,3)-"IOI"?0:c[i+2]+1; | ^~~~~ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1790 | operator-(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: template argument deduction/substitution failed: a.cc:5:47: note: 'std::__cxx11::basic_string<char>' is not derived from 'const std::move_iterator<_IteratorL>' 5 | for(a=0,i=m;--i;a+=c[i]>=n)c[i]=s.substr(i,3)-"IOI"?0:c[i+2]+1; | ^~~~~