submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s348294835
p00118
C
#include<stdio.h> #include<string.h> char map[105][105]; int flag[105][105],M,N; void dfs(int x,int y) { flag[x][y]=1; if((x+1)>=0&&(x+1)<M&&map[x+1][y]==map[x][y]) dfs(x+1,y); if((x-1)>=0&&(x-1)<M&&map[x-1][y]==map[x][y]) dfs(x-1,y); if((y+1)>0&&(y+1)<N&&map[x][y]==map[x][y+1]) dfs(x,y+1); if((y-1)>=0&&(y-1)<N&&map[x][y]==map[x][y-1]) dfs(x,y-1); } } int main() { while(scanf("%d%d",&M,&N)&&(M+N)) { int count=0; memset(flag,0,sizeof(flag)); for(int i=0;i<M;i++) scanf("%s",map[i]); for(int i=0;i<M;i++) for(int j=0;j<N;j++) if(flag[i][j]==0) { count++; dfs(i,j); } printf("%d\n",count); } }
main.c:17:1: error: expected identifier or '(' before '}' token 17 | } | ^
s943096744
p00118
C
/* Á·Ï°Ì⣺Property Distribution_AOJ 0118 */ #include <stdio.h> using namespace std; char maze[25][25]; int W, H; int sx, sy; int dx[]={1,0,-1,0}; int dy[]={0,1,0,-1}; int count; void dfs1(int x, int y) { for(int i=0; i<4; i++) { int nx=x+dx[i]; int ny=y+dy[i]; if(nx>=0&&nx<W&&ny>=0&&ny<H&&maze[nx][ny]=='@') { maze[nx][ny]='.'; dfs1(nx,ny); } } return ; } void dfs2(int x, int y) { for(int i=0; i<4; i++) { int nx=x+dx[i]; int ny=y+dy[i]; if(nx>=0&&nx<W&&ny>=0&&ny<H&&maze[nx][ny]=='*') { maze[nx][ny]='.'; dfs2(nx,ny); } } return ; } void dfs3(int x, int y) { for(int i=0; i<4; i++) { int nx=x+dx[i]; int ny=y+dy[i]; if(nx>=0&&nx<W&&ny>=0&&ny<H&&maze[nx][ny]=='#') { maze[nx][ny]='.'; dfs3(nx,ny); } } return ; } int main() { while(scanf("%d%d", &H, &W)!=EOF) { count=0; if(W==0&&H==0) break; getchar(); for(int i=0; i<H; i++) { for(int j=0; j<W; j++) maze[i][j]=getchar(); getchar(); } for(int i=0; i<H; i++) for(int j=0; j<W; j++) if(maze[i][j]=='@') { sx=i; sy=j; count++; dfs1(sx, sy); } else if(maze[i][j]=='*') { sx=i; sy=j; count++; dfs2(sx, sy); } else if(maze[i][j]=='#') { sx=i; sy=j; count++; dfs3(sx, sy); } printf("%d\n", count); } return 0; }
main.c:5:1: error: unknown type name 'using' 5 | using namespace std; | ^~~~~ main.c:5:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'std' 5 | using namespace std; | ^~~
s597706249
p00118
C
#include<cstdio> #include<cstring> const int maxn=100+5; char pic[maxn][maxn]; int dix[4]={0,1,0,-1},diy[4]={1,0,-1,0},sum,m,n; void dfs(int i,int j,char x) { if(i<0||i>=m||j<0||j>=n||pic[i][j]=='z')return; pic[i][j]='z'; for(int s=0;s<4;s++) if(pic[i+dix[s]][j+diy[s]]==x)dfs(i+dix[s],j+diy[s],x); } int main() { while(scanf("%d%d",&m,&n)!=EOF) { if(m==0&&n==0)break; for(int i=0;i<m;i++)scanf("%s",pic[i]); for(int i=0;i<m;i++) for(int j=0;j<n;j++) if(pic[i][j]!='z') { dfs(i,j,pic[i][j]); sum++; } printf("%d\n",sum); sum=0; } return 0; }
main.c:1:9: fatal error: cstdio: No such file or directory 1 | #include<cstdio> | ^~~~~~~~ compilation terminated.
s097054073
p00118
C
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int N,M,ans; char map[25][25]; int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1}; void dfs(int x,int y,char c) { map[x][y]='.'; for(int i = 0; i < 4;i++) { int nx = x + dx[i]; int ny = y + dy[i]; if(0 <= nx && nx < N && 0 <= ny && ny <= M && map[nx][ny]==c){ map[nx][ny]='.'; dfs(nx,ny,c); } } return ; } int main() { while(scanf("%d %d",&N,&M)!=EOF) { if(N==0&&M==0) break; ans=0; for(int i=0; i < N;i++) { scanf("%s",map[i]); } for(int i = 0; i < N;i++) { for(int j = 0; j < M;j++){ if(map[i][j]=='#'){ dfs(i,j,'#'); ans++; } else if(map[i][j]=='@'){ dfs(i,j,'@'); ans++; } else if(map[i][j]=='*'){ dfs(i,j,'*'); ans++; } } } printf("%d\n",ans); } return 0; }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s376722776
p00118
C
#include<iostream> #include<cstdio> #include<algorithm> #include<vector> using namespace std; int farm[101][101]; void kubun(int k,int a,int b){ farm[a][b]=0; if(k==farm[a-1][b])kubun(farm[a-1][b],a-1,b); if(k==farm[a+1][b])kubun(farm[a+1][b],a+1,b); if(k==farm[a][b-1])kubun(farm[a][b-1],a,b-1); if(k==farm[a][b+1])kubun(farm[a][b+1],a,b+1); } int main(void){ char c[101][101]; int a,b; int h,w; int ans=0; while(1){ ans=0; memset(farm,0,sizeof(farm)); cin >> h >> w; if(h==0 && w==0)break; for(b=0;b<w;b++){ cin >> c[b]; for(a=0;a<h;a++){ if(c[b][a]=='@')farm[a][b]=1; if(c[b][a]=='#')farm[a][b]=2; if(c[b][a]=='*')farm[a][b]=3; } } for(b=0;b<w;b++){ for(a=0;a<h;a++){ if(farm[a][b]==0); else{ ans++; kubun(farm[a][b],a,b); } } } cout<< ans << endl; } return 0; }
main.c:1:9: fatal error: iostream: No such file or directory 1 | #include<iostream> | ^~~~~~~~~~ compilation terminated.
s040026119
p00118
C
#include<stdio.h> #include<windows.h> void main(void){ int H,W,o;int QWE; int HW[100][102];//農場データ int SoldFlag[100][102];//売約済みフラグ int Queue[100*102][2]; int QueueStart=0,QueueEnd=1; int QueueNow=0; int Answer=0; int Count,CountH,CountW,CountQ,CountH2,CountW2; int MH,MW; for(CountH=0;CountH<100;CountH++){ for(CountW=0;CountW<102;CountW++){ SoldFlag[CountH][CountW]=0; } } for(CountH2=0;CountH2<10200;CountH2++){Queue[CountH2][0]=-1;Queue[CountH2][1]=-1;}//初期化 //入力処理 scanf("%d %d",&H,&W); for(Count=0;Count<H;Count++){ scanf("%s",HW[Count]); } scanf("%s",&o); //ここまで for(CountH=0;CountH<H;CountH++){ for(CountW=0;CountW<W;CountW++){ if(SoldFlag[CountH][CountW]!=1){//始点が売約済みでないことを確認 // 1 //4 2 // 3 Queue[0][0]=CountH;//始点をセット Queue[0][1]=CountW; SoldFlag[CountH][CountW]=1; while(1){ //printf("chk %d,%d,%d\n",QueueStart,QueueEnd,QueueNow); for(CountQ=QueueStart;CountQ<QueueEnd;CountQ++){ if(Queue[CountQ][0]!=0){//Up if(SoldFlag[Queue[CountQ][0]-1][Queue[CountQ][1]]==0&& HW[Queue[CountQ][0]][Queue[CountQ][1]]==HW[Queue[CountQ][0]-1][Queue[CountQ][1]]){ Queue[QueueEnd+QueueNow][0]=Queue[CountQ][0]-1; Queue[QueueEnd+QueueNow][1]=Queue[CountQ][1]; SoldFlag[Queue[CountQ][0]-1][Queue[CountQ][1]]=1; QueueNow++; //printf("tui %d,%d,%d",QueueStart,QueueEnd,QueueNow); } } if(Queue[CountQ][1]<W-1){//Right if(SoldFlag[Queue[CountQ][0]][Queue[CountQ][1]+1]==0&& HW[Queue[CountQ][0]][Queue[CountQ][1]]==HW[Queue[CountQ][0]][Queue[CountQ][1]+1]){ Queue[QueueEnd+QueueNow][0]=Queue[CountQ][0]; Queue[QueueEnd+QueueNow][1]=Queue[CountQ][1]+1; SoldFlag[Queue[CountQ][0]][Queue[CountQ][1]+1]=1; QueueNow++; //printf("tui %d,%d,%d",QueueStart,QueueEnd,QueueNow); } } if(Queue[CountQ][0]<H-1){//Down if(SoldFlag[Queue[CountQ][0]+1][Queue[CountQ][1]]==0&& HW[Queue[CountQ][0]][Queue[CountQ][1]]==HW[Queue[CountQ][0]+1][Queue[CountQ][1]]){ Queue[QueueEnd+QueueNow][0]=Queue[CountQ][0]+1; Queue[QueueEnd+QueueNow][1]=Queue[CountQ][1]; SoldFlag[Queue[CountQ][0]+1][Queue[CountQ][1]]=1; QueueNow++; //printf("tui %d,%d,%d",QueueStart,QueueEnd,QueueNow); } } if(Queue[CountQ][1]!=0){//Left if(SoldFlag[Queue[CountQ][0]][Queue[CountQ][1]-1]==0&& HW[Queue[CountQ][0]][Queue[CountQ][1]]==HW[Queue[CountQ][0]][Queue[CountQ][1]-1]){ Queue[QueueEnd+QueueNow][0]=Queue[CountQ][0]; Queue[QueueEnd+QueueNow][1]=Queue[CountQ][1]-1; SoldFlag[Queue[CountQ][0]][Queue[CountQ][1]-1]=1; QueueNow++; //printf("tui %d,%d,%d",QueueStart,QueueEnd,QueueNow); } } } //printf("QN:%d\n",QueueNow); if(QueueNow==0){Answer++;QueueStart=0;QueueEnd=1;QueueNow=0;break;} QueueStart=QueueEnd; QueueEnd+=QueueNow; QueueNow=0; } //for(MH=0;MH<H;MH++){ // for(MW=0;MW<W;MW++){ // printf("%2d",SoldFlag[MH][MW]); // } // printf("\n"); //} //for(QWE=0;QWE<10;QWE++){printf("%d,%d ",Queue[QWE][0],Queue[QWE][1]);} //system("pause"); } for(CountH2=0;CountH2<10200;CountH2++){Queue[CountH2][0]=-1;Queue[CountH2][1]=-1;}//初期化 } } printf("%d",Answer); // system("pause"); }
main.c:2:9: fatal error: windows.h: No such file or directory 2 | #include<windows.h> | ^~~~~~~~~~~ compilation terminated.
s517631077
p00118
C
#include<stdio.h> #include<windows.h> #include<string.h> void main(void){ int H,W,o;int QWE; char HW[100][102];//農場データ char SoldFlag[100][102];//売約済みフラグ char Queue[100*102][2]; int QueueStart=0,QueueEnd=1; int QueueNow=0; int Answer=0; int Count,CountH,CountW,CountQ,CountH2,CountW2; int MH,MW; char *FinalAnswer={0};//こいつを最後に出力 char *Ansbuff={0}; for(CountH=0;CountH<100;CountH++){ for(CountW=0;CountW<102;CountW++){ SoldFlag[CountH][CountW]=0; } } for(CountH2=0;CountH2<10200;CountH2++){Queue[CountH2][0]=-1;Queue[CountH2][1]=-1;}//初期化 //入力処理 while(1){ scanf("%d %d",&H,&W); if(H==0&&W==0){ //ここで回答出力 printf("%s",FinalAnswer); } for(Count=0;Count<H;Count++){ scanf("%s",HW[Count]); } //} //while(1){//からになったらbreak;で //ここで扱うマップを代入していく for(CountH=0;CountH<H;CountH++){ for(CountW=0;CountW<W;CountW++){ if(SoldFlag[CountH][CountW]!=1){//始点が売約済みでないことを確認 // 1 //4 2 // 3 Queue[0][0]=CountH;//始点をセット Queue[0][1]=CountW; SoldFlag[CountH][CountW]=1; while(1){ //printf("chk %d,%d,%d\n",QueueStart,QueueEnd,QueueNow); for(CountQ=QueueStart;CountQ<QueueEnd;CountQ++){ if(Queue[CountQ][0]!=0){//Up if(SoldFlag[Queue[CountQ][0]-1][Queue[CountQ][1]]==0&& HW[Queue[CountQ][0]][Queue[CountQ][1]]==HW[Queue[CountQ][0]-1][Queue[CountQ][1]]){ Queue[QueueEnd+QueueNow][0]=Queue[CountQ][0]-1; Queue[QueueEnd+QueueNow][1]=Queue[CountQ][1]; SoldFlag[Queue[CountQ][0]-1][Queue[CountQ][1]]=1; QueueNow++; } } if(Queue[CountQ][1]<W-1){//Right if(SoldFlag[Queue[CountQ][0]][Queue[CountQ][1]+1]==0&& HW[Queue[CountQ][0]][Queue[CountQ][1]]==HW[Queue[CountQ][0]][Queue[CountQ][1]+1]){ Queue[QueueEnd+QueueNow][0]=Queue[CountQ][0]; Queue[QueueEnd+QueueNow][1]=Queue[CountQ][1]+1; SoldFlag[Queue[CountQ][0]][Queue[CountQ][1]+1]=1; QueueNow++; } } if(Queue[CountQ][0]<H-1){//Down if(SoldFlag[Queue[CountQ][0]+1][Queue[CountQ][1]]==0&& HW[Queue[CountQ][0]][Queue[CountQ][1]]==HW[Queue[CountQ][0]+1][Queue[CountQ][1]]){ Queue[QueueEnd+QueueNow][0]=Queue[CountQ][0]+1; Queue[QueueEnd+QueueNow][1]=Queue[CountQ][1]; SoldFlag[Queue[CountQ][0]+1][Queue[CountQ][1]]=1; QueueNow++; } } if(Queue[CountQ][1]!=0){//Left if(SoldFlag[Queue[CountQ][0]][Queue[CountQ][1]-1]==0&& HW[Queue[CountQ][0]][Queue[CountQ][1]]==HW[Queue[CountQ][0]][Queue[CountQ][1]-1]){ Queue[QueueEnd+QueueNow][0]=Queue[CountQ][0]; Queue[QueueEnd+QueueNow][1]=Queue[CountQ][1]-1; SoldFlag[Queue[CountQ][0]][Queue[CountQ][1]-1]=1; QueueNow++; } } } if(QueueNow==0){Answer++;QueueStart=0;QueueEnd=1;QueueNow=0;break;} QueueStart=QueueEnd; QueueEnd+=QueueNow; QueueNow=0; } } for(CountH2=0;CountH2<10200;CountH2++){Queue[CountH2][0]=-1;Queue[CountH2][1]=-1;}//初期化 } } //sscanf(Ansbuff,"%d\n",Answer); sprintf(Ansbuff,"%d\n",Answer); strcat(FinalAnswer,Ansbuff); //printf("%d",Answer); } } //次回5/21 西9 519
main.c:2:9: fatal error: windows.h: No such file or directory 2 | #include<windows.h> | ^~~~~~~~~~~ compilation terminated.
s112563405
p00118
C
#include<stdio.h> int main(void) { int i, j, k; int H, W; char farm[102][102]; int vector[4][2]={{-1,0},{1,0},{0,-1},{0,1}}; int ans=0; while (scanf("%d %d\n",&H,&W) != EOF) { if (H == 0 && W == 0) { break; } for (i = 0; i < H + 2; i++) { if (i == 0 || i == H + 1) { for (j = 0; j < W + 2; j++) { farm[i][j] = 'o'; } } else { farm[i][0] = 'o'; scanf("%s", &farm[i][1]); farm[i][W+1] = 'o'; } } ans = 0; for (i = 1; i < H + 1; i++) { for (j = 1; j < W + 1; j++) { if (farm[i][j] != 'o') { ans += bfs(i, j, farm, vector); } } } printf("%d\n", ans); } return 0; }
main.c: In function 'main': main.c:39:48: error: implicit declaration of function 'bfs' [-Wimplicit-function-declaration] 39 | ans += bfs(i, j, farm, vector); | ^~~
s150921825
p00118
C
#include<iostream> #include<cstdio> using namespace std; int h,w; char fruit[100][100]; void dfs(int y, int x); int dx[4] = {0,1,0,-1},dy[4] = {1,0,-1,0}; main(){ while(1){ int cnt=0; cin >> h >> w; if(h==0 && w==0) break; for(int i=0; i<h ;i++){ cin >> fruit[i]; } for(int i=0; i<h; i++){ for(int j=0; j<w; j++){ if(fruit[i][j]!='.'){ dfs(i,j); cnt++; } } } cout << cnt << endl; } } void dfs(int y, int x){ char f=fruit[y][x]; fruit[y][x]='.'; for(int i=0; i<4 ; i++){ int ny = y+dy[i]; int nx= x+dx[i]; if(x>=0 && x<w && y>=0 && y<h && fruit[ny][nx]==f){ dfs(ny,nx); } } }
main.c:1:9: fatal error: iostream: No such file or directory 1 | #include<iostream> | ^~~~~~~~~~ compilation terminated.
s091524074
p00118
C
#include <stdio.h> #include <stdlib.h> int i, j; int h, w; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; char **data; char rLine[101]; void dfs(int x, int y, char fType) { data[y][x] = 0; int k; for (k=0; k<4; k++) { int nx = x + dx[k]; int ny = y + dy[k]; if (nx>=0 && nx<w && ny>=0 && ny<h && data[ny][nx] == fType) dfs(nx, ny, data[ny][nx]); } } int main() { while (1) { scanf("%d%d ", &h, &w); if (!h && !w) break; data = (char **)calloc(h, sizeof(char *)); for (i=0; i<h; i++) data[i] = (char *)calloc(w, sizeof(char)); for (i=0; i<h; i++) { gets(rLine); for (j=0; j<w; j++) data[i][j] = rLine[j]; } int res = 0; for (int i=0; i<h; i++) for (int j=0; j<w; j++) if (data[i][j] != 0) { dfs(j, i, data[i][j]); res++; } for (i=0; i<h; i++) free(data[i]); free(data); } return 0; }
main.c: In function 'main': main.c:35:25: error: implicit declaration of function 'gets'; did you mean 'fgets'? [-Wimplicit-function-declaration] 35 | gets(rLine); | ^~~~ | fgets
s073221132
p00118
C
#include <stdio.h> #include <stdlib.h> int i, j; int h, w; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; char **data; char rLine[101]; void dfs(int x, int y, char fType) { data[y][x] = 0; int k; for (k=0; k<4; k++) { int nx = x + dx[k]; int ny = y + dy[k]; if (nx>=0 && nx<w && ny>=0 && ny<h && data[ny][nx] == fType) dfs(nx, ny, data[ny][nx]); } } int main() { while (1) { scanf("%d%d ", &h, &w); if (!h && !w) break; data = (char **)calloc(h, sizeof(char *)); for (i=0; i<h; i++) data[i] = (char *)calloc(w, sizeof(char)); for (i=0; i<h; i++) { gets(rLine); for (j=0; j<w; j++) data[i][j] = rLine[j]; } int res = 0; for (int i=0; i<h; i++) for (int j=0; j<w; j++) if (data[i][j] != 0) { dfs(j, i, data[i][j]); res++; } printf("%d\n", res); for (i=0; i<h; i++) free(data[i]); free(data); } return 0; }
main.c: In function 'main': main.c:35:25: error: implicit declaration of function 'gets'; did you mean 'fgets'? [-Wimplicit-function-declaration] 35 | gets(rLine); | ^~~~ | fgets
s281972953
p00118
C
#include <stdio.h> char mp[102][102];//mp[w][h] void dfs(int wj,int hi,char c){ mp[wj][hi] = '.'; if(mp[wj+1][hi] == c) dfs(wj+1,hi,c); if(mp[wj-1][hi] == c) dfs(wj-1,hi,c); if(mp[wj][hi+1] == c) dfs(wj,hi+1,c); if(mp[wj][hi-1] == c) dfs(wj,hi-1,c); return; } int main(){ int w,h,i,j; while(1){ int cnt = 0; scanf("%d%d",&h,&w); if((!w) && (!h)) break; for(i=0;i <=w+1;i++) mp[i][0] ='.',mp[i][h+1] = '.'; for(i=1;i <=h;i++) mp[0][i] = '.'.mp[w+1][i] = '.'; for(i=1;i <= h;i++){ for(j=1;j <= w;j++){ scanf(" %c",&mp[j][i]); } } for(i=1;i <= h;i++){ for(j=1;j <= w;j++){ if(mp[j][i] != '.') cnt++,dfs(j,i,mp[j][i]); } } printf("%d\n",cnt); } return 0; }
main.c: In function 'main': main.c:21:38: error: request for member 'mp' in something not a structure or union 21 | for(i=1;i <=h;i++) mp[0][i] = '.'.mp[w+1][i] = '.'; | ^
s834603053
p00118
C++
#include<cstdio> int H , W; char room[100][100]; int next_step[4][2] = { {0 , 1} , {1 , 0} , {0 , -1} , {-1 , 0} }; int number; void dfs(int x , int y , char c) { room[x][y] = 'X'; for(int i = 0 ; i < 4 ; i++) { int nx = x + next_step[i][0] , ny = y + next_step[i][1]; if(nx >= 0 && nx < W && ny >= 0 && ny < H && room[nx][ny] == c) { dfs(nx , ny , c); } } } void solve() { for(int y = 0 ; y < H ; y++) for(int x = 0 ; x < W ; x++) { if(room[x][y] != 'X') { dfs(x , y , room[x][y]); number++; } } printf("%d\n",number ); } int main(int argc, char const *argv[]) { while(scanf("%d %d" , &H , &W) , H != 0) { number = 0; for(int y = 0 ; y < H ; y++) { scanf("%s", room[i]); } solve(); } return 0; } .......
a.cc: In function 'int main(int, const char**)': a.cc:40:42: error: 'i' was not declared in this scope 40 | scanf("%s", room[i]); | ^ a.cc: At global scope: a.cc:47:1: error: expected unqualified-id before '...' token 47 | ....... | ^~~
s179641269
p00118
C++
#include<cstdio> int H , W; char room[100][100]; int next_step[4][2] = { {0 , 1} , {1 , 0} , {0 , -1} , {-1 , 0} }; int number; void dfs(int x , int y , char c) { room[x][y] = 'X'; for(int i = 0 ; i < 4 ; i++) { int nx = x + next_step[i][0] , ny = y + next_step[i][1]; if(nx >= 0 && nx < W && ny >= 0 && ny < H && room[nx][ny] == c) { dfs(nx , ny , c); } } } void solve() { for(int y = 0 ; y < H ; y++) for(int x = 0 ; x < W ; x++) { if(room[x][y] != 'X') { dfs(x , y , room[x][y]); number++; } } printf("%d\n",number ); } int main(int argc, char const *argv[]) { while(scanf("%d %d" , &H , &W), H != 0) { number = 0; for(int y = 0 ; y < H ; y++) { scanf("%s" , room[y]); } solve(); } return 0; } .......................
a.cc:47:1: error: expected unqualified-id before '...' token 47 | ....................... | ^~~
s465178976
p00118
C++
#include<stdio.h> #include<iostream> using namespace std; int w,h; int dx[4]={1,0,-1,0},dy[4] = {0,1,0,-1}; char fruit[100][100]; //int num; void dfs(int x,int y,char c){ fruit[x][y]='.'; for(int i = 0; i < 4;i++){ int nx = x + dx[i], ny = y + dy[i]; if(nx<h&&nx>=0&&ny<w&&ny>=0&&fruit[nx][ny]==c) dfs(nx,ny,fruit[nx][ny]); } return ; } void solve(){ while(cin>>w>>h&&w&&h){ num = 0; for(int i = 0; i < h; i++){ for(int j = 0; j < w;j++) cin>>fruit[i][j]; } for(int i = 0; i < h; i++){ for(int j = 0; j < w;j++) { if(fruit[i][j]!='.'){ dfs(i,j,fruit[i][j]); num++; } } } printf("%d\n",num); } return ; } int main(){ solve(); return 0 ; }
a.cc: In function 'void solve()': a.cc:20:9: error: 'num' was not declared in this scope; did you mean 'enum'? 20 | num = 0; | ^~~ | enum
s466497968
p00118
C++
#include<iostream> #include<string> using namespace std; string map[101]; int count=0; int n,m; void dfs(char c,int i,int j){ s[i][j] = '.'; if(i+1 < n && s[i+1][j] == c) { dfs(c,i+1,j); } if(i-1 >= 0 && s[i-1][j] == c) { dfs(c,i-1,j); } if(j+1 < m && s[i][j+1] == c) { dfs(c,i,j+1); } if(j-1 >= 0 && s[i][j-1] == c) { dfs(c,i,j-1); } } int main(){ while(1){ cin >> n >> m; { if(n == 0 && m == 0) break; count = 0; rep(i,n) cin >> s[i]; rep(i,n) { rep(j,m) { if(s[i][j] != '.') { dfs(s[i][j],i,j); count++; } } } cout << count << endl } } }
a.cc: In function 'void dfs(char, int, int)': a.cc:12:5: error: 's' was not declared in this scope 12 | s[i][j] = '.'; | ^ a.cc: In function 'int main()': a.cc:41:12: error: 'i' was not declared in this scope 41 | rep(i,n) cin >> s[i]; | ^ a.cc:41:8: error: 'rep' was not declared in this scope 41 | rep(i,n) cin >> s[i]; | ^~~ a.cc:55:29: error: expected ';' before '}' token 55 | cout << count << endl | ^ | ; 56 | } | ~
s162968007
p00118
C++
#include<iostream> #include<string> using namespace std; string map[101]; int count=0; int n,m; void dfs(char c,int i,int j){ s[i][j] = '.'; if(i+1 < n && s[i+1][j] == c) { dfs(c,i+1,j); } if(i-1 >= 0 && s[i-1][j] == c) { dfs(c,i-1,j); } if(j+1 < m && s[i][j+1] == c) { dfs(c,i,j+1); } if(j-1 >= 0 && s[i][j-1] == c) { dfs(c,i,j-1); } } int main(){ while(1){ cin >> n >> m; { if(n == 0 && m == 0) break; count = 0; rep(i,n) cin >> s[i]; rep(i,n) { rep(j,m) { if(s[i][j] != '.') { dfs(s[i][j],i,j); count++; } } } cout << count << endl; } } }
a.cc: In function 'void dfs(char, int, int)': a.cc:12:5: error: 's' was not declared in this scope 12 | s[i][j] = '.'; | ^ a.cc: In function 'int main()': a.cc:41:12: error: 'i' was not declared in this scope 41 | rep(i,n) cin >> s[i]; | ^ a.cc:41:8: error: 'rep' was not declared in this scope 41 | rep(i,n) cin >> s[i]; | ^~~
s485086471
p00118
C++
#include <iostream> #include <cstido> using namespace std; const int MAX = 100; int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}; //INPUT int H, W, res; char garden[MAX][MAX]; void dfs(int x, int y, char c) { garden[x][y] = '.'; for (int i = 0; i < 4; i++) { int nx = x + dx[i], ny = y + dy[i]; if (garden[nx][ny] == c) dfs(nx, ny, c); } return ; } void solve() { res = 0; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { if (garden[i][j] == '#') { dfs(i, j, '#'); res++; } if (garden[i][j] == '*') { dfs(i, j, '*'); res++; } if (garden[i][j] == '@') { dfs(i, j, '@'); res++; } } } cout<<res<<endl; //从不是'.'的地方 开始填充 } int main() { while(2333) { //判断输入结束 cin>>H>>W; if (H * W == 0) return 0; //输入前重置garden memset(garden, '.', sizeof(garden)); for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) cin>>garden[i][j]; } solve(); } }
a.cc:2:10: fatal error: cstido: No such file or directory 2 | #include <cstido> | ^~~~~~~~ compilation terminated.
s339186459
p00118
C++
#include <iostream> #include <cstdio> using namespace std; const int MAX = 100; int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}; //INPUT int H, W, res; char garden[MAX][MAX]; void dfs(int x, int y, char c) { garden[x][y] = '.'; for (int i = 0; i < 4; i++) { int nx = x + dx[i], ny = y + dy[i]; if (garden[nx][ny] == c) dfs(nx, ny, c); } return ; } void solve() { res = 0; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { if (garden[i][j] == '#') { dfs(i, j, '#'); res++; } if (garden[i][j] == '*') { dfs(i, j, '*'); res++; } if (garden[i][j] == '@') { dfs(i, j, '@'); res++; } } } cout<<res<<endl; //从不是'.'的地方 开始填充 } int main() { while(2333) { //判断输入结束 cin>>H>>W; if (H * W == 0) return 0; //输入前重置garden memset(garden, '.', sizeof(garden)); for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) cin>>garden[i][j]; } solve(); } }
a.cc: In function 'int main()': a.cc:52:17: error: 'memset' was not declared in this scope 52 | memset(garden, '.', sizeof(garden)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include <cstdio> +++ |+#include <cstring> 3 |
s780794311
p00118
C++
#include<cstdio> int H, W; char map[201][201]; int dx[4]{ 0, 0, 1, -1 }; int dy[4]{ 1, -1, 0, 0 }; int ans = 0; void dfs(int x, int y,char ch) { map[x][y] = '.';//把符号@,#,*其中一个替换成.。和poj1979很像,稍微改下1979的代码就行 for (int i = 0; i < 4; i++) { int nx = x + dx[i], ny = y + dy[i]; if (0 <= nx&&nx < H && 0 <= ny&&ny < W&&map[nx][ny] ==ch)dfs(nx, ny, ch); } } int main() { scanf("%d%d", &H, &W); while (getchar() != '\n')continue; while (W&&H) { ans = 0; for (int i = 0; i < H; i++) gets(map[i]); for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++){ if (map[i][j] == '#'){ dfs(i, j, '#'); ans++; } else if (map[i][j] == '@'){ dfs(i, j, '@'); ans++; } else if (map[i][j] == '*'){ dfs(i, j, '*') ; ans++; } } } printf("%d\n", ans); scanf("%d%d", &H, &W); while (getchar() != '\n')continue; } }
a.cc: In function 'int main()': a.cc:25:25: error: 'gets' was not declared in this scope; did you mean 'getw'? 25 | gets(map[i]); | ^~~~ | getw
s346106284
p00118
C++
#include<cstdio> int H, W; char map[201][201]; int dx[4]{ 0, 0, 1, -1 }; int dy[4]{ 1, -1, 0, 0 }; int ans = 0; void dfs(int x, int y,char ch) { map[x][y] = '.'; for (int i = 0; i < 4; i++) { int nx = x + dx[i], ny = y + dy[i]; if (0 <= nx&&nx < H && 0 <= ny&&ny < W&&map[nx][ny] ==ch)dfs(nx, ny, ch); } } int main() { scanf("%d%d", &H, &W); while (getchar() != '\n')continue; while (W&&H) { ans = 0; for (int i = 0; i < H; i++) gets(map[i]); for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++){ if (map[i][j] == '#'){ dfs(i, j, '#'); ans++; } else if (map[i][j] == '@'){ dfs(i, j, '@'); ans++; } else if (map[i][j] == '*'){ dfs(i, j, '*') ; ans++; } } } printf("%d\n", ans); scanf("%d%d", &H, &W); while (getchar() != '\n') continue; } }
a.cc: In function 'int main()': a.cc:25:25: error: 'gets' was not declared in this scope; did you mean 'getw'? 25 | gets(map[i]); | ^~~~ | getw
s070420450
p00118
C++
#include<cstdio> int H, W; char map[201][201]; int dx[4]{ 0, 0, 1, -1 }; int dy[4]{ 1, -1, 0, 0 }; int ans = 0; void dfs(int x, int y,char ch) { map[x][y] = '.';//把符号@,#,*其中一个替换成.。和poj1979很像,稍微改下1979的代码就行 for (int i = 0; i < 4; i++) { int nx = x + dx[i], ny = y + dy[i]; if (0 <= nx&&nx < H && 0 <= ny&&ny < W&&map[nx][ny] ==ch)dfs(nx, ny, ch); } } int main() { scanf("%d%d", &H, &W); while (getchar() != '\n')continue; while (W&&H) { ans = 0; for (int i = 0; i < H; i++) gets(map[i]); for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++){ if (map[i][j] == '#'){ dfs(i, j, '#'); ans++; } else if (map[i][j] == '@'){ dfs(i, j, '@'); ans++; } else if (map[i][j] == '*'){ dfs(i, j, '*') ; ans++; } } } printf("%d\n", ans); scanf("%d%d", &H, &W); while (getchar() != '\n')continue; } return 0; }
a.cc: In function 'int main()': a.cc:24:25: error: 'gets' was not declared in this scope; did you mean 'getw'? 24 | gets(map[i]); | ^~~~ | getw
s929962390
p00118
C++
#include <cstdio> #include <cstring> const int MAXN = 105; char map[MAXN][MAXN]; int n, m; int d[4][2] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1} }; int dfs(int px, int py, char c) { map[px][py] = ' '; for(int i = 0; i < 4; i++) { int x = px + d[i][0]; int y = py + d[i][1]; if(x >= 0 && x < n && y >=0 && y < m && c == map[x][y]) dfs(x, y, c); } } int main() { while(~scanf("%d%d", &n, &m)) { if(0 == n && 0 == m) break; getchar(); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { scanf("%c", &map[i][j]); } getchar(); } int ans = 0; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { if(' ' != map[i][j]) { dfs(i, j, map[i][j]); ans++; } } } printf("%d\n", ans); } return 0; } #include <cstdio> #include <cstring> const int MAXN = 105; char map[MAXN][MAXN]; int n, m; int d[4][2] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1} }; int dfs(int px, int py, char c) { map[px][py] = ' '; for(int i = 0; i < 4; i++) { int x = px + d[i][0]; int y = py + d[i][1]; if(x >= 0 && x < n && y >=0 && y < m && c == map[x][y]) dfs(x, y, c); } } int main() { while(~scanf("%d%d", &n, &m)) { if(0 == n && 0 == m) break; getchar(); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { scanf("%c", &map[i][j]); } getchar(); } int ans = 0; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { if(' ' != map[i][j]) { dfs(i, j, map[i][j]); ans++; } } } printf("%d\n", ans); } return 0; }
a.cc: In function 'int dfs(int, int, char)': a.cc:21:1: warning: no return statement in function returning non-void [-Wreturn-type] 21 | } | ^ a.cc: At global scope: a.cc:57:11: error: redefinition of 'const int MAXN' 57 | const int MAXN = 105; | ^~~~ a.cc:5:11: note: 'const int MAXN' previously defined here 5 | const int MAXN = 105; | ^~~~ a.cc:58:6: error: redefinition of 'char map [105][105]' 58 | char map[MAXN][MAXN]; | ^~~ a.cc:6:6: note: 'char map [105][105]' previously declared here 6 | char map[MAXN][MAXN]; | ^~~ a.cc:59:5: error: redefinition of 'int n' 59 | int n, m; | ^ a.cc:7:5: note: 'int n' previously declared here 7 | int n, m; | ^ a.cc:59:8: error: redefinition of 'int m' 59 | int n, m; | ^ a.cc:7:8: note: 'int m' previously declared here 7 | int n, m; | ^ a.cc:60:5: error: redefinition of 'int d [4][2]' 60 | int d[4][2] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1} }; | ^ a.cc:8:5: note: 'int d [4][2]' previously defined here 8 | int d[4][2] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1} }; | ^ a.cc:62:5: error: redefinition of 'int dfs(int, int, char)' 62 | int dfs(int px, int py, char c) | ^~~ a.cc:10:5: note: 'int dfs(int, int, char)' previously defined here 10 | int dfs(int px, int py, char c) | ^~~ a.cc: In function 'int dfs(int, int, char)': a.cc:73:1: warning: no return statement in function returning non-void [-Wreturn-type] 73 | } | ^ a.cc: At global scope: a.cc:75:5: error: redefinition of 'int main()' 75 | int main() | ^~~~ a.cc:23:5: note: 'int main()' previously defined here 23 | int main() | ^~~~
s040685172
p00118
C++
#include <iostream> #include <vector> #include <algorithm> #include <numeric> #include <set> #include <map> #include <string> #include <stack> #include <queue> #include <cmath> #include <cstdio> #include <istream> #include <sstream> #include <iomanip> #include <iterator> #include <climits> using namespace std; typedef ostringstream OSS; typedef istringstream ISS; typedef vector<int> VI; typedef vector< VI > VVI; typedef long long LL; typedef pair<int, int> PII; typedef vector<PII> VPII; #define X first #define Y second int H, W; vector<string> ts; vector< vector<bool> > done; void dfs(int y, int x) { if (done[y][x]) return; done[y][x] = true; for (int dx = -1; dx <= 1; dx++) { for (int dy = -1; dy <= 1; dy++) { if (!(!dy ^ !dx)) continue; int nx = x + dx; int ny = y + dy; if (ny < 0 || nx < 0 || ny >= H || nx >= W) continue; if (ts[y][x] != ts[ny][nx]) continue; dfs(ny, nx); } } } int main(void) { while (cin >> H >> W, H) { ts = vector<string>(H); done = vector< vector<bool> >(H, vector<bool>(W)); for (int y = 0; y < H; y++) cin >> ts[y]; int cnt = 0; for (int y = 0; y < H; y++) { for (int x = 0; x < W; x++) { if (!done[y][x]) { dfs(y, x); cnt++; } } } cout << cnt << endl; } return 0; } ~
a.cc:80:2: error: expected class-name at end of input 80 | ~ | ^
s235284813
p00118
C++
import java.util.Arrays; import java.util.Scanner; public class Main { MyScanner sc = new MyScanner(); Scanner sc2 = new Scanner(System.in); final int MOD = 1000000007; int[] dx = { 1, 0, 0, -1 }; int[] dy = { 0, 1, -1, 0 }; char[][] f; boolean[][] visit; int H, W; void run() { for (;;) { H = sc.nextInt(); W = sc.nextInt(); if ((H | W) == 0) { return; } f = new char[H][W]; visit = new boolean[H][W]; for (int i = 0; i < H; i++) { String in = sc.next(); for (int j = 0; j < W; j++) { f[i][j] = in.charAt(j); } } int cnt = 0; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { if (!visit[i][j]) { dfs(i, j, f[i][j]); cnt++; } } } System.out.println(cnt); } } void dfs(int h, int w, char ob) { visit[h][w] = true; for (int i = 0; i < 4; i++) { int nextH = h + dy[i]; int nextW = w + dx[i]; if (inner(nextH, nextW, H, W)) { if (!visit[nextH][nextW] && f[nextH][nextW] == ob) { dfs(nextH, nextW, ob); } } } } public static void main(String[] args) { new Main().run(); } void debug(Object... o) { System.out.println(Arrays.deepToString(o)); } void debug2(char[][] array) { for (int i = 0; i < array.length; i++) { for (int j = 0; j < array[i].length; j++) { System.out.print(array[i][j]); } System.out.println(); } } boolean inner(int h, int w, int limH, int limW) { return 0 <= h && h < limH && 0 <= w && w < limW; } void swap(int[] x, int a, int b) { int tmp = x[a]; x[a] = x[b]; x[b] = tmp; } // find minimum i (a[i] >= border) int lower_bound(int a[], int border) { int l = -1; int r = a.length; while (r - l > 1) { int mid = (l + r) / 2; if (border <= a[mid]) { r = mid; } else { l = mid; } } // r = l + 1 return r; } class MyScanner { int nextInt() { try { int c = System.in.read(); while (c != '-' && (c < '0' || '9' < c)) c = System.in.read(); if (c == '-') return -nextInt(); int res = 0; do { res *= 10; res += c - '0'; c = System.in.read(); } while ('0' <= c && c <= '9'); return res; } catch (Exception e) { return -1; } } double nextDouble() { return Double.parseDouble(next()); } long nextLong() { return Long.parseLong(next()); } String next() { try { StringBuilder res = new StringBuilder(""); int c = System.in.read(); while (Character.isWhitespace(c)) c = System.in.read(); do { res.append((char) c); } while (!Character.isWhitespace(c = System.in.read())); return res.toString(); } catch (Exception e) { return null; } } int[] nextIntArray(int n) { int[] in = new int[n]; for (int i = 0; i < n; i++) { in[i] = nextInt(); } return in; } int[][] nextInt2dArray(int n, int m) { int[][] in = new int[n][m]; for (int i = 0; i < n; i++) { in[i] = nextIntArray(m); } return in; } double[] nextDoubleArray(int n) { double[] in = new double[n]; for (int i = 0; i < n; i++) { in[i] = nextDouble(); } return in; } long[] nextLongArray(int n) { long[] in = new long[n]; for (int i = 0; i < n; i++) { in[i] = nextLong(); } return in; } } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.Arrays; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.util.Scanner; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: expected unqualified-id before 'public' 4 | public class Main { | ^~~~~~
s578786910
p00118
C++
#include <cstdio> #include <queue> using namespace std; char area[200][200]; typedef pair<int, int> P; #define x first #define y second /* struct P{ int x, y; };*/ int dx[] = {-1, 0, 1, 0}; int dy[] = {0, -1, 0, 1}; int main() { int w, h, area_sum; while (scanf("%d%d", &w, &h), w != 0){ memset(area, 0, sizeof(area)); area_sum = 0; for (int i = 1; i <= h; i++){ for (int j = 1; j <= w; j++)scanf(" %c", &area[j][i]); } for (int i = 1; i <= h; i++){ for (int j = 1; j <= w; j++){ if (area[j][i]){ queue<P> que; que.push(P(j, i)); while (!que.empty()){ P st = que.front(); que.pop(); if (!area[st.x][st.y])continue; for (int i = 0; i < 4; i++){ if (area[st.x][st.y] == area[st.x + dx[i]][st.y + dy[i]]){ que.push(P(st.x + dx[i], st.y + dy[i])); } } area[st.x][st.y] = 0; } area_sum++; } } } printf("%d\n", area_sum); } }
a.cc: In function 'int main()': a.cc:23:17: error: 'memset' was not declared in this scope 23 | memset(area, 0, sizeof(area)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include <queue> +++ |+#include <cstring> 3 | using namespace std;
s680806360
p00118
C++
#include<iostream> using namespace std; char yard[102][102]; int ans=0; void dfs(int x,int y,char c){ if(yard[x][y]!=c) return; if(yard[x][y]==c) yard[x][y]='.'; for(int i=-1;i<=1;i++){ for(int j=-1;j<=1;j++){ if((i==0||j==0)&&(i!=0||j!=0)){ dfs(x+i,y+j,c); } } } return; } int main(){ memset(yard,'.',sizeof(yard)); int H,W; cin>>H>>W; for(int i=1;i<=H;i++){ for(int j=1;j<=W;j++){ cin>>yard[i][j]; } } for(int i=1;i<=H;i++){ for(int j=1;j<=W;j++){ if(yard[i][j]!='.'){ dfs(i,j,yard[i][j]); ans++; } } } cin>>H>>W; cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:20:9: error: 'memset' was not declared in this scope 20 | memset(yard,'.',sizeof(yard)); | ^~~~~~ 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;
s597022545
p00118
C++
#include<iostream> using namespace std; char yard[102][102]; int ans=0; void dfs(int x,int y,char c){ if(yard[x][y]!=c) return; if(yard[x][y]==c) yard[x][y]='.'; for(int i=-1;i<=1;i++){ for(int j=-1;j<=1;j++){ if((i==0||j==0)&&(i!=0||j!=0)){ dfs(x+i,y+j,c); } } } return; } int main(){ memset(yard,'.',sizeof(yard)); int H,W; cin>>H>>W; while(H!=0||W!=0){ for(int i=1;i<=H;i++){ for(int j=1;j<=W;j++){ cin>>yard[i][j]; } } for(int i=1;i<=H;i++){ for(int j=1;j<=W;j++){ if(yard[i][j]!='.'){ dfs(i,j,yard[i][j]); ans++; } } } cout<<ans<<endl; ans==0; cin>>H>>W; } }
a.cc: In function 'int main()': a.cc:20:9: error: 'memset' was not declared in this scope 20 | memset(yard,'.',sizeof(yard)); | ^~~~~~ 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;
s596374279
p00118
C++
using System; using System.Collections.Generic; using System.ComponentModel.Design; class Program { private static int h, w; private static char[][] m = new char[100][]; private static int[] dx = new[] {0, 1, 0, -1, 1, 1, -1, -1}; private static int[] dy = new[] {1, 0, -1, 0, 1, -1, 1, -1}; public static int Main() { Scanner cin = new Scanner(); while (true) { h = cin.nextInt(); w = cin.nextInt(); if (h == 0 || w == 0) { break; } int ans = 0; for (int i = 0; i < h; i++) { m[i] = cin.next().ToCharArray(); } for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (m[i][j] != '.') { dfs(i, j, m[i][j]); ans++; } } } Console.WriteLine(ans); } return 0; } public static void dfs(int x, int y, char nowchar) { m[x][y] = '.'; for (int i = 0; i < 4; i++) { if (x + dx[i] < 0 || y + dy[i] < 0 || x + dx[i] == h || y + dy[i] == w || nowchar != m[x + dx[i]][y + dy[i]]) { continue; } dfs(x + dx[i], y + dy[i], nowchar); } } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; do { s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries); } while ((s.Length == 1 && s[0] == "") || s.Length == 0); i = 0; return s[i++]; } public int nextInt() { return int.Parse(next()); } public long nextLong() { return long.Parse(next()); } public double nextDouble() { return double.Parse(next()); } }
a.cc:1:7: error: expected nested-name-specifier before 'System' 1 | using System; | ^~~~~~ a.cc:2:7: error: expected nested-name-specifier before 'System' 2 | using System.Collections.Generic; | ^~~~~~ a.cc:3:7: error: expected nested-name-specifier before 'System' 3 | using System.ComponentModel.Design; | ^~~~~~ a.cc:7:16: error: expected ':' before 'static' 7 | private static int h, w; | ^~~~~~~ | : a.cc:8:16: error: expected ':' before 'static' 8 | private static char[][] m = new char[100][]; | ^~~~~~~ | : a.cc:8:28: error: expected unqualified-id before '[' token 8 | private static char[][] m = new char[100][]; | ^ a.cc:9:16: error: expected ':' before 'static' 9 | private static int[] dx = new[] {0, 1, 0, -1, 1, 1, -1, -1}; | ^~~~~~~ | : a.cc:9:27: error: expected unqualified-id before '[' token 9 | private static int[] dx = new[] {0, 1, 0, -1, 1, 1, -1, -1}; | ^ a.cc:10:16: error: expected ':' before 'static' 10 | private static int[] dy = new[] {1, 0, -1, 0, 1, -1, 1, -1}; | ^~~~~~~ | : a.cc:10:27: error: expected unqualified-id before '[' token 10 | private static int[] dy = new[] {1, 0, -1, 0, 1, -1, 1, -1}; | ^ a.cc:11:15: error: expected ':' before 'static' 11 | public static int Main() | ^~~~~~~ | : a.cc:43:15: error: expected ':' before 'static' 43 | public static void dfs(int x, int y, char nowchar) | ^~~~~~~ | : a.cc:55:2: error: expected ';' after class definition 55 | } | ^ | ; a.cc: In static member function 'static int Program::Main()': a.cc:13:17: error: 'Scanner' was not declared in this scope 13 | Scanner cin = new Scanner(); | ^~~~~~~ a.cc:16:29: error: 'cin' was not declared in this scope 16 | h = cin.nextInt(); | ^~~ a.cc:25:33: error: 'm' was not declared in this scope 25 | m[i] = cin.next().ToCharArray(); | ^ a.cc:31:45: error: 'm' was not declared in this scope 31 | if (m[i][j] != '.') | ^ a.cc:38:25: error: 'Console' was not declared in this scope 38 | Console.WriteLine(ans); | ^~~~~~~ a.cc: In static member function 'static void Program::dfs(int, int, char)': a.cc:45:17: error: 'm' was not declared in this scope 45 | m[x][y] = '.'; | ^ a.cc:48:33: error: 'dx' was not declared in this scope; did you mean 'x'? 48 | if (x + dx[i] < 0 || y + dy[i] < 0 || x + dx[i] == h || y + dy[i] == w || nowchar != m[x + dx[i]][y + dy[i]]) | ^~ | x a.cc:48:50: error: 'dy' was not declared in this scope; did you mean 'y'? 48 | if (x + dx[i] < 0 || y + dy[i] < 0 || x + dx[i] == h || y + dy[i] == w || nowchar != m[x + dx[i]][y + dy[i]]) | ^~ | y a.cc:52:33: error: 'dx' was not declared in this scope; did you mean 'x'? 52 | dfs(x + dx[i], y + dy[i], nowchar); | ^~ | x a.cc:52:44: error: 'dy' was not declared in this scope; did you mean 'y'? 52 | dfs(x + dx[i], y + dy[i], nowchar); | ^~ | y a.cc: At global scope: a.cc:58:9: error: 'string' does not name a type 58 | string[] s; | ^~~~~~ a.cc:61:13: error: expected unqualified-id before '[' token 61 | char[] cs = new char[] { ' ' }; | ^ a.cc:63:15: error: expected ':' before 'Scanner' 63 | public Scanner() { | ^~~~~~~~ | : a.cc:68:15: error: expected ':' before 'string' 68 | public string next() { | ^~~~~~~ | : a.cc:68:16: error: 'string' does not name a type 68 | public string next() { | ^~~~~~ a.cc:77:15: error: expected ':' before 'int' 77 | public int nextInt() { | ^~~~ | : a.cc:81:15: error: expected ':' before 'long' 81 | public long nextLong() { | ^~~~~ | : a.cc:85:15: error: expected ':' before 'double' 85 | public double nextDouble() { | ^~~~~~~ | : a.cc:89:2: error: expected ';' after class definition 89 | } | ^ | ; a.cc: In constructor 'Scanner::Scanner()': a.cc:64:17: error: 's' was not declared in this scope 64 | s = new string[0]; | ^ a.cc:64:25: error: 'string' does not name a type 64 | s = new string[0]; | ^~~~~~ a.cc: In member function 'int Scanner::nextInt()': a.cc:78:24: error: expected primary-expression before 'int' 78 | return int.Parse(next()); | ^~~ a.cc:78:24: error: expected ';' before 'int' a.cc:78:27: error: expected unqualified-id before '.' token 78 | return int.Parse(next()); | ^ a.cc: In member function 'long int Scanner::nextLong()': a.cc:82:24: error: expected primary-expression before 'long' 82 | return long.Parse(next()); | ^~~~ a.cc:82:24: error: expected ';' before 'long' a.cc:82:28: error: expected unqualified-id before '.' token 82 | return long.Parse(next()); | ^ a.cc: In member function 'double Scanner::nextDouble()': a.cc:86:24: error: expected primary-expression before 'double' 86 | return double.Parse(next()); | ^~~~~~ a.cc:86:24: error: expected ';' before 'double' a.cc:86:30: error: expected unqualified-id before '.' token 86 | return double.Parse(next()); | ^
s502944382
p00118
C++
#include<vector> using namespace std; const int VECX[4]={-1,0,1,0}; const int VECY[4]={0,-1,0,1}; bool tukattaka[100][100]; int h,w,count;//hはx wはy char sekai[100][100]; void func(int x,int y,char ki){ tukattaka[x][y]=true; for(int i=0;i<4;i++){ if(x+VECX[i]<w&&x+VECX[i]>=0&&y+VECY[i]<h&&y+VECY[i]>=0&&tukattaka[x+VECX[i]][y+VECY[i]]==false&&sekai[x+VECX[i]][y+VECY[i]]==ki){ func(x+VECX[i],y+VECY[i],ki); } } } int main(){ while(true){ cin>>h>>w; if(h==0&&w==0)break; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cin>>sekai[i][j]; } } for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ if(!tukattaka[i][j]){ func(i,j,sekai[i][j]); count++; } } } cout<<count<<endl; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ tukattaka[i][j]=false; sekai[i][j]=NULL; } } count=0; } return 0; }
a.cc: In function 'int main()': a.cc:25:17: error: 'cin' was not declared in this scope 25 | cin>>h>>w; | ^~~ a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 1 | #include<vector> +++ |+#include <iostream> 2 | a.cc:40:17: error: 'cout' was not declared in this scope 40 | cout<<count<<endl; | ^~~~ a.cc:40:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:40:30: error: 'endl' was not declared in this scope 40 | cout<<count<<endl; | ^~~~ a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 1 | #include<vector> +++ |+#include <ostream> 2 | a.cc:44:45: warning: converting to non-pointer type 'char' from NULL [-Wconversion-null] 44 | sekai[i][j]=NULL; | ^~~~
s712878513
p00118
C++
#include<vector> using namespace std; const int VECX[4]={-1,0,1,0}; const int VECY[4]={0,-1,0,1}; bool tukattaka[100][100]; int h,w,count;//hはx wはy char sekai[100][100]; void func(int x,int y,char ki){ tukattaka[x][y]=true; for(int i=0;i<4;i++){ if(x+VECX[i]<w&&x+VECX[i]>=0&&y+VECY[i]<h&&y+VECY[i]>=0&&tukattaka[x+VECX[i]][y+VECY[i]]==false&&sekai[x+VECX[i]][y+VECY[i]]==ki){ func(x+VECX[i],y+VECY[i],ki); } } } int main(){ while(true){ std::cin>>h>>w; if(h==0&&w==0)break; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cin>>sekai[i][j]; } } for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ if(!tukattaka[i][j]){ func(i,j,sekai[i][j]); count++; } } } std::cout<<count<<std::endl; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ tukattaka[i][j]=false; sekai[i][j]=0; } } count=0; } return 0; }
a.cc: In function 'int main()': a.cc:25:22: error: 'cin' is not a member of 'std' 25 | std::cin>>h>>w; | ^~~ a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 1 | #include<vector> +++ |+#include <iostream> 2 | a.cc:29:33: error: 'cin' was not declared in this scope 29 | cin>>sekai[i][j]; | ^~~ a.cc:29:33: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:40:22: error: 'cout' is not a member of 'std' 40 | std::cout<<count<<std::endl; | ^~~~ a.cc:40:22: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:40:40: error: 'endl' is not a member of 'std' 40 | std::cout<<count<<std::endl; | ^~~~ a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 1 | #include<vector> +++ |+#include <ostream> 2 |
s764314324
p00118
C++
import java.util.*; public class Main{ Scanner sc=new Scanner(System.in); int H=sc.nextInt(); int W=sc.nextInt(); String[][] k=new String[H][W]; for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ k[i][j]=sc.next(); } } public static void main(String[] args){ int num=0; for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ if(k[i][j]!="."){ kukaku(k,i,j,H,W); num++; } } } System.out.println(num); } public static void kukaku(int I,int J){ String p=k[I][J]; k[I][J]="."; int[] dx={-1,0,0,1}; int[] dy={0,-1,1,0}; for(int i=0;i<4;i++){ if(p==k[I+dx[i]][J+dy[i]]&&I+dx[i]>=0&&I+dx[i]<H&&J+dy[i]>=0&&J+dy[i]<W){ kukaku(I+dx[i],J+dy[i]); } return; } } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.*; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: expected unqualified-id before 'public' 3 | public class Main{ | ^~~~~~
s967698206
p00118
C++
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int H=sc.nextInt(); int W=sc.nextInt(); String[][] k=new String[H][W]; for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ k[i][j]=sc.next(); } } int num=0; for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ if(k[i][j]!="."){ kukaku(k,i,j,H,W); num++; } } } System.out.println(num); } public static void kukaku(String k[][],int I,int J,int h,int w){ String p=k[I][J]; k[I][J]="."; int[] dx={-1,0,0,1}; int[] dy={0,-1,1,0}; for(int i=0;i<4;i++){ if(p==k[I+dx[i]][J+dy[i]]&&I+dx[i]>=0&&I+dx[i]<h&&J+dy[i]>=0&&J+dy[i]<w){ kukaku(k,I+dx[i],J+dy[i],h,w); } } return; } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.*; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: expected unqualified-id before 'public' 3 | public class Main{ | ^~~~~~
s200391185
p00118
C++
import java.util.Scanner; class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int H=sc.nextInt(); int W=sc.nextInt(); char[][] k=new char[H][W]; for(int i=0; i< H; i++){ String line=sc.next(); for(int j=0; j< W; j++){ k[i][j]=line.charAt(j); } } int num=0; for(int i=0; i<H; i++){ for(int j=0; j<W; j++){ if(k[i][j]!=' '){ dfs(i,j,H,W,k); num++; } } } System.out.println(num); } public static void dfs(int I,int J,final int H,final int W,char[][] k){ char p=k[I][J]; k[I][J]=' '; int[] dx={-1,0,0,1}; int[] dy={0,-1,1,0}; for(int t=0;t<4;t++){ if(p==k[I+dx[t]][J+dy[t]]&&I+dx[t]>=0&&I+dx[t]<H&&J+dy[t]>=0&&J+dy[t]<W){ dfs(I+dx[t],J+dy[t],H,W,k); } } return; } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.Scanner; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:8: error: expected ':' before 'static' 4 | public static void main(String[] args){ | ^~~~~~~ | : a.cc:4:26: error: 'String' has not been declared 4 | public static void main(String[] args){ | ^~~~~~ a.cc:4:35: error: expected ',' or '...' before 'args' 4 | public static void main(String[] args){ | ^~~~ a.cc:26:8: error: expected ':' before 'static' 26 | public static void dfs(int I,int J,final int H,final int W,char[][] k){ | ^~~~~~~ | : a.cc:26:37: error: 'final' has not been declared 26 | public static void dfs(int I,int J,final int H,final int W,char[][] k){ | ^~~~~ a.cc:26:37: error: two or more data types in declaration of 'H' a.cc:26:48: error: expected ')' before ',' token 26 | public static void dfs(int I,int J,final int H,final int W,char[][] k){ | ~ ^ | ) a.cc:26:49: error: variable or field 'final' declared void 26 | public static void dfs(int I,int J,final int H,final int W,char[][] k){ | ^~~~~ a.cc:26:49: error: expected ';' at end of member declaration 26 | public static void dfs(int I,int J,final int H,final int W,char[][] k){ | ^~~~~ | ; a.cc:26:61: error: expected unqualified-id before 'char' 26 | public static void dfs(int I,int J,final int H,final int W,char[][] k){ | ^~~~ a.cc:38:3: error: expected ';' after class definition 38 | } | ^ | ; a.cc: In static member function 'static void Main::main(int*)': a.cc:5:2: error: 'Scanner' was not declared in this scope 5 | Scanner sc=new Scanner(System.in); | ^~~~~~~ a.cc:6:8: error: 'sc' was not declared in this scope 6 | int H=sc.nextInt(); | ^~ a.cc:8:6: error: structured binding declaration cannot have type 'char' 8 | char[][] k=new char[H][W]; | ^~ a.cc:8:6: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:8:6: error: empty structured binding declaration a.cc:8:8: error: expected initializer before '[' token 8 | char[][] k=new char[H][W]; | ^ a.cc:10:1: error: 'String' was not declared in this scope 10 | String line=sc.next(); | ^~~~~~ a.cc:12:2: error: 'k' was not declared in this scope 12 | k[i][j]=line.charAt(j); | ^ a.cc:12:10: error: 'line' was not declared in this scope 12 | k[i][j]=line.charAt(j); | ^~~~ a.cc:18:5: error: 'k' was not declared in this scope 18 | if(k[i][j]!=' '){ | ^ a.cc:24:2: error: 'System' was not declared in this scope 24 | System.out.println(num); | ^~~~~~
s799580036
p00118
C++
import java.util.Scanner; class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int H=sc.nextInt(); int W=sc.nextInt(); char[][] k=new char[H][W]; for(int i=0; i< H; i++){ String line=sc.next(); for(int j=0; j< W; j++){ k[i][j]=line.charAt(j); } } int num=0; for(int i=0; i<H; i++){ for(int j=0; j<W; j++){ if(k[i][j]!=' '){ dfs(i,j,H,W,k); num++; } } } System.out.println(num); } public static void dfs(int I,int J,final int H,final int W,char[][] k){ char p=k[I][J]; k[I][J]=' '; int[] dx={-1,0,0,1}; int[] dy={0,-1,1,0}; for(int t=0;t<4;t++){ if(p==k[I+dx[t]][J+dy[t]]&&I+dx[t]>=0&&I+dx[t]<H&&J+dy[t]>=0&&J+dy[t]<W){ dfs(I+dx[t],J+dy[t],H,W,k); } } return; } }
a.cc:2:1: error: 'import' does not name a type 2 | import java.util.Scanner; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:5:8: error: expected ':' before 'static' 5 | public static void main(String[] args){ | ^~~~~~~ | : a.cc:5:26: error: 'String' has not been declared 5 | public static void main(String[] args){ | ^~~~~~ a.cc:5:35: error: expected ',' or '...' before 'args' 5 | public static void main(String[] args){ | ^~~~ a.cc:27:8: error: expected ':' before 'static' 27 | public static void dfs(int I,int J,final int H,final int W,char[][] k){ | ^~~~~~~ | : a.cc:27:37: error: 'final' has not been declared 27 | public static void dfs(int I,int J,final int H,final int W,char[][] k){ | ^~~~~ a.cc:27:37: error: two or more data types in declaration of 'H' a.cc:27:48: error: expected ')' before ',' token 27 | public static void dfs(int I,int J,final int H,final int W,char[][] k){ | ~ ^ | ) a.cc:27:49: error: variable or field 'final' declared void 27 | public static void dfs(int I,int J,final int H,final int W,char[][] k){ | ^~~~~ a.cc:27:49: error: expected ';' at end of member declaration 27 | public static void dfs(int I,int J,final int H,final int W,char[][] k){ | ^~~~~ | ; a.cc:27:61: error: expected unqualified-id before 'char' 27 | public static void dfs(int I,int J,final int H,final int W,char[][] k){ | ^~~~ a.cc:39:3: error: expected ';' after class definition 39 | } | ^ | ; a.cc: In static member function 'static void Main::main(int*)': a.cc:6:2: error: 'Scanner' was not declared in this scope 6 | Scanner sc=new Scanner(System.in); | ^~~~~~~ a.cc:7:8: error: 'sc' was not declared in this scope 7 | int H=sc.nextInt(); | ^~ a.cc:9:6: error: structured binding declaration cannot have type 'char' 9 | char[][] k=new char[H][W]; | ^~ a.cc:9:6: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:9:6: error: empty structured binding declaration a.cc:9:8: error: expected initializer before '[' token 9 | char[][] k=new char[H][W]; | ^ a.cc:11:2: error: 'String' was not declared in this scope 11 | String line=sc.next(); | ^~~~~~ a.cc:13:2: error: 'k' was not declared in this scope 13 | k[i][j]=line.charAt(j); | ^ a.cc:13:10: error: 'line' was not declared in this scope 13 | k[i][j]=line.charAt(j); | ^~~~ a.cc:19:5: error: 'k' was not declared in this scope 19 | if(k[i][j]!=' '){ | ^ a.cc:25:2: error: 'System' was not declared in this scope 25 | System.out.println(num); | ^~~~~~
s903908140
p00118
C++
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.awt.Point; import java.util.*; class Main{ public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String str; while(!(str=br.readLine()).equals("0 0")){ String[] value=str.split(" "); int h=Integer.parseInt(value[0]); int w=Integer.parseInt(value[1]); char[][] map=new char[h][w]; for(int i=0;i<h;i++){ map[i]=br.readLine().toCharArray(); } Deque <Point> fifo =new ArrayDeque<Point>(); int ans=0; for(int m=0;m<h;m++){ for(int n=0;n<w;n++){ if(map[m][n]!='.'){ ans++; Point p = new Point(n,m); fifo.addLast(p); while(fifo.peekFirst()!=null){ p=fifo.pollFirst(); int x=p.x; int y=p.y; char crop = map[y][x]; map[y][x]='.'; int [] dx ={0,1,0,-1}; int [] dy ={1,0,-1,0}; for(int i=0;i<4;i++){ int nx =x+dx[i]; int ny =y+dy[i]; if(map[ny][nx]==crop&&map[ny][nx]!='.'&&nx>=0&&nx<w&&ny>=0&&ny<h){ Point np = new Point(); np.x=nx; np.y=ny; fifo.addLast(np); } } } } } }System.out.println(ans); } } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.io.BufferedReader; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.io.IOException; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import java.io.InputStreamReader; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: 'import' does not name a type 4 | import java.awt.Point; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:5:1: error: 'import' does not name a type 5 | import java.util.*; | ^~~~~~ a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:8:7: error: expected ':' before 'static' 8 | public static void main(String[] args) throws IOException{ | ^~~~~~~ | : a.cc:8:25: error: 'String' has not been declared 8 | public static void main(String[] args) throws IOException{ | ^~~~~~ a.cc:8:34: error: expected ',' or '...' before 'args' 8 | public static void main(String[] args) throws IOException{ | ^~~~ a.cc:8:38: error: expected ';' at end of member declaration 8 | public static void main(String[] args) throws IOException{ | ^ | ; a.cc:8:40: error: 'throws' does not name a type 8 | public static void main(String[] args) throws IOException{ | ^~~~~~ a.cc:51:2: error: expected ';' after class definition 51 | } | ^ | ;
s750235369
p00118
C++
// Property Distribution import java.util.ArrayDeque; import java.util.Queue; import java.util.Scanner; public class Main { int h, w; char[][] field; public static void main(String[] args) { new Main().run(); } void run() { Scanner sc = new Scanner(System.in); while (true) { h = sc.nextInt(); w = sc.nextInt(); if ((h | w) == 0) break; field = new char[h][]; for (int i = 0; i < h; i++) field[i] = sc.next().toCharArray(); int result = 0; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (field[i][j] != '.') { result++; visit(i, j); } } } System.out.println(result); } sc.close(); } void visit(int y, int x) { char c = field[y][x]; Queue<P> queue = new ArrayDeque<P>(); queue.add(new P(x, y)); while (!queue.isEmpty()) { P p = queue.remove(); field[p.y][p.x] = '.'; if (p.y > 0 && field[p.y - 1][p.x] == c) queue.add(new P(p.x, p.y - 1)); if (p.x > 0 && field[p.y][p.x - 1] == c) queue.add(new P(p.x - 1, p.y)); if (p.y < h - 1 && field[p.y + 1][p.x] == c) queue.add(new P(p.x, p.y + 1)); if (p.x < w - 1 && field[p.y][p.x + 1] == c) queue.add(new P(p.x + 1, p.y)); } } } class P { int x, y; P(int x, int y) { this.x = x; this.y = y; } }
a.cc:2:1: error: 'import' does not name a type 2 | import java.util.ArrayDeque; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import java.util.Queue; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: 'import' does not name a type 4 | import java.util.Scanner; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:6:1: error: expected unqualified-id before 'public' 6 | public class Main { | ^~~~~~ a.cc:65:2: error: expected ';' after class definition 65 | } | ^ | ; a.cc: In constructor 'P::P(int, int)': a.cc:62:22: error: request for member 'x' in '(P*)this', which is of pointer type 'P*' (maybe you meant to use '->' ?) 62 | this.x = x; | ^ a.cc:63:22: error: request for member 'y' in '(P*)this', which is of pointer type 'P*' (maybe you meant to use '->' ?) 63 | this.y = y; | ^
s977793718
p00118
C++
#include<cstdio> #include<cmath> #include<algorithm> #include<iostream> #include<string> #include<vector> #include<map> #include<cstdlib> #include<iomanip> #include<queue> #include<set> using namespace std; char a[100][100]; int ans = 0; int h, w; void Solution(int y, int x, char z) { a[y][x] = '0'; if(a[y+1][x] == z) { Solution(y+1, x, z); } if(a[y - 1][x] == z) { Solution(y-1, x, z); } if(a[y][x + 1] == z) { Solution(y, x + 1, z); } if(a[y][x - 1] == z) { Solution(y, x - 1, z); } } int main() { while (cin>>h>>w && (n|m)) { ans = 0; for(int i = 0; i < h; i++) { for(int j = 0; j < w; j++) { a[i][j] = '0'; } } if(h == 0) { break; } for(int i = 0; i < h; i++) { for(int j = 0; j < w; j++) { cin >> a[i][j]; } } for(int i = 0; i < h; i++) { for(int j = 0; j < w; j++) { if(a[i][j] != '0') { Solution(i, j, a[i][j]); ans++; } } } cout<<ans<<endl; } }
a.cc: In function 'int main()': a.cc:47:26: error: 'n' was not declared in this scope; did you mean 'yn'? 47 | while (cin>>h>>w && (n|m)) | ^ | yn a.cc:47:28: error: 'm' was not declared in this scope 47 | while (cin>>h>>w && (n|m)) | ^
s989015263
p00118
C++
#include<cstdio> #include<cmath> #include<algorithm> #include<iostream> #include<string> #include<vector> #include<map> #include<cstdlib> #include<iomanip> #include<queue> #include<set> using namespace std; char a[101][101]; int ans = 0; int h, w; void Solution(int y, int x, char z) { a[y][x] = '0'; if(a[y+1][x] == z) { Solution(y+1, x, z); } if(a[y - 1][x] == z) { Solution(y-1, x, z); } if(a[y][x + 1] == z) { Solution(y, x + 1, z); } if(a[y][x - 1] == z) { Solution(y, x - 1, z); } } int main() { while (cin>>h>>w && (n|m)) { ans = 0; for(int i = 0; i < h; i++) { for(int j = 0; j < w; j++) { a[i][j] = '0'; } } if(h == 0) { break; } for(int i = 0; i < h; i++) { for(int j = 0; j < w; j++) { cin >> a[i][j]; } } for(int i = 0; i < h; i++) { for(int j = 0; j < w; j++) { if(a[i][j] != '0') { Solution(i, j, a[i][j]); ans++; } } } cout<<ans<<endl; } }
a.cc: In function 'int main()': a.cc:47:26: error: 'n' was not declared in this scope; did you mean 'yn'? 47 | while (cin>>h>>w && (n|m)) | ^ | yn a.cc:47:28: error: 'm' was not declared in this scope 47 | while (cin>>h>>w && (n|m)) | ^
s781839656
p00118
C++
#include<cstdio> #include<cmath> #include<algorithm> #include<iostream> #include<string> #include<vector> #include<map> #include<cstdlib> #include<iomanip> #include<queue> #include<set> using namespace std; char a[101][101]; int ans = 0; int h, w; void Solution(int y, int x, char z) { a[y][x] = '0'; if(a[y+1][x] == z) { Solution(y+1, x, z); } if(a[y - 1][x] == z) { Solution(y-1, x, z); } if(a[y][x + 1] == z) { Solution(y, x + 1, z); } if(a[y][x - 1] == z) { Solution(y, x - 1, z); } } int main() { while (cin>>h>>w && (n|m)) { ans = 0; for(int i = 0; i < h; i++) { for(int j = 0; j < w; j++) { a[i][j] = '0'; } } if(h == 0) { break; } for(int i = 0; i < h; i++) { for(int j = 0; j < w; j++) { cin >> a[i][j]; } } for(int i = 0; i < h; i++) { for(int j = 0; j < w; j++) { if(a[i][j] != '0') { Solution(i, j, a[i][j]); ans++; } } } cout<<ans<<endl; } }
a.cc: In function 'int main()': a.cc:47:26: error: 'n' was not declared in this scope; did you mean 'yn'? 47 | while (cin>>h>>w && (n|m)) | ^ | yn a.cc:47:28: error: 'm' was not declared in this scope 47 | while (cin>>h>>w && (n|m)) | ^
s804589829
p00118
C++
void append(char fruit[100][100], int (&map)[100][100], int count, int i, int j, int h, int w){ if(j != w -1){ if(map[i][j+1] == 0 && fruit[i][j+1] == fruit[i][j]){ map[i][j+1] = count; append(fruit, map, count, i, j+1, h, w); } } if(i != h - 1){ if(map[i+1][j] == 0 && fruit[i+1][j] == fruit[i][j]){ map[i+1][j] = count; append(fruit, map, count, i+1, j, h, w); } } if(j != 0){ if(map[i][j-1] == 0 && fruit[i][j-1] == fruit[i][j]){ map[i][j-1] = count; append(fruit, map, count, i, j-1, h, w); } } if(i != 0){ if(map[i-1][j] == 0 && fruit[i-1][j] == fruit[i][j]){ map[i-1][j] = count; append(fruit, map, count, i-1, j, h, w); } } } int main(int argc, const char * argv[]) { while(true){ int H,W; cin >> H >> W; if(H == 0 && W == 0){ break; } int count = 0; int map[100][100] = {}; char fruits[100][100] = {}; for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ cin >> fruits[i][j]; } } for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ if(map[i][j] != 0){ continue; }else{ count++; map[i][j] = count; append(fruits, map, count, i, j, H, W); } } } for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ cout << map[i][j] << " "; } cout << endl; } cout << count << endl; } return 0; }
a.cc: In function 'int main(int, const char**)': a.cc:37:9: error: 'cin' was not declared in this scope 37 | cin >> H >> W; | ^~~ a.cc:69:17: error: 'cout' was not declared in this scope; did you mean 'count'? 69 | cout << map[i][j] << " "; | ^~~~ | count a.cc:71:13: error: 'cout' was not declared in this scope; did you mean 'count'? 71 | cout << endl; | ^~~~ | count a.cc:71:21: error: 'endl' was not declared in this scope 71 | cout << endl; | ^~~~ a.cc:74:9: error: 'cout' was not declared in this scope; did you mean 'count'? 74 | cout << count << endl; | ^~~~ | count a.cc:74:26: error: 'endl' was not declared in this scope 74 | cout << count << endl; | ^~~~
s805491407
p00118
C++
#include<iostream> #include<algorithm> #include<vector> using namespace std; int H,W; void saiki(char map[][100],int i,int j,char c){ map[i][j] = ' '; for (int dx=-1;dx<=1;dx++){ if(i+dx >= 0 && i+dx<W){ if(map[i+dx][j] == c){ saiki(map,i+dx,j,c); } } } for (int dy=-1;dy<=1;dy++){ if(i+dy >= 0 && i+dy<W){ if(map[i][j+dy] == c){ saiki(map,i,j+dy,c); } } } } int main(){ bool flag=true; while(true){ int count = 0; cin >> H >> W; if(H==0&&W==0) break; char map[100][100]; for(int i=0;i<W;i++){ for(int j=0;j<H;j++){ cin >> map[i][j]; } } int i=0,j=0; char c; for(int i=0;i<W;i++){ for(int j=0;j<H;j++){ c = map[i][j]; if(c != ' '){ count++; saiki(map,i,j,c); } } } cout << count << endl; } return 0; }javascript:void(0)
a.cc:60:6: error: 'javascript' does not name a type 60 | }javascript:void(0) | ^~~~~~~~~~
s699423328
p00118
C++
//??-2015-11-1 /* ?意: 在H * W的矩形果?里有苹果、梨、蜜柑三?果?, 相?(上下左右)的同?果?属于同一个区域,?出果?的果?分布,求?共有多少个区域。 (原?的??中苹果?リ,梨?カ,蜜柑?ミ, ?中共10个区域) ?入: 多?数据,??数据第一行??个整数H,W(H <= 100, W <= 100), H = 0 且 W = 0代表?入?束。以下H行W列表示果?的果?分布, 苹果是@,梨是#, 蜜柑是*。 ?出: ?于??数据,?出其区域的个数。 */ # include <cstdio> # include <algorithm> # include <stack> # include <string> # include <iostream> using namespace std; int direction[4][2] = { { -1, 0 }, { 1, 0 }, { 0, -1 }, {0,1} }; //方向,上下左右 int H, W; int vis[105][105]; string s[105]; struct node { int w, h; }node1[10005]; void DFS(int i, int j) { stack<node>S; int k, z; char c = s[i][j]; node temp; temp.h = i; temp.w = j; vis[temp.h][temp.w] = 1; S.push(temp); while (!S.empty()) //?不空的? { node temp1 = S.top(); S.pop(); for (k = 0; k < 4; k++) { if (temp1.h + direction[k][0] >= 0 && temp1.h + direction[k][0] < H&&temp1.w + direction[k][1] >= 0 && temp1.w + direction[k][1] < W &&!vis[temp1.h + direction[k][0]][temp1.w + direction[k][1]] && s[temp1.h + direction[k][0]][temp1.w + direction[k][1]] == c) //没有越界,并且没有???,和原来的符号一??,就入? { node temp2; temp2.h = temp1.h + direction[k][0]; temp2.w = temp1.w + direction[k][1]; vis[temp2.h][temp2.w] = 1; //在入?的?候就?? S.push(temp2); } } } } int main(void) { //freopen("in.txt", "r", stdin); while (scanf("%d%d", &H, &W) != EOF&&H&&W) { memset(vis, 0, sizeof(vis)); int i, j,count_number = 0; getchar(); for (i = 0; i < H; i++) { cin >> s[i]; } for (i = 0; i < H; i++) { for (j = 0; j < W; j++) { if (!vis[i][j]) { DFS(i, j); count_number++; } } } printf("%d\n", count_number); } return 0; }
a.cc: In function 'int main()': a.cc:59:17: error: 'memset' was not declared in this scope 59 | memset(vis, 0, sizeof(vis)); | ^~~~~~ a.cc:15:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 14 | # include <iostream> +++ |+#include <cstring> 15 |
s303745401
p00118
C++
#include <bits/stdc++.h> #define range(i, a, n) for(int (i) = (a); (i) < (n); (i)++) #define rep(i, n) for(int (i) = 0; (i) < (n); (i)++) using namespace std; int h, w; string field[100]; int dx = { 1, 0,-1, 0}; int dy = { 0,-1, 0, 1}; void dfs(int y, int x, char mark){ field[y][x] = '-'; for(int i = 0; i < 4; i++){ int yy = y + dy[i]; int xx = x + dx[i]; if(yy < 0 || h <= yy || xx < 0 || w <= xx || field[yy][xx] != mark) continue; dfs(yy, xx, mark); } } int main(void){ while(1){ cin >> h >> w; if(h == 0 && w == 0) break; for(int y = 0; y < h; y++){ cin >> field[y]; } int res = 0; for(int y = 0; y < h; y++){ for(int x = 0; x < w; x++){ if(field[y][x] != '-'){ dfs(y, x, field[y][x]); res++; } } } cout << res << endl; } return 0; }
a.cc:9:5: error: scalar object 'dx' requires one element in initializer 9 | int dx = { 1, 0,-1, 0}; | ^~ a.cc:10:5: error: scalar object 'dy' requires one element in initializer 10 | int dy = { 0,-1, 0, 1}; | ^~
s230516534
p00118
C++
#include<stdio.h> int map[102][102]; void paint(int x,int y,int type){ if(map[x][y]==type){ map[x][y]=0; paint(x-1,y,type); paint(x+1,y,type); paint(x,y-1,type); paint(x,y+1,type); } } int main(void){ int h,w,i,j,ans=0; char str[110]; scanf("%d%d",&h,&w); while(h!=0 || w!=0){ for(i=0; i<=h+1; i++){ for(j=0; j<=w+1; j++){ map[i][j]=0; } } for(i=1; i<=h; i++){ scanf("%s",str); for(j=0; j<w; j++){ if(str[j]=='@'){ map[i][j+1]=1; }else if(str[j]=='#'){ map[i][j+1]=2; }else if(str[j]=='*'){ map[i][j+1]=3; } } } for(i=1; i<=h; i++){ for(j=1; j<=w; j++){ if(map[i][j]!=0){ paint(i,j,map[i][j]); ans++; } } } printf("%d\n",ans); scanf("%d%d",&h,&w); javascript:void(0) } return 0; }
a.cc: In function 'int main()': a.cc:50:27: error: expected ';' before '}' token 50 | javascript:void(0) | ^ | ; 51 | } | ~
s035875878
p00118
C++
#include <string> #include <vector> #include <iostream> using namespace std; int H, W; vector<string> map; const vector<int> dx = { 0, 1, 0, -1 }; const vector<int> dy = { 1, 0, -1, 0 }; void rec(int x, int y, char c) { map[y][x] = '.'; for(int i = 0; i < 4; i++) { if(0 <= x + dx[i] && x + dx[i] < W && 0 <= y + dy[i] && y + dy[i] < H) { if(map[y + dy[i]][x + dx[i]] == c) { dfs(x + dx[i], y + dy[i]); } } } } int solve() { int ret = 0; for(int i = 0; i < H; i++) { for(int i = 0; i < W; i++) { if(map[i][j] != '.') { rec(j, i); ret++; } } } return ret; } int main() { while(true) { cin >> H >> W; map = vector<string>(H); for(int i = 0; i < H; i++) { cin >> map[i]; } cout << solve() << endl; } return 0; }
a.cc: In function 'void rec(int, int, char)': a.cc:24:17: error: 'dfs' was not declared in this scope 24 | dfs(x + dx[i], y + dy[i]); | ^~~ a.cc: In function 'int solve()': a.cc:38:23: error: 'j' was not declared in this scope 38 | if(map[i][j] != '.') | ^
s432134529
p00118
C++
#include <string> #include <vector> #include <iostream> using namespace std; int H, W; vector<string> map; const vector<int> dx = { 0, 1, 0, -1 }; const vector<int> dy = { 1, 0, -1, 0 }; void rec(int x, int y, char c) { map[y][x] = '.'; for(int i = 0; i < 4; i++) { if(0 <= x + dx[i] && x + dx[i] < W && 0 <= y + dy[i] && y + dy[i] < H) { if(map[y + dy[i]][x + dx[i]] == c) { dfs(x + dx[i], y + dy[i]); } } } } int solve() { int ret = 0; for(int i = 0; i < H; i++) { for(int i = 0; i < W; i++) { if(map[i][j] != '.') { rec(j, i, map[i][j]); ret++; } } } return ret; } int main() { while(true) { cin >> H >> W; map = vector<string>(H); for(int i = 0; i < H; i++) { cin >> map[i]; } cout << solve() << endl; } return 0; }
a.cc: In function 'void rec(int, int, char)': a.cc:24:17: error: 'dfs' was not declared in this scope 24 | dfs(x + dx[i], y + dy[i]); | ^~~ a.cc: In function 'int solve()': a.cc:38:23: error: 'j' was not declared in this scope 38 | if(map[i][j] != '.') | ^
s464271892
p00118
C++
#include <iostream> #include <vector> #include <string> #include <cmath> using namespace std; typedef long long ll; ll W, H; char a[101][101]; ll sx, sy; ll SUM; void dfs(int x,int y, char cur) { if(a[y][x]==cur) { a[y][x] = '-'; }else { return; } int dx[4] = { -1,1,0,0 }; int dy[4] = { 0,0,-1,1 }; for (int i = 0; i < 4;i++) { int px = x + dx[i]; int py = y + dy[i]; if (0 <= px && px < W && 0<=py && py<H) { dfs(px, py, cur); } } } int main() { vector<ll> res; do { memset(a, 0, sizeof(a)); cin >> W >> H; SUM = 0; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { char tmp; cin >> tmp; a[i][j] = tmp; } } for (int i = 0; i < H; i++) { for (int j = 0; j < W;j++) { if (a[i][j] != '-') { dfs(j,i,a[i][j]); SUM++; } } } res.push_back(SUM); } while (W != 0 && H != 0); for (int i = 0; i < res.size() - 1;i++) { cout << res[i] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:33:17: error: 'memset' was not declared in this scope 33 | memset(a, 0, sizeof(a)); | ^~~~~~ a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 4 | #include <cmath> +++ |+#include <cstring> 5 |
s009483937
p00118
C++
#include <iostream> #include <vector> #include <string> #include <cmath> using namespace std; typedef long long ll; ll W, H; char a[101][101]; ll sx, sy; ll SUM; void dfs(int x,int y, char cur) { if(a[y][x]==cur) { a[y][x] = '-'; }else { return; } int dx[4] = { -1,1,0,0 }; int dy[4] = { 0,0,-1,1 }; for (int i = 0; i < 4;i++) { int px = x + dx[i]; int py = y + dy[i]; if (0 <= px && px < W && 0<=py && py<H) { dfs(px, py, cur); } } } int main() { vector<ll> res; do { memset(a, 0, sizeof(a)); cin >> W >> H; SUM = 0; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { char tmp; cin >> tmp; a[i][j] = tmp; } } for (int i = 0; i < H; i++) { for (int j = 0; j < W;j++) { if (a[i][j] != '-') { dfs(j,i,a[i][j]); SUM++; } } } res.push_back(SUM); } while (W != 0 && H != 0); for (int i = 0; i < res.size() - 1;i++) { cout << res[i] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:33:17: error: 'memset' was not declared in this scope 33 | memset(a, 0, sizeof(a)); | ^~~~~~ a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 4 | #include <cmath> +++ |+#include <cstring> 5 |
s982407359
p00118
C++
F #include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<(int)(n);i++) int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1}; int w, h; char f[102][102]; bool ng(int x, int y) { return (x<0 or y<0 or x>=w or y>=h); } void dfs(int x, int y) { char c = f[y][x]; f[y][x] = '.'; rep(i,4) { int nx = x + dx[i]; int ny = y + dy[i]; if(!ng(nx,ny) and f[ny][nx] == c) dfs(nx,ny); } return ; } int main() { while(cin>>w>>h and w) { rep(y,102) rep(x,102) f[y][x] = '.'; rep(y,h) rep(x,w) cin >> f[y][x]; int ans = 0; rep(y,h) rep(x,w) { if(f[y][x] == '.') continue; dfs(x, y); ans++; } cout << ans << endl; } return 0; }
a.cc:1:1: error: 'F' does not name a type 1 | F | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:2: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'? 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/cstddef:50, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41: /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here 443 | typedef decltype(nullptr) nullptr_t; | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'? 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here 443 | typedef decltype(nullptr) nullptr_t; | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared 2086 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope 2087 | struct remove_extent<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid 2087 | struct remove_extent<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared 2099 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope 2100 | struct remove_all_extents<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid 2100 | struct remove_all_extents<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared 2171 | template<std::size_t _Len> | ^~~ /usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope 2176 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^~~~ /usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^ /usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope 2202 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope 2203 | struct __attribute__((__aligned__((_Align)))) { } __align; | ^~~~~~ In file included from /usr/include/c++/14/bits/stl_tempbuf.h:59, from /usr/include/c++/14/bits/stl_algo.h:69, from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive] 132 | __attribute__((__externally_visible__)); | ^ /usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive] 134 | __attribute__((__externally_visible__)); | ^ /usr/include/c++/1
s910348542
p00118
C++
F #include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<(int)(n);i++) int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1}; int w, h; char f[102][102]; bool ng(int x, int y) { return (x<0 or y<0 or x>=w or y>=h); } void dfs(int x, int y) { char c = f[y][x]; f[y][x] = '.'; rep(i,4) { int nx = x + dx[i]; int ny = y + dy[i]; if(!ng(nx,ny) and f[ny][nx] == c) dfs(nx,ny); } return ; } int main() { while(cin>>w>>h and w) { rep(y,101) rep(x,101) f[y][x] = '.'; rep(y,h) rep(x,w) cin >> f[y][x]; int ans = 0; rep(y,h) rep(x,w) { if(f[y][x] == '.') continue; dfs(x, y); ans++; } cout << ans << endl; } return 0; }
a.cc:1:1: error: 'F' does not name a type 1 | F | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:2: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'? 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/cstddef:50, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41: /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here 443 | typedef decltype(nullptr) nullptr_t; | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'? 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here 443 | typedef decltype(nullptr) nullptr_t; | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared 2086 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope 2087 | struct remove_extent<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid 2087 | struct remove_extent<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared 2099 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope 2100 | struct remove_all_extents<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid 2100 | struct remove_all_extents<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared 2171 | template<std::size_t _Len> | ^~~ /usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope 2176 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^~~~ /usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^ /usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope 2202 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope 2203 | struct __attribute__((__aligned__((_Align)))) { } __align; | ^~~~~~ In file included from /usr/include/c++/14/bits/stl_tempbuf.h:59, from /usr/include/c++/14/bits/stl_algo.h:69, from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive] 132 | __attribute__((__externally_visible__)); | ^ /usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive] 134 | __attribute__((__externally_visible__)); | ^ /usr/include/c++/1
s327520544
p00118
C++
#include<iostream> using namespace std; #define MAXSIZE 100 char Graph[MAXSIZE][MAXSIZE]; int visited[MAXSIZE][MAXSIZE]; int h,w,number; int x[4]={-1,1,0,0}; int y[4]={0,0,-1,1}; void dfs(int i,int j) { int d,p,q; for(d=0;d<4;d++) { p=i+x[d]; q=j+y[d]; if(p>=0&&p<h&&q>=0&&q<w&&Graph[i][j]==Graph[p][q]&&visited[p][q]==0) { visited[p][q]=1; dfs(p,q); } } } int main() { int i,j; memset(visited,0,sizeof(visited)); while(cin>>h&&cin>>w&&h!=0&&w!=0) { number=0; for(i=0;i<h;i++) for(j=0;j<w;j++) cin>>Graph[i][j]; for(i=0;i<h;i++) for(j=0;j<w;j++) { if(!visited[i][j]) { visited[i][j]=1; dfs(i,j); number++; } } cout<<number<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:30:9: error: 'memset' was not declared in this scope 30 | memset(visited,0,sizeof(visited)); | ^~~~~~ 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;
s529352064
p00118
C++
#include <stdio.h> #include <stdlib.h> int dfs(char **map,int **check,int i,int j,int h){ int res=1; check[i][j]=2; if(map[i][j+1]==map[i][j] && check[i][j+1]==1)res=0; if(map[i][j+1]==map[i][j] && check[i][j+1]==0){ if(map[i][j+1]=='\n')return 0; else res*=dfs(map,check,i,j+1,h); } if(i+1>=h)return res; if(map[i+1][j]==map[i][j] && check[i+1][j]==0){ res*=dfs(map,check,i+1,j,h); } return res; } int main(){ char** map; int** check; int i,j,k,l,count,sx,sy; while(1){ count=0; scanf("%d %d",&sx,&sy); if(sx==0)break; map=malloc(sizeof(char *)*sx); for(i=0;i<sx;i++){ map[i]=malloc(sizeof(char)*(sy+1)); } check=malloc(sizeof(int *)*sx); for(i=0;i<sx;i++){ check[i]=malloc(sizeof(int)*(sy+1)); } for(i=0;i<sx;i++){ for(j=0;j<=sy;j++){ check[i][j]=0; } } scanf("%c",&map[0][0]); for(i=0;i<sx;i++){ for(j=0;j<=sy;j++){ scanf("%c",&map[i][j]); } } for(i=0;i<sx;i++){ for(j=0;j<sy;j++){ if(check[i][j]==0){ count+=dfs(map,check,i,j,sx); for(k=0;k<sx;k++){ for(l=0;l<=sy;l++){ if(check[k][l]==2)check[k][l]=1; } } } } } printf("%d\n",count); for(i=0;i<sx;i++){ free(map[i]); } free(map); } return 0; }
a.cc: In function 'int main()': a.cc:29:19: error: invalid conversion from 'void*' to 'char**' [-fpermissive] 29 | map=malloc(sizeof(char *)*sx); | ~~~~~~^~~~~~~~~~~~~~~~~~~ | | | void* a.cc:31:30: error: invalid conversion from 'void*' to 'char*' [-fpermissive] 31 | map[i]=malloc(sizeof(char)*(sy+1)); | ~~~~~~^~~~~~~~~~~~~~~~~~~~~ | | | void* a.cc:33:21: error: invalid conversion from 'void*' to 'int**' [-fpermissive] 33 | check=malloc(sizeof(int *)*sx); | ~~~~~~^~~~~~~~~~~~~~~~~~ | | | void* a.cc:35:32: error: invalid conversion from 'void*' to 'int*' [-fpermissive] 35 | check[i]=malloc(sizeof(int)*(sy+1)); | ~~~~~~^~~~~~~~~~~~~~~~~~~~ | | | void*
s879310895
p00118
C++
#include <iostream> using namespace std; int dx[] = {1, -1, 0, 0}; int dy[] = {0, 0, 1, -1}; char map[105][105]; //H <= 100, W <= 100 int h, w, vis[105][105]; void dfs(int x, int y, char c) { int i, xx, yy; for(i = 0; i < 4; i++) { xx = x + dx[i]; yy = y + dy[i]; if(xx >= 0 && xx < h && yy >= 0 && yy < w && !vis[xx][yy] && ma[xx][yy] == c) //?找相同区域?char相同 { vis[xx][yy] = 1; //搜索的?置?1以防下次搜索?区域 dfs(xx, yy, c); } } } int main() { int i, j, ans; while(scanf("%d%d", &h, &w) && (h || w)) { getchar(); //?行考? for(i = 0; i < h; i++) scanf("%s", map[i]); //按行?取 memset(vis, 0, sizeof vis); //vis全部元素置?0,即初始化数? ans = 0; for(i = 0; i < h; i++) { for(j = 0; j < w; j++) { if(!vis[i][j]) { ans++; //一?始就是一个区域 dfs(i, j, map[i][j]); //深度搜索 } } } printf("%d\n", ans); } return 0; } /* ??附? 在H*W的矩形果?里有苹果、梨、蜜柑三?果?,相?(上下左右)的同?果?属于同一个区域,?出果?的果?分布,求?共有多少个区域。 (原?的??中苹果?リ,梨?カ,蜜柑?ミ, ?中共10个区域) ?入: 多?数据,??数据第一行??个整数H、W(H <= 100, W <= 100), H =0 且 W = 0代表?入?束。 以下H行W列表示果?的果?分布,苹果是@,梨是#, 蜜柑是*。 ?出: ?于??数据,?出其区域的个数。 */
a.cc: In function 'void dfs(int, int, char)': a.cc:18:70: error: 'ma' was not declared in this scope; did you mean 'map'? 18 | if(xx >= 0 && xx < h && yy >= 0 && yy < w && !vis[xx][yy] && ma[xx][yy] == c) //?找相同区域?char相同 | ^~ | map a.cc: In function 'int main()': a.cc:35:9: error: 'memset' was not declared in this scope 35 | memset(vis, 0, sizeof vis); //vis全部元素置?0,即初始化数? | ^~~~~~ a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 | using namespace std;
s116901092
p00118
C++
#include <iostream> using namespace std; int dx[] = {1, -1, 0, 0}; int dy[] = {0, 0, 1, -1}; char map[105][105]; //H <= 100, W <= 100 int h, w, vis[105][105]; void dfs(int x, int y, char c) { int i, xx, yy; for(i = 0; i < 4; i++) { xx = x + dx[i]; yy = y + dy[i]; if(xx >= 0 && xx < h && yy >= 0 && yy < w && !vis[xx][yy] && map[xx][yy] == c) //?找相同区域?char相同 { vis[xx][yy] = 1; //搜索的?置?1以防下次搜索?区域 dfs(xx, yy, c); } } } int main() { int i, j, ans; while(scanf("%d%d", &h, &w) && (h || w)) { getchar(); //?行考? for(i = 0; i < h; i++) scanf("%s", map[i]); //按行?取 memset(vis, 0, sizeof vis); //vis全部元素置?0,即初始化数? ans = 0; for(i = 0; i < h; i++) { for(j = 0; j < w; j++) { if(!vis[i][j]) { ans++; //一?始就是一个区域 dfs(i, j, map[i][j]); //深度搜索 } } } printf("%d\n", ans); } return 0; } /* ??附? 在H*W的矩形果?里有苹果、梨、蜜柑三?果?,相?(上下左右)的同?果?属于同一个区域,?出果?的果?分布,求?共有多少个区域。 (原?的??中苹果?リ,梨?カ,蜜柑?ミ, ?中共10个区域) ?入: 多?数据,??数据第一行??个整数H、W(H <= 100, W <= 100), H =0 且 W = 0代表?入?束。 以下H行W列表示果?的果?分布,苹果是@,梨是#, 蜜柑是*。 ?出: ?于??数据,?出其区域的个数。 */
a.cc: In function 'int main()': a.cc:35:9: error: 'memset' was not declared in this scope 35 | memset(vis, 0, sizeof vis); //vis全部元素置?0,即初始化数? | ^~~~~~ a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 | using namespace std;
s844517491
p00118
C++
#include <iostream> #include <sstream> #include <cstdlib> const int MAX_W = 100; const int MAX_H = 100; int H, W; char field[MAX_H][MAX_W] = {'.'}; void solve(int y, int x) { int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, 1, 0, -1}; char c = field[y][x]; field[y][x] = '.'; for(int i = 0; i < 4; i++) { int nx = x + dx[i]; int ny = y + dy[i]; if(nx >= 0 and ny >= 0 and nx < W and ny < H and field[ny][nx] == c) { solve(ny, nx, H, W); } } } void print(int w, int h) { for(int i = 0; i < h; i++) { for(int j = 0; j < w; j++) { std::cout << field[i][j]; } std::cout << std::endl; } std::cout << std::endl; } int main() { while (std::cin >> H >> W, H) { for (int i = 0; i < H; i++) { std::cin >> field[i]; } int count = 0; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { if (field[i][j] != '.') { solve(i, j); count++; } } } std::cout << count << std::endl; } return 0; return 0; }
a.cc: In function 'void solve(int, int)': a.cc:20:18: error: too many arguments to function 'void solve(int, int)' 20 | solve(ny, nx, H, W); | ~~~~~^~~~~~~~~~~~~~ a.cc:10:6: note: declared here 10 | void solve(int y, int x) { | ^~~~~
s139750259
p00118
C++
#include <iostream> using namespace std; char f[124][124]; int H, W; const dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; inline bool inside(int y, int x){return 0 <= y && y < H && 0 <= x && x < W;} void area(int y, int x) { char if2 = f[y][x]; f[y][x] = '0'; for (int i = 0; i < 4; i++){ int ny = y + dy[i], nx = x + dx[i]; if (inside(y, x) && f[ny][nx] != '0' && f[ny][nx] == if2){ area(ny, nx); } } } int main() { while (cin >> H >> W, H || W){ int c = 0; for (int i = 0; i < H; i++){ cin >> f[i]; } for (int i = 0; i < H; i++){ for (int j = 0; j < W; j++){ if (f[i][j] != '0'){ area(i, j); c++; } } } cout << c << endl; } return 0; }
a.cc:7:7: error: 'dx' does not name a type 7 | const dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; | ^~ a.cc:7:27: error: expected unqualified-id before ',' token 7 | const dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; | ^ a.cc:7:34: error: expected constructor, destructor, or type conversion before '=' token 7 | const dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; | ^ a.cc: In function 'void area(int, int)': a.cc:16:30: error: 'dy' was not declared in this scope; did you mean 'ny'? 16 | int ny = y + dy[i], nx = x + dx[i]; | ^~ | ny a.cc:17:43: error: 'nx' was not declared in this scope; did you mean 'ny'? 17 | if (inside(y, x) && f[ny][nx] != '0' && f[ny][nx] == if2){ | ^~ | ny
s105644952
p00118
C++
#include<iostream> #include<cstdio> #include<cstring> using namespace std; const int maxn = 103; char map[maxn][maxn]; int move [][2] = {{0,1},{1,0},{0,-1},{-1,0}}; int n , m; int ans; void dfs ( int i , int j ){ char temp = map[i][j]; map[i][j] = '.'; for(int k = 0 ; k < 4 ; k ++){ if((i+move[k][0]>0)&&(i+move[k][0]<=n)&&(j+move[k][1]>0)&&(j+move[k][1]<=m)&&map[i+move[k][0]][j+move[k][1]]==temp){ dfs(i+move[k][0],j+move[k][1]); } } } int main(void){ while(cin>>n>>m){ if((!n)&&(!m))break; ans = 0; for(int i = 1 ; i <= n ; i ++){ for(int j = 1 ; j <= m ; j ++){ cin>>map[i][j]; } } for(int i = 1 ; i <= n ; i ++){ for(int j = 1 ; j <= m ; j ++){ if(map[i][j]!='.'){ dfs(i,j); ans++; } } } cout<<ans<<endl; } }
a.cc: In function 'void dfs(int, int)': a.cc:17:23: error: reference to 'move' is ambiguous 17 | if((i+move[k][0]>0)&&(i+move[k][0]<=n)&&(j+move[k][1]>0)&&(j+move[k][1]<=m)&&map[i+move[k][0]][j+move[k][1]]==temp){ | ^~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:675:5: note: candidates are: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)' 675 | move(_II __first, _II __last, _OI __result) | ^~~~ In file included from /usr/include/c++/14/bits/exception_ptr.h:41, from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41: /usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)' 137 | move(_Tp&& __t) noexcept | ^~~~ a.cc:9:5: note: 'int move [4][2]' 9 | int move [][2] = {{0,1},{1,0},{0,-1},{-1,0}}; | ^~~~ a.cc:17:41: error: reference to 'move' is ambiguous 17 | if((i+move[k][0]>0)&&(i+move[k][0]<=n)&&(j+move[k][1]>0)&&(j+move[k][1]<=m)&&map[i+move[k][0]][j+move[k][1]]==temp){ | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:675:5: note: candidates are: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)' 675 | move(_II __first, _II __last, _OI __result) | ^~~~ /usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)' 137 | move(_Tp&& __t) noexcept | ^~~~ a.cc:9:5: note: 'int move [4][2]' 9 | int move [][2] = {{0,1},{1,0},{0,-1},{-1,0}}; | ^~~~ a.cc:17:60: error: reference to 'move' is ambiguous 17 | if((i+move[k][0]>0)&&(i+move[k][0]<=n)&&(j+move[k][1]>0)&&(j+move[k][1]<=m)&&map[i+move[k][0]][j+move[k][1]]==temp){ | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:675:5: note: candidates are: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)' 675 | move(_II __first, _II __last, _OI __result) | ^~~~ /usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)' 137 | move(_Tp&& __t) noexcept | ^~~~ a.cc:9:5: note: 'int move [4][2]' 9 | int move [][2] = {{0,1},{1,0},{0,-1},{-1,0}}; | ^~~~ a.cc:17:78: error: reference to 'move' is ambiguous 17 | if((i+move[k][0]>0)&&(i+move[k][0]<=n)&&(j+move[k][1]>0)&&(j+move[k][1]<=m)&&map[i+move[k][0]][j+move[k][1]]==temp){ | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:675:5: note: candidates are: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)' 675 | move(_II __first, _II __last, _OI __result) | ^~~~ /usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)' 137 | move(_Tp&& __t) noexcept | ^~~~ a.cc:9:5: note: 'int move [4][2]' 9 | int move [][2] = {{0,1},{1,0},{0,-1},{-1,0}}; | ^~~~ a.cc:17:100: error: reference to 'move' is ambiguous 17 | if((i+move[k][0]>0)&&(i+move[k][0]<=n)&&(j+move[k][1]>0)&&(j+move[k][1]<=m)&&map[i+move[k][0]][j+move[k][1]]==temp){ | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:675:5: note: candidates are: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)' 675 | move(_II __first, _II __last, _OI __result) | ^~~~ /usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)' 137 | move(_Tp&& __t) noexcept | ^~~~ a.cc:9:5: note: 'int move [4][2]' 9 | int move [][2] = {{0,1},{1,0},{0,-1},{-1,0}}; | ^~~~ a.cc:17:114: error: reference to 'move' is ambiguous 17 | if((i+move[k][0]>0)&&(i+move[k][0]<=n)&&(j+move[k][1]>0)&&(j+move[k][1]<=m)&&map[i+move[k][0]][j+move[k][1]]==temp){ | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:675:5: note: candidates are: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)' 675 | move(_II __first, _II __last, _OI __result) | ^~~~ /usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)' 137 | move(_Tp&& __t) noexcept | ^~~~ a.cc:9:5: note: 'int move [4][2]' 9 | int move [][2] = {{0,1},{1,0},{0,-1},{-1,0}}; | ^~~~ a.cc:18:31: error: reference to 'move' is ambiguous 18 | dfs(i+move[k][0],j+move[k][1]); | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:675:5: note: candidates are: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)' 675 | move(_II __first, _II __last, _OI __result) | ^~~~ /usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)' 137 | move(_Tp&& __t) noexcept | ^~~~ a.cc:9:5: note: 'int move [4][2]' 9 | int move [][2] = {{0,1},{1,0},{0,-1},{-1,0}}; | ^~~~ a.cc:18:44: error: reference to 'move' is ambiguous 18 | dfs(i+move[k][0],j+move[k][1]); | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:675:5: note: candidates are: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)' 675 | move(_II __first, _II __last, _OI __result) | ^~~~ /usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)' 137 | move(_Tp&& __t) noexcept | ^~~~ a.cc:9:5: note: 'int move [4][2]' 9 | int move [][2] = {{0,1},{1,0},{0,-1},{-1,0}}; | ^~~~
s611717872
p00118
C++
#include<iostream> #include<cstdio> #include<cstring> using namespace std; const int maxn = 103; char map[maxn][maxn]; int move [4][2] = {{0,1},{1,0},{0,-1},{-1,0}}; int n , m; int ans; void dfs ( int i , int j ){ char temp = map[i][j]; map[i][j] = '.'; for(int k = 0 ; k < 4 ; k ++){ if((i+move[k][0]>0)&&(i+move[k][0]<=n)&&(j+move[k][1]>0)&&(j+move[k][1]<=m)&&map[i+move[k][0]][j+move[k][1]]==temp){ dfs(i+move[k][0],j+move[k][1]); } } } int main(void){ while(cin>>n>>m){ if((!n)&&(!m))break; ans = 0; for(int i = 1 ; i <= n ; i ++){ for(int j = 1 ; j <= m ; j ++){ cin>>map[i][j]; } } for(int i = 1 ; i <= n ; i ++){ for(int j = 1 ; j <= m ; j ++){ if(map[i][j]!='.'){ dfs(i,j); ans++; } } } cout<<ans<<endl; } }
a.cc: In function 'void dfs(int, int)': a.cc:17:23: error: reference to 'move' is ambiguous 17 | if((i+move[k][0]>0)&&(i+move[k][0]<=n)&&(j+move[k][1]>0)&&(j+move[k][1]<=m)&&map[i+move[k][0]][j+move[k][1]]==temp){ | ^~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:675:5: note: candidates are: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)' 675 | move(_II __first, _II __last, _OI __result) | ^~~~ In file included from /usr/include/c++/14/bits/exception_ptr.h:41, from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41: /usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)' 137 | move(_Tp&& __t) noexcept | ^~~~ a.cc:9:5: note: 'int move [4][2]' 9 | int move [4][2] = {{0,1},{1,0},{0,-1},{-1,0}}; | ^~~~ a.cc:17:41: error: reference to 'move' is ambiguous 17 | if((i+move[k][0]>0)&&(i+move[k][0]<=n)&&(j+move[k][1]>0)&&(j+move[k][1]<=m)&&map[i+move[k][0]][j+move[k][1]]==temp){ | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:675:5: note: candidates are: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)' 675 | move(_II __first, _II __last, _OI __result) | ^~~~ /usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)' 137 | move(_Tp&& __t) noexcept | ^~~~ a.cc:9:5: note: 'int move [4][2]' 9 | int move [4][2] = {{0,1},{1,0},{0,-1},{-1,0}}; | ^~~~ a.cc:17:60: error: reference to 'move' is ambiguous 17 | if((i+move[k][0]>0)&&(i+move[k][0]<=n)&&(j+move[k][1]>0)&&(j+move[k][1]<=m)&&map[i+move[k][0]][j+move[k][1]]==temp){ | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:675:5: note: candidates are: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)' 675 | move(_II __first, _II __last, _OI __result) | ^~~~ /usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)' 137 | move(_Tp&& __t) noexcept | ^~~~ a.cc:9:5: note: 'int move [4][2]' 9 | int move [4][2] = {{0,1},{1,0},{0,-1},{-1,0}}; | ^~~~ a.cc:17:78: error: reference to 'move' is ambiguous 17 | if((i+move[k][0]>0)&&(i+move[k][0]<=n)&&(j+move[k][1]>0)&&(j+move[k][1]<=m)&&map[i+move[k][0]][j+move[k][1]]==temp){ | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:675:5: note: candidates are: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)' 675 | move(_II __first, _II __last, _OI __result) | ^~~~ /usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)' 137 | move(_Tp&& __t) noexcept | ^~~~ a.cc:9:5: note: 'int move [4][2]' 9 | int move [4][2] = {{0,1},{1,0},{0,-1},{-1,0}}; | ^~~~ a.cc:17:100: error: reference to 'move' is ambiguous 17 | if((i+move[k][0]>0)&&(i+move[k][0]<=n)&&(j+move[k][1]>0)&&(j+move[k][1]<=m)&&map[i+move[k][0]][j+move[k][1]]==temp){ | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:675:5: note: candidates are: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)' 675 | move(_II __first, _II __last, _OI __result) | ^~~~ /usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)' 137 | move(_Tp&& __t) noexcept | ^~~~ a.cc:9:5: note: 'int move [4][2]' 9 | int move [4][2] = {{0,1},{1,0},{0,-1},{-1,0}}; | ^~~~ a.cc:17:114: error: reference to 'move' is ambiguous 17 | if((i+move[k][0]>0)&&(i+move[k][0]<=n)&&(j+move[k][1]>0)&&(j+move[k][1]<=m)&&map[i+move[k][0]][j+move[k][1]]==temp){ | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:675:5: note: candidates are: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)' 675 | move(_II __first, _II __last, _OI __result) | ^~~~ /usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)' 137 | move(_Tp&& __t) noexcept | ^~~~ a.cc:9:5: note: 'int move [4][2]' 9 | int move [4][2] = {{0,1},{1,0},{0,-1},{-1,0}}; | ^~~~ a.cc:18:31: error: reference to 'move' is ambiguous 18 | dfs(i+move[k][0],j+move[k][1]); | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:675:5: note: candidates are: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)' 675 | move(_II __first, _II __last, _OI __result) | ^~~~ /usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)' 137 | move(_Tp&& __t) noexcept | ^~~~ a.cc:9:5: note: 'int move [4][2]' 9 | int move [4][2] = {{0,1},{1,0},{0,-1},{-1,0}}; | ^~~~ a.cc:18:44: error: reference to 'move' is ambiguous 18 | dfs(i+move[k][0],j+move[k][1]); | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:675:5: note: candidates are: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)' 675 | move(_II __first, _II __last, _OI __result) | ^~~~ /usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)' 137 | move(_Tp&& __t) noexcept | ^~~~ a.cc:9:5: note: 'int move [4][2]' 9 | int move [4][2] = {{0,1},{1,0},{0,-1},{-1,0}}; | ^~~~
s003271672
p00118
C++
//AOJ0118 Property Distribution #include<cstdio> #include<cstring> char map[105][105]; int dx[4]={-1,0,1,0}; int dy[4]={0,1,0,-1}; int W,H; void dfs(int x,int y,char c){ map[x][y]='.'; for(int i=0;i<4;i++){ int nx=x+dx[i],ny=y+dy[i]; if(0<=nx&&nx<H&&0<=ny&&ny<W&&map[nx][ny]==c)dfs(nx,ny,c);果樹園 } } int main(){ while(scanf("%d%d",&W,&H),W&&H){ int cnt=0; memset(map,'.',sizeof(map)); for(int i=0;i<H;i++)scanf("%s",map[i]); for(int i=0;i<H;i++) for(int j=0;j<W;j++) if(map[i][j]!='.'){ dfs(i,j,map[i][j]); cnt++; } printf("%d\n",cnt); } return 0; }
a.cc: In function 'void dfs(int, int, char)': a.cc:12:66: error: '\U0000679c\U00006a39\U00005712' was not declared in this scope 12 | if(0<=nx&&nx<H&&0<=ny&&ny<W&&map[nx][ny]==c)dfs(nx,ny,c);果樹園 | ^~~~~~
s961586557
p00118
C++
#include <bits/stdc++.h> using namespace std; int H,M,cnt=0; char farm[100][100]; int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1}; void dfs(int x, int y ,char z){ farm[x][y]='.'; for(int i=0;i<4;i++){ if(x+dx[i]>=0 && x+dx[i]<H && y+dy[i]>=0 && y+dy[i]<M && farm[x+dx[i]][y+dy[i]]==z) dfs(x+dx[i],y+dy[i],z); return ; } } int main(){ scanf("%d %d",&H,&M); for(int i=0;i<H,i++){ for(int j=0;j<M;j++){ scanf("%c",&farm[i][j]); } } for(int i=0;i<H,i++){ for(int j=0;j<M;j++){ if(farm[i][j]!='.'){ dfs(i,j,farm[i][j]); cnt++; } } } printf("%d",cnt); return 0; }
a.cc: In function 'int main()': a.cc:21:22: error: expected ';' before ')' token 21 | for(int i=0;i<H,i++){ | ^ | ; a.cc:27:22: error: expected ';' before ')' token 27 | for(int i=0;i<H,i++){ | ^ | ;
s630838856
p00118
C++
#include <cstdio> #include <map> #include <queue> #include <cstring> #define PRINTF(...) int h, w; char area[100][100]; void visualize() { for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { PRINTF("%c", area[i][j]); } PRINTF("\n"); } } void replace(char c, int i, int j) { int dirs[][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}}; if (i < 0 || i >= h || j < 0 || j >= w || area[i][j] != c) { return; } area[i][j] = '.'; for (int k = 0; k < 4; k++) { replace(c, i + dirs[k][0], j + dirs[k][1]); } } int solve() { char buf[4096]; int count = 0; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (area[i][j] != '.') { PRINTF("before\n"); visualize(); count++; gets(buf); replace(area[i][j], i, j); PRINTF("after\n"); visualize(); gets(buf); } } } return count; } int main() { while (true) { scanf(" %d %d", &h, &w); PRINTF("h: %d w: %d\n", h, w); if (h == 0 && w == 0) break; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (scanf(" %c", &area[i][j]) == EOF) return 0; } } printf("%d\n", solve()); } }
a.cc: In function 'int solve()': a.cc:41:17: error: 'gets' was not declared in this scope; did you mean 'getw'? 41 | gets(buf); | ^~~~ | getw
s259829725
p00118
C++
#include <iostream> #include <limits.h> #include <queue> #include <algorithm> #include <string> //typedef pair<int,int> P; using namespace std; const int INF=INT_MAX/3; const int V_MAX=10000,E_MAX=10000; int H,W; const int MAX=200; char maps[MAX][MAX]; void solve(int i,int j){ int dx[4]={-1,0,1,0}; int dy[4]={0,-1,0,1}; char c=maps[i][j]; maps[i][j]='.'; for(int k=0;k<4;k++){ int ni=i+dx[k]; int nj=j+dy[k]; if((0<=ni && ni<H) && (0<=nj && nj<W)) if(maps[ni][nj]!='.' && c==maps[ni][nj]){ //cout<<"pohe"<<endl; solve(ni,nj); } } } int main(){ int res=0; while(1){ res=0; cin>>H>>W; if(H==0 && W==0) break; for(int i=0;i<H;i++){ cin>>maps[i]; } //cout<<"hoge\n"; for(int i=0;i<H;i++) for(int j=0;j<W;j++){ if(maps[i][j]!='.'){ solve(i,j); res++; //cout<<"piyo"<<endl; } /* for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ cout<<maps[i][j]<<" "; } cout<<endl; } cout<<endl; }*/ cout<<res<<endl; //cout<<solve()<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:80:2: error: expected '}' at end of input 80 | } | ^ a.cc:43:11: note: to match this '{' 43 | int main(){ | ^
s167296823
p00118
C++
#include <bits/stdc++.h> using namespace std; char a[100][100]; int vis[110][110], m, n; int di[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; void dfs(int x,int y,char zf){ vis[x][y] = 1; for(int i = 0;i < 4;i++) { int tx = x + di[i][0]; int ty = y + di[i][1]; if(a[tx][ty] == op && tx < m && tx >= 0 && ty < n && ty >= 0 && !vis[tx][ty]) dfs(tx, ty, op); } return ; } int main() { while(scanf("%d %d", &m, &n), m && n) { memset(vis, 0, sizeof(vis)); int ans = 0; for(int i = 0;i < m;i++) scanf("%s", a[i]); for(int i = 0;i < m;i++) for(int j = 0;j < n;j++) { if(!vis[i][j]) { dfs(i, j, a[i][j]); ans++; } } printf("%d\n", ans); } return 0; }
a.cc: In function 'void dfs(int, int, char)': a.cc:14:25: error: 'op' was not declared in this scope 14 | if(a[tx][ty] == op && tx < m && tx >= 0 && ty < n && ty >= 0 && !vis[tx][ty]) | ^~
s820311695
p00118
C++
#include<iostream> #include<string> using namespace std; const int MAX = 101; int X[MAX][MAX]; //??????????¨???? int used[MAX][MAX]; //???????????????????????????????????? int ans = 0; int H, W; void input() { cin >> H >> W; if (H == 0 && W == 0) return; for (int i = 0; i < H; i++) { string ch; cin >> ch; for (int j = 0; j < W; j++) { //char ch; //scanf("%c", &ch); if (ch[j] == '@') //????????´ X[i][j] = 1; if (ch[j] == '#') //?????? X[i][j] = 2; if (ch[j] == '*') //????????? X[i][j] = 3; } } memset(used, 0, sizeof(used)); ans = 0; } void dfs(int i, int j) // { used[i][j] = ans + 1; //test int same = X[i][j]; //????????? if (j - 1 >= 0 && !used[i][j - 1] && X[i][j - 1] == same) dfs(i, j - 1); //????????? if (i - 1 >= 0 && !used[i - 1][j] && X[i - 1][j] == same) dfs(i - 1, j); //??? if (!used[i][j + 1] && X[i][j + 1] == same) dfs(i, j + 1); //??? if (!used[i + 1][j] && X[i + 1][j] == same) dfs(i + 1, j); return; } void solve() { for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { if (!used[i][j]) { dfs(i, j); ans++; } } } cout << ans << endl; } int main() { while (1) { input(); if (H == 0 && W == 0) break; solve(); } return 0; }
a.cc: In function 'void input()': a.cc:29:9: error: 'memset' was not declared in this scope 29 | memset(used, 0, sizeof(used)); | ^~~~~~ a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include<iostream> +++ |+#include <cstring> 2 | #include<string>
s544872198
p00118
C++
#include "stdafx.h" #include <iostream> #include <algorithm> using namespace std; #define MAX_H 100 // ??\??? int H, W; char graph[MAX_H + 2][MAX_H + 2]; int visited[MAX_H + 2][MAX_H + 2]; bool dfs(int bx, int by, int x, int y) { int dx[] = { 1,-1, 0, 0 }, dy[] = { 0,0, 1, -1 }; int nx = x, ny = y; bool res; if (bx == -1 && by == -1) { visited[nx][ny] = 1; } else { if (graph[bx][by] == graph[nx][ny]) { visited[nx][ny] = 1; } else { return false; } } for (int i = 0; i < 4; i++) { if (visited[nx+dx[i]][ny+dy[i]] == 0) { res = dfs(nx, ny, nx + dx[i], ny + dy[i]); } } return true; } int main() { int cnt = 0; int dust1, dust2; bool res; cin >> H >> W; for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) { cin >> graph[i][j]; visited[i][j] = 0; } } cin >> dust1 >> dust2; for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) { if (visited[i][j] == 0) { res = dfs(-1, -1, i, j); cnt++; } } } cout << cnt << endl; return 0; }
a.cc:1:10: fatal error: stdafx.h: No such file or directory 1 | #include "stdafx.h" | ^~~~~~~~~~ compilation terminated.
s034909699
p00118
C++
#include <stdio.h> int H,W; char map[100][100]; bool paint(int i,int j,char data){ if(data==' ')return false; if(i>0&&map[i][j]==map[i-1][j])paint(i-1,j); if(j>0&&map[i][j]==map[i][j-1])paint(i,j-1); if(i<=H&&map[i][j]==map[i+1][j])paint(i+1,j); if(i<=W&&map[i][j]==map[i][j+1])paint(i,j+1); return true; int main(){ int num=0; scanf("%d %d",&H,&W); for(int i=0;i<W;i++){ scanf("%s",map[i]; } for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ if(paint(i,j))num++; } } printf("%d\n",num); return 0; }
a.cc: In function 'bool paint(int, int, char)': a.cc:9:45: error: too few arguments to function 'bool paint(int, int, char)' 9 | if(i>0&&map[i][j]==map[i-1][j])paint(i-1,j); | ~~~~~^~~~~~~ a.cc:6:6: note: declared here 6 | bool paint(int i,int j,char data){ | ^~~~~ a.cc:10:45: error: too few arguments to function 'bool paint(int, int, char)' 10 | if(j>0&&map[i][j]==map[i][j-1])paint(i,j-1); | ~~~~~^~~~~~~ a.cc:6:6: note: declared here 6 | bool paint(int i,int j,char data){ | ^~~~~ a.cc:11:46: error: too few arguments to function 'bool paint(int, int, char)' 11 | if(i<=H&&map[i][j]==map[i+1][j])paint(i+1,j); | ~~~~~^~~~~~~ a.cc:6:6: note: declared here 6 | bool paint(int i,int j,char data){ | ^~~~~ a.cc:12:46: error: too few arguments to function 'bool paint(int, int, char)' 12 | if(i<=W&&map[i][j]==map[i][j+1])paint(i,j+1); | ~~~~~^~~~~~~ a.cc:6:6: note: declared here 6 | bool paint(int i,int j,char data){ | ^~~~~ a.cc:15:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 15 | int main(){ | ^~ a.cc:15:9: note: remove parentheses to default-initialize a variable 15 | int main(){ | ^~ | -- a.cc:15:9: note: or replace parentheses with braces to value-initialize a variable a.cc:15:11: error: a function-definition is not allowed here before '{' token 15 | int main(){ | ^ a.cc:31:2: error: expected '}' at end of input 31 | } | ^ a.cc:6:34: note: to match this '{' 6 | bool paint(int i,int j,char data){ | ^
s605689271
p00118
C++
#include <stdio.h> int H,W; char map[100][100]; bool paint(int i,int j){ if(data==' ')return false; if(i>0&&map[i][j]==map[i-1][j])paint(i-1,j); if(j>0&&map[i][j]==map[i][j-1])paint(i,j-1); if(i<=H&&map[i][j]==map[i+1][j])paint(i+1,j); if(i<=W&&map[i][j]==map[i][j+1])paint(i,j+1); return true; } int main(){ int num=0; scanf("%d %d",&H,&W); for(int i=0;i<W;i++){ scanf("%s",map[i]; } for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ if(paint(i,j))num++; } } printf("%d\n",num); return 0; }
a.cc: In function 'bool paint(int, int)': a.cc:7:12: error: 'data' was not declared in this scope 7 | if(data==' ')return false; | ^~~~ a.cc: In function 'int main()': a.cc:21:34: error: expected ')' before ';' token 21 | scanf("%s",map[i]; | ~ ^ | )
s117064429
p00118
C++
#include <stdio.h> int H,W; char map[100][100]; bool paint(int i,int j){ if(map[i][j]==' ')return false; if(i>0&&map[i][j]==map[i-1][j])paint(i-1,j); if(j>0&&map[i][j]==map[i][j-1])paint(i,j-1); if(i<=H&&map[i][j]==map[i+1][j])paint(i+1,j); if(i<=W&&map[i][j]==map[i][j+1])paint(i,j+1); map[i][j]=' '; return true; } int main(){ int num=0; scanf("%d %d",&H,&W); for(int i=0;i<W;i++){ scanf("%s",map[i]; } for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ if(paint(i,j))num++; } } printf("%d\n",num); return 0; }
a.cc: In function 'int main()': a.cc:22:34: error: expected ')' before ';' token 22 | scanf("%s",map[i]; | ~ ^ | )
s427736609
p00118
C++
#include<stdio.h> #include<string.h> using namespace std; int m,n,ans,v[30][30],move[4][2]= {0,1,0,-1,1,0,-1,0}; char a[30][30]; void dfs(char c,int x,int y) { for(int i = 0; i < 4; i ++) { int x1 = x+move[i][0]; int y1 = y+move[i][1]; if(x1>=0&&x1<m&&y1<n&&y1>=0&&a[x1][y1]==c&&!v[x1][y1]) { v[x1][y1]=1; dfs(c,x1,y1); } } return; } int main() { while(scanf("%d%d",&n,&m)&&n!=0&&m!=0) { getchar(); int i,j; ans=0; memset(v,0,sizeof(v)); for(i=0; i<m; i++) gets(a[i]); for(i=0; i<m; i++) for(j=0; j<n; j++) if(!v[i][j]) { dfs(a[i][j],i,j); ans++; } printf("%d\n",ans); } return 0; }
a.cc: In function 'int main()': a.cc:29:13: error: 'gets' was not declared in this scope; did you mean 'getw'? 29 | gets(a[i]); | ^~~~ | getw
s425033302
p00118
C++
#include<iostream> using namespace std; const int MAXN = 200; char B[MAXN][MAXN]; int W,H,cnt; int dx[5] = {1,0,-1,0}; int dy[5] = {0,1,0,-1}; void isStar(int y, int x) { for(int i =0 ; i<5;i++) if(B[y+dy[i]][x+dx[i]]=='*') {B[y+dy[i]][x+dx[i]]='0';isStar(y+dy[i],x+dx[i]);} } void isSharp(int y, int x) { for(int i =0 ; i<5;i++) if(B[y+dy[i]][x+dx[i]]=='#') {B[y+dy[i]][x+dx[i]]='0';isSharp(y+dy[i],x+dx[i]);} } void isAt(int y, int x) { for(int i =0 ; i<5;i++) if(B[y+dy[i]][x+dx[i]]=='@') {B[y+dy[i]][x+dx[i]]='0';isAt(y+dy[i],x+dx[i]);} } void solve() { for(int i = 1; i<=H;i++) for(int j = 1; j<=W;j++) { if(B[i][j] == '*') { B[i][j] = '0'; cnt++; isStar(i,j); } else if(B[i][j] == '#') { B[i][j] = '0'; cnt++; isSharp(i,j); } else if(B[i][j] == '@') { B[i][j] = '0'; cnt++; isAt(i,j); } } cout << cnt<<endl; } int main() { while(cin >>H>> W && W||H) { memset(B,'0',sizeof(B)); for(int i = 1; i<= H; i++) { for(int j = 1; j<= W; j++) cin >> B[i][j]; getchar(); } cnt = 0; solve(); } }
a.cc: In function 'int main()': a.cc:69:17: error: 'memset' was not declared in this scope 69 | memset(B,'0',sizeof(B)); | ^~~~~~ a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include<iostream> +++ |+#include <cstring> 2 | using namespace std;
s044945587
p00118
C++
#include <cstdio> #include <algorithm> using namespace std; const int max_n = 21; int W, H; char farm[max_n][max_n]; const int dx[4] = {-1, 0, 1, 0}; const int dy[4] = {0, -1, 0, 1}; void dfs(int x, int y, char t){ farm[x][y] = '!'; for(int i = 0; i < 4; i++){ int xx = x+dx[i]; int yy = y+dy[i]; if(xx >= 0 && xx < H && yy >= 0 && yy < W && farm[xx][yy] == t){ dfs(xx, yy , t); } } } solve(){ int ans = 0; for(int i = 0; i < H; i++){ for(int j = 0; j < W; j++){ if(farm[i][j] != '!'){ dfs(i,j,farm[i][j]); ++ans; } } } printf("%d\n", ans); } int main(){ while(scanf("%d%d", &W, &H) > 0 && H && W){ getchar(); for(int i = 0; i < H; i++){ gets(farm[i]); } solve(); } return 0; }
a.cc:22:1: error: ISO C++ forbids declaration of 'solve' with no type [-fpermissive] 22 | solve(){ | ^~~~~ a.cc: In function 'int solve()': a.cc:35:1: warning: no return statement in function returning non-void [-Wreturn-type] 35 | } | ^ a.cc: In function 'int main()': a.cc:41:13: error: 'gets' was not declared in this scope; did you mean 'getw'? 41 | gets(farm[i]); | ^~~~ | getw
s839865707
p00118
C++
#include <cstdio> #include <algorithm> using namespace std; const int max_n = 21; int W, H; char farm[max_n][max_n]; const int dx[4] = {-1, 0, 1, 0}; const int dy[4] = {0, -1, 0, 1}; void dfs(int x, int y, char t){ farm[x][y] = '!'; for(int i = 0; i < 4; i++){ int xx = x+dx[i]; int yy = y+dy[i]; if(xx >= 0 && xx < H && yy >= 0 && yy < W && farm[xx][yy] == t){ dfs(xx, yy , t); } } } void solve(){ int ans = 0; for(int i = 0; i < H; i++){ for(int j = 0; j < W; j++){ if(farm[i][j] != '!'){ dfs(i,j,farm[i][j]); ++ans; } } } printf("%d\n", ans); } int main(){ while(scanf("%d%d", &W, &H) > 0 && H && W){ getchar(); for(int i = 0; i < H; i++){ gets(farm[i]); } solve(); } return 0; }
a.cc: In function 'int main()': a.cc:41:13: error: 'gets' was not declared in this scope; did you mean 'getw'? 41 | gets(farm[i]); | ^~~~ | getw
s561918545
p00118
C++
#include <stdio.h> void dfs(char values,int H,int W,int x, int y,int item) { if(x<0 || H<=x) return; if(y<0 || W<=y) return; if(values[x][y]!=item) return; farms[x][y] = '.'; dfs(values,H,W,x+1,y,item); dfs(values,H,W,x-1,y,item); dfs(values,H,W,x,y+1,item); dfs(values,H,W,x,y-1,item); } int solve(char values,int H,int W){ int res = 0; for(int i=0;i<H;i++) for(int j=0;j<W;j++) if(farms[i][j] != '.') { dfs(values,H,W,i,j,values[i][j]); res++; } return res; } int main() { int H, W; cin >> H >> W; char values[101][101]; while (!(H == 0 && W == 0)) { for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> values[i][j]; printf("%d", solve(value,H,W)); cin >> H >> W; } return 0; }
a.cc: In function 'void dfs(char, int, int, int, int, int)': a.cc:7:18: error: invalid types 'char[int]' for array subscript 7 | if(values[x][y]!=item) return; | ^ a.cc:8:9: error: 'farms' was not declared in this scope 8 | farms[x][y] = '.'; | ^~~~~ a.cc: In function 'int solve(char, int, int)': a.cc:20:28: error: 'farms' was not declared in this scope 20 | if(farms[i][j] != '.') | ^~~~~ a.cc:22:58: error: invalid types 'char[int]' for array subscript 22 | dfs(values,H,W,i,j,values[i][j]); | ^ a.cc: In function 'int main()': a.cc:31:9: error: 'cin' was not declared in this scope 31 | cin >> H >> W; | ^~~ a.cc:38:36: error: 'value' was not declared in this scope; did you mean 'values'? 38 | printf("%d", solve(value,H,W)); | ^~~~~ | values
s173241649
p00118
C++
#include<iostream> #include <stdio.h> using namespace std; void dfs(char values,int H,int W,int x, int y,int item) { if(x<0 || H<=x) return; if(y<0 || W<=y) return; if(values[x][y]!=item) return; farms[x][y] = '.'; dfs(values,H,W,x+1,y,item); dfs(values,H,W,x-1,y,item); dfs(values,H,W,x,y+1,item); dfs(values,H,W,x,y-1,item); } int solve(char values,int H,int W){ int res = 0; for(int i=0;i<H;i++) for(int j=0;j<W;j++) if(farms[i][j] != '.') { dfs(values,H,W,i,j,values[i][j]); res++; } return res; } int main() { int H, W; cin >> H >> W; char values[101][101]; while (!(H == 0 && W == 0)) { for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> values[i][j]; printf("%d", solve(value,H,W)); cin >> H >> W; } return 0; }
a.cc: In function 'void dfs(char, int, int, int, int, int)': a.cc:9:18: error: invalid types 'char[int]' for array subscript 9 | if(values[x][y]!=item) return; | ^ a.cc:10:9: error: 'farms' was not declared in this scope 10 | farms[x][y] = '.'; | ^~~~~ a.cc: In function 'int solve(char, int, int)': a.cc:22:28: error: 'farms' was not declared in this scope 22 | if(farms[i][j] != '.') | ^~~~~ a.cc:24:58: error: invalid types 'char[int]' for array subscript 24 | dfs(values,H,W,i,j,values[i][j]); | ^ a.cc: In function 'int main()': a.cc:40:36: error: 'value' was not declared in this scope; did you mean 'values'? 40 | printf("%d", solve(value,H,W)); | ^~~~~ | values
s452679405
p00118
C++
#include<iostream> #include <stdio.h> using namespace std; /* void dfs(char values,int H,int W,int x, int y,int item) { if(x<0 || H<=x) return; if(y<0 || W<=y) return; if(values[x][y]!=item) return; farms[x][y] = '.'; dfs(values,H,W,x+1,y,item); dfs(values,H,W,x-1,y,item); dfs(values,H,W,x,y+1,item); dfs(values,H,W,x,y-1,item); } int solve(char values,int H,int W){ int res = 0; for(int i=0;i<H;i++) for(int j=0;j<W;j++) if(farms[i][j] != '.') { dfs(values,H,W,i,j,values[i][j]); res++; } return res; } */ int main() { int H, W; cin >> H >> W; char values[101][101]; while (!(H == 0 && W == 0)) { for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> values[i][j]; printf("%d", solve(value,H,W)); cin >> H >> W; } return 0; }
a.cc: In function 'int main()': a.cc:41:36: error: 'value' was not declared in this scope; did you mean 'values'? 41 | printf("%d", solve(value,H,W)); | ^~~~~ | values a.cc:41:30: error: 'solve' was not declared in this scope 41 | printf("%d", solve(value,H,W)); | ^~~~~
s327181197
p00118
C++
#include<iostream> #include <stdio.h> using namespace std; /* void dfs(char values,int H,int W,int x, int y,int item) { if(x<0 || H<=x) return; if(y<0 || W<=y) return; if(values[x][y]!=item) return; farms[x][y] = '.'; dfs(values,H,W,x+1,y,item); dfs(values,H,W,x-1,y,item); dfs(values,H,W,x,y+1,item); dfs(values,H,W,x,y-1,item); } int solve(char values,int H,int W){ int res = 0; for(int i=0;i<H;i++) for(int j=0;j<W;j++) if(farms[i][j] != '.') { dfs(values,H,W,i,j,values[i][j]); res++; } return res; } */ int main() { int H, W; std::cin >> H >> W; char values[101][101]; while (!(H == 0 && W == 0)) { for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) std::cin >> values[i][j]; std::cout << solve(value,H,W) << std::endl; std::cin >> H >> W; } return 0; }
a.cc: In function 'int main()': a.cc:41:36: error: 'value' was not declared in this scope; did you mean 'values'? 41 | std::cout << solve(value,H,W) << std::endl; | ^~~~~ | values a.cc:41:30: error: 'solve' was not declared in this scope 41 | std::cout << solve(value,H,W) << std::endl; | ^~~~~
s818044667
p00118
C++
#include<iostream> #include <stdio.h> using namespace std; /* void dfs(char values,int H,int W,int x, int y,int item) { if(x<0 && H<=x) return; if(y<0 && W<=y) return; if(values[x][y]!=item) return; farms[x][y] = '.'; dfs(values,H,W,x+1,y,item); dfs(values,H,W,x-1,y,item); dfs(values,H,W,x,y+1,item); dfs(values,H,W,x,y-1,item); } int solve(char values,int H,int W){ int res = 0; for(int i=0;i<H;i++) for(int j=0;j<W;j++) if(farms[i][j] != '.') { dfs(values,H,W,i,j,values[i][j]); res++; } return res; } */ int main() { int H, W; std::cin >> H >> W; char values[101][101]; while (!(H == 0 && W == 0)) { for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) std::cin >> values[i][j]; std::cout << solve(values,H,W) << std::endl; std::cin >> H >> W; } return 0; }
a.cc: In function 'int main()': a.cc:41:30: error: 'solve' was not declared in this scope 41 | std::cout << solve(values,H,W) << std::endl; | ^~~~~
s629973181
p00118
C++
#include <stdio.h> /* void dfs(char values,int H,int W,int x, int y,int item) { if(x<0 && H<=x) return; if(y<0 && W<=y) return; if(values[x][y]!=item) return; farms[x][y] = '.'; dfs(values,H,W,x+1,y,item); dfs(values,H,W,x-1,y,item); dfs(values,H,W,x,y+1,item); dfs(values,H,W,x,y-1,item); } int solve(char values,int H,int W){ int res = 0; for(int i=0;i<H;i++) for(int j=0;j<W;j++) if(farms[i][j] != '.') { dfs(values,H,W,i,j,values[i][j]); res++; } return res; } */ int main() { int H, W; std::cin >> H >> W; char values[101][101]; while (!(H == 0 && W == 0)) { for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) std::cin >> values[i][j]; std::cout << solve(values,H,W) << std::endl; std::cin >> H >> W; } return 0; }
a.cc: In function 'int main()': a.cc:32:14: error: 'cin' is not a member of 'std' 32 | std::cin >> H >> W; | ^~~ a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 1 | #include <stdio.h> +++ |+#include <iostream> 2 | a.cc:38:38: error: 'cin' is not a member of 'std' 38 | std::cin >> values[i][j]; | ^~~ a.cc:38:38: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:39:22: error: 'cout' is not a member of 'std' 39 | std::cout << solve(values,H,W) << std::endl; | ^~~~ a.cc:39:22: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:39:30: error: 'solve' was not declared in this scope 39 | std::cout << solve(values,H,W) << std::endl; | ^~~~~ a.cc:39:56: error: 'endl' is not a member of 'std' 39 | std::cout << solve(values,H,W) << std::endl; | ^~~~ a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 1 | #include <stdio.h> +++ |+#include <ostream> 2 | a.cc:40:22: error: 'cin' is not a member of 'std' 40 | std::cin >> H >> W; | ^~~ a.cc:40:22: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
s660225231
p00118
C++
#include <stdio.h> /* void dfs(char values,int H,int W,int x, int y,int item) { if(x<0 && H<=x) return; if(y<0 && W<=y) return; if(values[x][y]!=item) return; farms[x][y] = '.'; dfs(values,H,W,x+1,y,item); dfs(values,H,W,x-1,y,item); dfs(values,H,W,x,y+1,item); dfs(values,H,W,x,y-1,item); } int solve(char values,int H,int W){ int res = 0; for(int i=0;i<H;i++) for(int j=0;j<W;j++) if(farms[i][j] != '.') { dfs(values,H,W,i,j,values[i][j]); res++; } return res; } */ int main() { int H, W; std::cin >> H >> W; char values[101][101]; while (!(H == 0 && W == 0)) { /* for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) std::cin >> values[i][j]; std::cout << solve(values,H,W) << std::endl; std::cin >> H >> W; */ } return 0; }
a.cc: In function 'int main()': a.cc:32:14: error: 'cin' is not a member of 'std' 32 | std::cin >> H >> W; | ^~~ a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 1 | #include <stdio.h> +++ |+#include <iostream> 2 |
s564729203
p00118
C++
import sys sys.setrecursionlimit(100000) fields = [] i = 0 H, W = 0, 0 field = [] for line in sys.stdin: line = line.rstrip() if line[0] not in ["#", "@", "*"]: line = line.split(" ") tmpH = H tmpW = W H = int(line[0]) W = int(line[1]) if (len(field) != 0): fields.append([field, tmpH, tmpW]) field = [] if (H == 0 and W == 0): break else: field.append(list(line)) i += 1 def dfs(x, y, fruit): field[x][y] = "0" for dx in [-1, 0, 1]: if dx == -1: width = [0] if dx == 0: width = [-1, 0, 1] if dx == 1: width = [0] for dy in width: nx = x+dx ny = y+dy inField = (0 <= nx) and (0 <= ny) and (nx < H) and (ny < W) if inField and field[nx][ny] == fruit: dfs(nx, ny, fruit) print(fields) count = 0 for field_info in fields: field = field_info[0] H = field_info[1] W = field_info[2] for x in range(H): for y in range(W): if (field[x][y] != "0"): dfs(x, y, field[x][y]) count += 1 print(count) count = 0
a.cc:1:1: error: 'import' does not name a type 1 | import sys | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
s990641811
p00118
C++
#include <iostream> using namespace std; /* void dfs(char values,int H,int W,int x, int y,int item) { if(x<0 && H<=x) return; if(y<0 && W<=y) return; if(values[x][y]!=item) return; farms[x][y] = '.'; dfs(values,H,W,x+1,y,item); dfs(values,H,W,x-1,y,item); dfs(values,H,W,x,y+1,item); dfs(values,H,W,x,y-1,item); } int solve(char values,int H,int W){ int res = 0; for(int i=0;i<H;i++) for(int j=0;j<W;j++) if(farms[i][j] != '.') { dfs(values,H,W,i,j,values[i][j]); res++; } return res; } */ int main() { int H, W; std::cin >> H >> W; char values[101][101]; while (!(H == 0 && W == 0)) { for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) std::cin >> values[i][j]; std::cout << solve(values,H,W) << std::endl; std::cin >> H >> W; } return 0; }
a.cc: In function 'int main()': a.cc:39:30: error: 'solve' was not declared in this scope 39 | std::cout << solve(values,H,W) << std::endl; | ^~~~~
s395072985
p00118
C++
import sys sys.setrecursionlimit(100000000) def main(): process() def process(): for data in get_dataset(): print search(data) def search(data): count = 0 H = len(data) W = len(data[0]) for i in xrange(H): for j in xrange(W): if data[i][j] == '.': continue _search(i, j, H, W, data[i][j], data) count += 1 return count def _search(i, j, H, W, cell, data): data[i][j] = '.' for a in xrange(i-1, i+2): if -1 < a < H: pass else: continue for b in xrange(j-1, j+2): if -1 < b < W: pass else: continue if a != i and b != j: continue if data[a][b] == '.': continue if cell == data[a][b]: _search(a, b, H, W, cell, data) return def get_dataset(): dataset = [] while True: line = raw_input().rstrip().split() H = int(line[0]) if H == 0: break data = [] for i in xrange(H): data.append(list(raw_input().rstrip())) dataset.append(data) return dataset if __name__ == '__main__': main()
a.cc:65:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes 65 | if __name__ == '__main__': | ^~~~~~~~~~ a.cc:1:1: error: 'import' does not name a type 1 | import sys | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
s558624734
p00118
C++
#include <iostream> using namespace std; int dir[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}}; char table[100][100]; void Dfs(vector<vector<char> >& table, int h, int w, int x, int y) { char cur = table[x][y]; table[x][y] = 'X'; for (int i = 0; i < 4; ++i) { int next_x = x + dir[i][0]; int next_y = y + dir[i][1]; if (next_x >= 0 && next_x < w && next_y >=0 && next_y < h && table[next_x][next_y] == cur) { Dfs(table, h, w, next_x, next_y); } } } int main() { int h, w; while (cin >> h >> w) { if (h == 0 || w == 0) break; for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { cin >> table[i][j]; } } int ret = 0; for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { if (table[i][j] != 'X') { Dfs(table, h, w, i, j); ++ret; } } } cout << ret << endl; } return 0; }
a.cc:8:6: error: variable or field 'Dfs' declared void 8 | void Dfs(vector<vector<char> >& table, int h, int w, int x, int y) { | ^~~ a.cc:8:10: error: 'vector' was not declared in this scope 8 | void Dfs(vector<vector<char> >& table, int h, int w, int x, int y) { | ^~~~~~ a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' 1 | #include <iostream> +++ |+#include <vector> 2 | a.cc:8:17: error: 'vector' was not declared in this scope 8 | void Dfs(vector<vector<char> >& table, int h, int w, int x, int y) { | ^~~~~~ a.cc:8:17: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' a.cc:8:24: error: expected primary-expression before 'char' 8 | void Dfs(vector<vector<char> >& table, int h, int w, int x, int y) { | ^~~~ a.cc:8:40: error: expected primary-expression before 'int' 8 | void Dfs(vector<vector<char> >& table, int h, int w, int x, int y) { | ^~~ a.cc:8:47: error: expected primary-expression before 'int' 8 | void Dfs(vector<vector<char> >& table, int h, int w, int x, int y) { | ^~~ a.cc:8:54: error: expected primary-expression before 'int' 8 | void Dfs(vector<vector<char> >& table, int h, int w, int x, int y) { | ^~~ a.cc:8:61: error: expected primary-expression before 'int' 8 | void Dfs(vector<vector<char> >& table, int h, int w, int x, int y) { | ^~~ a.cc: In function 'int main()': a.cc:35:11: error: 'Dfs' was not declared in this scope 35 | Dfs(table, h, w, i, j); | ^~~
s861574791
p00118
C++
#include<iostream> using namespace std; char table[100][100]; int W, H; const int direction[4][2] = {{ -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 }}; void dfs(int x, int y, char cur) { table[x][y] = 'x'; for (int i = 0; i < 4; ++i) { int nx = x + direction[i][0]; int ny = y + direction[i][1]; if (nx >= 0 && nx < W && ny >= 0 && ny < H && table[nx][ny] == tree) { dfs(nx, ny, tree); } } } int main() { while (cin >> H >> W, W > 0) { int res = 0; int x, y; for (y = 0; y < H; ++y) { for (x = 0; x < W; ++x) { cin >> table[x][y]; } } for (y = 0; y < H; ++y) { for (x = 0; x < W; ++x) { if (table[x][y] != 'x') { dfs(x, y, table[x][y]); ++res; } } } cout << res << endl; } return 0; }
a.cc: In function 'void dfs(int, int, char)': a.cc:16:68: error: 'tree' was not declared in this scope; did you mean 'free'? 16 | if (nx >= 0 && nx < W && ny >= 0 && ny < H && table[nx][ny] == tree) | ^~~~ | free
s753132222
p00118
C++
#include<iostream> using namespace std; char table[100][100]; int W, H; const int direction[4][2] = {{ -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 }}; void Dfs(int x, int y, char cur) { table[x][y] = 'X'; for (int i = 0; i < 4; ++i) { int next_x = x + dir[i][0]; int next_y = y + dir[i][1]; if (next_x >= 0 && next_x < w && next_y >=0 && next_y < h && table[next_x][next_y] == cur) { Dfs(next_x, next_y, cur); } } } int main() { while (cin >> H >> W, W > 0) { int res = 0; int x, y; for (y = 0; y < H; ++y) { for (x = 0; x < W; ++x) { cin >> table[x][y]; } } for (y = 0; y < H; ++y) { for (x = 0; x < W; ++x) { if (table[x][y] != 'x') { Dfs(x, y, table[x][y]); ++res; } } } cout << res << endl; } return 0; }
a.cc: In function 'void Dfs(int, int, char)': a.cc:13:22: error: 'dir' was not declared in this scope; did you mean 'div'? 13 | int next_x = x + dir[i][0]; | ^~~ | div a.cc:15:33: error: 'w' was not declared in this scope 15 | if (next_x >= 0 && next_x < w | ^ a.cc:16:35: error: 'h' was not declared in this scope 16 | && next_y >=0 && next_y < h | ^
s860791130
p00118
C++
#include<iostream> using namespace std; char table[100][100]; int W, H; const int dir[4][2] = {{ -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 }}; void Dfs(int x, int y, char cur) { table[x][y] = 'X'; for (int i = 0; i < 4; ++i) { int next_x = x + dir[i][0]; int next_y = y + dir[i][1]; if (next_x >= 0 && next_x < w && next_y >=0 && next_y < h && table[next_x][next_y] == cur) { Dfs(next_x, next_y, cur); } } } int main() { while (cin >> H >> W, W > 0) { int res = 0; int x, y; for (y = 0; y < H; ++y) { for (x = 0; x < W; ++x) { cin >> table[x][y]; } } for (y = 0; y < H; ++y) { for (x = 0; x < W; ++x) { if (table[x][y] != 'x') { Dfs(x, y, table[x][y]); ++res; } } } cout << res << endl; } return 0; }
a.cc: In function 'void Dfs(int, int, char)': a.cc:15:33: error: 'w' was not declared in this scope 15 | if (next_x >= 0 && next_x < w | ^ a.cc:16:35: error: 'h' was not declared in this scope 16 | && next_y >=0 && next_y < h | ^
s643269563
p00118
C++
#include<iostream> using namespace std; char Array[200000][200000]; int count; void DFS(int h,int w,char c){ if(Array[h][w] != c){ return; } char tmp=Array[h][w]; Array[h][w] = '.'; DFS(h-1,w,tmp); DFS(h,w+1,tmp); DFS(h+1,w,tmp); DFS(h,w-1,tmp); } int main(){ int H,W; while(1){ cin >> H >> W; if(H == 0 && W == 0){ break; } for(int i=1;i<=H;i++){ for(int j=1;j<=W;j++){ cin >> Array[i][j]; } } for(int i=1;i<=H;i++){ for(int j=1;j<=W;j++){ if(Array[i][j] != '.'){ count++; DFS(i,j,Array[i][j]); } } } cout << count << endl; } return 0; }
/tmp/ccgoxiMR.o: in function `main': a.cc:(.text+0x1bc): relocation truncated to fit: R_X86_64_PC32 against symbol `count' defined in .bss section in /tmp/ccgoxiMR.o a.cc:(.text+0x1c5): relocation truncated to fit: R_X86_64_PC32 against symbol `count' defined in .bss section in /tmp/ccgoxiMR.o a.cc:(.text+0x21b): relocation truncated to fit: R_X86_64_PC32 against symbol `count' defined in .bss section in /tmp/ccgoxiMR.o collect2: error: ld returned 1 exit status
s392767528
p00118
C++
#include <iostream> using namespace std; char T[102][102]; void DFS(int y,int x,char f){ if(T[y][x]!=f) return; T[y][x]='?'; DFS(y-1,x ,f); DFS(y-1,x+1,f); DFS(y ,x+1,f); DFS(y+1,x+1,f); DFS(y+1,x ,f); DFS(y+1,x-1,f); DFS(y ,x-1,f); DFS(y-1,x-1,f); } int main(){ int h,w; cin>>h>>w; for(int i=1;i<=h;i++){ for(int j=1;j<=w;j++){ cin>>T[i][j]; } } int count=0; for(int i=1;i<=h;i++){ for(int j=1;j<=w;j++){ if(T[i][j]=='@'){ count++; DFS(i,j,@); } } } for(int i=1;i<=h;i++){ for(int j=1;j<=w;j++){ if(T[i][j]=='#'){ count++; DFS(i,j,#); } } } for(int i=1;i<=h;i++){ for(int j=1;j<=w;j++){ if(T[i][j]=='*'){ count++; DFS(i,j,*); } } } cout<<count<<endl; return 0; }
a.cc:40:41: error: stray '@' in program 40 | DFS(i,j,@); | ^ a.cc:50:41: error: stray '#' in program 50 | DFS(i,j,#); | ^ a.cc: In function 'int main()': a.cc:40:42: error: expected primary-expression before ')' token 40 | DFS(i,j,@); | ^ a.cc:50:42: error: expected primary-expression before ')' token 50 | DFS(i,j,#); | ^ a.cc:60:42: error: expected primary-expression before ')' token 60 | DFS(i,j,*); | ^
s695762791
p00118
C++
#include<iostream> using namespace std; char HW[101][101]; void DFS(int Y,int X,char c) { if(HW[Y][X]=='0'||HW[Y][X]!=c) return; HW[Y][X]='0'; DFS(Y-1,X,c); DFS(Y,X+1,c); DFS(Y+1,X,c); DFS(Y,X-1,c); } int main() { int H,W; while(1){ cin>>H>>W; if(H==0&&W==0) break; for(int y=1;y<=H+1;y++){ for(int x=1;x<=W;x++){ cin>>HW[y][x]; int count=0; for(int y=1;y<=H;y++){ for(int x=1;x<=W;x++){ if((HW[y][x]=='@')||(HW[y][x]=='#')||(HW[y][x]=='*')){ count++; DFS(y,x,HW[y][x]); } } } cout<<count<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:46:2: error: expected '}' at end of input 46 | } | ^ a.cc:22:17: note: to match this '{' 22 | while(1){ | ^ a.cc:46:2: error: expected '}' at end of input 46 | } | ^ a.cc:20:1: note: to match this '{' 20 | { | ^
s719390317
p00118
C++
#include<iostream> #include<algorithm> #include<utility> #include<cmath> #include<string> using namespace std; char map[101][101]; void dfs(int x,int y,char a){ if(x>a||x<0){ return; } else if(y>b||y<0){ return; } if(map[x][y]== a){ map[x][y]='x'; } else{ return; } dfs(x+1,y,a); dfs(x-1,y,a); dfs(x,y+1,a); dfs(x,y-1,a); } int main(){ int a,b; int ans; ans=0; while(cin>>a>>b){ if(a==0&&b==0){ return 0; } for(int i=0;i<a;i++){ for(int j=0;j<b;i++){ cin >> map[i][j]; } } for(int i=0;i<a;i++){ for(int j=0;j<b;i++){ if(map[i][j]!='x'){ dfs(i,j,map[i][j]); ans+=1; } } } } cout << ans << endl; return 0; }
a.cc: In function 'void dfs(int, int, char)': a.cc:15:13: error: 'b' was not declared in this scope 15 | else if(y>b||y<0){ | ^
s667233845
p00118
C++
#include<iostream> #include<algorithm> #include<utility> #include<cmath> #include<string> using namespace std; char map[101][101]; void dfs(int x,int y,char a){ if(x>a||x<0){ return; } else if(y>b||y<0){ return; } if(map[x][y]== a){ map[x][y]='x'; } else{ return; } dfs(x+1,y,a); dfs(x-1,y,a); dfs(x,y+1,a); dfs(x,y-1,a); } int main(){ int a,b; int ans; ans=0; while(cin>>a>>b){ if(a==0&&b==0){ return 0; } for(int i=0;i<a;i++){ for(int j=0;j<b;i++){ cin >> map[i][j]; } } for(int i=0;i<a;i++){ for(int j=0;j<b;i++){ if(map[i][j]!='x'){ dfs(i,j,map[i][j]); ans+=1; } } } } cout << ans << endl; return 0; }
a.cc: In function 'void dfs(int, int, char)': a.cc:15:13: error: 'b' was not declared in this scope 15 | else if(y>b||y<0){ | ^
s967985314
p00118
C++
#include<iostream> #include<algorityhm> using namespace std; int x,y; int map(int a,int b,char s){ if(a>x||a<0){ return; } if(b>y||b<0){ return; } if(s=='@'||s=='#'||s=='*'){ s='X'; } if(s!='X'){ map(a+1,b,s); map(a-1,b,s); map(a,b-1,s); map(a,b+1,s); } } int main(){ char t[100][100]; while(cin>>x>>y){ if(x==0&&y==0){ return 0; } int ans=0; for(int i=0;i<y;i++){ for(int j=0;j<x;j++){ cin>>t[i][j]; } } for(int i=0;i<y;i++){ for(int j=0;j<x;j++){ if(t[i][j]!='X'){ map(i,j,t[i][j]); } else{ ans+=1; } } } cout << ans << endl; } return 0; }
a.cc:2:9: fatal error: algorityhm: No such file or directory 2 | #include<algorityhm> | ^~~~~~~~~~~~ compilation terminated.
s038698481
p00118
C++
#include<iostream> using namespace std; int x,y; int map(int a,int b,char s){ if(a>x||a<0){ return; } if(b>y||b<0){ return; } if(s=='@'||s=='#'||s=='*'){ s='X'; } if(s!='X'){ map(a+1,b,s); map(a-1,b,s); map(a,b-1,s); map(a,b+1,s); } } int main(){ char t[100][100]; while(cin>>x>>y){ if(x==0&&y==0){ return 0; } int ans=0; for(int i=0;i<y;i++){ for(int j=0;j<x;j++){ cin>>t[i][j]; } } for(int i=0;i<y;i++){ for(int j=0;j<x;j++){ if(t[i][j]!='X'){ map(i,j,t[i][j]); } else{ ans+=1; } } } cout << ans << endl; } return 0; }
a.cc: In function 'int map(int, int, char)': a.cc:9:5: error: return-statement with no value, in function returning 'int' [-fpermissive] 9 | return; | ^~~~~~ a.cc:12:5: error: return-statement with no value, in function returning 'int' [-fpermissive] 12 | return; | ^~~~~~ a.cc:23:1: warning: control reaches end of non-void function [-Wreturn-type] 23 | } | ^
s194281750
p00118
C++
#include<iostream> #include<cstdio> #include<cstring> using namespace std; const int maxn=1000,inf=0x3f3f3f3f; char maze[maxn][maxn]; int h,w,ans=0; void dfs(int x,int y,char sig){ maze[x][y]='.'; for(int i=-1;i<=1;i++){ for(int j=-1;j<=1;j++){ if(i*j==0){ int nx=x+i,ny=y+j; if(0<=nx&&nx<h&&0<=ny&&ny<w&&maze[nx][ny]==sig) dfs(nx,ny,sig); } } } } int main() { //freopen("read.txt", "r", stdin); while(cin>>h>>w&&h&&w){ for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin>>maze[i][j]; for(int i=0;i<h;i++) for(int j=0;j<w;j++){ if(maze[i][j]!='.'){ char c=maze[i][j]; dfs(i,j,c); ans++; } } cout<<ans<<endl; ans=0 } //fclose(stdin); return 0; }
a.cc: In function 'int main()': a.cc:36:22: error: expected ';' before '}' token 36 | ans=0 | ^ | ; 37 | } | ~
s967496735
p00118
C++
def infection(i, j,H, W, moji): if farm[i][j] == moji: farm[i][j] = '+' if j + 1 < W : infection(i, j + 1,H,W,moji) if i + 1 < H : infection(i + 1, j,H,W,moji) if j - 1 >= 0 :infection(i, j - 1,H,W,moji) if i - 1 >= 0 :infection(i - 1, j,H,W,moji) while(1): farm = [] cnt = 0 H, W = list(map(int, input().split())) if H == 0 and W == 0: break for i in range(H): farm.append(list(input())) for i in range(H): for j in range(W): if farm[i][j] == '+': continue cnt += 1 infection(i, j,H,W,moji) print(cnt)
a.cc:1:1: error: 'def' does not name a type 1 | def infection(i, j,H, W, moji): | ^~~
s753059028
p00118
C++
#include <stdio.h> #include <string.h> int k,t=0; char a[100][100]; void bfs(int i,int j,int n,int m,char x) { k=0; if (i<0||j<0||i>=n||j>=m||a[i][j]=='\0'||a[i][j]!=x) return ; a[i][j]='\0'; bfs(i-1,j,n,m,x); bfs(i+1,j,n,m,x); bfs(i,j-1,n,m,x); bfs(i,j+1,n,m,x); k++; } int main (void) { int n,m,i,j; while (scanf ("%d%d",&n,&m)!=EOF) { if (n==0&&m==0) return 0; getchar(); for (i=0;i<n;i++) gets(a[i]); for (i=0;i<n;i++) for (j=0;j<m;j++) { bfs(i,j,n,m,a[i][j]); if (k!=0) t++; } printf ("%d\n",t); } return 0; }
a.cc: In function 'int main()': a.cc:24:17: error: 'gets' was not declared in this scope; did you mean 'getw'? 24 | gets(a[i]); | ^~~~ | getw
s123910824
p00118
C++
#include<iostream> #include<algorithm> #include<cstring> char arr[105][105],temp; int n,m; int direction[4][2]={{0,1},{-1,0},{0,-1},{1,0}}; using namespace std; void bfs(int i,int j) { if(i<0||i>=m||j<0||j>=n) return; if(arr[i][j]!=temp) return; arr[i][j]='.'; for(int k=0;k<4;k++) bfs(i+direction[k][0],j+direction[k][1]); } int main() { while(scanf("%d%d",&m,&n)==2&&m!=0&&n!=0) { int cnt=0; getchar(); for(int i=0;i<m;i++) gets(arr[i]); for(int i=0;i<m;i++) { for(int j=0;j<n;j++) { if(arr[i][j]!='.') { temp=arr[i][j]; bfs(i,j); cnt++; } } } cout << cnt <<endl; } }
a.cc: In function 'int main()': a.cc:29:20: error: 'gets' was not declared in this scope; did you mean 'getw'? 29 | gets(arr[i]); | ^~~~ | getw
s622029179
p00118
C++
/* Á·Ï°Ì⣺Property Distribution_AOJ 0118 */ #include <cstdio> using namespace std; char maze[25][25]; int W, H; int sx, sy; int dx[]={1,0,-1,0}; int dy[]={0,1,0,-1}; int count; void dfs1(int x, int y) { for(int i=0; i<4; i++) { int nx=x+dx[i]; int ny=y+dy[i]; if(nx>=0&&nx<W&&ny>=0&&ny<H&&maze[nx][ny]=='@') { maze[nx][ny]='.'; dfs1(nx,ny); } } return ; } void dfs2(int x, int y) { for(int i=0; i<4; i++) { int nx=x+dx[i]; int ny=y+dy[i]; if(nx>=0&&nx<W&&ny>=0&&ny<H&&maze[nx][ny]=='*') { maze[nx][ny]='.'; dfs2(nx,ny); } } return ; } void dfs3(int x, int y) { for(int i=0; i<4; i++) { int nx=x+dx[i]; int ny=y+dy[i]; if(nx>=0&&nx<W&&ny>=0&&ny<H&&maze[nx][ny]=='#') { maze[nx][ny]='.'; dfs3(nx,ny); } } return ; } int main() { while(scanf("%d%d", &H, &W)!=EOF) { count=0; if(W==0&&H==0) break; getchar(); for(int i=0; i<W; i++) gets(maze[i]); for(int i=0; i<W; i++) for(int j=0; j<H; j++) if(maze[i][j]=='@') { sx=i; sy=j; count++; dfs1(sx, sy); } else if(maze[i][j]=='*') { sx=i; sy=j; count++; dfs2(sx, sy); } else if(maze[i][j]=='#') { sx=i; sy=j; count++; dfs3(sx, sy); } printf("%d\n", count); } return 0; }
a.cc: In function 'int main()': a.cc:66:25: error: 'gets' was not declared in this scope; did you mean 'getw'? 66 | gets(maze[i]); | ^~~~ | getw
s920805652
p00118
C++
/* Á·Ï°Ì⣺Property Distribution_AOJ 0118 */ #include <cstdio> using namespace std; char maze[25][25]; int W, H; int sx, sy; int dx[]={1,0,-1,0}; int dy[]={0,1,0,-1}; int count; void dfs1(int x, int y) { for(int i=0; i<4; i++) { int nx=x+dx[i]; int ny=y+dy[i]; if(nx>=0&&nx<W&&ny>=0&&ny<H&&maze[nx][ny]=='@') { maze[nx][ny]='.'; dfs1(nx,ny); } } return ; } void dfs2(int x, int y) { for(int i=0; i<4; i++) { int nx=x+dx[i]; int ny=y+dy[i]; if(nx>=0&&nx<W&&ny>=0&&ny<H&&maze[nx][ny]=='*') { maze[nx][ny]='.'; dfs2(nx,ny); } } return ; } void dfs3(int x, int y) { for(int i=0; i<4; i++) { int nx=x+dx[i]; int ny=y+dy[i]; if(nx>=0&&nx<W&&ny>=0&&ny<H&&maze[nx][ny]=='#') { maze[nx][ny]='.'; dfs3(nx,ny); } } return ; } int main() { while(scanf("%d%d", &H, &W)!=EOF) { count=0; if(W==0&&H==0) break; getchar(); for(int i=0; i<W; i++) gets(maze[i]); for(int i=0; i<W; i++) for(int j=0; j<H; j++) if(maze[i][j]=='@') { sx=i; sy=j; count++; dfs1(sx, sy); } else if(maze[i][j]=='*') { sx=i; sy=j; count++; dfs2(sx, sy); } else if(maze[i][j]=='#') { sx=i; sy=j; count++; dfs3(sx, sy); } printf("%d\n", count); } return 0; }
a.cc: In function 'int main()': a.cc:66:25: error: 'gets' was not declared in this scope; did you mean 'getw'? 66 | gets(maze[i]); | ^~~~ | getw