Submission #22644

# Submission time Handle Problem Language Result Execution time Memory
22644 2017-04-30T06:06:21 Z dried chocochip on Daegu asphalt(#897, suzy, zych1751, Acka) Young Zebra (KRIII5_YZ) C++11
2 / 7
33 ms 10916 KB
#include<bits/stdc++.h>

using namespace std;

int n, m;
char mmap[400][400];
int cc[400][400], c_idx;
bool visited[400][400];
int cc_sz[400*400+2];
int di[4] = {-1, 0, 1, 0};
int dj[4] = {0, 1, 0, -1};

void dfs(int i, int j)
{
	visited[i][j] = true;
	cc[i][j] = c_idx;
	cc_sz[c_idx]++;

	for(int k = 0; k < 4; k++)
	{
		int ni = i+di[k], nj = j+dj[k];
		if(ni < 0)	ni += n;
		if(ni >= n)	ni -= n;
		if(nj < 0)	nj += m;
		if(nj >= m)	nj -= m;

		if(!visited[ni][nj] && mmap[i][j] == mmap[ni][nj])
			dfs(ni, nj);
	}
}

int main()
{
	scanf("%d %d", &n, &m);
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			scanf(" %c", &mmap[i][j]);

	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			if(!visited[i][j])
			{
				c_idx++;
				dfs(i, j);
			}

	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
			printf("%d ", cc_sz[cc[i][j]]);
		printf("\n");
	}
	return 0;
}

Compilation message

YZ.cpp: In function 'int main()':
YZ.cpp:34:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
                        ^
YZ.cpp:37:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf(" %c", &mmap[i][j]);
                             ^
# Verdict Execution time Memory Grader output
1 Partially correct 23 ms 9168 KB Output is partially correct
2 Partially correct 23 ms 8328 KB Output is partially correct
3 Partially correct 33 ms 8264 KB Output is partially correct
4 Partially correct 19 ms 5732 KB Output is partially correct
5 Partially correct 29 ms 4472 KB Output is partially correct
6 Partially correct 26 ms 4132 KB Output is partially correct
7 Partially correct 29 ms 7820 KB Output is partially correct
8 Partially correct 23 ms 5356 KB Output is partially correct
9 Partially correct 29 ms 7824 KB Output is partially correct
10 Partially correct 29 ms 5352 KB Output is partially correct
11 Partially correct 29 ms 10904 KB Output is partially correct
12 Partially correct 26 ms 10916 KB Output is partially correct
13 Partially correct 33 ms 7656 KB Output is partially correct
14 Partially correct 26 ms 6876 KB Output is partially correct
15 Partially correct 29 ms 4888 KB Output is partially correct
16 Partially correct 29 ms 6448 KB Output is partially correct
17 Partially correct 29 ms 7160 KB Output is partially correct
18 Partially correct 26 ms 7156 KB Output is partially correct
19 Correct 33 ms 3580 KB Output is correct
20 Partially correct 23 ms 5740 KB Output is partially correct
21 Partially correct 29 ms 8392 KB Output is partially correct
22 Partially correct 29 ms 8280 KB Output is partially correct
23 Partially correct 26 ms 4660 KB Output is partially correct
24 Partially correct 33 ms 4756 KB Output is partially correct
25 Partially correct 26 ms 5956 KB Output is partially correct
26 Partially correct 0 ms 3580 KB Output is partially correct
27 Partially correct 0 ms 3580 KB Output is partially correct
28 Partially correct 0 ms 3584 KB Output is partially correct
29 Partially correct 0 ms 3584 KB Output is partially correct
30 Partially correct 0 ms 3580 KB Output is partially correct
31 Partially correct 0 ms 3580 KB Output is partially correct
32 Partially correct 0 ms 3580 KB Output is partially correct
33 Partially correct 0 ms 3580 KB Output is partially correct
34 Partially correct 0 ms 3580 KB Output is partially correct
35 Partially correct 0 ms 3580 KB Output is partially correct
36 Partially correct 0 ms 3784 KB Output is partially correct
37 Partially correct 0 ms 3664 KB Output is partially correct
38 Correct 0 ms 3580 KB Output is correct
39 Partially correct 0 ms 3672 KB Output is partially correct
40 Partially correct 0 ms 3796 KB Output is partially correct