submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s802247534
p00468
C++
#include<stdio.h> #include<iostream> #include<string.h> using namespace std; int s[1001]={0}; int main(){ while(1){ int i,j,n,m,l=0,a,b; cin>>n>>m; memset(s,0,sizeof(s)); s[1]=3; for(i=0;i<m;i++){ cin>>a>>b; if(s[a]>0&&s[b]==0)s[b]=s[a]-1; if(s[b]>0&&s[a]==0)s[a]=s[b]-1; } for(i=1;i<=n;i++){ if(s[i]>0)l++; } cout<<l<<endl; return 0; }
a.cc: In function 'int main()': a.cc:22:2: error: expected '}' at end of input 22 | } | ^ a.cc:6:11: note: to match this '{' 6 | int main(){ | ^
s291744039
p00468
C++
#include <iostream> using namespace std; int d[10000],e[10000]; int main(void){ for (;;){ long a,b,c,g=0; cin>>a>>b; if (a==0&&b==0) break; long f[501]={0}; for (c=0;c<b;c++){ cin>>d[c]>>e[c]; if (d[c]==1)f[e[c]]=2; } for(c=0;c<m;c++){ if(f[d[c]]==2)f[e[c]]=1; if(f[e[c]]==2)f[d[c]]=1; for (c=0;c<b;c++){ if (f[c]!=0)g++; } cout<<g<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:14:27: error: 'm' was not declared in this scope 14 | for(c=0;c<m;c++){ | ^ a.cc:23:2: error: expected '}' at end of input 23 | } | ^ a.cc:4:15: note: to match this '{' 4 | int main(void){ | ^
s828746678
p00468
C++
#include <iostream> using namespace std; int d[10000],e[10000]; int main(void){ for (;;){ long a,b,c,g=0; cin>>a>>b; if (a==0&&b==0) break; long f[501]={0}; for (c=0;c<b;c++){ cin>>d[c]>>e[c]; if (d[c]==1)f[e[c]]=2; } for(c=0;c<m;c++){ if(f[d[c]]==2)f[e[c]]=1; if(f[e[c]]==2)f[d[c]]=1; for (c=0;c<b;c++){ if (f[c]!=0)g++; } cout<<g<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:14:27: error: 'm' was not declared in this scope 14 | for(c=0;c<m;c++){ | ^ a.cc:23:2: error: expected '}' at end of input 23 | } | ^ a.cc:4:15: note: to match this '{' 4 | int main(void){ | ^
s074001010
p00468
C++
#include <iostream> using namespace std; int d[10000],e[10000]; int main(void){ for (;;){ long a,b,c,g=0; cin>>a>>b; if (a==0&&b==0) break; long f[501]={0}; for (c=0;c<b;c++){ cin>>d[c]>>e[c]; if (d[c]==1)f[e[c]]=2; } for(c=0;c<m;c++){ if(f[d[c]]==2)f[e[c]]=1; if(f[e[c]]==2)f[d[c]]=1; for (c=0;c<b;c++){ if (f[c]!=0)g++; } cout<<g<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:14:27: error: 'm' was not declared in this scope 14 | for(c=0;c<m;c++){ | ^ a.cc:23:2: error: expected '}' at end of input 23 | } | ^ a.cc:4:15: note: to match this '{' 4 | int main(void){ | ^
s809757040
p00468
C++
#include<iostream> #include<string.h> using namespace std; int r[501][1001]={0}; int ans=0,n; takahashi(int i){ for(int j=1;j<=n;j++){ if(r[i][j]==1&&r[1][j]!=0){ ans++; takahashi(j); } } } int main(){ while(1){ int m,a,b; ans=0; cin>>n>>m; if(n==0&&m==0)break; memset(r,0,sizeof(r)); for(int i=0;i<m;i++){ cin>>a>>b; r[a][b]=1; } for(int i=1;i<=n;i++){ if(r[1][i]==1){ ans++; takahashi(i); } } cout<<ans<<endl; } }
a.cc:6:1: error: ISO C++ forbids declaration of 'takahashi' with no type [-fpermissive] 6 | takahashi(int i){ | ^~~~~~~~~ a.cc: In function 'int takahashi(int)': a.cc:13:1: warning: no return statement in function returning non-void [-Wreturn-type] 13 | } | ^
s233337994
p00468
C++
50 200 24 40 17 20 23 27 38 46 31 47 11 16 15 21 29 49 11 29 34 42 18 43 15 44 13 50 2 50 16 36 6 27 13 40 17 23 12 39 40 49 40 41 16 37 14 30 37 38 1 39 16 43 22 37 40 45 32 34 37 41 7 23 12 13 7 9 11 43 21 40 1 7 13 33 21 37 18 44 5 22 32 41 3 15 7 39 6 46 4 8 6 41 2 29 1 48 17 44 3 20 13 18 23 40 18 19 10 23 27 47 2 43 22 33 23 39 46 50 24 47 10 25 29 38 18 36 25 29 6 21 22 23 10 44 28 37 28 42 7 8 21 38 31 48 18 29 15 22 38 40 21 24 10 29 2 4 18 21 45 48 12 27 20 42 4 7 4 35 47 49 31 44 13 24 8 11 39 47 30 40 8 29 1 45 7 38 27 32 24 39 4 34 34 41 21 48 19 29 13 25 6 13 1 33 19 38 16 18 13 28 9 47 9 22 34 36 7 12 27 45 16 19 37 47 38 41 23 37 6 43 17 41 11 44 44 50 5 33 4 20 15 36 14 38 17 21 17 40 17 18 3 45 29 32 10 41 19 24 11 38 13 16 6 11 26 47 25 35 26 49 19 27 20 39 30 32 1 37 18 26 17 31 4 47 22 49 39 46 10 16 19 28 19 49 18 45 36 44 11 18 38 39 11 41 3 35 8 43 21 34 17 32 13 36 21 41 25 43 21 32 17 45 8 48 27 49 34 40 4 50 23 50 25 33 16 35 36 45 31 38 24 31 13 48 25 38 11 17 20 29 9 12 8 31 15 17 12 18 21 26 6 48 18 31 12 40 24 28 21 46 7 43 23 47 22 44 4 41 17 26 1 49 1 18 7 27 2 8 9 50 18 38 22 25 17 46 25 47 35 46
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 50 | ^~
s678505475
p00468
C++
#include <bits/stdc++.h> #include <stdio.h> using namespace std; #define INF 1.1e9 #define LINF 1.1e18 #define FOR(i,a,b) for (long long i = (a); i < (b); ++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(), (v).end() #define pb push_back #define fi first #define se second typedef long long ll; typedef pair<int, int> P; typedef pair<int, P> PP; int n,m; vector<int> v[501]; set<int> st,ss; int main() { cin.tie(0); ios::sync_with_stdio(false); while(true) { cin>>n>>m; if(n==0&m==0) break; v.clear(); st.clear();ss.clear(); REP(i,m) { int a,b; cin>>a>>b; v[a].pb(b); v[b].pb(a); } st.insert(1); REP(i,v[1].size()) { st.insert(v[1][i]); } for(auto x:st) { REP(i,v[x].size()) { ss.insert(v[x][i]); } } for(auto x:st) { ss.insert(x); } cout<<ss.size()-1<<endl; return 0; }
a.cc: In function 'int main()': a.cc:29:11: error: request for member 'clear' in 'v', which is of non-class type 'std::vector<int> [501]' 29 | v.clear(); | ^~~~~ a.cc:52:2: error: expected '}' at end of input 52 | } | ^ a.cc:22:12: note: to match this '{' 22 | int main() { | ^
s244210792
p00468
C++
#include <bits/stdc++.h> #include <stdio.h> using namespace std; #define INF 1.1e9 #define LINF 1.1e18 #define FOR(i,a,b) for (long long i = (a); i < (b); ++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(), (v).end() #define pb push_back #define fi first #define se second typedef long long ll; typedef pair<int, int> P; typedef pair<int, P> PP; int n,m; vector<int> v[501]; set<int> st,ss; int main() { cin.tie(0); ios::sync_with_stdio(false); while(true) { cin>>n>>m; if(n==0&m==0) break; v.clear(); st.clear();ss.clear(); REP(i,m) { int a,b; cin>>a>>b; v[a].pb(b); v[b].pb(a); } st.insert(1); REP(i,v[1].size()) { st.insert(v[1][i]); } for(auto x:st) { REP(i,v[x].size()) { ss.insert(v[x][i]); } } for(auto x:st) { ss.insert(x); } cout<<ss.size()-1<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:29:11: error: request for member 'clear' in 'v', which is of non-class type 'std::vector<int> [501]' 29 | v.clear(); | ^~~~~
s153611809
p00468
C++
// 0545.cpp : コンソール アプリケーションのエントリ ポイントを定義します。 // #include "stdafx.h" #include<stdio.h> #include <algorithm> #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <iterator> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <iomanip> #include <stack> #include <string> #include <vector> using namespace std; #define ll long long #define ld long double #define roop(a,t) for(int a=0;a<t;a++) #define forever while(true) int main() { cin.tie(0); ios::sync_with_stdio(false); forever { bool a[500][500]; for (int i = 0; i < 500; i++) { for (int j = 0; j < 500; j++) { a[i][j] = false; } } int n, m; cin >> n >> m; if (n == 0 && m == 0) { break; } int p, q; roop(i, m) { cin >> p >> q; a[p - 1][q - 1] = true; a[q - 1][p - 1] = true; } bool ans[500]; for (int i = 0; i < 500; i++) { ans[i] = false; } for (int i = 1; i < n; i++) { if (a[0][i]) { ans[i] = true; } } for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { if (i == j) { continue; } if (a[0][i] && a[i][j]) { ans[j]=true; } } } int answer = 0; for (int i = 1; i < 500; i++) { if (ans[i]) { answer++; } }cout << answer<<endl; } return 0; }
a.cc:4:10: fatal error: stdafx.h: No such file or directory 4 | #include "stdafx.h" | ^~~~~~~~~~ compilation terminated.
s215284528
p00468
C++
#include<iostream> using namespace std; int main(){ int n,cut,m,a,b,i,j,k; int c[500][500]={0}; c[1][1]=0; cin>>n; cin>>m; for(i=1;i<=m;i++){ cin>>a>>b; if(a==1){ c[a][b]=1; } else if(b==1){ c[b][a]=1; } else{ c[a][b]=1; c[b][a]=1; } } cut=0; for(i=2;i<=n;i++){ if(c[1][i]==1){ cut++; j=2; k=i-1+j; for(j=2;j<=k;) } } } cout<<cut<<endl; return 0; }
a.cc: In function 'int main()': a.cc:29:25: error: expected primary-expression before '}' token 29 | } | ^ a.cc: At global scope: a.cc:32:9: error: 'cout' does not name a type 32 | cout<<cut<<endl; | ^~~~ a.cc:33:9: error: expected unqualified-id before 'return' 33 | return 0; | ^~~~~~ a.cc:34:1: error: expected declaration before '}' token 34 | } | ^
s062944958
p00468
C++
#include<iostream> using namespace std; int main(){ int n,cut,m,a,b,i,j,k; int c[500][500]={0}; c[1][1]=0; cin>>n; cin>>m; for(i=1;i<=m;i++){ cin>>a>>b; if(a==1){ c[a][b]=1; } else if(b==1){ c[b][a]=1; } else{ c[a][b]=1; c[b][a]=1; } } cut=0; for(i=2;i<=n;i++){ if(c[1][i]==1){ cut++; j=2; k=i-1+j; for(j=2;j<=k;) } } } cout<<cut<<endl; return 0; }
a.cc: In function 'int main()': a.cc:29:25: error: expected primary-expression before '}' token 29 | } | ^ a.cc: At global scope: a.cc:32:9: error: 'cout' does not name a type 32 | cout<<cut<<endl; | ^~~~ a.cc:33:9: error: expected unqualified-id before 'return' 33 | return 0; | ^~~~~~ a.cc:34:1: error: expected declaration before '}' token 34 | } | ^
s892058832
p00468
C++
#include<iostream> using namespace std; int main(){ int n,cut,m,a,b,i,j,k; int c[500][500]={0}; c[1][1]=0; cin>>n; cin>>m; for(i=1;i<=m;i++){ cin>>a>>b; if(a==1){ c[a][b]=1; } else if(b==1){ c[b][a]=1; } else{ c[a][b]=1; c[b][a]=1; } } cut=0; for(i=2;i<=n;i++){ if(c[1][i]==1){ cut++; j=2; k=i-1+j; for(j=2;j<=k;) } } } cout<<cut<<endl; return 0; }
a.cc: In function 'int main()': a.cc:29:25: error: expected primary-expression before '}' token 29 | } | ^ a.cc: At global scope: a.cc:32:9: error: 'cout' does not name a type 32 | cout<<cut<<endl; | ^~~~ a.cc:33:9: error: expected unqualified-id before 'return' 33 | return 0; | ^~~~~~ a.cc:34:1: error: expected declaration before '}' token 34 | } | ^
s483956073
p00468
C++
#include <iostream> #include <vector> #include <queue> #include <stack> #include <string> #include <functional> #include <algorithm> using namespace std; typedef pair<int, int> P; int f[501][501]; bool visited[501]; int main() { int n, m; while(cin >> n >> m && n && m) { int a, b; memset(f, 0, sizeof(f)); for(int i = 0; i < m; i++) { cin >> a >> b; f[a][b] = f[b][a] = 1; } queue<P> que; que.push(P(0, 1)); memset(visited, 0, sizeof(visited)); visited[1] = true; int ans = 0; while(!que.empty()) { P p = que.front(); que.pop(); ans++; if(p.first == 2) continue; for(int j = 1; j <= n; j++) if(f[p.second][j] == 1 && !visited[j]) { que.push(P(p.first + 1, j)); visited[j] = true; } } cout << (ans - 1) << endl; } }
a.cc: In function 'int main()': a.cc:19:9: error: 'memset' was not declared in this scope 19 | memset(f, 0, sizeof(f)); | ^~~~~~ a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 7 | #include <algorithm> +++ |+#include <cstring> 8 | using namespace std;
s457011923
p00468
C++
#include <cstdio> using namespace std; //‚·‚²‚ë‚­‚̃}ƒXî•ñ int tbl[1010]; int main(int argc, char **argv) { int n,m; scanf("%d%d", &n, &m); for(int i = 0; i < n; ++i) { scanf("%d", &tbl[i]); } int cur = 0; for(int i = 0; i < m; ++i) { int t; scanf("%d", &t); // ‚³‚¢‚±‚ë‚É‚æ‚éˆÚ“® cur += t; if(cur >= n-1) { printf("%d\n", i+1); return 0; } // ƒ}ƒX–Ú‚ÌŽwަ‚É‚æ‚éˆÚ“® cur += tbl[cur]; // ‚±‚Á‚¿‚Ìif•¶‚ð‘‚«–Y‚ê‚邯4“_Œ¸“_B116“_‚̐l‚Í‘½‚©‚Á‚½‚悤‚Å‚·B if(cur >= n-1) { printf("%d\n", i+1); return 0; } } return 0; } –â‘è3 /* * JOI 2010 —\‘I –â‘è3 C++‰ð“š—á by qnighy */ // –â‘è: // ƒp[ƒeƒB[ // http://www.ioi-jp.org/joi/2009/2010-yo-prob_and_sol/2010-yo-t3/2010-yo-t3.html #include <cstdio> // memset‚ðŽg‚¤‚Ì‚Åinclude‚µ‚Ă܂· #include <cstring> using namespace std; // 2l‚Í—FlŠÖŒW‚É‚ ‚é‚©‚Ç‚¤‚© bool mat[500][500]; // >>1‚³‚ñ‚Ì—F’B‚â—F’B‚Ì—F’B‚©‚Ç‚¤‚©‚̃tƒ‰ƒO bool flags[500]; int main(int argc, char **argv) { // ‰Šú‰» memset(mat, 0, sizeof(mat)); memset(flags, 0, sizeof(flags)); int n,m; scanf("%d%d", &n, &m); for(int i = 0; i < m; ++i) { int a,b; scanf("%d%d", &a, &b); // ‚±‚±‚Å‚Í0ƒXƒ^[ƒg‚̔ԍ†‚É‚µ‚½‚¢‚Ì‚Å1‚Ђ¢‚Ä‚é // —¼•ûŒü‚̃tƒ‰ƒO‚𗧂Ă邱‚ƂɒˆÓ mat[a-1][b-1]=mat[b-1][a-1]=true; } for(int i = 0; i < n; ++i) { if(mat[0][i]) { // —F’Bƒtƒ‰ƒO flags[i] = true; for(int j = 0; j < n; ++j) { if(mat[i][j]) { // —F’B‚Ì—F’Bƒtƒ‰ƒO flags[j] = true; } } } } // Ž©•ª‚͏œŠO // —F’B‚Ì—F’B‚ªŽ©•ª‚¾‚Á‚½‚è‚·‚é‚̂Šflags[0] = false; // ”‚¦‚ďo—Í int cnt = 0; for(int i = 0; i < n; ++i) { if(flags[i])cnt++; } printf("%d\n", cnt); return 0; }
a.cc:35:1: error: extended character – is not valid in an identifier 35 | –â‘è3 | ^ a.cc:35:1: error: extended character ‘ is not valid in an identifier a.cc:35:1: error: '\302\226\303\242\302\221\303\2503' does not name a type 35 | –â‘è3 | ^~~~~ In file included from a.cc:46: /usr/include/c++/14/cstring:78:11: error: 'memchr' has not been declared in '::' 78 | using ::memchr; | ^~~~~~ /usr/include/c++/14/cstring:79:11: error: 'memcmp' has not been declared in '::' 79 | using ::memcmp; | ^~~~~~ /usr/include/c++/14/cstring:80:11: error: 'memcpy' has not been declared in '::' 80 | using ::memcpy; | ^~~~~~ /usr/include/c++/14/cstring:81:11: error: 'memmove' has not been declared in '::' 81 | using ::memmove; | ^~~~~~~ /usr/include/c++/14/cstring:82:11: error: 'memset' has not been declared in '::' 82 | using ::memset; | ^~~~~~ /usr/include/c++/14/cstring:83:11: error: 'strcat' has not been declared in '::' 83 | using ::strcat; | ^~~~~~ /usr/include/c++/14/cstring:84:11: error: 'strcmp' has not been declared in '::' 84 | using ::strcmp; | ^~~~~~ /usr/include/c++/14/cstring:85:11: error: 'strcoll' has not been declared in '::' 85 | using ::strcoll; | ^~~~~~~ /usr/include/c++/14/cstring:86:11: error: 'strcpy' has not been declared in '::' 86 | using ::strcpy; | ^~~~~~ /usr/include/c++/14/cstring:87:11: error: 'strcspn' has not been declared in '::' 87 | using ::strcspn; | ^~~~~~~ /usr/include/c++/14/cstring:88:11: error: 'strerror' has not been declared in '::' 88 | using ::strerror; | ^~~~~~~~ /usr/include/c++/14/cstring:89:11: error: 'strlen' has not been declared in '::' 89 | using ::strlen; | ^~~~~~ /usr/include/c++/14/cstring:90:11: error: 'strncat' has not been declared in '::' 90 | using ::strncat; | ^~~~~~~ /usr/include/c++/14/cstring:91:11: error: 'strncmp' has not been declared in '::' 91 | using ::strncmp; | ^~~~~~~ /usr/include/c++/14/cstring:92:11: error: 'strncpy' has not been declared in '::' 92 | using ::strncpy; | ^~~~~~~ /usr/include/c++/14/cstring:93:11: error: 'strspn' has not been declared in '::' 93 | using ::strspn; | ^~~~~~ /usr/include/c++/14/cstring:95:11: error: 'strtok' has not been declared in '::' 95 | using ::strtok; | ^~~~~~ /usr/include/c++/14/cstring:97:11: error: 'strxfrm' has not been declared in '::' 97 | using ::strxfrm; | ^~~~~~~ /usr/include/c++/14/cstring:98:11: error: 'strchr' has not been declared in '::' 98 | using ::strchr; | ^~~~~~ /usr/include/c++/14/cstring:99:11: error: 'strpbrk' has not been declared in '::' 99 | using ::strpbrk; | ^~~~~~~ /usr/include/c++/14/cstring:100:11: error: 'strrchr' has not been declared in '::' 100 | using ::strrchr; | ^~~~~~~ /usr/include/c++/14/cstring:101:11: error: 'strstr' has not been declared in '::' 101 | using ::strstr; | ^~~~~~ a.cc:55:5: error: redefinition of 'int main(int, char**)' 55 | int main(int argc, char **argv) | ^~~~ a.cc:7:5: note: 'int main(int, char**)' previously defined here 7 | int main(int argc, char **argv) | ^~~~ a.cc: In function 'int main(int, char**)': a.cc:58:5: error: 'memset' was not declared in this scope 58 | memset(mat, 0, sizeof(mat)); | ^~~~~~ a.cc:47:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 46 | #include <cstring> +++ |+#include <cstring> 47 |
s308738388
p00468
C++
include<iostream> using namespace std; int main(){ int n,m; while(cin >> n >> m && n + m){ int data[n+1]; int sum = -1; for(int i = 0; i <= n; i++) data[i] = 0; data[1] = 1; int a[m],b[m]; for(int i = 0; i < m; i++){ cin >> a[i] >> b[i]; if(data[a[i]] == 1 && data[a[i]] < 3) data[b[i]] = 2; } for(int i = 0; i < m; i++){ if(data[a[i]] == 2 && data[a[i]] < 3) data[b[i]] = 3; } for(int i = 1; i <= n; i++){ if(data[i] > 0 && data[i] < 4) sum++; } cout << sum << endl; } return 0; }
a.cc:1:1: error: 'include' does not name a type 1 | include<iostream> | ^~~~~~~ a.cc: In function 'int main()': a.cc:8:9: error: 'cin' was not declared in this scope 8 | while(cin >> n >> m && n + m){ | ^~~ a.cc:24:5: error: 'cout' was not declared in this scope 24 | cout << sum << endl; | ^~~~ a.cc:24:20: error: 'endl' was not declared in this scope 24 | cout << sum << endl; | ^~~~
s716616638
p00468
C++
while(1){int n,m,i,j,a,b,x[501]={},c[501][501]={},num[501]={},sum=0;scanf("%d%d",&n,&m);if(n==0)break;for(i=1;i<=m;i++){scanf("%d%d",&a,&b);if(a==1){num[b]++;}c[a][b]=1;c[b][a]=1;}for(i=1;i<=n;i++){for(j=1;j<=n;j++){if(c[1][i]==1&&c[i][j]==1){num[j]++;}}}for(i=2;i<=n;i++){if(num[i]!=0)sum++;}printf("%d\n",sum);}
a.cc:1:1: error: expected unqualified-id before 'while' 1 | while(1){int n,m,i,j,a,b,x[501]={},c[501][501]={},num[501]={},sum=0;scanf("%d%d",&n,&m);if(n==0)break;for(i=1;i<=m;i++){scanf("%d%d",&a,&b);if(a==1){num[b]++;}c[a][b]=1;c[b][a]=1;}for(i=1;i<=n;i++){for(j=1;j<=n;j++){if(c[1][i]==1&&c[i][j]==1){num[j]++;}}}for(i=2;i<=n;i++){if(num[i]!=0)sum++;}printf("%d\n",sum);} | ^~~~~
s342466344
p00468
C++
#include <iostream> #include <string> using namespace std; int main(){ int n; int m; int c; int e; while(cin >>n>>m){ if(n==0&&m==0){break;} int a[m]; int b[m]; c=0; while(c<m){ cin >>a[c]>>b[c]; c=c+1;} int d[n]; d[0]=3; c=1; while(c<n){ d[c]=0; c=c+1;} c=0; while(c<m){ if(a[c]==1){d[b[c]-1]=2;} if(b[c]==1){d[a[c]-1]=2;} c=c+1;} c=0; while(c<m){ if(d[a[c]-1]==2&&d[b[c]-1]==0){d[b[c]-1]=1;} if(d[b[c]-1]==2&&d[b[c]-1]==0){d[a[c]-1]=1;} c=c+1;} e=0; c=1; while(c<n){ if(d[c]==1||d[c]==2){e=e+1;} c=c+1;} cout <<e<<endl;}
a.cc: In function 'int main()': a.cc:38:17: error: expected '}' at end of input 38 | cout <<e<<endl;} | ^ a.cc:4:11: note: to match this '{' 4 | int main(){ | ^
s932529318
p00468
C++
#include <stdio.h> int main (void) { int j,i,n,m,friend[501][501]={0},from,to,called[501] = {0}; int count = 0; while(1){ for(i = 0; i < 501;i++){ for(j = 0; j < 501;j++){ friend[i][j] = 0; } called[i] = 0; } count = 0; scanf("%d",&n); scanf("%d",&m); if(m == 0 && n == 0)break; for(i = 0; i < m; i++ ){ scanf("%d %d",&from,&to); // printf("from: %d to: %d\n", from, to); friend[from][to] = 1; friend[to][from] = 1; } /* for(i=1; i <= n; i++) for(j=1; j <= n; j++) printf("friend[%d][%d]: %d\n", i, j, friend[i][j]); */ called[0] = 1; called[1] = 1; for(i = 1; i <= n; i++){ if(friend[1][i] == 1){ if(called[i] == 0) { count++; } called[i] = 1; for(j = 1; j <= n; j++){ if(friend[i][j] == 1 && called[j] == 0){ called[j] = 1; count++; } } } } printf("%d\n",count); } return 0; }
a.cc: In function 'int main()': a.cc:6:15: error: expected unqualified-id before 'friend' 6 | int j,i,n,m,friend[501][501]={0},from,to,called[501] = {0}; | ^~~~~~ a.cc:6:35: error: expected primary-expression before ',' token 6 | int j,i,n,m,friend[501][501]={0},from,to,called[501] = {0}; | ^ a.cc:6:36: error: 'from' was not declared in this scope 6 | int j,i,n,m,friend[501][501]={0},from,to,called[501] = {0}; | ^~~~ a.cc:6:41: error: 'to' was not declared in this scope 6 | int j,i,n,m,friend[501][501]={0},from,to,called[501] = {0}; | ^~ a.cc:6:44: error: 'called' was not declared in this scope 6 | int j,i,n,m,friend[501][501]={0},from,to,called[501] = {0}; | ^~~~~~ a.cc:12:5: error: 'friend' used outside of class 12 | friend[i][j] = 0; | ^~~~~~ | ------ a.cc:12:11: error: ISO C++ forbids declaration of 'structured binding' with no type [-fpermissive] 12 | friend[i][j] = 0; | ^~~ a.cc:12:11: error: structured binding declaration cannot have type 'int' a.cc:12:11: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:12:14: error: expected initializer before '[' token 12 | friend[i][j] = 0; | ^ a.cc:12:14: error: expected ';' before '[' token a.cc:27:7: error: 'friend' used outside of class 27 | friend[from][to] = 1; | ^~~~~~ | ------ a.cc:27:13: error: ISO C++ forbids declaration of 'structured binding' with no type [-fpermissive] 27 | friend[from][to] = 1; | ^~~~~~ a.cc:27:13: error: structured binding declaration cannot have type 'int' a.cc:27:13: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:27:19: error: expected initializer before '[' token 27 | friend[from][to] = 1; | ^ a.cc:27:19: error: expected ';' before '[' token a.cc:28:7: error: 'friend' used outside of class 28 | friend[to][from] = 1; | ^~~~~~ | ------ a.cc:28:13: error: ISO C++ forbids declaration of 'structured binding' with no type [-fpermissive] 28 | friend[to][from] = 1; | ^~~~ a.cc:28:13: error: structured binding declaration cannot have type 'int' a.cc:28:13: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:28:17: error: expected initializer before '[' token 28 | friend[to][from] = 1; | ^ a.cc:28:17: error: expected ';' before '[' token a.cc:40:10: error: 'friend' used outside of class 40 | if(friend[1][i] == 1){ | ^~~~~~ | ------ ' a.cc:40: confused by earlier errors, bailing out
s830483190
p00468
C++
#include <stdio.h> int main (void) { int j,i,n,m,friend[501][501]={0},from,to,called[501] = {0}; int count = 0; while(1){ for(i = 0; i < 501;i++){ for(j = 0; j < 501;j++){ friend[i][j] = 0; } called[i] = 0; } count = 0; scanf("%d",&n); scanf("%d",&m); if(m == 0 && n == 0)break; for(i = 0; i < m; i++ ){ scanf("%d %d",&from,&to); // printf("from: %d to: %d\n", from, to); friend[from][to] = 1; friend[to][from] = 1; } /* for(i=1; i <= n; i++) for(j=1; j <= n; j++) printf("friend[%d][%d]: %d\n", i, j, friend[i][j]); */ called[0] = 1; called[1] = 1; for(i = 1; i <= n; i++){ if(friend[1][i] == 1){ if(called[i] == 0) { count++; } called[i] = 1; for(j = 1; j <= n; j++){ if(friend[i][j] == 1 && called[j] == 0){ called[j] = 1; count++; } } } } printf("%d\n",count); } return 0; }
a.cc: In function 'int main()': a.cc:6:15: error: expected unqualified-id before 'friend' 6 | int j,i,n,m,friend[501][501]={0},from,to,called[501] = {0}; | ^~~~~~ a.cc:6:35: error: expected primary-expression before ',' token 6 | int j,i,n,m,friend[501][501]={0},from,to,called[501] = {0}; | ^ a.cc:6:36: error: 'from' was not declared in this scope 6 | int j,i,n,m,friend[501][501]={0},from,to,called[501] = {0}; | ^~~~ a.cc:6:41: error: 'to' was not declared in this scope 6 | int j,i,n,m,friend[501][501]={0},from,to,called[501] = {0}; | ^~ a.cc:6:44: error: 'called' was not declared in this scope 6 | int j,i,n,m,friend[501][501]={0},from,to,called[501] = {0}; | ^~~~~~ a.cc:12:5: error: 'friend' used outside of class 12 | friend[i][j] = 0; | ^~~~~~ | ------ a.cc:12:11: error: ISO C++ forbids declaration of 'structured binding' with no type [-fpermissive] 12 | friend[i][j] = 0; | ^~~ a.cc:12:11: error: structured binding declaration cannot have type 'int' a.cc:12:11: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:12:14: error: expected initializer before '[' token 12 | friend[i][j] = 0; | ^ a.cc:12:14: error: expected ';' before '[' token a.cc:27:7: error: 'friend' used outside of class 27 | friend[from][to] = 1; | ^~~~~~ | ------ a.cc:27:13: error: ISO C++ forbids declaration of 'structured binding' with no type [-fpermissive] 27 | friend[from][to] = 1; | ^~~~~~ a.cc:27:13: error: structured binding declaration cannot have type 'int' a.cc:27:13: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:27:19: error: expected initializer before '[' token 27 | friend[from][to] = 1; | ^ a.cc:27:19: error: expected ';' before '[' token a.cc:28:7: error: 'friend' used outside of class 28 | friend[to][from] = 1; | ^~~~~~ | ------ a.cc:28:13: error: ISO C++ forbids declaration of 'structured binding' with no type [-fpermissive] 28 | friend[to][from] = 1; | ^~~~ a.cc:28:13: error: structured binding declaration cannot have type 'int' a.cc:28:13: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:28:17: error: expected initializer before '[' token 28 | friend[to][from] = 1; | ^ a.cc:28:17: error: expected ';' before '[' token a.cc:40:10: error: 'friend' used outside of class 40 | if(friend[1][i] == 1){ | ^~~~~~ | ------ ' a.cc:40: confused by earlier errors, bailing out
s836323295
p00468
C++
#include<iostream> #include<cstdio> #include<cstring> #define SWAP(type,a,b) do{type temp=a;a=b;b=temp;}while(0) using namespace std; int main(){ int n[501],m[501][501],tmp[501]; int nt,mt,a,b,sum=0; while(1){ sum=0; for(int i=0;i<=500;i++){ for(int j=0;j<=500;j++){ m[i][j]=0; } n[i]=m[i]=0; } cin >> nt >> mt; if(nt==0&&mt==0)break; for(int i=0;i<mt;i++){ cin >> a >> b; if(b<a)SWAP(int,a,b); if(a==1){ n[b]=tmp[b]=1; }else{ m[a][b]=1; m[b][a]=1; } } for(int i=2;i<=500;i++){ if(n[i]==1){ for(int j=2;j<=500;j++){ if(m[i][j]==1)tmp[j]=1; } } } for(int i=2;i<=500;i++){ if(tmp[i]==1){ sum++; } } cout << sum << endl; } }
a.cc: In function 'int main()': a.cc:15:16: error: incompatible types in assignment of 'int' to 'int [501]' 15 | n[i]=m[i]=0; | ~~~~^~
s945404792
p00468
C++
#include<iostream> using namespace std; int main(){ int ans,n,m,state1,state2,fre[501][501]={{0}}; while(1){ cin >> n; cin >> m; if(n==0 && m==0){ break; } for(int i=0;i<n+2;i++){ memset(fre[i],0,sizeof(fre[i])); } for(int i=0;i<m;i++){ cin >> state1 >> state2; fre[state1][state2]=1; } ans=0; for(int i=0;i<n;i++){ if(fre[1][i]==1 || fre[1][i]==2){ fre[1][i]=0; //cout << "友達:" << i << endl; if(fre[1][i]==2){ ans++; } for(int j=0;j<n;j++){ if(fre[i][j]==1){ ans++; fre[i][j]=0; fre[1][j]=2; //cout << "友達の友達:" << j << endl; } } } } cout << ans << endl; } }
a.cc: In function 'int main()': a.cc:12:7: error: 'memset' was not declared in this scope 12 | memset(fre[i],0,sizeof(fre[i])); | ^~~~~~ 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;
s649801002
p00468
C++
/* title: Party * source: JOI2009-2010 Yosen No.3 * hint: * 多頂点最短路を探索して自分からの距離が2以下のものを列挙すればよい * 最短路探索はDijkstra, Bellman-Ford, Warshall-Floydなどのアルゴリズムが有名 * Warshall-Floyd が一番簡単なのでこれだけでも覚えておこう * でも実際、予選は全ての資料を持込可能なので覚えている必要もない * 蟻本のどこに載っているかぐらいは覚えておこう */ #include <iostream> #include <vector> using namespace std; const int INF = 1 << 30; int main() { while(true) { int N, M; cin >> N >> M; if(!(N || M)) break; vector<vector<int> > G(N, vector<int>(N, INF)); for(int i = 0; i < M; i++) { int a, b; cin >> a >> b; G[a-1][b-1] = G[b-1][a-1] = 1; } for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) for(int k = 0; k < N; k++) if(G[i][k] != INF && G[k][j] != INF) G[i][j] = min(G[i][j], G[i][k] + G[k][j]); cout << count_if(G[0].begin()+1, G[0].end(), [](int l){ return l <= 2; }) << endl; } }
a.cc: In function 'int main()': a.cc:42:25: error: 'count_if' was not declared in this scope 42 | cout << count_if(G[0].begin()+1, G[0].end(), [](int l){ return l <= 2; }) << endl; | ^~~~~~~~
s590013759
p00468
C++
include<iostream> #include<cstring> using namespace std; int main() { int n,m; for(;cin>>n>>m,n||m;) { int data[n+1]; memset(data,-1,sizeof(data)); int list[2][m]; for(int i=0;i<m;i++) { cin>>list[0][i]>>list[1][i]; if(list[0][i]==1) data[list[1][i]]=1; } for(int i=0;i<m;i++) { if(data[list[0][i]]==1) data[list[1][i]]=2; if(data[list[1][i]]==1) data[list[0][i]]=2; } int cnt=0; for(int i=2;i<n+1;i++) if(data[i]>0) cnt++; cout<<cnt<<endl; } }
a.cc:1:1: error: 'include' does not name a type 1 | include<iostream> | ^~~~~~~ a.cc: In function 'int main()': a.cc:8:8: error: 'cin' was not declared in this scope 8 | for(;cin>>n>>m,n||m;) | ^~~ a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 2 | #include<cstring> +++ |+#include <iostream> 3 | using namespace std; a.cc:30:7: error: 'cout' was not declared in this scope 30 | cout<<cnt<<endl; | ^~~~ a.cc:30:7: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:30:18: error: 'endl' was not declared in this scope 30 | cout<<cnt<<endl; | ^~~~ a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 2 | #include<cstring> +++ |+#include <ostream> 3 | using namespace std;
s119405353
p00469
C
#include<cstdio> #include<set> using namespace std; set<int> numbers; int n, k, cards[10], used[10]; void addcard(int x, int y){ if(x == 0){ numbers.insert(y); } for(int i = 0;i < n;i++){ if(used[i] == 0){ int shift = 10; if(cards[i] >= 10)shift *= 10; used[i] = 1; addcard(x - 1, y * shift + cards[i]); used[i] = 0; } } } int main(){ while(1){ numbers.clear(); scanf("%d%d", &n, &k); if(n == 0 && k == 0)return 0; for(int i = 0;i < n;i++){ used[i] = 0; scanf("%d", cards + i); } addcard(k, 0); printf("%d\n", numbers.size()); } }
main.c:1:9: fatal error: cstdio: No such file or directory 1 | #include<cstdio> | ^~~~~~~~ compilation terminated.
s650789154
p00469
C++
#include "bits/stdc++.h" #define rep(i, n) for(int i = 0; i < (int)n; i++) #define all(co) co.begin(), co.end() using namespace std; //using P = pair<int, int>; int main() { int n; while (cin >> n && n) { int k; cin >> k; vector<string> vec(n); rep(i, n) cin >> vec[i]; set<string> sets; vector<bool> used(n); void dfs(string str, int count) { if (count == k) { sets.insert(str); return; } rep(i, n) if (!used[i]) { used[i] = true; dfs(str + vec[i], count + 1); used[i] = false; } }; dfs("", 0); cout << sets.size() << endl; } return 0; }
a.cc: In function 'int main()': a.cc:17:49: error: a function-definition is not allowed here before '{' token 17 | void dfs(string str, int count) { | ^ a.cc:28:17: error: 'dfs' was not declared in this scope; did you mean 'ffs'? 28 | dfs("", 0); | ^~~ | ffs
s034768893
p00469
C++
#include "bits/stdc++.h" #define rep(i, n) for(int i = 0; i < (int)n; i++) #define all(co) co.begin(), co.end() using namespace std; //using P = pair<int, int>; int main() { int n; while (cin >> n && n) { int k; cin >> k; vector<string> vec(n); rep(i, n) cin >> vec[i]; set<string> sets; vector<bool> used(n); extern "C" void dfs (string str, int count) { if (count == k) { sets.insert(str); return; } rep(i, n) if (!used[i]) { used[i] = true; dfs(str + vec[i], count + 1); used[i] = false; } } dfs("", 0); cout << sets.size() << endl; } return 0; }
a.cc: In function 'int main()': a.cc:17:16: error: expected unqualified-id before string constant 17 | extern "C" void dfs (string str, int count) { | ^~~ a.cc:28:9: error: 'dfs' was not declared in this scope; did you mean 'ffs'? 28 | dfs("", 0); | ^~~ | ffs
s322172325
p00469
C++
#include "bits/stdc++.h" #define rep(i, n) for(int i = 0; i < (int)n; i++) #define all(co) co.begin(), co.end() using namespace std; //using P = pair<int, int>; int main() { int n; while (cin >> n && n) { int k; cin >> k; vector<string> vec(n); rep(i, n) cin >> vec[i]; set<string> sets; vector<bool> used(n); extern "C"{ void dfs (string str, int count) { if (count == k) { sets.insert(str); return; } rep(i, n) if (!used[i]) { used[i] = true; dfs(str + vec[i], count + 1); used[i] = false; } }} dfs("", 0); cout << sets.size() << endl; } return 0; }
a.cc: In function 'int main()': a.cc:17:16: error: expected unqualified-id before string constant 17 | extern "C"{ void dfs (string str, int count) { | ^~~ a.cc:28:9: error: 'dfs' was not declared in this scope; did you mean 'ffs'? 28 | dfs("", 0); | ^~~ | ffs
s120404640
p00469
C++
#include <iostream> #include <cstdio> #include <vector> using namespace std; vector<string> v; v_push(string str){ bool checker; checker = true; for(int len = 0; len < v.size(); len++){ if(v.at(len) == str){ checker = false; break; } } if(checker){ v.push_back(str); } } string str_int(int num){ string str = ""; if(num == 0){ str = "0"; return str; } while(true){ if(num == 0){ break; } string d = "D"; d[0] = '0' + (num % 10); str = d + str; num /= 10; } return str; } int main(){ int n, k; int num[20]; while(true){ cin >> n >> k; if(n == 0 && k == 0){ break; } for(int i = 0; i < n; i++){ cin >> num[i]; } string str; if(k == 2){ for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ if(i == j){ continue; }else{ str = str_int(num[i]) + str_int(num[j]); v_push(str); } } } }else if(k == 3){ for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ for(int k = 0; k < n; k++){ if(i == j || i == k || j == k){ continue; }else{ str = str_int(num[i]) + str_int(num[j]) + str_int(num[k]); v_push(str); } } } } }else if(k == 4){ for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ for(int k = 0; k < n; k++){ for(int l = 0; l < n; l++){ if(i == j || i == k || j == k || i == l || j == l || k == l){ continue; }else{ str = str_int(num[i]) + str_int(num[j]) + str_int(num[k]) + str_int(num[l]); v_push(str); } } } } } } printf("%d\n", v.size()); v.erase(v.begin(), v.end()); } return 0; }
a.cc:9:1: error: ISO C++ forbids declaration of 'v_push' with no type [-fpermissive] 9 | v_push(string str){ | ^~~~~~ a.cc: In function 'int v_push(std::string)': a.cc:22:1: warning: no return statement in function returning non-void [-Wreturn-type] 22 | } | ^
s300780353
p00469
C++
#include <iostream> #include <cstdio> #include <vector> using namespace std; vector<string> v; v_push(string str){ bool checker; checker = true; for(int len = 0; len < v.size(); len++){ if(v.at(len) == str){ checker = false; break; } } if(checker){ v.push_back(str); } } string str_int(int num){ string str = ""; if(num == 0){ str = "0"; return str; } while(true){ if(num == 0){ break; } string d = "D"; d[0] = '0' + (num % 10); str = d + str; num /= 10; } return str; } int main(){ int n, k; int num[20]; while(true){ cin >> n >> k; if(n == 0 && k == 0){ break; } for(int i = 0; i < n; i++){ cin >> num[i]; } string str; if(k == 2){ for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ if(i == j){ continue; }else{ str = str_int(num[i]) + str_int(num[j]); v_push(str); } } } }else if(k == 3){ for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ for(int k = 0; k < n; k++){ if(i == j || i == k || j == k){ continue; }else{ str = str_int(num[i]) + str_int(num[j]) + str_int(num[k]); v_push(str); } } } } }else if(k == 4){ for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ for(int k = 0; k < n; k++){ for(int l = 0; l < n; l++){ if(i == j || i == k || j == k || i == l || j == l || k == l){ continue; }else{ str = str_int(num[i]) + str_int(num[j]) + str_int(num[k]) + str_int(num[l]); v_push(str); } } } } } } printf("%d\n", v.size()); v.erase(v.begin(), v.end()); } return 0; }
a.cc:9:1: error: ISO C++ forbids declaration of 'v_push' with no type [-fpermissive] 9 | v_push(string str){ | ^~~~~~ a.cc: In function 'int v_push(std::string)': a.cc:22:1: warning: no return statement in function returning non-void [-Wreturn-type] 22 | } | ^
s285888723
p00469
C++
#include <iostream> #include <string> #include <sstream> #include <algorithm> #include <vector> #include <utility> #include <stack> #include <queue> #include <map> #include <set> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <ctime> using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) #define repc(i,s,e) for(int i=(s); i<(e); i++) #define pb(n) push_back((n)) #define mp(n,m) make_pair((n),(m)) #define all(r) r.begin(),r.end() #define fi first #define se second typedef long long ll; typedef vector<int> vi; typedef vector<vi> vii; typedef vector<ll> vl; typedef vector<vl> vll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int INF = 10000000; const int MOD = 1e9 + 7; int n, k; set<string> st; string s; vi v; void calc(int c, vi u){ if(c == k){ do{ string t; for(int i = 0; i < k; i++){ t += to_string(u[i]); } st.insert(t); }while(next_permutation(all(u)); return; } for(int i = c; i + k - c <n; i++){ u.pb(v[i]); calc(c+1, u); u.pop_back(); } } int main(){ while(cin>>n>>k){ if(n == 0 && k == 0) break; v = vi(n); rep(i, n) cin>>v[i]; s = ""; st.clear(); vi tmp; calc(0,tmp); cout<<st.size()<<endl; } }
a.cc: In function 'void calc(int, vi)': a.cc:54:48: error: expected ')' before ';' token 54 | }while(next_permutation(all(u)); | ~ ^ | )
s152008533
p00469
C++
#include <bits/stdc++.h> #define FOR(i,n) for(int i=0;i<(int)(n);i++) #define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++) #define pb(a) push_back(a) #define ZERO(a) memset(a,0,sizeof(a)) #define len(a) sizeof(a) #define ll long long #define INF 1<<29 #define MAX 11 using namespace std; int a[MAX],s[MAX]; void solve(){ int n,k; for(;;){ cin>>n; cin>>k; if(!n&&!k) break; set<string> S; string ss; FOR(i,n) cin>>a[i]; FOR(i,1<<n){ if(__builtin_popcount(i)!=k) continue; int p=0; FOR(j,n) if((1<<j)&i) s[p++]=j; vector<int> ord(k); FOR(j,k) ord.pb(j); do{ ss=""; FOR(j,k) s+=to_string(a[s[ord[j]]]); S.insert(ss); }while(next_permutation(ord.begin(),ord.end())); } cout<<S.size()<<endl; } } int main(){ solve(); return 0; }
a.cc: In function 'void solve()': a.cc:31:15: error: no match for 'operator+=' (operand types are 'int [11]' and 'std::string' {aka 'std::__cxx11::basic_string<char>'}) 31 | FOR(j,k) s+=to_string(a[s[ord[j]]]); | ~^~~~~~~~~~~~~~~~~~~~~~~~~
s143219145
p00469
C++
#include <bits/stdc++.h> #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--) #define REP(i,n) for(int i=0;i<(n);i++) #define RREP(i,n) for(int i=n-1;i>=0;i--) #define PB push_back #define INF (1<<29) #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(),(a).rend() #define CLR(a) memset(a,0,sizeof(a)) const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0}; typedef long long int ll; using namespace std; vector<string> card; set<int> used; set<int> ans; int n,k; void saiki(int t,string s){ if(t == k){ ans.insert(stoi(s)); } REP(i,n){ if(used.find(i) == used.end()){ used.insert(i); saiki(t+1,s+card[i]); used.erase(i); } } } int main(){ while(true){ cin >> n >> k; if(n==0&&k==0) break; card = vector<string>(n); memset(c,false,sizeof(c)); REP(i,n){ cin >> card[i]; } saiki(0,""); cout << ans.size() << endl; ans.clear(); used.clear(); } return 0; }
a.cc: In function 'int main()': a.cc:41:16: error: 'c' was not declared in this scope 41 | memset(c,false,sizeof(c)); | ^
s583073463
p00469
C++
#include <iostream> #include <algorithm> #include <vector> #include <queue> #include <set> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> using namespace std; #define rep(i,n) for(int i=0;i<(n);i++) #define reps(i,f,n) for(int i=(f);i<(n);i++) int main(void){ while(1){ int n, k; scanf("%d %d", &n, &k); if(n == 0 && k == 0) return 0; vector<string> data(n); set<string> num; rep(i, n) scanf("%d", &data[i]); sort(data.begin(), data.end()); do{ string tmp; rep(i, k){ tmp += data[i] } num.insert(tmp); }while(next_permutation(data.begin(), data.second())); printf("%d\n", num.size()); } }
a.cc: In function 'int main()': a.cc:28:47: error: expected ';' before '}' token 28 | tmp += data[i] | ^ | ; 29 | } | ~ a.cc:31:60: error: 'class std::vector<std::__cxx11::basic_string<char> >' has no member named 'second' 31 | }while(next_permutation(data.begin(), data.second())); | ^~~~~~
s957543783
p00469
C++
#include<stdio.h> #include<string> #include<set> using namespace std; int n, k; int card[10]; bool b[10]; set<string>ans; void solve(string sum, int rest) { if (!rest) { ans.insert(sum); return; } for (int i = 0; i < n; i++) { if (!b[i]){ b[i] = true; solve(sum + to_string(card[i]), rest - 1); b[i] = false; } } } int main(){ while (scanf("%d%d", &n, &k), n){ ans.clear(); memset(b, 0, sizeof(b)); for (int i = 0; i < n; i++) scanf("%d", &card[i]); solve("\0", k); printf("%d\n", ans.size()); } return 0; }
a.cc: In function 'int main()': a.cc:26:17: error: 'memset' was not declared in this scope 26 | memset(b, 0, sizeof(b)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include<set> +++ |+#include <cstring> 4 | using namespace std;
s887079786
p00469
C++
#include<iostream> #include<vector> #include<string> #include<algorithm> using namespace std; int n,k,a[10],power[5]; vector<string>vec; int main(){ while(true){ cin>>n>>k;vec.clear();power[0]=1;for(int i=1;i<5;i++)power[i]=power[i-1]*n; if(n==0 && k==0)break; for(int i=0;i<n;i++)cin>>a[i]; for(int i=0;i<power[k];i++){ int bit[4];for(int j=0;j<k;j++)bit[j]=(i/power[j])%n; bool OK=true; if(k==2 && (bit[0]==bit[1]))OK=false; if(k==3 && (bit[0]==bit[1] || bit[0]==bit[2] || bit[1]==bit[2]))OK=false; if(k==4 && (bit[0]==bit[1] || bit[0]==bit[2] || bit[1]==bit[2]))OK=false; if(k==3 && (bit[0]==bit[3] || bit[1]==bit[3] || bit[2]==bit[3]))OK=false; if(OK==true){ string S=""; for(int j=0;j<k;j++)S+=to_string(a[bit[j]]); vec.push_back(S); } } sort(S.begin(),S.end());int cnt=1; for(int i=1;i<S.size();i++){ if(S[i-1]!=S[i])cnt++; } cout<<cnt<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:26:22: error: 'S' was not declared in this scope 26 | sort(S.begin(),S.end());int cnt=1; | ^
s199064939
p00469
C++
#include <iostream> #include <vector> using namespace std; int n={},k={}; string integer[11]={}; vector<string>num={}; int chousen[11]={}; string complete_integer[10000]={}; string answer={}; int integer_count=0; void operation(){ for(int i=1;i<=n;i++){ if (chousen[i]==0){ chousen[i]=1; num.push_back(integer[i]); if(num.size()==k){ for(int i=1;i<=k;i++){ answer+=num[i-1]; } for(int i=1;i<=integer_count;i++){ if(answer==complete_integer[i]){ goto none; } } integer_count+=1; complete_integer[integer_count]=answer; none:; answer={}; }else{ operation(); } num.pop_back(); chousen[i]=0; } } }
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s549635492
p00469
C++
#include <iostream> #include <vector> using namespace std; int n={},k={}; string integer[11]={}; vector<string>num={}; int chousen[11]={}; string complete_integer[10000]={}; string answer={}; int integer_count=0; void operation(){ for(int i=1;i<=n;i++){ if (chousen[i]==0){ chousen[i]=1; num.push_back(integer[i]); if(num.size()==k){ for(int i=1;i<=k;i++){ answer+=num[i-1]; } for(int i=1;i<=integer_count;i++){ if(answer==complete_integer[i]){ goto none; } } integer_count+=1; complete_integer[integer_count]=answer; none:; answer={}; }else{ operation(); } num.pop_back(); chousen[i]=0; } } }
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s468977163
p00469
C++
#include <iostream> #include <set> #include <string> using namespace std; int main(){ int n,k; while(1){ cin>>n>>k; string S[11]; if(n==0&&k==0) break; for(int i=0; i<n; i++) cin>>S[i]; sort(S,S+n); set<string> SS; do{ string str; for(int i=0; i<k; i++) str+=S[i]; SS.insert(str); }while(next_permutation(S, S+n)); cout<<SS.size()<<endl; } }
a.cc: In function 'int main()': a.cc:13:9: error: 'sort' was not declared in this scope; did you mean 'short'? 13 | sort(S,S+n); | ^~~~ | short a.cc:19:16: error: 'next_permutation' was not declared in this scope 19 | }while(next_permutation(S, S+n)); | ^~~~~~~~~~~~~~~~
s952448860
p00469
C++
??£???
a.cc:1:3: error: extended character £ is not valid in an identifier 1 | ??£??? | ^ a.cc:1:1: error: expected unqualified-id before '?' token 1 | ??£??? | ^
s080820783
p00469
C++
#include<iostream> #include<vector> #include<set> using namespace std; int main(){ int n,k; while(scanf("%d%d",&n,&k),n+k){ int card[n]; set<int> s; for(int i=0; i<n; i++) scanf("%d",&card[i]); vector<int> v(n); for(int i=0; i<k; i++) v[n-k+i] = i+1; do{ int a[k]; for(int i=0; i<n; i++){ if(card[i]!=0) a[v[i]-1]=card[i]; } int nn = 0; for(int i=0; i<k; i++){ int tmp = a[i]; int keta = 1; while(tmp!=0){ keta*=10; tmp/=10; } nn*=keta; nn+=a[i]; } s.insert(nn); }while(next_permutation(v.begin(), v.end())); cout << s.size() << endl; } return 0; }
a.cc: In function 'int main()': a.cc:35:12: error: 'next_permutation' was not declared in this scope 35 | }while(next_permutation(v.begin(), v.end())); | ^~~~~~~~~~~~~~~~
s715894769
p00469
C++
#include<cstdio> #include<algorithm> #include<vector> #include<sstream> #include<cstdlib> using namespace std; int main(){ while(1){ int n,k; scanf("%d%d",&n,&k); if(n==0) break; vector<int> card(n); for(int i=0;i<n;i++){ scanf("%d",&card[i]); } sort(card.begin(),card.end()); vector<int> data; do{ stringstream sst; for(int i=0;i<k;i++){ sst<<card[i]; } data.push_back(atoi(sst.str().begin())); reverse( card.begin()+k,card.end()); }while( next_permutation(card.begin(),card.end()) ); sort(data.begin(),data.end()); printf("%d\n",distance(data.begin(),unique(data.begin(),data.end())) ); } }
a.cc: In function 'int main()': a.cc:31:60: error: cannot convert 'std::__cxx11::basic_string<char>::iterator' to 'const char*' 31 | data.push_back(atoi(sst.str().begin())); | ~~~~~~~~~~~~~~~^~ | | | std::__cxx11::basic_string<char>::iterator In file included from /usr/include/c++/14/cstdlib:79, from /usr/include/c++/14/bits/stl_algo.h:71, from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/stdlib.h:105:30: note: initializing argument 1 of 'int atoi(const char*)' 105 | extern int atoi (const char *__nptr) | ~~~~~~~~~~~~^~~~~~
s909960961
p00469
C++
#include<cstdio> #include<algorithm> #include<vector> #include<sstream> #include<cstdlib> using namespace std; int main(){ while(1){ int n,k; scanf("%d%d",&n,&k); if(n==0) break; vector<int> card(n); for(int i=0;i<n;i++){ scanf("%d",&card[i]); } sort(card.begin(),card.end()); vector<int> data; do{ stringstream sst; for(int i=0;i<k;i++){ sst<<card[i]; } data.push_back(atoi(sst.str().begin())); reverse( card.begin()+k,card.end()); }while( next_permutation(card.begin(),card.end()) ); sort(data.begin(),data.end()); printf("%d\n",distance(data.begin(),unique(data.begin(),data.end())) ); } }
a.cc: In function 'int main()': a.cc:31:60: error: cannot convert 'std::__cxx11::basic_string<char>::iterator' to 'const char*' 31 | data.push_back(atoi(sst.str().begin())); | ~~~~~~~~~~~~~~~^~ | | | std::__cxx11::basic_string<char>::iterator In file included from /usr/include/c++/14/cstdlib:79, from /usr/include/c++/14/bits/stl_algo.h:71, from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/stdlib.h:105:30: note: initializing argument 1 of 'int atoi(const char*)' 105 | extern int atoi (const char *__nptr) | ~~~~~~~~~~~~^~~~~~
s968890361
p00469
C++
#include<cstdio> #include<algorithm> #include<vector> #include<sstream> #include<cstdlib> using namespace std; int main(){ while(1){ int n,k; scanf("%d%d",&n,&k); if(n==0) break; vector<int> card(n); for(int i=0;i<n;i++){ scanf("%d",&card[i]); } sort(card.begin(),card.end()); vector<int> data; do{ stringstream sst; for(int i=0;i<k;i++){ sst<<card[i]; } data.push_back(atoi(sst.str().begin())); reverse( card.begin()+k,card.end()); }while( next_permutation(card.begin(),card.end()) ); sort(data.begin(),data.end()); printf("%d\n",distance(data.begin(),unique(data.begin(),data.end())) ); } }
a.cc: In function 'int main()': a.cc:31:60: error: cannot convert 'std::__cxx11::basic_string<char>::iterator' to 'const char*' 31 | data.push_back(atoi(sst.str().begin())); | ~~~~~~~~~~~~~~~^~ | | | std::__cxx11::basic_string<char>::iterator In file included from /usr/include/c++/14/cstdlib:79, from /usr/include/c++/14/bits/stl_algo.h:71, from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/stdlib.h:105:30: note: initializing argument 1 of 'int atoi(const char*)' 105 | extern int atoi (const char *__nptr) | ~~~~~~~~~~~~^~~~~~
s387391542
p00469
C++
#include<iostream> #include<cstdio> #include<string> #include<cstdlib> #include<set> using namespace std; int arr[10]; int sub[10]; int n,k; int now = 0; int cont; int c = 0; set<int> visit2; void saiki(int[],int); int main() { for(;;) { visit2.clear(); int i; c = 0; now = 0; scanf("%d",&n); scanf("%d",&k); if(n == 0 && k == 0){ break; } for(i = 0; i < n; i++){ scanf("%d",&arr[i]); } for(i = 0; i < n; i++){ sub[0] = arr[i]; // printf("\næ“ªƒJ[ƒhF%d\n",arr[i]); saiki(sub,1); now++; } cout <<visit2.size()-c << endl; } } void saiki(int temp[], int kk) { //k:’TõŠK” int used[50] = {0}; int i; int t = 0; char str[256] = ""; for(i = 0; i < kk; i++){ sprintf(str+strlen(str),"%d",temp[i]); } t = atoi(str); if(kk == k){ visit2.insert(t); return; } else{ int j; // cout << "*t = " << t << endl; for(i = 0; i < kk; i++){ for(j = 0; j < n; ++j ){ if( used[j] == 0 && arr[j] == temp[i] ){ // printf("ƒJ[ƒh%d‚ÍŽg—pÏ‚Ý\n",arr[j]); used[j] = 1; break; } } } for(i = 0; i < n; i++){ if(used[i] == 0){ temp[kk] = arr[i]; used[i] = 1; saiki(temp, kk+1); used[i] = 0; } } } }
a.cc: In function 'void saiki(int*, int)': a.cc:57:29: error: 'strlen' was not declared in this scope 57 | sprintf(str+strlen(str),"%d",temp[i]); | ^~~~~~ a.cc:6:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 5 | #include<set> +++ |+#include <cstring> 6 |
s305593820
p00469
C++
#include<iostream> #include<cstdio> #include<string> #include<set> #include<ctype.h> #include<cstdlib> using namespace std; int arr[10]; int sub[10]; int n,k; int now = 0; int cont; int c = 0; set<int> visit2; void saiki(int[],int); int main() { for(;;) { visit2.clear(); int i; c = 0; now = 0; scanf("%d",&n); scanf("%d",&k); if(n == 0 && k == 0){ break; } for(i = 0; i < n; i++){ scanf("%d",&arr[i]); } for(i = 0; i < n; i++){ sub[0] = arr[i]; saiki(sub,1); now++; } cout <<visit2.size()-c << endl; } } void saiki(int temp[], int kk) { //k:’TõŠK” int used[50] = {0}; int i,j; int t = 0; char str[256] = ""; for(i = 0; i < kk; i++){ sprintf(str+strlen(str),"%d",temp[i]); } t = atoi(str); if(kk == k){ visit2.insert(t); return; } else{ for(i = 0; i < kk; i++){ for(j = 0; j < n; ++j ){ if( used[j] == 0 && arr[j] == temp[i] ){ used[j] = 1; break; } } } for(i = 0; i < n; i++){ if(used[i] == 0){ temp[kk] = arr[i]; used[i] = 1; saiki(temp, kk+1); used[i] = 0; } } } }
a.cc: In function 'void saiki(int*, int)': a.cc:57:29: error: 'strlen' was not declared in this scope 57 | sprintf(str+strlen(str),"%d",temp[i]); | ^~~~~~ a.cc:7:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 6 | #include<cstdlib> +++ |+#include <cstring> 7 |
s977061140
p00469
C++
#include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <stack> #include <queue> #include <cstring> #include <sstream> #include <cassert> using namespace std; static const double EPS = 1e-5; typedef long long ll; typedef pair<int,int> PI; typedef vector<int> vi; #define rep(i,n) for(int i=0;i<(int)n;++i) #define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i) #define ALL(c) (c).begin(), (c).end() #define mp make_pair #define pb push_back #define f first #define s second set<string> ans; vi in; vi select; void dfs(int k,int pos){ //cout<<"dfs "<<k<<" "<<pos<<endl; if(k==0){ sort(ALL(select)); do{ string str; rep(i,select.size()){ stringstream ss; ss<<select[i]; str+=ss.str(); } ans.insert(str); }while(next_permutation(ALL(select))); sort(ALL(select)); reverse(ALL(select)); }else{ for(int i=pos;i<in.size();i++){ select[k-1]=in[i]; dfs(k-1,i+1); } } } main(){ int n,k; while(cin>>n>>k,k|n){ in.clear(); ans.clear(); select.clear(); select.resize(k); rep(i,n){ int t; cin>>t; in.pb(t); } sort(ALL(in)); dfs(k,0); cout<<ans.size()<<endl; } }
a.cc:37:4: error: 'vi select' redeclared as different kind of entity 37 | vi select; | ^~~~~~ In file included from /usr/include/x86_64-linux-gnu/sys/types.h:179, from /usr/include/stdlib.h:514, from /usr/include/c++/14/cstdlib:79, from a.cc:2: /usr/include/x86_64-linux-gnu/sys/select.h:102:12: note: previous declaration 'int select(int, fd_set*, fd_set*, fd_set*, timeval*)' 102 | extern int select (int __nfds, fd_set *__restrict __readfds, | ^~~~~~ a.cc: In function 'void dfs(int, int)': a.cc:29:20: error: request for member 'begin' in 'select', which is of non-class type 'int(int, fd_set*, fd_set*, fd_set*, timeval*)' 29 | #define ALL(c) (c).begin(), (c).end() | ^~~~~ a.cc:42:10: note: in expansion of macro 'ALL' 42 | sort(ALL(select)); | ^~~ a.cc:29:33: error: request for member 'end' in 'select', which is of non-class type 'int(int, fd_set*, fd_set*, fd_set*, timeval*)' 29 | #define ALL(c) (c).begin(), (c).end() | ^~~ a.cc:42:10: note: in expansion of macro 'ALL' 42 | sort(ALL(select)); | ^~~ a.cc:45:20: error: request for member 'size' in 'select', which is of non-class type 'int(int, fd_set*, fd_set*, fd_set*, timeval*)' 45 | rep(i,select.size()){ | ^~~~ a.cc:27:37: note: in definition of macro 'rep' 27 | #define rep(i,n) for(int i=0;i<(int)n;++i) | ^ a.cc:47:21: warning: pointer to a function used in arithmetic [-Wpointer-arith] 47 | ss<<select[i]; | ^ a.cc:29:20: error: request for member 'begin' in 'select', which is of non-class type 'int(int, fd_set*, fd_set*, fd_set*, timeval*)' 29 | #define ALL(c) (c).begin(), (c).end() | ^~~~~ a.cc:51:29: note: in expansion of macro 'ALL' 51 | }while(next_permutation(ALL(select))); | ^~~ a.cc:29:33: error: request for member 'end' in 'select', which is of non-class type 'int(int, fd_set*, fd_set*, fd_set*, timeval*)' 29 | #define ALL(c) (c).begin(), (c).end() | ^~~ a.cc:51:29: note: in expansion of macro 'ALL' 51 | }while(next_permutation(ALL(select))); | ^~~ a.cc:29:20: error: request for member 'begin' in 'select', which is of non-class type 'int(int, fd_set*, fd_set*, fd_set*, timeval*)' 29 | #define ALL(c) (c).begin(), (c).end() | ^~~~~ a.cc:52:10: note: in expansion of macro 'ALL' 52 | sort(ALL(select)); | ^~~ a.cc:29:33: error: request for member 'end' in 'select', which is of non-class type 'int(int, fd_set*, fd_set*, fd_set*, timeval*)' 29 | #define ALL(c) (c).begin(), (c).end() | ^~~ a.cc:52:10: note: in expansion of macro 'ALL' 52 | sort(ALL(select)); | ^~~ a.cc:29:20: error: request for member 'begin' in 'select', which is of non-class type 'int(int, fd_set*, fd_set*, fd_set*, timeval*)' 29 | #define ALL(c) (c).begin(), (c).end() | ^~~~~ a.cc:53:13: note: in expansion of macro 'ALL' 53 | reverse(ALL(select)); | ^~~ a.cc:29:33: error: request for member 'end' in 'select', which is of non-class type 'int(int, fd_set*, fd_set*, fd_set*, timeval*)' 29 | #define ALL(c) (c).begin(), (c).end() | ^~~ a.cc:53:13: note: in expansion of macro 'ALL' 53 | reverse(ALL(select)); | ^~~ a.cc:56:17: warning: pointer to a function used in arithmetic [-Wpointer-arith] 56 | select[k-1]=in[i]; | ^ cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith] a.cc:56:18: error: assignment of read-only location '*(select + (((sizetype)k) + 18446744073709551615))' 56 | select[k-1]=in[i]; a.cc: At global scope: a.cc:62:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 62 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:67:12: error: request for member 'clear' in 'select', which is of non-class type 'int(int, fd_set*, fd_set*, fd_set*, timeval*)' 67 | select.clear(); | ^~~~~ a.cc:68:12: error: request for member 'resize' in 'select', which is of non-class type 'int(int, fd_set*, fd_set*, fd_set*, timeval*)' 68 | select.resize(k); | ^~~~~~
s689967457
p00469
C++
#include <iostream> #include <vector> #include <string> #include <map> #include <set> using namespace std; typedef vector<int> comb; int s_to_i(string s){ bool flag = false; int n = 0; for(unsigned int i=0 ; i < s.size() ; ++i ){ if( i == 0 && s[i] == '-' ){ flag = true; }else if( s[i] >= '0' && s[i] <= '9' ){ n *= 10; n += s[i] - '0'; }else{ break; } } return (flag)? -n : n ; } string i_to_s(int n){ bool flag = false; string s; if( n < 0 ){ flag = true; n *= -1; } do{ s.push_back( (n%10)+'0' ); n /= 10; }while( n != 0 ); reverse( s.begin() , s.end() ); if( flag ) s.insert( s.begin() , 1 , '-' ); return s; } inline int first(int n){ return ((1 << n) - 1); } inline int nextSet(int x){ int small, ripple, newSmall,ones; small = x & -x; ripple = x + small; newSmall = ripple & -ripple; ones = (( newSmall / small ) >> 1) - 1; return ( ripple | ones ); } comb setComb(int s, int n, comb a){ comb c; for(int i=0 ; i<n ; i++){ if( s & 1 ) c.push_back( a[i] ); s >>= 1; } return c; } int main(){ int n, k, x, s; comb c; while( cin >> n >> k , n || k ){ vector<int> a; set<int> ans; for(int i=0 ; i<n ; i++ ){ cin >> s; a.push_back( s ); } x = first(k); while( !(x & ~first(n) ) ){ c = setComb( x , n , a ); do{ string s = ""; for(int i=0 ; i < (int)c.size() ; i++ ){ s += i_to_s( c[i] ); } int num = s_to_i(s); //if( !count(ans.begin(),ans.end(),num) ) //ans.push_back( num ); ans.insert( num ); }while( next_permutation( c.begin() , c.end() ) ); x = nextSet( x ); } cout << "ans : "; cout << ans.size() << endl; } }
a.cc: In function 'std::string i_to_s(int)': a.cc:38:9: error: 'reverse' was not declared in this scope 38 | reverse( s.begin() , s.end() ); | ^~~~~~~ a.cc: In function 'int main()': a.cc:95:25: error: 'next_permutation' was not declared in this scope 95 | }while( next_permutation( c.begin() , c.end() ) ); | ^~~~~~~~~~~~~~~~
s025501163
p00469
C++
#include <cstdio> #include <algorithm> #include <set> #include <string> using namespace std; int N, K; set<int> result; int card[16]; bool used[16]; void solve(int k, int ans) { if(k == K) { result.insert(ans); return; } for(int i = 0; i < N; i++) { if(used[i] == true) continue; used[i] = true; int t = card[i]; int next; if(t < 10) { next = ans * 10; } else { next = ans * 100; } next += t; solve(k + 1, next); used[i] = false; } } int main() { for(;;) { result.clear(); memset(used, 0, sizeof used); scanf("%d %d", &N, &K); if(N == 0 && K == 0) break; for(int i = 0; i < N; i++) { scanf(" %d", &card[i]); } solve(0, 0); printf("%d\n", result.size()); } return 0; }
a.cc: In function 'int main()': a.cc:36:17: error: 'memset' was not declared in this scope 36 | memset(used, 0, sizeof used); | ^~~~~~ a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 4 | #include <string> +++ |+#include <cstring> 5 | using namespace std;
s456145003
p00469
C++
#include <cstdio> #include <set> using namespace std; int N, K; set<int> result; int card[16]; bool used[16]; void solve(int k, int ans) { if(k == K) { result.insert(ans); return; } for(int i = 0; i < N; i++) { if(used[i] == true) continue; used[i] = true; int t = card[i]; int next; if(t < 10) { next = ans * 10; } else { next = ans * 100; } next += t; solve(k + 1, next); used[i] = false; } } int main() { for(;;) { result.clear(); memset(used, 0, sizeof used); scanf("%d %d", &N, &K); if(N == 0 && K == 0) break; for(int i = 0; i < N; i++) { scanf(" %d", &card[i]); } solve(0, 0); printf("%d\n", result.size()); } return 0; }
a.cc: In function 'int main()': a.cc:34:17: error: 'memset' was not declared in this scope 34 | memset(used, 0, sizeof used); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include <set> +++ |+#include <cstring> 3 | using namespace std;
s966118914
p00469
C++
#include <cstdio> #include <vector> #include <algorithm> using namespace std; int count(int n) { int ret = 1; for(int mul = 10; mul <= n; mul *= 10) ++ret; return ret; } void add(int k, int sum, vector<int> &c, vector<int> &result) { if(k == 0) { result.push_back(sum); return; } for(int i = pos + 1; i < c.size(); ++i) { if(c[i] == 0) continue; int tmp = c[i]; c[i] = 0; add(k - 1, sum * count(tmp) + tmp, c, result); c[i] = tmp; } return; } int main() { while(true) { int n, k; vector<int> c; vector<int> result; scanf("%d%d", &n, &k); if(n == 0) break; c.resize(n); for(int i = 0; i < n; ++i) scanf("%d", &c[i]); count(k, 0, c, result); sort(result.begin(), result.end()); result.remove(unique(result.begin(), result.end()), result.end()); printf("%d\n", result.size()); } return 0; }
a.cc: In function 'void add(int, int, std::vector<int>&, std::vector<int>&)': a.cc:19:13: error: 'pos' was not declared in this scope 19 | for(int i = pos + 1; i < c.size(); ++i) { | ^~~ a.cc: In function 'int main()': a.cc:42:6: error: no matching function for call to 'count(int&, int, std::vector<int>&, std::vector<int>&)' 42 | count(k, 0, c, result); | ~~~~~^~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:61, from a.cc:3: /usr/include/c++/14/bits/stl_algo.h:4025:5: note: candidate: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)' 4025 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value) | ^~~~~ /usr/include/c++/14/bits/stl_algo.h:4025:5: note: candidate expects 3 arguments, 4 provided In file included from /usr/include/c++/14/algorithm:86: /usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' 101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: template argument deduction/substitution failed: a.cc:42:6: note: deduced conflicting types for parameter '_ForwardIterator' ('int' and 'std::vector<int>') 42 | count(k, 0, c, result); | ~~~~~^~~~~~~~~~~~~~~~~ a.cc:6:5: note: candidate: 'int count(int)' 6 | int count(int n) | ^~~~~ a.cc:6:5: note: candidate expects 1 argument, 4 provided a.cc:44:8: error: 'class std::vector<int>' has no member named 'remove' 44 | result.remove(unique(result.begin(), result.end()), result.end()); | ^~~~~~
s718286272
p00469
C++
#include <cstdio> #include <vector> #include <algorithm> using namespace std; int count(int n) { int ret = 1; for(int mul = 10; mul <= n; mul *= 10) ++ret; return ret; } void add(int k, int sum, vector<int> &c, vector<int> &result) { if(k == 0) { result.push_back(sum); return; } for(int i = 0; i < c.size(); ++i) { if(c[i] == 0) continue; int tmp = c[i]; c[i] = 0; add(k - 1, sum * count(tmp) + tmp, c, result); c[i] = tmp; } return; } int main() { while(true) { int n, k; vector<int> c; vector<int> result; scanf("%d%d", &n, &k); if(n == 0) break; c.resize(n); for(int i = 0; i < n; ++i) scanf("%d", &c[i]); count(k, 0, c, result); sort(result.begin(), result.end()); result.remove(unique(result.begin(), result.end()), result.end()); printf("%d\n", result.size()); } return 0; }
a.cc: In function 'int main()': a.cc:42:6: error: no matching function for call to 'count(int&, int, std::vector<int>&, std::vector<int>&)' 42 | count(k, 0, c, result); | ~~~~~^~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:61, from a.cc:3: /usr/include/c++/14/bits/stl_algo.h:4025:5: note: candidate: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)' 4025 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value) | ^~~~~ /usr/include/c++/14/bits/stl_algo.h:4025:5: note: candidate expects 3 arguments, 4 provided In file included from /usr/include/c++/14/algorithm:86: /usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' 101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: template argument deduction/substitution failed: a.cc:42:6: note: deduced conflicting types for parameter '_ForwardIterator' ('int' and 'std::vector<int>') 42 | count(k, 0, c, result); | ~~~~~^~~~~~~~~~~~~~~~~ a.cc:6:5: note: candidate: 'int count(int)' 6 | int count(int n) | ^~~~~ a.cc:6:5: note: candidate expects 1 argument, 4 provided a.cc:44:8: error: 'class std::vector<int>' has no member named 'remove' 44 | result.remove(unique(result.begin(), result.end()), result.end()); | ^~~~~~
s084283053
p00469
C++
#include <cstdio> #include <vector> #include <algorithm> using namespace std; int count(int n) { int ret = 1; for(int mul = 10; mul <= n; mul *= 10) ++ret; return ret; } void add(int k, int sum, vector<int> &c, vector<int> &result) { if(k == 0) { result.push_back(sum); return; } for(int i = 0; i < c.size(); ++i) { if(c[i] == 0) continue; int tmp = c[i]; c[i] = 0; add(k - 1, sum * count(tmp) + tmp, c, result); c[i] = tmp; } return; } int main() { while(true) { int n, k; vector<int> c; vector<int> result; scanf("%d%d", &n, &k); if(n == 0) break; c.resize(n); for(int i = 0; i < n; ++i) scanf("%d", &c[i]); add(k, 0, c, result); sort(result.begin(), result.end()); result.remove(unique(result.begin(), result.end()), result.end()); printf("%d\n", result.size()); } return 0; }
a.cc: In function 'int main()': a.cc:44:8: error: 'class std::vector<int>' has no member named 'remove' 44 | result.remove(unique(result.begin(), result.end()), result.end()); | ^~~~~~
s116041612
p00469
C++
#include<cstdio> #include<set> using namespace std; set<int> se; int N,K; int card[10]; bool used[10]; void rec(int num,int k) { if(k==K) { se.insert(num); return; } for(int i=0;i<N;i++) { if(used[i]==true) continue; used[i]=true; int nnum; if(card[i]<10) nnum=num*10+card[i]; else nnum=num*100+card[i]; rec(nnum,k+1); used[i]=false; } } int main() { scanf("%d%d",&N,&K); for(int i=0;i<N;i++) { scanf("%d",card+i); } memset(used,false,sizeof(used)); rec(0,0); printf("%d\n",se.size()); return 0; }
a.cc: In function 'int main()': a.cc:39:9: error: 'memset' was not declared in this scope 39 | memset(used,false,sizeof(used)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include<set> +++ |+#include <cstring> 3 |
s001996571
p00469
C++
#include <cstdio> #include <cstdlib> #include <map> #include <vector> #include <string> #include <sstream> #include <algorithm> using namespace std; map<string,bool> bmap; short card[10]; short select[4],temp[4]; bool used[10]; int n,k,num; void solve(int m) { if(m==k) { for(int i=0;i<k;i++)temp[i]=select[i]; do { stringstream str; for(int i=0;i<k;i++)str<<(int)select[i]; if(bmap.find(str.str())==bmap.end())num++; bmap[str.str()]=true; }while(next_permutation(select,select+k)); for(int i=0;i<k;i++)select[i]=temp[i]; }else { for(int i=0;i<n;i++) { if(used[i]==false) { used[i]=true; select[m]=card[i]; solve(m+1); used[i]=false; } } } } int main() { while(scanf("%d %d",&n,&k),n) { for(int i=0;i<n;i++)scanf("%d",&card[i]); fill(used,used+10,0); bmap.clear(); num=0; solve(0); printf("%d\n",num); } }
a.cc:11:15: error: 'short int select [4]' redeclared as different kind of entity 11 | short select[4],temp[4]; | ^ In file included from /usr/include/x86_64-linux-gnu/sys/types.h:179, from /usr/include/stdlib.h:514, from /usr/include/c++/14/cstdlib:79, from a.cc:2: /usr/include/x86_64-linux-gnu/sys/select.h:102:12: note: previous declaration 'int select(int, fd_set*, fd_set*, fd_set*, timeval*)' 102 | extern int select (int __nfds, fd_set *__restrict __readfds, | ^~~~~~ a.cc: In function 'void solve(int)': a.cc:16:53: warning: pointer to a function used in arithmetic [-Wpointer-arith] 16 | for(int i=0;i<k;i++)temp[i]=select[i]; | ^ a.cc:16:53: error: invalid conversion from 'int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)' to 'short int' [-fpermissive] 16 | for(int i=0;i<k;i++)temp[i]=select[i]; | ~~~~~~~~^ | | | int (*)(int, fd_set*, fd_set*, fd_set*, timeval*) a.cc:19:63: warning: pointer to a function used in arithmetic [-Wpointer-arith] 19 | for(int i=0;i<k;i++)str<<(int)select[i]; | ^ a.cc:19:50: error: cast from 'int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)' to 'int' loses precision [-fpermissive] 19 | for(int i=0;i<k;i++)str<<(int)select[i]; | ^~~~~~~~~~~~~~ a.cc:22:54: warning: pointer to a function used in arithmetic [-Wpointer-arith] 22 | }while(next_permutation(select,select+k)); | ~~~~~~^~ a.cc:23:45: warning: pointer to a function used in arithmetic [-Wpointer-arith] 23 | for(int i=0;i<k;i++)select[i]=temp[i]; | ^ a.cc:23:46: error: assignment of read-only location '*(select + ((sizetype)i))' 23 | for(int i=0;i<k;i++)select[i]=temp[i]; | ~~~~~~~~~^~~~~~~~ a.cc:28:41: warning: pointer to a function used in arithmetic [-Wpointer-arith] 28 | select[m]=card[i]; | ^ a.cc:28:42: error: assignment of read-only location '*(select + ((sizetype)m))' 28 | select[m]=card[i]; | ~~~~~~~~~^~~~~~~~ In file included from /usr/include/c++/14/bits/stl_tree.h:63, from /usr/include/c++/14/map:62, from a.cc:3: /usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*); _ForwardIterator2 = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)]': /usr/include/c++/14/bits/stl_algo.h:2910:22: required from 'bool std::__next_permutation(_BidirectionalIterator, _BidirectionalIterator, _Compare) [with _BidirectionalIterator = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*); _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 2910 | std::iter_swap(__i, __j); | ~~~~~~~~~~~~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:2951:2: required from 'bool std::next_permutation(_BIter, _BIter) [with _BIter = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)]' 2950 | return std::__next_permutation | ~~~~~~~~~~~~~~~~~~~~~~~ 2951 | (__first, __last, __gnu_cxx::__ops::__iter_less_iter()); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:22:26: required from here 22 | }while(next_permutation(select,select+k)); | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:185:11: error: no matching function for call to 'swap(int (&)(int, fd_set*, fd_set*, fd_set*, timeval*), int (&)(int, fd_set*, fd_set*, fd_set*, timeval*))' 185 | swap(*__a, *__b); | ~~~~^~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:61, from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/bits/move.h:226:5: note: candidate: 'template<class _Tp> std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&)' 226 | swap(_Tp& __a, _Tp& __b) | ^~~~ /usr/include/c++/14/bits/move.h:226:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/14/bits/stl_pair.h:60: /usr/include/c++/14/type_traits: In substitution of 'template<bool _Cond, class _Tp> using std::__enable_if_t = typename std::enable_if::type [with bool _Cond = false; _Tp = void]': /usr/include/c++/14/type_traits:2323:11: required by substitution of 'template<class ... _Cond> using std::_Require = std::__enable_if_t<((bool)std::__and_<_Bn>::value)> [with _Cond = {std::__not_<std::__is_tuple_like<int(int, fd_set*, fd_set*, fd_set*, timeval*)> >, std::is_move_constructible<int(int, fd_set*, fd_set*, fd_set*, timeval*)>, std::is_move_assignable<int(int, fd_set*, fd_set*, fd_set*, timeval*)>}]' 2323 | using _Require = __enable_if_t<__and_<_Cond...>::value>; | ^~~~~~~~ /usr/include/c++/14/bits/move.h:226:5: required by substitution of 'template<class _Tp> std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = int(int, fd_set*, fd_set*, fd_set*, timeval*)]' 226 | swap(_Tp& __a, _Tp& __b) | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:185:11: required from 'void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*); _ForwardIterator2 = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)]' 185 | swap(*__a, *__b); | ~~~~^~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:2910:22: required from 'bool std::__next_permutation(_BidirectionalIterator, _BidirectionalIterator, _Compare) [with _BidirectionalIterator = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*); _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 2910 | std::iter_swap(__i, __j); | ~~~~~~~~~~~~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:2951:2: required from 'bool std::next_permutation(_BIter, _BIter) [with _BIter = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)]' 2950 | return std::__next_permutation | ~~~~~~~~~~~~~~~~~~~~~~~ 2951 | (__first, __last, __gnu_cxx::__ops::__iter_less_iter()); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:22:26: required from here 22 | }while(next_permutation(select,select+k)); | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/type_traits:138:11: error: no type named 'type' in 'struct std::enable_if<false, void>' 138 | using __enable_if_t = typename enable_if<_Cond, _Tp>::type; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*); _ForwardIterator2 = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)]': /usr/include/c++/14/bits/stl_algo.h:2910:22: required from 'bool std::__next_permutation(_BidirectionalIterator, _BidirectionalIterator, _Compare) [with _BidirectionalIterator = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*); _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 2910 | std::iter_swap(__i, __j); | ~~~~~~~~~~~~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:2951:2: required from 'bool std::next_permutation(_BIter, _BIter) [with _BIter = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)]' 2950 | return std::__next_permutation | ~~~~~~~~~~~~~~~~~~~~~~~ 2951 | (__first, __last, __gnu_cxx::__ops::__iter_less_iter()); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:22:26: required from here 22 | }while(next_permutation(select,select+k)); | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/move.h:250:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> std::__enable_if_t<((bool)std::__is_swappable<_Tp>::value)> std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm])' 250 | swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) | ^~~~ /usr/include/c++/14/bits/move.h:250:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_algobase.h:185:11: note: mismatched types '_Tp [_Nm]' and 'int(int, fd_set*, fd_set*, fd_set*, timeval*)' 185 | swap(*__a, *__b); | ~~~~^~~~~~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1089:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)' 1089 | swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y) | ^~~~ /usr/include/c++/14/bits/stl_pair.h:1089:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_algobase.h:185:11: note: mismatched types 'std::pair<_T1, _T2>' and 'int(int, fd_set*, fd_set*, fd_set*, timeval*)' 185 | swap(*__a, *__b); | ~~~~^~~~~~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1106:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<(! std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value)>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)' (deleted) 1106 | swap(pair<_T1, _T2>&, pair<_T1, _T2>&) = delete; | ^~~~ /usr/include/c++/14/bits/stl_pair.h:1106:5: note: template argument ded
s716837425
p00469
C++
#include <cstdio> #include <cstdlib> #include <map> #include <vector> #include <string> #include <sstream> #include <algorithm> using namespace std; map<string,bool> bmap; int card[10]; int select[4],temp[4]; bool used[10]; int n,k,num; void solve(int m) { if(m==k) { for(int i=0;i<k;i++)temp[i]=select[i]; do { stringstream str; for(int i=0;i<k;i++)str<<(int)select[i]; if(bmap.find(str.str())==bmap.end())num++; bmap[str.str()]=true; }while(next_permutation(select,select+k)); for(int i=0;i<k;i++)select[i]=temp[i]; }else { for(int i=0;i<n;i++) { if(used[i]==false) { used[i]=true; select[m]=card[i]; solve(m+1); used[i]=false; } } } } int main() { while(scanf("%d %d",&n,&k),n) { for(int i=0;i<n;i++)scanf("%d",&card[i]); fill(used,used+10,0); bmap.clear(); num=0; solve(0); printf("%d\n",num); } }
a.cc:11:13: error: 'int select [4]' redeclared as different kind of entity 11 | int select[4],temp[4]; | ^ In file included from /usr/include/x86_64-linux-gnu/sys/types.h:179, from /usr/include/stdlib.h:514, from /usr/include/c++/14/cstdlib:79, from a.cc:2: /usr/include/x86_64-linux-gnu/sys/select.h:102:12: note: previous declaration 'int select(int, fd_set*, fd_set*, fd_set*, timeval*)' 102 | extern int select (int __nfds, fd_set *__restrict __readfds, | ^~~~~~ a.cc: In function 'void solve(int)': a.cc:16:53: warning: pointer to a function used in arithmetic [-Wpointer-arith] 16 | for(int i=0;i<k;i++)temp[i]=select[i]; | ^ a.cc:16:53: error: invalid conversion from 'int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)' to 'int' [-fpermissive] 16 | for(int i=0;i<k;i++)temp[i]=select[i]; | ~~~~~~~~^ | | | int (*)(int, fd_set*, fd_set*, fd_set*, timeval*) a.cc:19:63: warning: pointer to a function used in arithmetic [-Wpointer-arith] 19 | for(int i=0;i<k;i++)str<<(int)select[i]; | ^ a.cc:19:50: error: cast from 'int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)' to 'int' loses precision [-fpermissive] 19 | for(int i=0;i<k;i++)str<<(int)select[i]; | ^~~~~~~~~~~~~~ a.cc:22:54: warning: pointer to a function used in arithmetic [-Wpointer-arith] 22 | }while(next_permutation(select,select+k)); | ~~~~~~^~ a.cc:23:45: warning: pointer to a function used in arithmetic [-Wpointer-arith] 23 | for(int i=0;i<k;i++)select[i]=temp[i]; | ^ a.cc:23:46: error: assignment of read-only location '*(select + ((sizetype)i))' 23 | for(int i=0;i<k;i++)select[i]=temp[i]; | ~~~~~~~~~^~~~~~~~ a.cc:28:41: warning: pointer to a function used in arithmetic [-Wpointer-arith] 28 | select[m]=card[i]; | ^ a.cc:28:42: error: assignment of read-only location '*(select + ((sizetype)m))' 28 | select[m]=card[i]; | ~~~~~~~~~^~~~~~~~ In file included from /usr/include/c++/14/bits/stl_tree.h:63, from /usr/include/c++/14/map:62, from a.cc:3: /usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*); _ForwardIterator2 = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)]': /usr/include/c++/14/bits/stl_algo.h:2910:22: required from 'bool std::__next_permutation(_BidirectionalIterator, _BidirectionalIterator, _Compare) [with _BidirectionalIterator = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*); _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 2910 | std::iter_swap(__i, __j); | ~~~~~~~~~~~~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:2951:2: required from 'bool std::next_permutation(_BIter, _BIter) [with _BIter = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)]' 2950 | return std::__next_permutation | ~~~~~~~~~~~~~~~~~~~~~~~ 2951 | (__first, __last, __gnu_cxx::__ops::__iter_less_iter()); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:22:26: required from here 22 | }while(next_permutation(select,select+k)); | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:185:11: error: no matching function for call to 'swap(int (&)(int, fd_set*, fd_set*, fd_set*, timeval*), int (&)(int, fd_set*, fd_set*, fd_set*, timeval*))' 185 | swap(*__a, *__b); | ~~~~^~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:61, from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/bits/move.h:226:5: note: candidate: 'template<class _Tp> std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&)' 226 | swap(_Tp& __a, _Tp& __b) | ^~~~ /usr/include/c++/14/bits/move.h:226:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/14/bits/stl_pair.h:60: /usr/include/c++/14/type_traits: In substitution of 'template<bool _Cond, class _Tp> using std::__enable_if_t = typename std::enable_if::type [with bool _Cond = false; _Tp = void]': /usr/include/c++/14/type_traits:2323:11: required by substitution of 'template<class ... _Cond> using std::_Require = std::__enable_if_t<((bool)std::__and_<_Bn>::value)> [with _Cond = {std::__not_<std::__is_tuple_like<int(int, fd_set*, fd_set*, fd_set*, timeval*)> >, std::is_move_constructible<int(int, fd_set*, fd_set*, fd_set*, timeval*)>, std::is_move_assignable<int(int, fd_set*, fd_set*, fd_set*, timeval*)>}]' 2323 | using _Require = __enable_if_t<__and_<_Cond...>::value>; | ^~~~~~~~ /usr/include/c++/14/bits/move.h:226:5: required by substitution of 'template<class _Tp> std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = int(int, fd_set*, fd_set*, fd_set*, timeval*)]' 226 | swap(_Tp& __a, _Tp& __b) | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:185:11: required from 'void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*); _ForwardIterator2 = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)]' 185 | swap(*__a, *__b); | ~~~~^~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:2910:22: required from 'bool std::__next_permutation(_BidirectionalIterator, _BidirectionalIterator, _Compare) [with _BidirectionalIterator = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*); _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 2910 | std::iter_swap(__i, __j); | ~~~~~~~~~~~~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:2951:2: required from 'bool std::next_permutation(_BIter, _BIter) [with _BIter = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)]' 2950 | return std::__next_permutation | ~~~~~~~~~~~~~~~~~~~~~~~ 2951 | (__first, __last, __gnu_cxx::__ops::__iter_less_iter()); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:22:26: required from here 22 | }while(next_permutation(select,select+k)); | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/type_traits:138:11: error: no type named 'type' in 'struct std::enable_if<false, void>' 138 | using __enable_if_t = typename enable_if<_Cond, _Tp>::type; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*); _ForwardIterator2 = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)]': /usr/include/c++/14/bits/stl_algo.h:2910:22: required from 'bool std::__next_permutation(_BidirectionalIterator, _BidirectionalIterator, _Compare) [with _BidirectionalIterator = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*); _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 2910 | std::iter_swap(__i, __j); | ~~~~~~~~~~~~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:2951:2: required from 'bool std::next_permutation(_BIter, _BIter) [with _BIter = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)]' 2950 | return std::__next_permutation | ~~~~~~~~~~~~~~~~~~~~~~~ 2951 | (__first, __last, __gnu_cxx::__ops::__iter_less_iter()); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:22:26: required from here 22 | }while(next_permutation(select,select+k)); | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/move.h:250:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> std::__enable_if_t<((bool)std::__is_swappable<_Tp>::value)> std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm])' 250 | swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) | ^~~~ /usr/include/c++/14/bits/move.h:250:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_algobase.h:185:11: note: mismatched types '_Tp [_Nm]' and 'int(int, fd_set*, fd_set*, fd_set*, timeval*)' 185 | swap(*__a, *__b); | ~~~~^~~~~~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1089:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)' 1089 | swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y) | ^~~~ /usr/include/c++/14/bits/stl_pair.h:1089:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_algobase.h:185:11: note: mismatched types 'std::pair<_T1, _T2>' and 'int(int, fd_set*, fd_set*, fd_set*, timeval*)' 185 | swap(*__a, *__b); | ~~~~^~~~~~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1106:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<(! std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value)>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)' (deleted) 1106 | swap(pair<_T1, _T2>&, pair<_T1, _T2>&) = delete; | ^~~~ /usr/include/c++/14/bits/stl_pair.h:1106:5: note: template argument deduction/substitut
s618131709
p00469
C++
#include "stdio.h" #include <vector> #include <queue> #include <set> using namespace std; int x[10]; int main() { while(1) { int n,k; scanf("%d",&n); scanf("%d",&k); if(n == 0 && k == 0) { break; } for(int i = 0; i < n; i++) { scanf("%d",&x[i]); } int w = 1; for(int i = 0; i < k; i++) { w *= n; } set<int> sw; for(int i = 0; i < w; i++) { priority_queue<int> q1; vector<int> q2; int s = i; for(int i = 0; i < k; i++) { int l = s % n; q1.push(l); q2.push_back(l); s /= n; } int flgw = 0; int mae = -1; for(int ii = 0; ii < k; ii++) { if(mae == q1.top()) { flgw = 1; break; } mae = q1.top(); q1.pop(); } if(flgw == 1) { continue; } int g = 0; for(int ii = 0; ii < k; ii++) { if(x[q2[ii]] < 10) { g = g * 10 + x[q2[ii]]; } else { g = g * 100 + x[q2[ii]]; } } sw.insert(g); } printf("%d\n",sw.size()); { return 0; }
a.cc: In function 'int main()': a.cc:81:2: error: expected '}' at end of input 81 | } | ^ a.cc:13:1: note: to match this '{' 13 | { | ^ a.cc:81:2: error: expected '}' at end of input 81 | } | ^ a.cc:11:1: note: to match this '{' 11 | { | ^
s499210511
p00470
C
#include<stdio.h>int main(void){ int i,j,w,h,a[101][101][2]; while(scanf("%d%d",&w,&h),w+h){ h++;w++; for(i=0;i<h;i++){ for(j=0;j<w;j++){ if(i==1||j==1){ a[i][j][0]=1; a[i][j][1]=1; }else{ a[i][j][0]=0; a[i][j][1]=0; } } } for(i=2;i<h;i++){ for(j=2;j<w;j++){ a[i][j][0]=a[i-2][j][1]+a[i][j-2][0]+a[i-2][j-1][1]; a[i][j][1]=a[i-2][j][1]+a[i][j-2][0]+a[i-1][j-2][0]; a[i][j][0]%=100000; a[i][j][1]%=100000; } } printf("%d/n",(a[i][j-1][0]+a[i-1][j][1])%100000); } return 0;}
main.c:1:18: warning: extra tokens at end of #include directive 1 | #include<stdio.h>int main(void){ | ^~~ main.c:3:1: error: expected identifier or '(' before 'while' 3 | while(scanf("%d%d",&w,&h),w+h){ | ^~~~~ main.c:28:1: error: expected identifier or '(' before 'return' 28 | return 0;} | ^~~~~~ main.c:28:10: error: expected identifier or '(' before '}' token 28 | return 0;} | ^
s167653722
p00470
C
#include<stdio.h>int main(void){ int i,j,w,h,a[101][101][2]; while(scanf("%d%d",&w,&h),w+h){ h++;w++; for(i=0;i<h;i++){ for(j=0;j<w;j++){ if(i==1||j==1){ a[i][j][0]=1; a[i][j][1]=1; }else{ a[i][j][0]=0; a[i][j][1]=0; } } } for(i=2;i<h;i++){ for(j=2;j<w;j++){ a[i][j][0]=a[i-2][j][1]+a[i][j-2][0]+a[i-2][j-1][1]; a[i][j][1]=a[i-2][j][1]+a[i][j-2][0]+a[i-1][j-2][0]; a[i][j][0]%=100000; a[i][j][1]%=100000; } } printf("%d/n",(a[i][j-1][0]+a[i-1][j][1])%100000); } return 0;}
main.c:1:18: warning: extra tokens at end of #include directive 1 | #include<stdio.h>int main(void){ | ^~~ main.c:3:1: error: expected identifier or '(' before 'while' 3 | while(scanf("%d%d",&w,&h),w+h){ | ^~~~~ main.c:28:1: error: expected identifier or '(' before 'return' 28 | return 0;} | ^~~~~~ main.c:28:10: error: expected identifier or '(' before '}' token 28 | return 0;} | ^
s453787822
p00470
C
#define Z 100 M[Z][Z][2],l=100000;main(w,h,i,j){ M[0][0][0]=M[0][0][1]=M[1][1][0]=M[1][1][1]=1; for(i=1;i<Z;i++)M[i][0][0]=M[i-1][0][0],M[i][0][1]=0; for(j=1;j<Z;j++)M[0][j][0]=0,M[0][j][1]=M[0][j-1][1]; for(i=1;i<Z;i++){ for(j=1;j<Z;j++)M[i][j][0]=(M[i-1][j][0]+M[i-1][j-1][1])%l,M[i][j][1]=(M[i][j-1][1]+M[i-1][j-1][0]%l; } for(;scanf("%d%d",&w,&h),w;)printf("%d\n",(M[h-1][w-1][0]+M[h-1][w-1][1])%l);exit(0); }
main.c:2:1: warning: data definition has no type or storage class 2 | M[Z][Z][2],l=100000;main(w,h,i,j){ | ^ main.c:2:1: error: type defaults to 'int' in declaration of 'M' [-Wimplicit-int] main.c:2:12: error: type defaults to 'int' in declaration of 'l' [-Wimplicit-int] 2 | M[Z][Z][2],l=100000;main(w,h,i,j){ | ^ main.c:2:21: error: return type defaults to 'int' [-Wimplicit-int] 2 | M[Z][Z][2],l=100000;main(w,h,i,j){ | ^~~~ main.c: In function 'main': main.c:2:21: error: type of 'w' defaults to 'int' [-Wimplicit-int] main.c:2:21: error: type of 'h' defaults to 'int' [-Wimplicit-int] main.c:2:21: error: type of 'i' defaults to 'int' [-Wimplicit-int] main.c:2:21: error: type of 'j' defaults to 'int' [-Wimplicit-int] main.c:7:117: error: expected ')' before ';' token 7 | for(j=1;j<Z;j++)M[i][j][0]=(M[i-1][j][0]+M[i-1][j-1][1])%l,M[i][j][1]=(M[i][j-1][1]+M[i-1][j-1][0]%l; | ~ ^ | ) main.c:7:118: error: expected ';' before '}' token 7 | for(j=1;j<Z;j++)M[i][j][0]=(M[i-1][j][0]+M[i-1][j-1][1])%l,M[i][j][1]=(M[i][j-1][1]+M[i-1][j-1][0]%l; | ^ | ; 8 | } | ~ main.c:9:14: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 9 | for(;scanf("%d%d",&w,&h),w;)printf("%d\n",(M[h-1][w-1][0]+M[h-1][w-1][1])%l);exit(0); | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | #define Z 100 main.c:9:14: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 9 | for(;scanf("%d%d",&w,&h),w;)printf("%d\n",(M[h-1][w-1][0]+M[h-1][w-1][1])%l);exit(0); | ^~~~~ main.c:9:14: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:9:37: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 9 | for(;scanf("%d%d",&w,&h),w;)printf("%d\n",(M[h-1][w-1][0]+M[h-1][w-1][1])%l);exit(0); | ^~~~~~ main.c:9:37: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:9:37: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:9:37: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:9:86: error: implicit declaration of function 'exit' [-Wimplicit-function-declaration] 9 | for(;scanf("%d%d",&w,&h),w;)printf("%d\n",(M[h-1][w-1][0]+M[h-1][w-1][1])%l);exit(0); | ^~~~ main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'exit' +++ |+#include <stdlib.h> 1 | #define Z 100 main.c:9:86: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch] 9 | for(;scanf("%d%d",&w,&h),w;)printf("%d\n",(M[h-1][w-1][0]+M[h-1][w-1][1])%l);exit(0); | ^~~~ main.c:9:86: note: include '<stdlib.h>' or provide a declaration of 'exit'
s270276997
p00470
C++
#include<iostream> using namespace std; #define MOD 100000; int main(){ int x[101][101][2][2]; int h,w,sum; while(true){ memset(x,0,sizeof(x)); for(int i=1;i<=100;i++){ x[i][1][0][0]=1; } for(int i=1;i<=100;i++){ x[1][i][1][0]=1; } cin>>h>>w; if(h==0 && w==0){ break; } for(int i=2;i<=h;i++){ for(int j=2;j<=w;j++){ x[i][j][0][0]=(x[i-1][j][0][0]+x[i-1][j][0][1])%MOD; x[i][j][0][1]=x[i-1][j][1][0]%MOD; x[i][j][1][0]=(x[i][j-1][1][0]+x[i][j-1][1][1])%MOD; x[i][j][1][1]=x[i][j-1][0][0]%MOD; } } sum=(x[h][w][0][0]+x[h][w][0][1]+x[h][w][1][0]+x[h][w][1][1])%MOD; cout<<sum<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:10:17: error: 'memset' was not declared in this scope 10 | memset(x,0,sizeof(x)); | ^~~~~~ 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;
s116392264
p00470
C++
#include<bits/stdc++.h> using namespace std; const int mod = 100000; int main(){ int w,h; while(cin >> w >> h, w){ int dp[100][100][2] = {}; dp[0][0][0] = dp[0][0][1] = 1; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ if(i>0) dp[i][j][0] += dp[i-1][j][0]) %= mod; if(i>1) dp[i][j][0] += dp[i-2][j][1]) %= mod; if(j>0) dp[i][j][1] += dp[i][j-1][1]) %= mod; if(j>1) dp[i][j][1] += dp[i][j-2][0]) %= mod; } } cout << (dp[h-1][w-1][0] + dp[h-1][w-1][0])%mod << endl; } }
a.cc: In function 'int main()': a.cc:14:45: error: expected ';' before ')' token 14 | if(i>0) dp[i][j][0] += dp[i-1][j][0]) %= mod; | ^ | ; a.cc:15:45: error: expected ';' before ')' token 15 | if(i>1) dp[i][j][0] += dp[i-2][j][1]) %= mod; | ^ | ; a.cc:16:45: error: expected ';' before ')' token 16 | if(j>0) dp[i][j][1] += dp[i][j-1][1]) %= mod; | ^ | ; a.cc:17:45: error: expected ';' before ')' token 17 | if(j>1) dp[i][j][1] += dp[i][j-2][0]) %= mod; | ^ | ;
s031105569
p00470
C++
# include <iostream> # include <string> constexpr int MAX_W = 100; constexpr int MAX_H = 100; constexpr int MOD = 100000; int h, w; int dp[MAX_H][MAX_W][4]; int main() { while (1) { std::cin >> w >> h; if (w + h == 0) break; std::memset(dp, 0, sizeof(dp)); for (int i = 1; i < w; ++i) dp[0][i][0] = 1; for (int i = 1; i < h; ++i) dp[i][0][4] = 1; dp[1][1][2] = 1; dp[1][1][1] = 1; for (int i = 2; i < w; ++i) { dp[1][i][0] = 1; dp[1][i][2] = 1; } for (int i = 2; i < h; ++i) { dp[i][1][1] = 1; dp[i][1][3] = 1; } for (int i = 2; i < h; ++i) { for (int j = 2; j < w; ++j) { for (int k = 0; k < 4; ++k) { dp[i][j][0] += dp[i][j - 2][k]; dp[i][j][0] %= MOD; dp[i][j][3] += dp[i - 2][j][k]; dp[i][j][3] %= MOD; } dp[i][j][1] = dp[i - 1][j - 1][2] + dp[i - 1][j - 1][3]; dp[i][j][1] %= MOD; dp[i][j][2] = dp[i - 1][j - 1][0] + dp[i - 1][j - 1][1]; dp[i][j][2] %= MOD; } } int ans = 0; for (int i = 0; i < 4; ++i) { ans += dp[h - 1][w - 1][i]; ans %= MOD; } std::cout << ans << std::endl; } return 0; }
a.cc: In function 'int main()': a.cc:16:22: error: 'memset' is not a member of 'std'; did you mean 'wmemset'? 16 | std::memset(dp, 0, sizeof(dp)); | ^~~~~~ | wmemset
s841583247
p00470
C++
#include <iostream> #include <fstream> #include <cstdio> #include <cmath> #include <vector> #include <string> #include <map> #include <queue> #include <algorithm> using namespace std; #define REP(i,n) for(int i=0; i<n; i++) #define FOR(i,a,b) for(int i=a; i<=b; i++) #define FORR(i,a,b) for (int i=a; i>=b; i--) typedef long long ll; #define mod 100000 int dp[100][100][4]={}; // 0:rr 1:ru 2:ur 3:uu int main(void) { int n,m; while(cin >> n >> m && n>0) REP(i,n){ dp[i][0][0]=1; } REP(i,m){ dp[0][i][3]=1; } FOR(i,1,n-1){ FOR(j,1,m-1){ dp[i][j][0]=dp[i-1][j][0]+dp[i-1][j][2]; dp[i][j][3]=dp[i][j-1][1]+dp[i][j-1][3]; dp[i][j][1]=dp[i][j-1][0]; dp[i][j][2]=dp[i-1][j][3]; REP(k,4){ dp[i][j][k]%=mod; } } } int ans=0; REP(i,4){ ans = ans+dp[n-1][m-1][i]; } ans %= mod; cout << ans << endl; } return 0; }
a.cc:53:5: error: expected unqualified-id before 'return' 53 | return 0; | ^~~~~~ a.cc:54:1: error: expected declaration before '}' token 54 | } | ^
s092018154
p00470
C++
#include<iostream> #include<string> #include<vector> #include<stdio.h> #include<algorithm> using namespace std; int a[101][101][3][3];//??????,??????,???????????????,?????????????????????0???1 int main(){ int h,w; while(1){ scanf("%d%d",&w,&h); if(w==0&&h==0)break; memset(a,0,sizeof(a)); for(int i=1;i<101;i++){ a[1][i][0][0]=1; a[i][1][1][1]=1; } for(int i=2;i<101;i++){ for(int j=2;j<101;j++){ a[i][j][0][0]=(a[i][j-2][0][0]+a[i][j-2][1][0]+a[i][j-2][1][1])%100000; a[i][j][1][0]=(a[i-1][j-1][0][1]+a[i-1][j-1][1][1])%100000; a[i][j][0][1]=(a[i-1][j-1][0][0]+a[i-1][j-1][1][0])%100000; a[i][j][1][1]=(a[i-2][j][0][0]+a[i-2][j][0][1]+a[i-2][j][1][1])%100000; } } cout<<(a[w][h][0][0]+a[w][h][0][1]+a[w][h][1][0]+a[w][h][1][1])%100000<<endl; } }
a.cc: In function 'int main()': a.cc:13:17: error: 'memset' was not declared in this scope 13 | memset(a,0,sizeof(a)); | ^~~~~~ a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 5 | #include<algorithm> +++ |+#include <cstring> 6 | using namespace std;
s347087680
p00470
C++
#include<iostream> #include<string> #include<vector> #include<stdio.h> #include<algorithm> using namespace std; int a[101][101][3][3]; int main(){ int h,w; while(1){ scanf("%d%d",&w,&h); if(w==0&&h==0)break; memset(a,0,sizeof(a)); for(int i=1;i<101;i++){ a[1][i][0][0]=1; a[i][1][1][1]=1; } for(int i=2;i<101;i++){ for(int j=2;j<101;j++){ a[i][j][0][0]=(a[i][j-2][0][0]+a[i][j-2][1][0]+a[i][j-2][1][1])%100000; a[i][j][1][0]=(a[i-1][j-1][0][1]+a[i-1][j-1][1][1])%100000; a[i][j][0][1]=(a[i-1][j-1][0][0]+a[i-1][j-1][1][0])%100000; a[i][j][1][1]=(a[i-2][j][0][0]+a[i-2][j][0][1]+a[i-2][j][1][1])%100000; } } cout<<(a[w][h][0][0]+a[w][h][0][1]+a[w][h][1][0]+a[w][h][1][1])%100000<<endl; } }
a.cc: In function 'int main()': a.cc:13:17: error: 'memset' was not declared in this scope 13 | memset(a,0,sizeof(a)); | ^~~~~~ a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 5 | #include<algorithm> +++ |+#include <cstring> 6 | using namespace std;
s455729790
p00470
C++
#include<cstdio> #define rep(i,a) for(i=0;i<a;i++) int MOD=100000,i; int main(){ int n,m; while(scanf("%d%d",&n,&m),n){ int dp[110][110][2]={0}; dp[1][0][0]=dp[0][1][1]=1; rep(i,n)rep(j,m)rep(k,2){ dp[i+1+k][j][0]=(dp[i+1+k][j][0]+dp[i][j][k])%MOD; dp[i][j+1+(1^k)][1]=(dp[i][j+1+(1^k)][1]+dp[i][j][k])%MOD; } printf("%d\n",(dp[n][m-1][0]+dp[n-1][m][1])%MOD); } }
a.cc: In function 'int main()': a.cc:9:21: error: 'j' was not declared in this scope 9 | rep(i,n)rep(j,m)rep(k,2){ | ^ a.cc:2:22: note: in definition of macro 'rep' 2 | #define rep(i,a) for(i=0;i<a;i++) | ^ a.cc:9:29: error: 'k' was not declared in this scope 9 | rep(i,n)rep(j,m)rep(k,2){ | ^ a.cc:2:22: note: in definition of macro 'rep' 2 | #define rep(i,a) for(i=0;i<a;i++) | ^
s681045590
p00470
C++
#define rep(i,a) for(i=0;i<a;i++) MOD=100000,i,j,k,n,m; int main(){ while(scanf("%d%d",&n,&m),n){ int dp[110][110][2]={0}; dp[1][0][0]=dp[0][1][1]=1; rep(i,n)rep(j,m)rep(k,2){ dp[i+1+k][j][0]=(dp[i+1+k][j][0]+dp[i][j][k])%MOD; dp[i][j+1+(1^k)][1]=(dp[i][j+1+(1^k)][1]+dp[i][j][k])%MOD; } printf("%d\n",(dp[n][m-1][0]+dp[n-1][m][1])%MOD); } }
a.cc:2:1: error: 'MOD' does not name a type 2 | MOD=100000,i,j,k,n,m; | ^~~ a.cc: In function 'int main()': a.cc:4:25: error: 'n' was not declared in this scope 4 | while(scanf("%d%d",&n,&m),n){ | ^ a.cc:4:28: error: 'm' was not declared in this scope 4 | while(scanf("%d%d",&n,&m),n){ | ^ a.cc:4:11: error: 'scanf' was not declared in this scope 4 | while(scanf("%d%d",&n,&m),n){ | ^~~~~ a.cc:7:13: error: 'i' was not declared in this scope 7 | rep(i,n)rep(j,m)rep(k,2){ | ^ a.cc:1:22: note: in definition of macro 'rep' 1 | #define rep(i,a) for(i=0;i<a;i++) | ^ a.cc:7:21: error: 'j' was not declared in this scope 7 | rep(i,n)rep(j,m)rep(k,2){ | ^ a.cc:1:22: note: in definition of macro 'rep' 1 | #define rep(i,a) for(i=0;i<a;i++) | ^ a.cc:7:29: error: 'k' was not declared in this scope 7 | rep(i,n)rep(j,m)rep(k,2){ | ^ a.cc:1:22: note: in definition of macro 'rep' 1 | #define rep(i,a) for(i=0;i<a;i++) | ^ a.cc:8:71: error: 'MOD' was not declared in this scope 8 | dp[i+1+k][j][0]=(dp[i+1+k][j][0]+dp[i][j][k])%MOD; | ^~~ a.cc:11:61: error: 'MOD' was not declared in this scope 11 | printf("%d\n",(dp[n][m-1][0]+dp[n-1][m][1])%MOD); | ^~~ a.cc:11:17: error: 'printf' was not declared in this scope 11 | printf("%d\n",(dp[n][m-1][0]+dp[n-1][m][1])%MOD); | ^~~~~~ a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | #define rep(i,a) for(i=0;i<a;i++)
s980832341
p00470
C++
#include <iostream> using namespace std; const int mod = 100000; int dp[102][102][4]; int main() { int w, h; while (cin >> w >> h, w) { memset(dp, 0, sizeof(dp)); dp[0][1][1] = 1; dp[1][0][0] = 1; for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { // k == 0: ?????????????¶????????????? // k == 1: ?????????????¶????????????? // k == 2: ??´????????????????????£??? // k == 3: ??´????????????????????£??? if (i - 1 >= 0) { (dp[i][j][0] += dp[i - 1][j][0] + dp[i - 1][j][2]) %= mod;; (dp[i][j][2] += dp[i - 1][j][1]) %= mod; } if (j - 1 >= 0) { (dp[i][j][1] += dp[i][j - 1][1] + dp[i][j - 1][3]) %= mod; (dp[i][j][3] += dp[i][j - 1][0]) %= mod; } } } int ans = 0; for (int i = 0; i < 4; ++i) ans += dp[h - 1][w - 1][i]; ans %= mod; cout << ans << endl; } }
a.cc: In function 'int main()': a.cc:14:9: 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 |
s285640435
p00470
C++
#include<iostream> #include<algorithm> #define mod 100000 using namespace std; int main(){ int w,h; while(cin>>w>>h,w||h){ int dp[101][101][2][2]={{{{0}}}},sum=0; dp[0][0][0][1]=dp[0][0][1][1]=1; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ for(int k=0;k<2;k++)for(int l=0;l<2;l++)dp[i][j][k][l]%=mod; dp[i+1][j][0][0]+=dp[i][j][0][1]; dp[i][j+1][1][0]+=dp[i][j][1][1]; dp[i+1][j][0][0]+=dp[i][j][0][0]; dp[i][j+1][1][0]+=dp[i][j][1][0]; dp[i+1][j][0][1]+=dp[i][j][1][0]; dp[i][j+1][1][1]+=dp[i][j][0][0]; } } for(int i=0;i<2;i++) for(int j=0;j<2;j++) sum+=dp[h-1][w-1][i][j]; sum%=mod; cout<<sum<<endl; } } Compile Error Logs: You are not authorized to see the message. Status Judge: 1/1 C++ CPU: 00.00 sec Memory: 1324 KB Length: 928 B 2014-12-08 19:42 2014-12-08 19:42 Results for testcases Case # Verdict CPU Time Memory In Out Case Name Case #1: : Accepted 00.00 sec 1324 KB 33 B 25 B test_case_1 < prev | 1 / 1 | next > : Accepted 00.00 sec 1324 KB Judge Input #1 ( in1.txt | 33 B) Judge Output #1 ( out1.txt | 25 B) 4 6 13 6 17 21 96 87 100 100 0 0 14 266 11162 50240 71084 Comments Under Construction. Categories Free Tags
a.cc:38:81: error: invalid digit "8" in octal constant 38 | Judge: 1/1 C++ CPU: 00.00 sec Memory: 1324 KB Length: 928 B 2014-12-08 19:42 2014-12-08 19:42 | ^~ a.cc:38:105: error: invalid digit "8" in octal constant 38 | Judge: 1/1 C++ CPU: 00.00 sec Memory: 1324 KB Length: 928 B 2014-12-08 19:42 2014-12-08 19:42 | ^~ a.cc:40:6: error: stray '#' in program 40 | Case # Verdict CPU Time Memory In Out Case Name | ^ a.cc:41:6: error: stray '#' in program 41 | Case #1: : Accepted 00.00 sec 1324 KB 33 B 25 B test_case_1 | ^ a.cc:45:13: error: stray '#' in program 45 | Judge Input #1 ( in1.txt | 33 B) Judge Output #1 ( out1.txt | 25 B) | ^ a.cc:45:62: error: stray '#' in program 45 | Judge Input #1 ( in1.txt | 33 B) Judge Output #1 ( out1.txt | 25 B) | ^ a.cc:34:1: error: 'Compile' does not name a type 34 | Compile Error Logs: | ^~~~~~~
s827190324
p00470
C++
#include<cstdio> #include <iostream> #include<algorithm> #include<string> #include<cstring> #include<queue> #include<vector> #include<functional> #include<cmath> #include<map> #include<stack> #include<cstdlib> #include<list> #include<set> #include<numeric> #include<intrin.h> #define MOD 1000000007 using namespace std; typedef long long ll; typedef pair<int, int> P; int W, H, dp[100][100][4]; const int mod = 100000; int rec(int y, int x, int j) { if (y >= H || x >= W)return 0; if (dp[y][x][j])return dp[y][x][j]; if (y == H - 1 && x == W - 1)return 1; int ret; if (!y && !x) ret = rec(y + 1, x, 0) + rec(y, x + 1, 1); else if (j == 0)ret = rec(y + 1, x,0) + rec(y, x + 1, 3); else if (j == 1)ret = rec(y + 1, x, 2) + rec(y, x + 1, 1); else if (j == 2)ret = rec(y + 1, x, 0); else if (j == 3)ret = rec(y, x + 1, 1); return dp[y][x][j] = ret % mod; } int main() { while (cin >> W >> H, W) { for (int i = 0; i < 100; i++) { for (int j = 0; j < 100; j++) { for (int k = 0; k < 4; k++) { dp[i][j][k] = -1; } } } } cout << rec(0, 0, 0) << endl; return 0; }
a.cc:16:9: fatal error: intrin.h: No such file or directory 16 | #include<intrin.h> | ^~~~~~~~~~ compilation terminated.
s950857199
p00470
C++
#include<cstdio> #include <iostream> #include<algorithm> #include<string> #include<cstring> #include<queue> #include<vector> #include<functional> #include<cmath> #include<map> #include<stack> #include<cstdlib> #include<list> #include<set> #include<numeric> #include<intrin.h> #define MOD 1000000007 using namespace std; typedef long long ll; typedef pair<int, int> P; int W, H, dp[100][100][4]; const int mod = 100000; int rec(int y, int x, int j) { if (y >= H || x >= W)return 0; if (!dp[y][x][j])return dp[y][x][j]; if (y == H - 1 && x == W - 1)return 1; int ret; if (!y && !x) ret = rec(y + 1, x, 0) + rec(y, x + 1, 1); else if (j == 0)ret = rec(y + 1, x,0) + rec(y, x + 1, 3); else if (j == 1)ret = rec(y + 1, x, 2) + rec(y, x + 1, 1); else if (j == 2)ret = rec(y + 1, x, 0); else if (j == 3)ret = rec(y, x + 1, 1); return dp[y][x][j] = ret % mod; } int main() { while (cin >> W >> H, W) { for (int i = 0; i < 100; i++) { for (int j = 0; j < 100; j++) { for (int k = 0; k < 4; k++) { dp[i][j][k] = -1; } } } cout << rec(0, 0, 0) << endl; } return 0; }
a.cc:16:9: fatal error: intrin.h: No such file or directory 16 | #include<intrin.h> | ^~~~~~~~~~ compilation terminated.
s001216990
p00470
C++
#include <stdio.h> int main(void){ int i,j,w,h; while(scanf("%d%d",&w,&h),w,h){ unsigned __int64 dp[101][101][5]={0}; for(i=1;i<=h;i++) dp[i][1][4]=1; for(j=1;j<=w;j++) dp[1][j][4]=1; for(i=2;i<=h;i++){ for(j=2;j<=w;j++){ dp[i][j][0]=dp[i-1][j][3]+dp[i-1][j][4]; dp[i][j][1]=dp[i][j-1][2]+dp[i][j-1][4]; dp[i][j][2]=dp[i-1][j][0]+dp[i-1][j][2]; dp[i][j][3]=dp[i][j-1][1]+dp[i][j-1][3]; } } /* for(i=1;i<=h;i++){ for(j=1;j<=w;j++){ printf("(%I64d,%I64d,%dI64,%I64d,%I64d) ",dp[i][j][0],dp[i][j][1],dp[i][j][2],dp[i][j][3],dp[i][j][4]); } puts(""); } */ printf("%I64d\n",(dp[h][w][0]+dp[h][w][1]+dp[h][w][2]+dp[h][w][3])%100000); } return 0; }
a.cc: In function 'int main()': a.cc:6:34: error: expected initializer before 'dp' 6 | unsigned __int64 dp[101][101][5]={0}; | ^~ a.cc:8:35: error: 'dp' was not declared in this scope 8 | for(i=1;i<=h;i++) dp[i][1][4]=1; | ^~ a.cc:9:35: error: 'dp' was not declared in this scope 9 | for(j=1;j<=w;j++) dp[1][j][4]=1; | ^~ a.cc:13:33: error: 'dp' was not declared in this scope 13 | dp[i][j][0]=dp[i-1][j][3]+dp[i-1][j][4]; | ^~ a.cc:27:35: error: 'dp' was not declared in this scope 27 | printf("%I64d\n",(dp[h][w][0]+dp[h][w][1]+dp[h][w][2]+dp[h][w][3])%100000); | ^~
s492698228
p00470
C++
#include <cstring> #include <iostream> using namespace std; inline int rem(int n) { return n % 100000; } int main() { for (;;) { int w, h, streets[100][100][4]; cin >> w >> h; if (!w && !h) return 0; memset(streets, 0, sizeof streets); streets[0][0] = { 1, 0, 1, 0 }; for (int i = 1; i < w; i++) streets[0][i] = { 1, 0, 0, 1 }; for (int j = 1; j < h; j++) streets[j][0] = { 0, 1, 1, 0 }; for (int j = 1; j < h; j++) for (int i = 1; i < w; i++) streets[j][i] = { rem(streets[j][i-1][0] + streets[j][i-1][1]), streets[j-1][i][2], rem(streets[j-1][i][2] + streets[j-1][i][3]), streets[j][i-1][0] }; cout << rem(streets[h-1][w-1][0] + streets[h-1][w-1][2]) << endl; } }
a.cc: In function 'int main()': a.cc:16:19: error: assigning to an array from an initializer list 16 | streets[0][0] = { 1, 0, 1, 0 }; | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~ a.cc:18:21: error: assigning to an array from an initializer list 18 | streets[0][i] = { 1, 0, 0, 1 }; | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~ a.cc:20:21: error: assigning to an array from an initializer list 20 | streets[j][0] = { 0, 1, 1, 0 }; | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~ a.cc:23:23: error: assigning to an array from an initializer list 23 | streets[j][i] = { | ~~~~~~~~~~~~~~^~~ 24 | rem(streets[j][i-1][0] + streets[j][i-1][1]), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 25 | streets[j-1][i][2], | ~~~~~~~~~~~~~~~~~~~ 26 | rem(streets[j-1][i][2] + streets[j-1][i][3]), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 27 | streets[j][i-1][0] | ~~~~~~~~~~~~~~~~~~ 28 | }; | ~
s216146855
p00470
C++
#include <cstdio> #include <algorithm> const int mod = 100000; const int maxx = 128, maxy = 128; int main() { int w1[maxx][maxy] = {0}; int w2[maxx][maxy] = {0}; int s1[maxx][maxy] = {0}; int s2[maxx][maxy] = {0}; for(int i = 0; i < maxx) w2[i][0] = 1; for(int i = 0; i < maxy) s2[0][i] = 1; for(int x = 1; x < maxx) { for(int y = 1; y < maxy) { w1[x][y] = s1[x - 1][y] + s2[x - 1][y]; w2[x][y] = w1[x - 1][y] + w2[x - 1][y]; s1[x][y] = w1[x][y - 1] + w2[x][y - 1]; s2[x][y] = s1[x][y - 1] + s2[x][y - 1]; } } while(true) { int w, h; scanf("%d%d", &w, &h); if(w == 0) break; w -= 1, h -= 1; int ans = s1[w][h] + s2[w][h] + w1[w][h] + w2[w][h]; printf("%d\n", ans); } return 0; }
a.cc: In function 'int main()': a.cc:14:24: error: expected ';' before ')' token 14 | for(int i = 0; i < maxx) | ^ | ; a.cc:16:24: error: expected ';' before ')' token 16 | for(int i = 0; i < maxy) | ^ | ; a.cc:19:24: error: expected ';' before ')' token 19 | for(int x = 1; x < maxx) { | ^ | ; a.cc:20:24: error: expected ';' before ')' token 20 | for(int y = 1; y < maxy) { | ^ | ;
s923446180
p00470
C++
#include <cstdio> #include <algorithm> const int mod = 100000; const int maxx = 128, maxy = 128; int main() { int w1[maxx][maxy] = {0}; int w2[maxx][maxy] = {0}; int s1[maxx][maxy] = {0}; int s2[maxx][maxy] = {0}; for(int i = 0; i < maxx; ++i) w2[i][0] = 1; for(int i = 0; i < maxy; ++i) s2[0][i] = 1; for(int x = 1; x < maxx) { for(int y = 1; y < maxy) { w1[x][y] = s1[x - 1][y] + s2[x - 1][y]; w2[x][y] = w1[x - 1][y] + w2[x - 1][y]; s1[x][y] = w1[x][y - 1] + w2[x][y - 1]; s2[x][y] = s1[x][y - 1] + s2[x][y - 1]; } } while(true) { int w, h; scanf("%d%d", &w, &h); if(w == 0) break; w -= 1, h -= 1; int ans = s1[w][h] + s2[w][h] + w1[w][h] + w2[w][h]; printf("%d\n", ans); } return 0; }
a.cc: In function 'int main()': a.cc:19:24: error: expected ';' before ')' token 19 | for(int x = 1; x < maxx) { | ^ | ; a.cc:20:24: error: expected ';' before ')' token 20 | for(int y = 1; y < maxy) { | ^ | ;
s327064504
p00470
C++
#include<iostream> #include<algorithm> using namespace std; #define mod 100000 int w,h,memo[101][101][5]; int solve(int y,int x,int shine){ if(y<0 || y >= h || x < 0 || x >= w) return 0; if(memo[y][x][shine]) return memo[y][x][shine]; if(y == h - 1 && x == w - 1) return 1; if(!shine) //生きてる☆ return memo[y][x][shine] = solve(y+1,x,1) + solve(y,x+1,2) % mod; if(shine == 1) // 死にそう^v^ return memo[y][x][shine] = solve(y+1,x,1) + solve(y,x+1,4) % mod; if(shine == 2) // 死にそう^v^ return memo[y][x][shine] = solve(y+1,x,3) + solve(y,x+1,2) % mod; if(shine == 3) //死んでる(・^・) return memo[y][x][shine] = solve(y+1,x,1) % mod; if(shine == 4) //死んでる(・^・) return memo[y][x][shine] = solve(y,x+1,2) % mod; } int main(){ while(cin >> w >> h , w){ fill_n(memo[0][0],101*101*4,0) cout << solve(0,0,0) % mod <<endl; } }
a.cc: In function 'int main()': a.cc:23:35: error: expected ';' before 'cout' 23 | fill_n(memo[0][0],101*101*4,0) | ^ | ; 24 | cout << solve(0,0,0) % mod <<endl; | ~~~~ a.cc: In function 'int solve(int, int, int)': a.cc:20:1: warning: control reaches end of non-void function [-Wreturn-type] 20 | } | ^
s602519017
p00470
C++
#include <iostream> using namespace std; int dp[102][102][2]; void solve() { memset(dp, 0, sizeof(dp)); for(int i = 1; i <= 100; ++i) { dp[1][i][0] = 1; dp[1][i][1] = 1; dp[i][1][0] = 1; dp[i][1][1] = 1; } for(int i = 2; i <= 100; ++i) { for(int j = 2; j <= 100; ++j) { dp[i][j][0] = (dp[i][j - 1][0] + dp[i - 2][j][1]) % 100000; dp[i][j][1] = (dp[i][j - 2][0] + dp[i - 1][j][1]) % 100000; } } int w, h; while(cin >> w >> h, w || h) { cout << (dp[h][w - 1][0] + dp[h - 1][w][1]) % 100000 << endl; } } int main() { solve(); return(0); }
a.cc: In function 'void solve()': a.cc:8:9: error: 'memset' was not declared in this scope 8 | 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 |
s234590141
p00471
Java
#include <math.h> #include <utility> #include <string> #include <vector> #include <algorithm> #include <iostream> using namespace std; int m; int n; int map[10][10] = {0}; int cnt = 0; int churchx; int churchy; int dx[4] = {-1,1,0,0}; int dy[4] = {0,0,-1,1}; int saiki( int xinput, int yinput, int nokori ) { for ( int i = 0; i < 4; i++ ) { int x = xinput; int y = yinput; if ( nokori == 0 ) { if ( y == churchy && x > churchx && i != 0 ) continue; if ( y == churchy && x < churchx && i != 1 ) continue; if ( x == churchx && y > churchy && i != 2 ) continue; if ( x == churchx && y < churchy && i != 3 ) continue; } while(true) { x += dx[i]; y += dy[i]; if ( x < 0 || x >= m || y < 0 || y >= n ) break; if (map[x][y] == 1){ map[x][y] = 3; saiki(x, y, nokori-1); map[x][y] = 1; break; }else if(map[x][y] == 2 ){ if(nokori == 0){ cnt++; return 0; } } } } return 0; } int main(){ while(true) { cin >> m; cin >> n; if ( m == 0 ) break; int nokori = 0; for ( int i = 0; i < n; i++ ) { for ( int j = 0; j < m; j++ ) { cin >> map[j][i]; //unvisited if ( map[j][i] == 1 ) { nokori++; //is_church }else if(map[j][i] == 2) { churchx = j; churchy = i; } } } cnt = 0; saiki( churchx, churchy, nokori ); cout << cnt << endl; } return 0; }
Main.java:1: error: illegal character: '#' #include <math.h> ^ Main.java:1: error: class, interface, enum, or record expected #include <math.h> ^ Main.java:2: error: illegal character: '#' #include <utility> ^ Main.java:3: error: illegal character: '#' #include <string> ^ Main.java:4: error: illegal character: '#' #include <vector> ^ Main.java:5: error: illegal character: '#' #include <algorithm> ^ Main.java:6: error: illegal character: '#' #include <iostream> ^ Main.java:9: error: unnamed classes are a preview feature and are disabled by default. int m; ^ (use --enable-preview to enable unnamed classes) Main.java:11: error: class, interface, enum, or record expected int map[10][10] = {0}; ^ Main.java:15: error: class, interface, enum, or record expected int dx[4] = {-1,1,0,0}; ^ Main.java:16: error: class, interface, enum, or record expected int dy[4] = {0,0,-1,1}; ^ Main.java:52: error: not a statement cin >> m; ^ Main.java:53: error: not a statement cin >> n; ^ Main.java:58: error: not a statement cin >> map[j][i]; ^ Main.java:73: error: not a statement cout << cnt << endl; ^ 15 errors
s770826861
p00471
C
#include <stdio.h> int chousa(int[][],int,int,int,int,int); int main(void) { int x,y; int map[10][10]; int m,n; int kx,ky; int kazu=0; scanf("%d %d",&m,&n); /*読み込み*/ for(y=0;y<n;y++) { for(x=0;x<m;x++) { scanf("%d",&map[x][y]); if(map[x][y]==2) {/*教会*/ kx=x; ky=y; } else if(map[x][y]==1)kazu++;/*家*/ } } /*計算*/ printf("%d\n",chousa(map,kx,ky,kazu,m,n)); return 0; } int chousa(int map[10][10],int kx,int ky,int nokori,int m,int n) { int x,y; int result=0; int house=0; if(map[kx][ky]==1) {/*今いる家を通ったことにする*/ map[kx][ky]=0; house=1; } /*左に道順を調査*/ for(x=kx-1;x>=0;x--) { /*家に降りる*/ if(map[x][ky]==1) { result+=chousa(map,x,ky,nokori-1,m,n); break;/*家の上を通る場合には必ずプレゼントを拾う*/ } /*教会に戻る*/ else if(map[x][ky]==2 && nokori==0) { result++; break; } /*通れない*/ else if(map[x][ky]==3)break; } /*右に道順を調査*/ for(x=kx+1;x<m;x++) { /*家に降りる*/ if(map[x][ky]==1) { result+=chousa(map,x,ky,nokori-1,m,n); break;/*家の上を通る場合には必ずプレゼントを拾う*/ } /*教会に戻る*/ else if(map[x][ky]==2 && nokori==0) { result++; break; } /*通れない*/ else if(map[x][ky]==3)break; } /*上に道順を調査*/ for(y=ky-1;y>=0;y--) { /*家に降りる*/ if(map[kx][y]==1) { result+=chousa(map,kx,y,nokori-1,m,n); break;/*家の上を通る場合には必ずプレゼントを拾う*/ } /*教会に戻る*/ else if(map[kx][y]==2 && nokori==0) { result++; break; } /*通れない*/ else if(map[kx][y]==3)break; } /*下に道順を調査*/ for(y=ky+1;y<n;y++) { /*家に降りる*/ if(map[kx][y]==1) { result+=chousa(map,kx,y,nokori-1,m,n); break;/*家の上を通る場合には必ずプレゼントを拾う*/ } /*教会に戻る*/ else if(map[kx][y]==2 && nokori==0) { result++; break; } /*通れない*/ else if(map[kx][y]==3)break; } if(house)map[kx][ky]=1;/*通った家を元に戻す*/ return result; }
main.c:3:15: error: array type has incomplete element type 'int[]' 3 | int chousa(int[][],int,int,int,int,int); | ^ main.c:3:15: note: declaration of multidimensional array must have bounds for all dimensions except the first main.c: In function 'main': main.c:23:30: error: type of formal parameter 1 is incomplete 23 | printf("%d\n",chousa(map,kx,ky,kazu,m,n)); | ^~~
s919295326
p00471
C
#include <stdio.h> int map[10][10]; int m,n; int chousa(int kx,int ky,int nokori) { int x,y; int result=0; int house=0; if(map[kx][ky]==1) {/*今いる家を通ったことにする*/ map[kx][ky]=0; house=1; } /*左に道順を調査*/ for(x=kx-1;x>=0;x--) { /*家に降りる*/ if(map[x][ky]==1) { result+=chousa(map,x,ky,nokori-1,m,n); break;/*家の上を通る場合には必ずプレゼントを拾う*/ } /*教会に戻る*/ else if(map[x][ky]==2 && nokori==0) { result++; break; } /*通れない*/ else if(map[x][ky]==3)break; } /*右に道順を調査*/ for(x=kx+1;x<m;x++) { /*家に降りる*/ if(map[x][ky]==1) { result+=chousa(map,x,ky,nokori-1,m,n); break;/*家の上を通る場合には必ずプレゼントを拾う*/ } /*教会に戻る*/ else if(map[x][ky]==2 && nokori==0) { result++; break; } /*通れない*/ else if(map[x][ky]==3)break; } /*上に道順を調査*/ for(y=ky-1;y>=0;y--) { /*家に降りる*/ if(map[kx][y]==1) { result+=chousa(map,kx,y,nokori-1,m,n); break;/*家の上を通る場合には必ずプレゼントを拾う*/ } /*教会に戻る*/ else if(map[kx][y]==2 && nokori==0) { result++; break; } /*通れない*/ else if(map[kx][y]==3)break; } /*下に道順を調査*/ for(y=ky+1;y<n;y++) { /*家に降りる*/ if(map[kx][y]==1) { result+=chousa(map,kx,y,nokori-1,m,n); break;/*家の上を通る場合には必ずプレゼントを拾う*/ } /*教会に戻る*/ else if(map[kx][y]==2 && nokori==0) { result++; break; } /*通れない*/ else if(map[kx][y]==3)break; } if(house)map[kx][ky]=1;/*通った家を元に戻す*/ return result; } int main(void) { int x,y; int kx,ky; int kazu; while(1) { scanf("%d %d",&m,&n); if(m==0 && n==0)break; kazu=0; /*読み込み*/ for(y=0;y<n;y++) { for(x=0;x<m;x++) { scanf("%d",&map[x][y]); if(map[x][y]==2) {/*教会*/ kx=x; ky=y; } else if(map[x][y]==1)kazu++;/*家*/ } } /*計算*/ printf("%d\n",chousa(map,kx,ky,kazu,m,n)); } return 0; }
main.c: In function 'chousa': main.c:18:40: error: passing argument 1 of 'chousa' makes integer from pointer without a cast [-Wint-conversion] 18 | result+=chousa(map,x,ky,nokori-1,m,n); | ^~~ | | | int (*)[10] main.c:6:16: note: expected 'int' but argument is of type 'int (*)[10]' 6 | int chousa(int kx,int ky,int nokori) { | ~~~~^~ main.c:18:33: error: too many arguments to function 'chousa' 18 | result+=chousa(map,x,ky,nokori-1,m,n); | ^~~~~~ main.c:6:5: note: declared here 6 | int chousa(int kx,int ky,int nokori) { | ^~~~~~ main.c:33:40: error: passing argument 1 of 'chousa' makes integer from pointer without a cast [-Wint-conversion] 33 | result+=chousa(map,x,ky,nokori-1,m,n); | ^~~ | | | int (*)[10] main.c:6:16: note: expected 'int' but argument is of type 'int (*)[10]' 6 | int chousa(int kx,int ky,int nokori) { | ~~~~^~ main.c:33:33: error: too many arguments to function 'chousa' 33 | result+=chousa(map,x,ky,nokori-1,m,n); | ^~~~~~ main.c:6:5: note: declared here 6 | int chousa(int kx,int ky,int nokori) { | ^~~~~~ main.c:48:40: error: passing argument 1 of 'chousa' makes integer from pointer without a cast [-Wint-conversion] 48 | result+=chousa(map,kx,y,nokori-1,m,n); | ^~~ | | | int (*)[10] main.c:6:16: note: expected 'int' but argument is of type 'int (*)[10]' 6 | int chousa(int kx,int ky,int nokori) { | ~~~~^~ main.c:48:33: error: too many arguments to function 'chousa' 48 | result+=chousa(map,kx,y,nokori-1,m,n); | ^~~~~~ main.c:6:5: note: declared here 6 | int chousa(int kx,int ky,int nokori) { | ^~~~~~ main.c:63:40: error: passing argument 1 of 'chousa' makes integer from pointer without a cast [-Wint-conversion] 63 | result+=chousa(map,kx,y,nokori-1,m,n); | ^~~ | | | int (*)[10] main.c:6:16: note: expected 'int' but argument is of type 'int (*)[10]' 6 | int chousa(int kx,int ky,int nokori) { | ~~~~^~ main.c:63:33: error: too many arguments to function 'chousa' 63 | result+=chousa(map,kx,y,nokori-1,m,n); | ^~~~~~ main.c:6:5: note: declared here 6 | int chousa(int kx,int ky,int nokori) { | ^~~~~~ main.c: In function 'main': main.c:97:38: error: passing argument 1 of 'chousa' makes integer from pointer without a cast [-Wint-conversion] 97 | printf("%d\n",chousa(map,kx,ky,kazu,m,n)); | ^~~ | | | int (*)[10] main.c:6:16: note: expected 'int' but argument is of type 'int (*)[10]' 6 | int chousa(int kx,int ky,int nokori) { | ~~~~^~ main.c:97:31: error: too many arguments to function 'chousa' 97 | printf("%d\n",chousa(map,kx,ky,kazu,m,n)); | ^~~~~~ main.c:6:5: note: declared here 6 | int chousa(int kx,int ky,int nokori) { | ^~~~~~
s760478089
p00471
C
#include <stdio.h> int map[10][10]; int m,n; int chousa(int kx,int ky,int nokori) { int x,y; int result=0; int house=0; if(map[kx][ky]==1) {/*今いる家を通ったことにする*/ map[kx][ky]=0; house=1; } /*左に道順を調査*/ for(x=kx-1;x>=0;x--) { /*家に降りる*/ if(map[x][ky]==1) { result+=chousa(map,x,ky,nokori-1,m,n); break;/*家の上を通る場合には必ずプレゼントを拾う*/ } /*教会に戻る*/ else if(map[x][ky]==2 && nokori==0) { result++; break; } /*通れない*/ else if(map[x][ky]==3)break; } /*右に道順を調査*/ for(x=kx+1;x<m;x++) { /*家に降りる*/ if(map[x][ky]==1) { result+=chousa(map,x,ky,nokori-1,m,n); break;/*家の上を通る場合には必ずプレゼントを拾う*/ } /*教会に戻る*/ else if(map[x][ky]==2 && nokori==0) { result++; break; } /*通れない*/ else if(map[x][ky]==3)break; } /*上に道順を調査*/ for(y=ky-1;y>=0;y--) { /*家に降りる*/ if(map[kx][y]==1) { result+=chousa(map,kx,y,nokori-1,m,n); break;/*家の上を通る場合には必ずプレゼントを拾う*/ } /*教会に戻る*/ else if(map[kx][y]==2 && nokori==0) { result++; break; } /*通れない*/ else if(map[kx][y]==3)break; } /*下に道順を調査*/ for(y=ky+1;y<n;y++) { /*家に降りる*/ if(map[kx][y]==1) { result+=chousa(map,kx,y,nokori-1,m,n); break;/*家の上を通る場合には必ずプレゼントを拾う*/ } /*教会に戻る*/ else if(map[kx][y]==2 && nokori==0) { result++; break; } /*通れない*/ else if(map[kx][y]==3)break; } if(house)map[kx][ky]=1;/*通った家を元に戻す*/ return result; } int main(void) { int x,y; int kx,ky; int kazu; while(1) { scanf("%d %d",&m,&n); if(m==0 && n==0)break; kazu=0; /*読み込み*/ for(y=0;y<n;y++) { for(x=0;x<m;x++) { scanf("%d",&map[x][y]); if(map[x][y]==2) {/*教会*/ kx=x; ky=y; } else if(map[x][y]==1)kazu++;/*家*/ } } /*計算*/ printf("%d\n",chousa(kx,ky,kazu)); } return 0; }
main.c: In function 'chousa': main.c:18:40: error: passing argument 1 of 'chousa' makes integer from pointer without a cast [-Wint-conversion] 18 | result+=chousa(map,x,ky,nokori-1,m,n); | ^~~ | | | int (*)[10] main.c:6:16: note: expected 'int' but argument is of type 'int (*)[10]' 6 | int chousa(int kx,int ky,int nokori) { | ~~~~^~ main.c:18:33: error: too many arguments to function 'chousa' 18 | result+=chousa(map,x,ky,nokori-1,m,n); | ^~~~~~ main.c:6:5: note: declared here 6 | int chousa(int kx,int ky,int nokori) { | ^~~~~~ main.c:33:40: error: passing argument 1 of 'chousa' makes integer from pointer without a cast [-Wint-conversion] 33 | result+=chousa(map,x,ky,nokori-1,m,n); | ^~~ | | | int (*)[10] main.c:6:16: note: expected 'int' but argument is of type 'int (*)[10]' 6 | int chousa(int kx,int ky,int nokori) { | ~~~~^~ main.c:33:33: error: too many arguments to function 'chousa' 33 | result+=chousa(map,x,ky,nokori-1,m,n); | ^~~~~~ main.c:6:5: note: declared here 6 | int chousa(int kx,int ky,int nokori) { | ^~~~~~ main.c:48:40: error: passing argument 1 of 'chousa' makes integer from pointer without a cast [-Wint-conversion] 48 | result+=chousa(map,kx,y,nokori-1,m,n); | ^~~ | | | int (*)[10] main.c:6:16: note: expected 'int' but argument is of type 'int (*)[10]' 6 | int chousa(int kx,int ky,int nokori) { | ~~~~^~ main.c:48:33: error: too many arguments to function 'chousa' 48 | result+=chousa(map,kx,y,nokori-1,m,n); | ^~~~~~ main.c:6:5: note: declared here 6 | int chousa(int kx,int ky,int nokori) { | ^~~~~~ main.c:63:40: error: passing argument 1 of 'chousa' makes integer from pointer without a cast [-Wint-conversion] 63 | result+=chousa(map,kx,y,nokori-1,m,n); | ^~~ | | | int (*)[10] main.c:6:16: note: expected 'int' but argument is of type 'int (*)[10]' 6 | int chousa(int kx,int ky,int nokori) { | ~~~~^~ main.c:63:33: error: too many arguments to function 'chousa' 63 | result+=chousa(map,kx,y,nokori-1,m,n); | ^~~~~~ main.c:6:5: note: declared here 6 | int chousa(int kx,int ky,int nokori) { | ^~~~~~
s416975233
p00471
C
#include<stdio.h> bool hs[10][10]; bool used[10][10]; int cx,cy; int nh; int dx[4]={-1,0,1,0}; int dy[4]={0,1,0,-1}; int w,h; int dfs(int x,int y,int f){ if(f==nh){ if(x==cx||y==cy)return 1; return 0; } int i,j; int res=0; for(i=0;i<4;i++){ for(j=1;j<10;j++){ int nx=x+j*dx[i]; int ny=y+j*dy[i]; if(nx<0||nx>=h||ny<0||ny>=w)break; if(hs[nx][ny]){ if(!used[nx][ny]){ used[nx][ny]=true; res+=dfs(nx,ny,f+1); used[nx][ny]=false; break; } } } } return res; } int main(){ while(1){ int i,j; scanf("%d %d",&w,&h); if(w==0)return 0; for(i=0;i<h;i++)for(j=0;j<w;j++){ hs[i][j]=false; used[i][j]=false; } nh=0; for(i=0;i<h;i++){ for(j=0;j<w;j++){ char c; scanf(" %c",&c); if(c=='1'){ hs[i][j]=true; used[i][j]=false; nh++; } if(c=='2'){cx=i;cy=j;} } } printf("%d\n",dfs(cx,cy,0)); } }
main.c:2:1: error: unknown type name 'bool' 2 | bool hs[10][10]; | ^~~~ 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 | bool hs[10][10]; main.c:3:1: error: unknown type name 'bool' 3 | bool used[10][10]; | ^~~~ main.c:3:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' main.c: In function 'dfs': main.c:23:54: error: 'true' undeclared (first use in this function) 23 | used[nx][ny]=true; | ^~~~ main.c:23:54: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' main.c:23:54: note: each undeclared identifier is reported only once for each function it appears in main.c:25:54: error: 'false' undeclared (first use in this function) 25 | used[nx][ny]=false; | ^~~~~ main.c:25:54: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' main.c: In function 'main': main.c:39:26: error: 'false' undeclared (first use in this function) 39 | hs[i][j]=false; | ^~~~~ main.c:39:26: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' main.c:48:42: error: 'true' undeclared (first use in this function) 48 | hs[i][j]=true; | ^~~~ main.c:48:42: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
s337696146
p00471
C++
#include <iostream> #include <fstream> #include <stdio.h> #include <math.h> #include <time.h> #include <string> #include <tuple> #include <vector> #include <map> #include <unordered_map> #include <list> #include <set> #include <stack> #include <queue> #include <cstdlib> #include <algorithm> #include <random> #include <cassert> using namespace std; #define LL long long #define MP(a, b) make_pair(a, b) #define MMP(a, b, c) make_pair(make_pair(a, b), c) #define MAX 1000000000 #undef INT_MIN #undef INT_MAX #define INT_MIN -2147483648 #define INT_MAX 2147483647 #define LL_MIN -9223372036854775808 #define LL_MAX 9223372036854775807 #define PI 3.14159265359 int n,m,x,y,ie,bit,l; int mp[10][10]; map<pair<int,int>,int> memo; map<pair<int,int>,int> num; int dfs(int I, int J){ if(l != -1 && num.count(MP(bit,l)) != 0 return memo[MP(bit,l)]; if(bit == ie){ if(I != x && J != y) return 0; int ans = 0; for(int i=I-1; i>=0; i--){ if(mp[i][J] == -1) break; if(mp[i][J] == 2) ans++; } for(int i=I+1; i<n; i++){ if(mp[i][J] == -1) break; if(mp[i][J] == 2) ans++; } for(int j=J-1; j>=0; j--){ if(mp[I][j] == -1) break; if(mp[I][j] == 2) ans++; } for(int j=J+1; j<m; j++){ if(mp[I][j] == -1) break; if(mp[I][j] == 2) ans++; } return memo[MP(bit,l)] = ans; } int ans = 0; int L = l; for(int i=I-1; i>=0; i--){ if(mp[i][J] == -1) break; if(mp[i][J] == 1){ mp[i][J] *= -1; bit = bit ^ (1<<num[MP(i,J)]); l = num[MP(i,J)]; ans += dfs(i,J); mp[i][J] *= -1; bit = bit ^ (1<<num[MP(i,J)]); } } for(int i=I+1; i<n; i++){ if(mp[i][J] == -1) break; if(mp[i][J] == 1){ mp[i][J] *= -1; bit = bit ^ (1<<num[MP(i,J)]); l = num[MP(i,J)]; ans += dfs(i,J); mp[i][J] *= -1; bit = bit ^ (1<<num[MP(i,J)]); } } for(int j=J-1; j>=0; j--){ if(mp[I][j] == -1) break; if(mp[I][j] == 1){ mp[I][j] *= -1; bit = bit ^ (1<<num[MP(I,j)]); l = num[MP(I,j)]; ans += dfs(I,j); mp[I][j] *= -1; bit = bit ^ (1<<num[MP(I,j)]); } } for(int j=J+1; j<m; j++){ if(mp[I][j] == -1) break; if(mp[I][j] == 1){ mp[I][j] *= -1; bit = bit ^ (1<<num[MP(I,j)]); l = num[MP(I,j)]; ans += dfs(I,j); mp[I][j] *= -1; bit = bit ^ (1<<num[MP(I,j)]); } } return memo[MP(bit,l)] = ans; } int main(){ iostream::sync_with_stdio(false); while(true){ cin >> m >> n; if(n == 0 && m == 0) break; num.clear(); ie = 0; bit = 0; for(int i=0; i<n; i++){ for(int j=0; j<m; j++){ cin >> mp[i][j]; if(mp[i][j] == 2){ x = i; y = j; } if(mp[i][j] == 1){ num[MP(i,j)] = ie; ie++; } } } ie = (1<<ie) - 1; l = -1; memo.clear(); cout << dfs(x,y) << endl; } return 0; }
a.cc: In function 'int dfs(int, int)': a.cc:37:44: error: expected ';' before 'return' 37 | if(l != -1 && num.count(MP(bit,l)) != 0 return memo[MP(bit,l)]; | ^~~~~~~ | ; a.cc:39:5: error: expected primary-expression before 'if' 39 | if(bit == ie){ | ^~ a.cc:37:68: error: expected ')' before 'if' 37 | if(l != -1 && num.count(MP(bit,l)) != 0 return memo[MP(bit,l)]; | ~ ^ | ) 38 | 39 | if(bit == ie){ | ~~ a.cc:69:13: error: 'ans' was not declared in this scope; did you mean 'abs'? 69 | ans += dfs(i,J); | ^~~ | abs a.cc:80:13: error: 'ans' was not declared in this scope; did you mean 'abs'? 80 | ans += dfs(i,J); | ^~~ | abs a.cc:91:13: error: 'ans' was not declared in this scope; did you mean 'abs'? 91 | ans += dfs(I,j); | ^~~ | abs a.cc:102:13: error: 'ans' was not declared in this scope; did you mean 'abs'? 102 | ans += dfs(I,j); | ^~~ | abs a.cc:108:30: error: 'ans' was not declared in this scope; did you mean 'abs'? 108 | return memo[MP(bit,l)] = ans; | ^~~ | abs
s185126212
p00471
C++
/* よいウンコードの例 *. #include <cstdio> #include <stack> using namespace std; #define EMPTY 0 #define YET_DELIVERED 1 #define CHURCH 2 #define DELIVERED 3 int m; int n; int count; int house_num; int dx[] = {-1, 1, 0, 0}; int dy[] = {0, 0, -1, 1}; int map[10][10]; void rec(char x, char y) { char i; char times = 0; char x2; char y2; stack<char> s; char k; call: i = 0; loop: x2 = x; y2 = y; while (1) { x2 += dx[i]; y2 += dy[i]; if (x2 >= m || x2 < 0 || y2 >= n || y2 <0) break; if (map[y2][x2] == DELIVERED) break; if (map[y2][x2] == CHURCH) { if (times == house_num) { ++count; } } else if (map[y2][x2] == YET_DELIVERED) { map[y2][x2] = DELIVERED; s.push(i); s.push(x); s.push(y); x = x2; y = y2; ++times; goto call; } resume: ; } ++i; if (i < 4) { goto loop; } if (s.empty()) return ; map[y][x] = YET_DELIVERED; --times; x2 = x; y2 = y; y = s.top(); s.pop(); x = s.top(); s.pop(); i = s.top(); s.pop(); goto resume; } int main() { while (1) { int i; int church_x, church_y; scanf("%d %d", &m, &n); if ((m | n) == 0) { return 0; } count = 0; house_num = 0; for (i=0; i<n; i++) { int j; for (j=0; j<m; j++) { scanf("%d", &map[i][j]); if (map[i][j] == YET_DELIVERED) { ++house_num; } else if (map[i][j] == CHURCH) { church_x = j; church_y = i; } } } rec((char)church_x, (char)church_y); printf("%d\n", count); } }
a.cc:1:1: error: unterminated comment 1 | /* よいウンコードの例 *. | ^
s967920217
p00471
C++
#include<iostream> #include<queue> #include<vector> #include <bitset> using namespace std; typedef pair<int, int> P; int i, j, k; int m, n; int dp[25][1024 * 1024 * 16], town[11][11]; P p[25]; void bfs(int now, int flag); int main() { while (cin >> m >> n&& m && n) { int s, count = 1; memset(dp, 0, sizeof(dp)); for (i = 1; i <= n; i++) { for (j = 1; j <= m; j++) { cin >> town[i][j]; if (town[i][j] == 2) { s = count; } if (town[i][j]) { town[i][j] = count; p[count] = make_pair(i, j); count++; } } } /*for (i = 1; i <= n;i++){ for (j = 1; j <= m; j++) { cout << town[i][j]; } cout << endl; }*/ bfs(s, 0); j = 1; for (i = 0; i < count - 1; i++) j = j * 2; cout << dp[s][j - 1] << endl; } } void bfs(int start, int flag) { dp[start][flag] = 1; vector<P> que; que.push_back(make_pair(flag, start)); while (!que.empty()) { //cout << que.size()<<' '; que.erase(unique(que.begin(), que.end()), que.end()); sort(que.begin(), que.end()); P pp; pp = que[0]; start = pp.second; flag = pp.first; //cout << start << ' ' << static_cast<std::bitset<24> >(flag) << endl; que.erase(que.begin()); for (j = p[start].second; j <= m; j++) { if (town[p[start].first][j]&&j!=p[start].second) { if (flag & 1 << (town[p[start].first][j]-1)) { break; } else { int flag2 = flag | 1 << (town[p[start].first][j] - 1); dp[town[p[start].first][j]][flag2] += dp[town[p[start].first][p[start].second]][flag]; // cout << 1 << endl; que.push_back(make_pair(flag2, town[p[start].first][j])); } } } for (j = p[start].second; j >= 1; j--) { if (town[p[start].first][j]&&j != p[start].second) { if (flag & 1 << (town[p[start].first][j]- 1)) { break; } else { int flag2 = flag | 1 << (town[p[start].first][j] - 1); dp[town[p[start].first][j]][flag2] += dp[town[p[start].first][p[start].second]][flag]; que.push_back(make_pair(flag2, town[p[start].first][j])); // cout << 2 << endl; } } } for (j = p[start].first; j <= n; j++) { if (town[j][p[start].second]&& j != p[start].first) { if (flag & 1 << (town[j][p[start].second] - 1)) { break; } else { int flag2 = flag | 1 << (town[j][p[start].second] - 1); dp[town[j][p[start].second]][flag2] += dp[town[p[start].first][p[start].second]][flag]; que.push_back(make_pair(flag2, town[j][p[start].second])); // cout << 3 << endl; } } } for (j = p[start].first; j >= 1; j--) { if (town[j][p[start].second] && j != p[start].first) { if (flag & 1 << (town[j][p[start].second] - 1)) { break; } else { int flag2 = flag | 1 << (town[j][p[start].second] - 1); dp[town[j][p[start].second]][flag2] += dp[town[p[start].first][p[start].second]][flag]; que.push_back(make_pair(flag2, town[j][p[start].second])); //cout << 4 << endl; //cout << j << ' ' << flag2 << ' ' << p[start].first << endl; } } } } }
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:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 4 | #include <bitset> +++ |+#include <cstring> 5 | a.cc: In function 'void bfs(int, int)': a.cc:49:27: error: 'unique' was not declared in this scope 49 | que.erase(unique(que.begin(), que.end()), que.end()); | ^~~~~~ a.cc:50:17: error: 'sort' was not declared in this scope; did you mean 'short'? 50 | sort(que.begin(), que.end()); | ^~~~ | short
s533745277
p00471
C++
#include <iostream> #include <cstdio> #include <vector> #include <cmath> #include <cstring> #include <numeric> #include <algorithm> #include <functional> #include <array> #include <map> #include <queue> #include <limits.h> #include <set> #include <stack> #include <random> #define rep(i,s,n) for(int i = (s); (n) > i; i++) #define REP(i,n) rep(i,0,n) #define RANGE(x,a,b) ((a) <= (x) && (x) <= (b)) #define POWT(x) ((x)*(x)) #define ALL(x) (x).begin(), (x).end() #define MODI 10000 #define bitcheck(a,b) (a >> b) & 1 #define bitset(a,b) a |= (1 << b) #define bitunset(a,b) a &= ~(1 << b) using namespace std; typedef pair<int, int> pii; typedef long long ll; signed main() { int w,h; scanf("%d %d", &w, &h); vector<vector<int>> mp(w,vector<int>(h,-1)); pii cha; vector<pii> homp; int homc = 0; REP(i, h) { REP(j, w) { int a = 0; scanf("%d", &a); if (a == 2) { cha = { j,i }; } if (a == 1) { homp.push_back({ j,i }); mp[j][i] = homc; homc++; } } } homp.push_back(cha); map<pii, int> dp[2];//?±\??´????????¨??° dp[0][{0, homc}] = 1; bool t = 0; REP(i,homc){ for(auto cur : dp[t]) { pii curpos = homp[cur.first.second]; int cnum; for (int j = curpos.second + 1; h > j; j++) {//??? cnum = mp[curpos.first][j]; if (cnum == -1) continue; if (bitcheck(cur.first.first, cnum)) break; int buf = cur.first.first; bitset(buf, cnum); dp[1 - t][{buf, cnum}] += cur.second; } for (int j = curpos.second - 1; 0 <= j; j--) {//??? cnum = mp[curpos.first][j]; if (cnum == -1) continue; if (bitcheck(cur.first.first, cnum)) break; int buf = cur.first.first; bitset(buf, cnum); dp[1 - t][{buf, cnum}] += cur.second; } for (int j = curpos.first + 1; w > j; j++) {//??? cnum = mp[j][curpos.second]; if (cnum == -1) continue; if (bitcheck(cur.first.first, cnum)) break; int buf = cur.first.first; bitset(buf, cnum); dp[1 - t][{buf, cnum}] += cur.second; } for (int j = curpos.first - 1; 0 <= j; j--) {//??? cnum = mp[j][curpos.second]; if (cnum == -1) continue; if (bitcheck(cur.first.first, cnum)) break; int buf = cur.first.first; bitset(buf, cnum); dp[1 - t][{buf, cnum}] += cur.second; } } dp[t].swap(map<pii,int>()); t = 1 - t; } int cnum,ans = 0; set<int> targets; for (int j = cha.first; w > j; j++) { cnum = mp[j][cha.second]; if (cnum > -1) { targets.insert(cnum); break; } } for (int j = cha.first; 0 <= j; j--) { cnum = mp[j][cha.second]; if (cnum > -1) { targets.insert(cnum); break; } } for (int j = cha.second; h > j; j++) { cnum = mp[cha.first][j]; if (cnum > -1) { targets.insert(cnum); break; } } for (int j = cha.second; 0 <= j; j--) { cnum = mp[cha.first][j]; if (cnum > -1) { targets.insert(cnum); break; } } for (auto cur : dp[t]) { if(targets.find(cur.first.second) != targets.end()) ans += cur.second; } printf("%d\n", ans); return 0; }
a.cc: In function 'int main()': a.cc:95:28: error: cannot bind non-const lvalue reference of type 'std::map<std::pair<int, int>, int>&' to an rvalue of type 'std::map<std::pair<int, int>, int>' 95 | dp[t].swap(map<pii,int>()); | ^~~~~~~~~~~~~~ In file included from /usr/include/c++/14/map:63, from a.cc:10: /usr/include/c++/14/bits/stl_map.h:1171:17: note: initializing argument 1 of 'void std::map<_Key, _Tp, _Compare, _Alloc>::swap(std::map<_Key, _Tp, _Compare, _Alloc>&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' 1171 | swap(map& __x) | ~~~~~^~~
s166012121
p00471
C++
#include <iostream> #include <cstdio> #include <vector> #include <cmath> #include <cstring> #include <numeric> #include <algorithm> #include <functional> #include <array> #include <map> #include <queue> #include <limits.h> #include <set> #include <stack> #include <random> #define rep(i,s,n) for(int i = (s); (n) > i; i++) #define REP(i,n) rep(i,0,n) #define RANGE(x,a,b) ((a) <= (x) && (x) <= (b)) #define POWT(x) ((x)*(x)) #define ALL(x) (x).begin(), (x).end() #define MODI 10000 #define bitcheck(a,b) (a >> b) & 1 #define bitset(a,b) a |= (1 << b) #define bitunset(a,b) a &= ~(1 << b) using namespace std; typedef pair<int, int> pii; typedef long long ll; signed main() { int w,h; scanf("%d %d", &w, &h); vector<vector<int>> mp(w,vector<int>(h,-1)); pii cha; vector<pii> homp; int homc = 0; REP(i, h) { REP(j, w) { int a = 0; scanf("%d", &a); if (a == 2) { cha = { j,i }; } if (a == 1) { homp.push_back({ j,i }); mp[j][i] = homc; homc++; } } } homp.push_back(cha); map<pii, int> dp[2];//?±\??´????????¨??° dp[0][{0, homc}] = 1; bool t = 0; REP(i,homc){ for(auto cur : dp[t]) { pii curpos = homp[cur.first.second]; int cnum; for (int j = curpos.second + 1; h > j; j++) {//??? cnum = mp[curpos.first][j]; if (cnum == -1) continue; if (bitcheck(cur.first.first, cnum)) break; int buf = cur.first.first; bitset(buf, cnum); dp[1 - t][{buf, cnum}] += cur.second; } for (int j = curpos.second - 1; 0 <= j; j--) {//??? cnum = mp[curpos.first][j]; if (cnum == -1) continue; if (bitcheck(cur.first.first, cnum)) break; int buf = cur.first.first; bitset(buf, cnum); dp[1 - t][{buf, cnum}] += cur.second; } for (int j = curpos.first + 1; w > j; j++) {//??? cnum = mp[j][curpos.second]; if (cnum == -1) continue; if (bitcheck(cur.first.first, cnum)) break; int buf = cur.first.first; bitset(buf, cnum); dp[1 - t][{buf, cnum}] += cur.second; } for (int j = curpos.first - 1; 0 <= j; j--) {//??? cnum = mp[j][curpos.second]; if (cnum == -1) continue; if (bitcheck(cur.first.first, cnum)) break; int buf = cur.first.first; bitset(buf, cnum); dp[1 - t][{buf, cnum}] += cur.second; } } dp[t].swap(map<pii,int>()); t = 1 - t; } int cnum,ans = 0; set<int> targets; for (int j = cha.first; w > j; j++) { cnum = mp[j][cha.second]; if (cnum > -1) { targets.insert(cnum); break; } } for (int j = cha.first; 0 <= j; j--) { cnum = mp[j][cha.second]; if (cnum > -1) { targets.insert(cnum); break; } } for (int j = cha.second; h > j; j++) { cnum = mp[cha.first][j]; if (cnum > -1) { targets.insert(cnum); break; } } for (int j = cha.second; 0 <= j; j--) { cnum = mp[cha.first][j]; if (cnum > -1) { targets.insert(cnum); break; } } for (auto cur : dp[t]) { if(targets.find(cur.first.second) != targets.end()) ans += cur.second; } printf("%d\n", ans); return 0; }
a.cc: In function 'int main()': a.cc:95:28: error: cannot bind non-const lvalue reference of type 'std::map<std::pair<int, int>, int>&' to an rvalue of type 'std::map<std::pair<int, int>, int>' 95 | dp[t].swap(map<pii,int>()); | ^~~~~~~~~~~~~~ In file included from /usr/include/c++/14/map:63, from a.cc:10: /usr/include/c++/14/bits/stl_map.h:1171:17: note: initializing argument 1 of 'void std::map<_Key, _Tp, _Compare, _Alloc>::swap(std::map<_Key, _Tp, _Compare, _Alloc>&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' 1171 | swap(map& __x) | ~~~~~^~~
s834482322
p00471
C++
#include <bits/stdc++.h> template<typename T> void fill_all(T& ar,const T& v){ ar=v; } template<typename T,size_t N,typename U> void fill_all(T(& ar)[N],const U& v){ for(auto&i:ar){fill_all(i,v);} } int w,h; const int goal = 23; const int empty = 24; int graph[25][4][25];//???????????? int map[10][10]; const bitmax = 1<<20; //bit???????????? int dp[23][bitmax]; int func(int now, int bit){ if(now==empty){return 0;} if(now==goal){ #ifdef DEBUG std::cout<<"OUTg0:" << now <<' '<<bit<<':'<<((now==goal&&bit==0)?1:0)<<std::endl; #endif return ((now==goal&&bit==0)?1:0); } if(bit==0){ for(auto& g:graph[now]){ if(g[0] == goal){ #ifdef DEBUG std::cout<<"OUTb0:" << now <<' '<<bit<<':'<<1<<std::endl; #endif return 1; } } #ifdef DEBUG std::cout<<"OUTb0:" << now <<' '<<bit<<':'<<0<<std::endl; #endif return 0; } if(bit<bitmax)if(dp[now][bit]>=0){return dp[now][bit];} int res = 0; for(int graph_num =0;graph_num<4;++graph_num){ for(auto iter=graph[now][graph_num];*iter!=empty;++iter){ if(bit&(1<<*iter)){ res += func(*iter,bit&(~(1<<*iter))); } else{ break; } } } #ifdef DEBUG std::cout<<"OUT:" << now <<' '<<bit<<':'<<res<<std::endl; for(int graph_num =0;graph_num<4;++graph_num){ for(auto iter=graph[now][graph_num];*iter!=empty;++iter){ std::cout << ' '<<*iter; if(bit&(1<<*iter)){std::cout<<"(OK:"<<(bit&(~(1<<*iter)))<<")";} else{break;} } } std::cout<< std::endl; #endif if(bit<bitmax)return dp[now][bit]=res; return res; } int main() { for(;;){ fill_all(dp,-1); fill_all(map,empty); fill_all(graph,empty); std::cin>>w>>h;if(w==0&&h==0){break;} int count = 0; for(auto y=0;y<h;++y)for(auto x=0;x<w;++x){ std::cin >> map[y][x]; if(map[y][x]==0){ map[y][x]=empty; continue; } else if(map[y][x]==1){ map[y][x]=count++; } else if(map[y][x]==2){ map[y][x]=goal; } auto pushback=[](int*g, int v){ while(*g!=empty){++g;}*g=v; }; auto iter = graph[map[y][x]][0]; for(int ox=x-1;ox>=0;--ox){ if(empty>map[y][ox]){ #ifdef DEBUG std::cout <<"PASSx "<<x<<' '<<y<<"<->"<<ox<<' '<<y<<' '<<map[y][ox] <<"\n"; #endif *(iter++) = map[y][ox]; pushback(graph[map[y][ox]][2],map[y][x]); #ifdef DEBUG std::cout <<"graph "<<*(iter-1) <<' '<<map[y][x]<<"\n"; #endif } } iter = graph[map[y][x]][1]; for(int oy=y-1;oy>=0;--oy){ if(empty>map[oy][x]){ #ifdef DEBUG std::cout <<"PASSy "<<x<<' '<<y<<"<->"<<x<<' '<<oy<<' '<<map[oy][x]<<"\n"; #endif *(iter++) = map[oy][x]; pushback(graph[map[oy][x]][3],map[y][x]); #ifdef DEBUG std::cout <<"graph "<<*(iter-1) <<' '<<map[y][x]<<"\n"; #endif } } } int bit = 0; while(--count>=0){bit<<=1;bit|=1;} #ifdef DEBUG std::cout<<bit<<std::endl; for(auto& g:graph[goal])for(auto iter=g;iter!=g+5;++iter){ std::cout << *iter << ' '; }std::cout<<std::endl; for(auto& g:graph[4])for(auto iter=g;iter!=g+5;++iter){ std::cout << *iter << ' '; }std::cout<<std::endl; for(auto& g:graph[3])for(auto iter=g;iter!=g+5;++iter){ std::cout << *iter << ' '; }std::cout<<std::endl; #endif int res = 0; for(auto& arr : graph[goal]){ for(auto iter=arr;*iter!=empty;++iter){ res+=func(*iter,bit&(~(1<<*iter))); } } std::cout << res << std::endl; } }
a.cc:20:7: error: 'bitmax' does not name a type 20 | const bitmax = 1<<20; | ^~~~~~ a.cc:22:12: error: 'bitmax' was not declared in this scope 22 | int dp[23][bitmax]; | ^~~~~~ a.cc: In function 'int func(int, int)': a.cc:46:16: error: 'bitmax' was not declared in this scope 46 | if(bit<bitmax)if(dp[now][bit]>=0){return dp[now][bit];} | ^~~~~~ a.cc:46:26: error: 'dp' was not declared in this scope; did you mean 'dup'? 46 | if(bit<bitmax)if(dp[now][bit]>=0){return dp[now][bit];} | ^~ | dup a.cc:69:16: error: 'bitmax' was not declared in this scope 69 | if(bit<bitmax)return dp[now][bit]=res; | ^~~~~~ a.cc:69:30: error: 'dp' was not declared in this scope; did you mean 'dup'? 69 | if(bit<bitmax)return dp[now][bit]=res; | ^~ | dup a.cc: In function 'int main()': a.cc:75:18: error: 'dp' was not declared in this scope; did you mean 'dup'? 75 | fill_all(dp,-1); | ^~ | dup
s736916798
p00471
C++
#include <bits/stdc++.h> template<typename T> void fill_all(T& ar,const T& v){ ar=v; } template<typename T,size_t N,typename U> void fill_all(T(& ar)[N],const U& v){ for(auto&i:ar){fill_all(i,v);} } int w,h; const int goal = 23; const int empty = 24; int graph[25][4][25];//???????????? int map[10][10]; const int nposmax = 6; const int bitmax = 1<<21; //bit???????????? int dp[nposmax][bitmax]; int func(int now, int bit){ if(now==empty){return 0;} if(now==goal){ #ifdef DEBUG std::cout<<"OUTg0:" << now <<' '<<bit<<':'<<((now==goal&&bit==0)?1:0)<<std::endl; #endif return ((now==goal&&bit==0)?1:0); } if(bit==0){ for(auto& g:graph[now]){ if(g[0] == goal){ #ifdef DEBUG std::cout<<"OUTb0:" << now <<' '<<bit<<':'<<1<<std::endl; #endif return 1; } } #ifdef DEBUG std::cout<<"OUTb0:" << now <<' '<<bit<<':'<<0<<std::endl; #endif return 0; } if(bit<bitmax&&now<nposmax)if(dp[now][bit]>=0){return dp[now][bit];} int res = 0; #if 0 for(int graph_num =0;graph_num<4;++graph_num){ for(auto iter=graph[now][graph_num];*iter!=empty;++iter){ if(bit&(1<<*iter)){ res += func(*iter,bit&(~(1<<*iter))); } else{ break; } } } #endif for(int graph_num =0;graph_num<4;++graph_num){ { auto iter = &graph[now][0]; if(bit&(1<<*iter)){ res += func(*iter,bit&(~(1<<*iter))); } else{ break; } } } if(bit<bitmax&&now<nposmax)return dp[now][bit]=res; return res; } int main() { for(;;){ fill_all(dp,-1); fill_all(map,empty); fill_all(graph,empty); std::cin>>w>>h;if(w==0&&h==0){break;} int count = 0; for(auto y=0;y<h;++y)for(auto x=0;x<w;++x){ std::cin >> map[y][x]; if(map[y][x]==0){ map[y][x]=empty; continue; } else if(map[y][x]==1){ map[y][x]=count++; } else if(map[y][x]==2){ map[y][x]=goal; } auto pushback=[](int*g, int v){ while(*g!=empty){++g;}*g=v; }; auto iter = graph[map[y][x]][0]; for(int ox=x-1;ox>=0;--ox){ if(empty>map[y][ox]){ #ifdef DEBUG std::cout <<"PASSx "<<x<<' '<<y<<"<->"<<ox<<' '<<y<<' '<<map[y][ox] <<"\n"; #endif *(iter++) = map[y][ox]; pushback(graph[map[y][ox]][2],map[y][x]); #ifdef DEBUG std::cout <<"graph "<<*(iter-1) <<' '<<map[y][x]<<"\n"; #endif } } iter = graph[map[y][x]][1]; for(int oy=y-1;oy>=0;--oy){ if(empty>map[oy][x]){ #ifdef DEBUG std::cout <<"PASSy "<<x<<' '<<y<<"<->"<<x<<' '<<oy<<' '<<map[oy][x]<<"\n"; #endif *(iter++) = map[oy][x]; pushback(graph[map[oy][x]][3],map[y][x]); #ifdef DEBUG std::cout <<"graph "<<*(iter-1) <<' '<<map[y][x]<<"\n"; #endif } } } int bit = 0; while(--count>=0){bit<<=1;bit|=1;} #ifdef DEBUG std::cout<<bit<<std::endl; for(auto& g:graph[goal])for(auto iter=g;iter!=g+5;++iter){ std::cout << *iter << ' '; }std::cout<<std::endl; for(auto& g:graph[4])for(auto iter=g;iter!=g+5;++iter){ std::cout << *iter << ' '; }std::cout<<std::endl; for(auto& g:graph[3])for(auto iter=g;iter!=g+5;++iter){ std::cout << *iter << ' '; }std::cout<<std::endl; #endif int res = 0; for(auto& arr : graph[goal]){ for(auto iter=arr;*iter!=empty;++iter){ res+=func(*iter,bit&(~(1<<*iter))); } } std::cout << res << std::endl; } }
a.cc: In function 'int func(int, int)': a.cc:65:34: error: invalid operands of types 'int' and 'int [25]' to binary 'operator<<' 65 | if(bit&(1<<*iter)){ | ~^~~~~~~ | | | | | int [25] | int a.cc:66:59: error: invalid operands of types 'int' and 'int [25]' to binary 'operator<<' 66 | res += func(*iter,bit&(~(1<<*iter))); | ~^~~~~~~ | | | | | int [25] | int
s276958408
p00471
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 m, n; int maze[11][11]; int house[11][11]; int housecount; int dfs(int y, int x, int depth) { int ret = 0; for (int i = y - 1; i >= 0; --i) { if (depth == housecount && maze[i][x] == 2) return 1; if (maze[i][x] == 1) { maze[i][x] = 0; ret += dfs(i, x, depth + 1); maze[i][x] = 1; break; } } for (int i = y + 1; i < n; ++i) { if (depth == housecount && maze[i][x] == 2) return 1; if (maze[i][x] == 1) { maze[i][x] = 0; ret += dfs(i, x, depth + 1); maze[i][x] = 1; break; } } for (int i = x - 1; i >= 0; --i) { if (depth == housecount && maze[y][i] == 2) return 1; if (maze[y][i] == 1) { maze[y][i] = 0; ret += dfs(y, i, depth + 1); maze[y][i] = 1; break; } } for (int i = x + 1; i < m; ++i) { if (depth == housecount && maze[y][i] == 2) return 1; if (maze[y][i] == 1) { maze[y][i] = 0; ret += dfs(y, i, depth + 1); maze[y][i] = 1; break; } } if (depth == housecount) return 0; return ret; } int main() { while (cin >> m >> n && (m || n)) { for (int i = 0; i < 11; i++)for (int j = 0; j < 11; j++)maze[i][j] = housecount[i][j] = 0; int si, sj; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> maze[i][j]; if (maze[i][j] == 1) { house[i][j] = housecount; housecount++; } if (maze[i][j] == 2) { si = i, sj = j; } } } cout << dfs(si, sj, 0) << endl; } }
a.cc: In function 'int main()': a.cc:101:96: error: invalid types 'int[int]' for array subscript 101 | for (int i = 0; i < 11; i++)for (int j = 0; j < 11; j++)maze[i][j] = housecount[i][j] = 0; | ^
s749354960
p00471
C++
#include <bits/stdc++.h> using namespace std; const int dy[] = {1, 0, -1, 0}; const int dx[] = {0, 1, 0, -1}; int W, H, N = 0; int mas[11][11]; int X[25], Y[25]; bool isin(int y, int x) { return (y >= 0 && x >= 0 && y < H && x < W); } int dfs(int y, int x, int bit) { int ret = 0; if(bit == 0) return (1); for(int i = 0; i < 4; i++) { int ny = y + dy[i], nx = x + dx[i]; while(isin(ny, nx) && (mas[ny][nx] < 0 || (bit != (1 << N) && mas[ny][nx] == N) || (bit & ~(1 << mas[ny][nx])) == bit)) ny += dy[i], nx += dx[i]; if(isin(ny, nx)) ret += dfs(ny, nx, bit & ~(1 << mas[ny][nx])); } return (ret); } int main() { int px, py; cin >> W >> H; for(int i = 0; i < H; i++) { for(int j = 0; j < W; j++) { cin >> mas[i][j]; if(mas[i][j] == 0) mas[i][j] = -1; else if(mas[i][j] == 1) mas[i][j] = N, N++; else py = i, px = j; } } mas[py][px] = N; cout << dfs(py, px, (1 << (N + 1)) - 1) << endl; return (0); } bash-4.3(leia):~/syoribu/JOI/2017/sp/pr 572:{ei1629}$ bc 4^7 * 2^16 1073741824 cat ^Cquit bash-4.3(leia):~/syoribu/JOI/2017/sp/pr 573:{ei1629}$ cat Reindeer_with_no_sense_of_direction.cpp #include <bits/stdc++.h> using namespace std; const int dy[] = {1, 0, -1, 0}; const int dx[] = {0, 1, 0, -1}; int W, H, N = 0; int mas[11][11]; bool isin(int y, int x) { return (y >= 0 && x >= 0 && y < H && x < W); } int dfs(int y, int x, int bit) { int ret = 0; if(bit == 0) return (1); for(int i = 0; i < 4; i++) { int ny = y + dy[i], nx = x + dx[i]; while(isin(ny, nx) && (mas[ny][nx] < 0 || (bit != (1 << N) && mas[ny][nx] == N) || (bit & ~(1 << mas[ny][nx])) == bit)) ny += dy[i], nx += dx[i]; if(isin(ny, nx)) ret += dfs(ny, nx, bit & ~(1 << mas[ny][nx])); } return (ret); } int main() { int px, py; while(cin >> W >> H, W || H) { for(int i = 0; i < H; i++) { for(int j = 0; j < W; j++) { cin >> mas[i][j]; if(mas[i][j] == 0) mas[i][j] = -1; else if(mas[i][j] == 1) mas[i][j] = N, N++; else py = i, px = j; } } mas[py][px] = N; cout << dfs(py, px, (1 << (N + 1)) - 1) << endl; } return (0); }
a.cc:40:1: error: 'bash' does not name a type 40 | bash-4.3(leia):~/syoribu/JOI/2017/sp/pr | ^~~~ a.cc:41:13: error: '$' does not name a type 41 | 572:{ei1629}$ bc | ^ a.cc:46:13: error: '$' does not name a type 46 | 573:{ei1629}$ cat Reindeer_with_no_sense_of_direction.cpp | ^ a.cc:49:11: error: redefinition of 'const int dy []' 49 | const int dy[] = {1, 0, -1, 0}; | ^~ a.cc:3:11: note: 'const int dy [4]' previously defined here 3 | const int dy[] = {1, 0, -1, 0}; | ^~ a.cc:50:11: error: redefinition of 'const int dx []' 50 | const int dx[] = {0, 1, 0, -1}; | ^~ a.cc:4:11: note: 'const int dx [4]' previously defined here 4 | const int dx[] = {0, 1, 0, -1}; | ^~ a.cc:51:5: error: redefinition of 'int W' 51 | int W, H, N = 0; | ^ a.cc:5:5: note: 'int W' previously declared here 5 | int W, H, N = 0; | ^ a.cc:51:8: error: redefinition of 'int H' 51 | int W, H, N = 0; | ^ a.cc:5:8: note: 'int H' previously declared here 5 | int W, H, N = 0; | ^ a.cc:51:11: error: redefinition of 'int N' 51 | int W, H, N = 0; | ^ a.cc:5:11: note: 'int N' previously defined here 5 | int W, H, N = 0; | ^ a.cc:52:5: error: redefinition of 'int mas [11][11]' 52 | int mas[11][11]; | ^~~ a.cc:6:5: note: 'int mas [11][11]' previously declared here 6 | int mas[11][11]; | ^~~ a.cc:53:6: error: redefinition of 'bool isin(int, int)' 53 | bool isin(int y, int x) | ^~~~ a.cc:8:6: note: 'bool isin(int, int)' previously defined here 8 | bool isin(int y, int x) | ^~~~ a.cc:57:5: error: redefinition of 'int dfs(int, int, int)' 57 | int dfs(int y, int x, int bit) | ^~~ a.cc:12:5: note: 'int dfs(int, int, int)' previously defined here 12 | int dfs(int y, int x, int bit) | ^~~ a.cc:69:5: error: redefinition of 'int main()' 69 | int main() | ^~~~ a.cc:24:5: note: 'int main()' previously defined here 24 | int main() | ^~~~
s862965281
p00471
C++
#include<cstdio> #include<vector> using namespace std; int ans; int vec[4][2]={{1,0},{0,1},{-1,0},{0,-1}}; int tab[12][12]; int wx,wy; void solve(int nx,int ny,int rem){ for(int v=0;v<4;v++){ int nowx=nx,nowy=ny; LA: nowx+=vec[v][0],nowy+=vec[v][1]; if(!(0<=nowx&&nowx<wx&&0<=nowy&&nowy<wy)) goto LB; if(tab[nowx][nowy]==2&&rem==0)ans++; if(tab[nowx][nowy]==1){ tab[nowx][nowy]=-1; solve(nowx,nowy,wx,wy,rem-1); tab[nowx][nowy]=1; goto LB; } goto LA; LB: } } } int main(){ for(;;){ int m,n; scanf("%d%d",&m,&n); if(m==0&&n==0)break; int stx,sty,homec=0; for(int i=0;i<n;i++)for(int j=0;j<m;j++){ scanf("%d",&tab[i][j]); if(tab[i][j]==1)homec++; else if(tab[i][j]==2){stx=i;sty=j;} } wx=n;wy=m; ans=0; solve(stx,sty,n,m,homec); printf("%d\n",ans); } }
a.cc: In function 'void solve(int, int, int)': a.cc:17:22: error: too many arguments to function 'void solve(int, int, int)' 17 | solve(nowx,nowy,wx,wy,rem-1); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~ a.cc:8:6: note: declared here 8 | void solve(int nx,int ny,int rem){ | ^~~~~ a.cc:23:9: warning: label at end of compound statement only available with '-std=c++2b' or '-std=gnu++2b' [-Wc++23-extensions] 23 | } | ^ a.cc: At global scope: a.cc:25:1: error: expected declaration before '}' token 25 | } | ^ a.cc: In function 'int main()': a.cc:39:14: error: too many arguments to function 'void solve(int, int, int)' 39 | solve(stx,sty,n,m,homec); | ~~~~~^~~~~~~~~~~~~~~~~~~ a.cc:8:6: note: declared here 8 | void solve(int nx,int ny,int rem){ | ^~~~~
s177720496
p00471
C++
#include <iostream> #include <map> #include <cmath> #include <memory> #include <cstdlib> #include <cstdio> #include <algorithm> using namespace std; typedef pair<int, int> P; #define rep(i, n) for(int i = 0; i < n; i++) int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int field[12][12]; int nums[12][12]; map<P, bool> ng; int dfs(int state, int x, int y){ if(ng[P(state, nums[y][x])]) return 0; if(state == 0){ rep(i, 4){ int x2 = x + dx[i]; int y2 = y + dy[i]; while(field[y2][x2] == 0){ y2 += dy[i]; x2 += dx[i]; } if(field[y2][x2] == 2) return 1; } ng[P(state, nums[y][x])] = true; return 0; } int res = 0; rep(i, 4){ int x2 = x + dx[i]; int y2 = y + dy[i]; while(field[y2][x2] != 3){ if(field[y2][x2] == 1){ field[y2][x2] = 3; res += dfs(state - (1 << nums[y2][x2]), x2, y2); field[y2][x2] = 1; } x2 += dx[i]; y2 += dy[i]; } } return res; } int main(){ int n, m, sx, sy, cnt; while(cin >> m >> n && (n || m)){ cnt = 0; fill(&field[0][0], &field[11][11] + 1, 3); memset(nums, 0, sizeof(nums)); ng.clear(); rep(i, n){ rep(j, m){ cin >> field[i+1][j+1]; if(field[i+1][j+1] == 2){ sx = j + 1; sy = i + 1; } if(field[i+1][j+1] == 1){ nums[i+1][j+1] = cnt++; } } } cout << dfs((1 << cnt) - 1, sx, sy) << endl; } return 0; }
a.cc: In function 'int main()': a.cc:57:5: error: 'memset' was not declared in this scope 57 | memset(nums, 0, sizeof(nums)); | ^~~~~~ a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 7 | #include <algorithm> +++ |+#include <cstring> 8 | using namespace std;
s085707229
p00471
C++
#include<iostream> #include<cmath> #define MAX 12 using namespace std; int h,w; int sum; int sx,sy; int dp[(1<<18)][23]; int s[MAX][MAX]; int housInd[MAX][MAX]; /* 2 1 3 0 */ int dx[]={0,-1,0,1},dy[]={1,0,-1,0}; int func(int ny, int nx, int bit){ if(housInd[ny][nx] != -1 && bit < (1 << 18) && dp[bit][housInd[ny][nx]] != -1) return dp[bit][housInd[ny][nx]]; int ret = 0; bool isLast = bit == (1 << sum) - 1; for (int i = 0; i < 4; i++) { for (int x = nx+dx[i], y = ny+dy[i]; 0 <= x && x < w && 0 <= y && y < h; x += dx[i], y += dy[i]) { int ind = housInd[y][x]; if (ind == -1) { if (isLast && s[y][x] == 2) return dp[bit][housInd[ny][nx]] = 1; } else { if ((bit & 1 << ind) != 0) break; if (!isLast)ret += func(y, x, bit | (1 << ind)); } } } return housInd[ny][nx] != -1 && bit < (1 << 18) ? (dp[bit][housInd[ny][nx]] = ret) : ret; } int main(){ while(cin>>w>>h,w||h){ sum=0; memset(dp,-1,sizeof(dp)); for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cin>>s[i][j]; housInd[i][j] = -1; if(s[i][j]==2){ sy=i;sx=j; }else if(s[i][j]==1) { housInd[i][j] = sum++; } } } int ans=func(sy,sx,0); cout<<ans<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:41:17: error: 'memset' was not declared in this scope 41 | memset(dp,-1,sizeof(dp)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include<cmath> +++ |+#include <cstring> 3 | #define MAX 12
s386242650
p00471
C++
#include<iostream> #include<cmath> #include<stdlib.h> #define MAX 12 using namespace std; int h,w; int sum; int sx,sy; int dp[(1<<18)][23]; int s[MAX][MAX]; int housInd[MAX][MAX]; /* 2 1 3 0 */ int dx[]={0,-1,0,1},dy[]={1,0,-1,0}; int func(int ny, int nx, int bit){ if(housInd[ny][nx] != -1 && bit < (1 << 18) && dp[bit][housInd[ny][nx]] != -1) return dp[bit][housInd[ny][nx]]; int ret = 0; bool isLast = bit == (1 << sum) - 1; for (int i = 0; i < 4; i++) { for (int x = nx+dx[i], y = ny+dy[i]; 0 <= x && x < w && 0 <= y && y < h; x += dx[i], y += dy[i]) { int ind = housInd[y][x]; if (ind == -1) { if (isLast && s[y][x] == 2) return dp[bit][housInd[ny][nx]] = 1; } else { if ((bit & 1 << ind) != 0) break; if (!isLast)ret += func(y, x, bit | (1 << ind)); } } } return housInd[ny][nx] != -1 && bit < (1 << 18) ? (dp[bit][housInd[ny][nx]] = ret) : ret; } int main(){ while(cin>>w>>h,w||h){ sum=0; memset(dp,-1,sizeof(dp)); for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cin>>s[i][j]; housInd[i][j] = -1; if(s[i][j]==2){ sy=i;sx=j; }else if(s[i][j]==1) { housInd[i][j] = sum++; } } } int ans=func(sy,sx,0); cout<<ans<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:42:17: error: 'memset' was not declared in this scope 42 | memset(dp,-1,sizeof(dp)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include<stdlib.h> +++ |+#include <cstring> 4 | #define MAX 12
s975299219
p00471
C++
#include<iostream> #define MAX 11 using namespace std; int h,w; int sum; int sx,sy; int s[MAX][MAX]; int housInd[MAX][MAX]; int dx[]={0,-1,0,1},dy[]={1,0,-1,0}; int func(int ny, int nx, int bit){ // cout << "hi" << bit << endl; int ret = 0; bool isLast = bit == (1 << sum) - 1; for (int i = 0; i < 4; i++) { for (int x = nx+dx[i], y = ny+dy[i]; 0 <= x && x < w && 0 <= y && y < h; x += dx[i], y += dy[i]) { int ind = housInd[y][x]; if (ind == -1) { if (isLast && s[y][x] == 2) return 1; } else { if (!isLast) { if ((bit & 1 << ind) == 0) { ret += func(y, x, bit | (1 << ind)); break; } } } } } return ret; } int main(){ while(cin>>w>>h,w||h){ sum=0; dp.clear(); for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cin>>s[i][j]; housInd[i][j] = -1; if(s[i][j]==2){ sy=i;sx=j; }else if(s[i][j]==1) { housInd[i][j] = sum++; } } } int ans=func(sy,sx,0); cout<<ans<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:38:17: error: 'dp' was not declared in this scope; did you mean 'dy'? 38 | dp.clear(); | ^~ | dy
s248415725
p00471
C++
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <map> #define PLANE (-1) #define HOUSE (1) #define CHURCH (100) int x, y; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int home[10][10]; int n; map<int, int> memo[24]; int goChurch(int ty, int tx) { int i; int my, mx; for (i = 0; i < 4; i++){ my = ty + dy[i]; mx = tx + dx[i]; while (0 <= my && my < y && 0 <= mx && mx < x){ if (home[my][mx] == CHURCH){ return (1); } my += dy[i]; mx += dx[i]; } } return (0); } int dfs(int v, int bit, int ty, int tx, char state[][11]) { int i; int ky, kx; int ans; if (memo[pos].find(bit) != memo[pos].end()){ return (memo[v][bit]); } if (bit == (1 << n) - 1){ if (__builtin_popcount(bit) < 19){ return (memo[v][bit] = goChurch(ty, tx)); } return (goChurch(ty, tx)); } ans = 0; for (i = 0; i < 4; i++){ kx = tx + dx[i]; ky = ty + dy[i]; //ツ逆ツ渉づ可プツδ個ゼツδ督トツづーツ置ツつ「ツづつ「ツつュ while (0 <= kx && kx < x && 0 <= ky && ky < y && (home[ky][kx] == PLANE || home[ky][kx] == CHURCH || state[ky][kx] == 1)){ ky += dy[i]; kx += dx[i]; } if (0 <= kx && kx < x && 0 <= ky && ky < y){ state[ky][kx] = 1; ans += dfs(home[ky][kx] , bit | (1 << home[ky][kx]) , ky, kx, state); state[ky][kx] = 0; } } if (__builtin_popcount(bit) < 19){ memo[v][bit] = ans; } return (ans); } int main(void) { int sy, sx; int i, j; char state[10][11]; while (1){ scanf("%d%d", &x, &y); if (x + y == 0){ break; } n = 0; for (i = 0; i < y; i++){ for (j = 0; j < x; j++){ scanf("%d", &home[i][j]); if (home[i][j] == 2){ home[i][j] = CHURCH; sy = i; sx = j; } else if (home[i][j] == HOUSE){ home[i][j] = n++; } else if (home[i][j] == 0){ home[i][j] = PLANE; } } } memset(state, 0, sizeof(state)); for (i = 0; i < 24; i++){ memo[i].clear(); } printf("%d\n", dfs(n, 0, sy, sx, state)); } return (0); }
a.cc:15:1: error: 'map' does not name a type 15 | map<int, int> memo[24]; | ^~~ a.cc: In function 'int dfs(int, int, int, int, char (*)[11])': a.cc:41:9: error: 'memo' was not declared in this scope 41 | if (memo[pos].find(bit) != memo[pos].end()){ | ^~~~ a.cc:41:14: error: 'pos' was not declared in this scope 41 | if (memo[pos].find(bit) != memo[pos].end()){ | ^~~ a.cc:47:21: error: 'memo' was not declared in this scope 47 | return (memo[v][bit] = goChurch(ty, tx)); | ^~~~ a.cc:70:9: error: 'memo' was not declared in this scope 70 | memo[v][bit] = ans; | ^~~~ a.cc: In function 'int main()': a.cc:107:13: error: 'memo' was not declared in this scope 107 | memo[i].clear(); | ^~~~
s535454123
p00471
C++
#include <cstdio> #include <cstring> #include <cstdlib> #include <map> #define PLANE (-1) #define HOUSE (1) #define CHURCH (100) using namespace std; int x, y; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int home[10][10]; int n; map<int, int> memo[24]; int goChurch(int ty, int tx) { int i; int my, mx; for (i = 0; i < 4; i++){ my = ty + dy[i]; mx = tx + dx[i]; while (0 <= my && my < y && 0 <= mx && mx < x){ if (home[my][mx] == CHURCH){ return (1); } my += dy[i]; mx += dx[i]; } } return (0); } int dfs(int v, int bit, int ty, int tx, char state[][11]) { int i; int ky, kx; int ans; if (memo[pos].find(bit) != memo[pos].end()){ return (memo[v][bit]); } if (bit == (1 << n) - 1){ if (__builtin_popcount(bit) < 19){ return (memo[v][bit] = goChurch(ty, tx)); } return (goChurch(ty, tx)); } ans = 0; for (i = 0; i < 4; i++){ kx = tx + dx[i]; ky = ty + dy[i]; //ツ逆ツ渉づ可プツδ個ゼツδ督トツづーツ置ツつ「ツづつ「ツつュ while (0 <= kx && kx < x && 0 <= ky && ky < y && (home[ky][kx] == PLANE || home[ky][kx] == CHURCH || state[ky][kx] == 1)){ ky += dy[i]; kx += dx[i]; } if (0 <= kx && kx < x && 0 <= ky && ky < y){ state[ky][kx] = 1; ans += dfs(home[ky][kx] , bit | (1 << home[ky][kx]) , ky, kx, state); state[ky][kx] = 0; } } if (__builtin_popcount(bit) < 19){ memo[v][bit] = ans; } return (ans); } int main(void) { int sy, sx; int i, j; char state[10][11]; while (1){ scanf("%d%d", &x, &y); if (x + y == 0){ break; } n = 0; for (i = 0; i < y; i++){ for (j = 0; j < x; j++){ scanf("%d", &home[i][j]); if (home[i][j] == 2){ home[i][j] = CHURCH; sy = i; sx = j; } else if (home[i][j] == HOUSE){ home[i][j] = n++; } else if (home[i][j] == 0){ home[i][j] = PLANE; } } } memset(state, 0, sizeof(state)); for (i = 0; i < 24; i++){ memo[i].clear(); } printf("%d\n", dfs(n, 0, sy, sx, state)); } return (0); }
a.cc: In function 'int dfs(int, int, int, int, char (*)[11])': a.cc:43:14: error: 'pos' was not declared in this scope 43 | if (memo[pos].find(bit) != memo[pos].end()){ | ^~~
s082548139
p00471
C++
#include <cstdio> #include <cstring> #include <cstdlib> #include <map> #define PLANE (-1) #define HOUSE (1) #define CHURCH (100) using namespace std; int x, y; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int home[10][10]; int n; map<int, int> memo[24]; int goChurch(int ty, int tx) { int i; int my, mx; for (i = 0; i < 4; i++){ my = ty + dy[i]; mx = tx + dx[i]; while (0 <= my && my < y && 0 <= mx && mx < x){ if (home[my][mx] == CHURCH){ return (1); } my += dy[i]; mx += dx[i]; } } return (0); } int dfs(int v, int bit, int ty, int tx, char state[][11]) { int i; int ky, kx; int ans; if (memo[pos].find(bit) != memo[v].end()){ return (memo[v][bit]); } if (bit == (1 << n) - 1){ if (__builtin_popcount(bit) < 19){ return (memo[v][bit] = goChurch(ty, tx)); } return (goChurch(ty, tx)); } ans = 0; for (i = 0; i < 4; i++){ kx = tx + dx[i]; ky = ty + dy[i]; //ツ逆ツ渉づ可プツδ個ゼツδ督トツづーツ置ツつ「ツづつ「ツつュ while (0 <= kx && kx < x && 0 <= ky && ky < y && (home[ky][kx] == PLANE || home[ky][kx] == CHURCH || state[ky][kx] == 1)){ ky += dy[i]; kx += dx[i]; } if (0 <= kx && kx < x && 0 <= ky && ky < y){ state[ky][kx] = 1; ans += dfs(home[ky][kx] , bit | (1 << home[ky][kx]) , ky, kx, state); state[ky][kx] = 0; } } if (__builtin_popcount(bit) < 19){ memo[v][bit] = ans; } return (ans); } int main(void) { int sy, sx; int i, j; char state[10][11]; while (1){ scanf("%d%d", &x, &y); if (x + y == 0){ break; } n = 0; for (i = 0; i < y; i++){ for (j = 0; j < x; j++){ scanf("%d", &home[i][j]); if (home[i][j] == 2){ home[i][j] = CHURCH; sy = i; sx = j; } else if (home[i][j] == HOUSE){ home[i][j] = n++; } else if (home[i][j] == 0){ home[i][j] = PLANE; } } } memset(state, 0, sizeof(state)); for (i = 0; i < 24; i++){ memo[i].clear(); } printf("%d\n", dfs(n, 0, sy, sx, state)); } return (0); }
a.cc: In function 'int dfs(int, int, int, int, char (*)[11])': a.cc:43:14: error: 'pos' was not declared in this scope 43 | if (memo[pos].find(bit) != memo[v].end()){ | ^~~
s212190706
p00471
C++
#include<iostream> using namespace std; int x,y; int map[10][10]; int hmx[24],hmy[24]; int gx,gy; int home; int ans; bool hm[24]; int dx[5]={0,0,1,0,-1}; int dy[5]={0,1,0,-1,0}; void dfs(int mx,int my,int d,int ho2,int map2[10][10],int hmmx[24],int hmmy[24],bool hm2[24]){ if(ho2==0){ if(mx==gx || my==gy){ bool ch=true; if(mx==gx){ if(my>gy){ for(int j=0;j<home;j++){ if(mx==hmmx[j] && my>hmmy[j] && hmmy[j]>gy && hm2[j]==true)ch=false; } } if(my<gy){ for(int j=0;j<home;j++){ if(mx==hmmx[j] && my<hmmy[j] && hmmy[j]<gy && hm2[j]==true)ch=false; } } } if(my==gy){ if(mx>gx){ for(int j=0;j<home;j++){ if(my==hmmy[j] && mx>hmmx[j] && hmmx[j]>gx && hm2[j]==true)ch=false; } } if(mx<gx){ for(int j=0;j<home;j++){ if(my==hmmy[j] && mx<hmmx[j] && hmmx[j]<gx && hm2[j]==true)ch=false; } } } if(ch)ans++; } }else for(int i=0;i<home;i++){ if(hm2[i]==false)if(mx==hmmx[i] || my==hmmy[i]){ bool ch=true; if(mx==hmmx[i]){ if(my>hmmy[i]){ for(int j=0;j<home;j++){ if(mx==hmmx[j] && my>hmmy[j] && hmmy[j]>hmmy[i] && hm2[j]==true)ch=false; } } if(my<hmmy[i]){ for(int j=0;j<home;j++){ if(mx==hmmx[j] && my<hmmy[j] && hmmy[j]<hmmy[i] && hm2[j]==true)ch=false; } } } if(my==hmmy[i]){ if(mx>hmmx[i]){ for(int j=0;j<home;j++){ if(my==hmmy[j] && mx>hmmx[j] && hmmx[j]>hmmx[i] && hm2[j]==true)ch=false; } } if(mx<hmmx[i]){ for(int j=0;j<home;j++){ if(my==hmmy[j] && mx<hmmx[j] && hmmx[j]<hmmx[i] && hm2[j]==true)ch=false; } } } if(ch){ hm2[i]=true; dfs(hmmx[i],hmmy[i],0,ho2-1,map2,hmmx,hmmy,hm2); hm2[i]=false; } } } /*if(map2[mx][my]==2 && ho2==0)ans++; else{ if(map2[mx][my]==1){ map2[mx][my]=3; ho2-=1; dfs(mx,my,0,ho2,map2); map2[mx][my]=1; ho2+=1; } if(d==0){ for(int i=1;i<=4;i++){ int kx=mx+dx[i],ky=my+dy[i]; if(kx>=0 && kx<x && ky>=0 && ky<y && map2[kx][ky]!=3){ dfs(kx,ky,i,ho2,map2); } } }else{ int kx=mx+dx[d],ky=my+dy[d]; if(kx>=0 && kx<x && ky>=0 && ky<y && map2[kx][ky]!=3){ dfs(kx,ky,d,ho2,map2); } } }*/ } int main(void){ while(1){ scanf("%d%d",&x,&y); if(x==0 && y==0)break; home=0; ans=0; memset(hm,false,sizeof(hm)); for(int i=0;i<y;i++){ for(int j=0;j<x;j++){ scanf("%d",&map[j][i]); if(map[j][i]==2)gx=j,gy=i; if(map[j][i]==1)hmx[home]=j,hmy[home]=i; if(map[j][i]==1)home++; } } dfs(gx,gy,0,home,map,hmx,hmy,hm); printf("%d\n",ans); } return 0; }
a.cc: In function 'int main()': a.cc:110:17: error: 'memset' was not declared in this scope 110 | memset(hm,false,sizeof(hm)); | ^~~~~~ 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 |