Submission #22508

# Submission time Handle Problem Language Result Execution time Memory
22508 2017-04-30T05:10:40 Z dried chocochip on Daegu asphalt(#897, suzy, zych1751, Acka) Young Zebra (KRIII5_YZ) C++11
0 / 7
93 ms 21888 KB
#include<bits/stdc++.h>

using namespace std;

int n, m;
char mmap[1200][1200];
int cc[1200][1200], c_idx;
bool visited[1200][1200];
int cc_sz[1200*1200+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 >= 3*n || nj < 0 || nj >= 3*m)	continue;
		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 < 3*n; i++)
		for(int j = 0; j < 3*m; j++)
			mmap[i][j] = mmap[i%n][j%m];

	for(int i = 0; i < 3*n; i++)
		for(int j = 0; j < 3*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++)
		{
			bool check = false;
			for(int ddi = 0; ddi < 3; ddi++)
				for(int ddj = 0; ddj < 3; ddj++)
				{
					if(ddi == 1 && ddj == 1)	continue;
					if(cc[i+n][j+m] == cc[i+ddi*n][j+ddj*m])
						check = true;
				}

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

Compilation message

YZ.cpp: In function 'int main()':
YZ.cpp:51:9: warning: variable 'check' set but not used [-Wunused-but-set-variable]
    bool check = false;
         ^
YZ.cpp:30: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:33: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 93 ms 21888 KB Output is partially correct
2 Incorrect 79 ms 21220 KB Output isn't correct
3 Halted 0 ms 0 KB -