Submission #22417

# Submission time Handle Problem Language Result Execution time Memory
22417 2017-04-30T04:30:42 Z 크리콘 B번 문제는 그리디로 풀려요(#918, imsifile) Young Zebra (KRIII5_YZ) C++
2 / 7
46 ms 13552 KB
#include<stdio.h>

int N, M;
char ba[555][555]; int dap[555][555];
int chk1[555][555]/*, chk2[1010][1010]*/;

int cnt, xx[4]={0,0,1,-1}, yy[4]={1,-1,0,0};
void dfs1(int x, int y, char gr, int ty, int val){
	if(chk1[x][y] != ty || ba[x][y] != gr) return;
	chk1[x][y]++; cnt++;
	if(val) dap[x][y]=val;
	for(int i=0; i<4; i++)dfs1((x+N+xx[i])%N, (y+M+yy[i])%M, gr, ty, val);
}
/*
int err, col;
void dfs2(int x, int y, char gr){
	if(x<0 || y<0 || x>=2*N || y>=2*M){
		x=(x+2*N)%(2*N), y=(y+2*M)%(2*M);
		if(chk2[x][y] == col) err=1;
		return;
	}
	if(chk2[x][y] != 0 || ba[x%N][y%M] != gr) return;
	chk2[x][y]=col;
	for(int i=0; i<4; i++)dfs2(x+xx[i], y+yy[i], gr);
}*/

int main(){
	scanf("%d%d\n", &N, &M);
	for(int i=0; i<N; i++)gets(ba[i]);
	for(int i=0; i<N; i++){
		for(int j=0; j<M; j++){
			if(chk1[i][j])continue;
			cnt=0, dfs1(i, j, ba[i][j], 0, 0);
			dfs1(i, j, ba[i][j], 1, cnt);
		}
	}
/*	for(int i=0; i<2*N; i++){
		for(int j=0; j<2*M; j++){
			if(chk2[i][j])continue;
			col++, err=0, dfs2(i, j, ba[i][j]);
			if(err)dfs1(i%N, j%M, ba[i][j], 2, -1);
		}
	}*/
	for(int i=0; i<N; i++){
		for(int j=0; j<M; j++)printf("%d ", dap[i][j]);
		puts("");
	}
	return 0;
}

Compilation message

YZ.cpp: In function 'int main()':
YZ.cpp:29:24: warning: 'char* gets(char*)' is deprecated [-Wdeprecated-declarations]
  for(int i=0; i<N; i++)gets(ba[i]);
                        ^
In file included from YZ.cpp:1:0:
/usr/include/stdio.h:638:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^
YZ.cpp:29:24: warning: 'char* gets(char*)' is deprecated [-Wdeprecated-declarations]
  for(int i=0; i<N; i++)gets(ba[i]);
                        ^
In file included from YZ.cpp:1:0:
/usr/include/stdio.h:638:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^
YZ.cpp:29:34: warning: 'char* gets(char*)' is deprecated [-Wdeprecated-declarations]
  for(int i=0; i<N; i++)gets(ba[i]);
                                  ^
In file included from YZ.cpp:1:0:
/usr/include/stdio.h:638:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^
YZ.cpp:28:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d\n", &N, &M);
                         ^
YZ.cpp:29:35: warning: ignoring return value of 'char* gets(char*)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0; i<N; i++)gets(ba[i]);
                                   ^
/tmp/ccZkGT9s.o: In function `main':
YZ.cpp:(.text.startup+0x4e): warning: the `gets' function is dangerous and should not be used.
# Verdict Execution time Memory Grader output
1 Partially correct 26 ms 8676 KB Output is partially correct
2 Partially correct 29 ms 6340 KB Output is partially correct
3 Partially correct 36 ms 8040 KB Output is partially correct
4 Partially correct 33 ms 5844 KB Output is partially correct
5 Partially correct 29 ms 5432 KB Output is partially correct
6 Partially correct 33 ms 4524 KB Output is partially correct
7 Partially correct 36 ms 11176 KB Output is partially correct
8 Partially correct 33 ms 9528 KB Output is partially correct
9 Partially correct 26 ms 9672 KB Output is partially correct
10 Partially correct 39 ms 7560 KB Output is partially correct
11 Partially correct 26 ms 10272 KB Output is partially correct
12 Partially correct 39 ms 13552 KB Output is partially correct
13 Partially correct 36 ms 9220 KB Output is partially correct
14 Partially correct 36 ms 5040 KB Output is partially correct
15 Partially correct 29 ms 7336 KB Output is partially correct
16 Partially correct 39 ms 6128 KB Output is partially correct
17 Partially correct 33 ms 8636 KB Output is partially correct
18 Partially correct 33 ms 8632 KB Output is partially correct
19 Correct 36 ms 3824 KB Output is correct
20 Partially correct 43 ms 6320 KB Output is partially correct
21 Partially correct 39 ms 10284 KB Output is partially correct
22 Partially correct 43 ms 10132 KB Output is partially correct
23 Partially correct 43 ms 6060 KB Output is partially correct
24 Partially correct 46 ms 5132 KB Output is partially correct
25 Partially correct 26 ms 7028 KB Output is partially correct
26 Partially correct 0 ms 3824 KB Output is partially correct
27 Partially correct 0 ms 3824 KB Output is partially correct
28 Partially correct 0 ms 3876 KB Output is partially correct
29 Partially correct 0 ms 3876 KB Output is partially correct
30 Partially correct 0 ms 3824 KB Output is partially correct
31 Partially correct 0 ms 3824 KB Output is partially correct
32 Partially correct 0 ms 3824 KB Output is partially correct
33 Partially correct 0 ms 3824 KB Output is partially correct
34 Partially correct 0 ms 3824 KB Output is partially correct
35 Partially correct 0 ms 3824 KB Output is partially correct
36 Partially correct 3 ms 4128 KB Output is partially correct
37 Partially correct 3 ms 3864 KB Output is partially correct
38 Correct 3 ms 3824 KB Output is correct
39 Partially correct 0 ms 3948 KB Output is partially correct
40 Partially correct 0 ms 4144 KB Output is partially correct