# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
22830 |
2017-04-30T07:46:05 Z |
dried chocochip on Daegu asphalt(#897, suzy, zych1751, Acka) |
Young Zebra (KRIII5_YZ) |
C++11 |
|
43 ms |
11076 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};
int mod(int val, int m)
{
while(val < 0)
val += m*m*m;
return val%m;
}
int si, sj;
bool cc_inf[400*400+2];
void dfs(int i, int j)
{
int ii = mod(i, n), jj = mod(j, m);
visited[ii][jj] = true;
cc[ii][jj] = c_idx;
cc_sz[c_idx]++;
for(int k = 0; k < 4; k++)
{
int ni = i+di[k], nj = j+dj[k];
int nii = mod(ni, n), njj = mod(nj, m);
if(!(si == ni && sj == nj))
if(si == nii && sj == njj)
cc_inf[c_idx] = true;
if(!visited[nii][njj] && mmap[ii][jj] == mmap[nii][njj])
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])
{
si = i, sj = j;
c_idx++;
dfs(i, j);
}
for(int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
printf("%d ", cc_inf[cc[i][j]] ? -1 : cc_sz[cc[i][j]]);
printf("\n");
}
return 0;
}
Compilation message
YZ.cpp: In function 'int main()':
YZ.cpp:46: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:49: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 |
Correct |
26 ms |
9320 KB |
Output is correct |
2 |
Correct |
26 ms |
8484 KB |
Output is correct |
3 |
Correct |
33 ms |
8424 KB |
Output is correct |
4 |
Partially correct |
33 ms |
5884 KB |
Output is partially correct |
5 |
Partially correct |
26 ms |
4628 KB |
Output is partially correct |
6 |
Correct |
23 ms |
4288 KB |
Output is correct |
7 |
Correct |
29 ms |
7976 KB |
Output is correct |
8 |
Partially correct |
29 ms |
5512 KB |
Output is partially correct |
9 |
Correct |
36 ms |
7980 KB |
Output is correct |
10 |
Correct |
33 ms |
5508 KB |
Output is correct |
11 |
Correct |
43 ms |
11064 KB |
Output is correct |
12 |
Correct |
39 ms |
11076 KB |
Output is correct |
13 |
Partially correct |
29 ms |
7816 KB |
Output is partially correct |
14 |
Partially correct |
33 ms |
7036 KB |
Output is partially correct |
15 |
Correct |
29 ms |
5044 KB |
Output is correct |
16 |
Partially correct |
29 ms |
6608 KB |
Output is partially correct |
17 |
Partially correct |
33 ms |
7316 KB |
Output is partially correct |
18 |
Correct |
29 ms |
7312 KB |
Output is correct |
19 |
Correct |
36 ms |
3736 KB |
Output is correct |
20 |
Correct |
29 ms |
5892 KB |
Output is correct |
21 |
Correct |
36 ms |
8548 KB |
Output is correct |
22 |
Correct |
33 ms |
8436 KB |
Output is correct |
23 |
Correct |
39 ms |
4816 KB |
Output is correct |
24 |
Correct |
36 ms |
4912 KB |
Output is correct |
25 |
Correct |
36 ms |
6116 KB |
Output is correct |
26 |
Correct |
0 ms |
3736 KB |
Output is correct |
27 |
Correct |
0 ms |
3736 KB |
Output is correct |
28 |
Correct |
0 ms |
3740 KB |
Output is correct |
29 |
Correct |
0 ms |
3740 KB |
Output is correct |
30 |
Correct |
0 ms |
3736 KB |
Output is correct |
31 |
Correct |
0 ms |
3736 KB |
Output is correct |
32 |
Partially correct |
0 ms |
3736 KB |
Output is partially correct |
33 |
Partially correct |
0 ms |
3736 KB |
Output is partially correct |
34 |
Correct |
0 ms |
3736 KB |
Output is correct |
35 |
Correct |
0 ms |
3736 KB |
Output is correct |
36 |
Correct |
0 ms |
3936 KB |
Output is correct |
37 |
Correct |
0 ms |
3824 KB |
Output is correct |
38 |
Correct |
0 ms |
3736 KB |
Output is correct |
39 |
Correct |
0 ms |
3828 KB |
Output is correct |
40 |
Correct |
0 ms |
3956 KB |
Output is correct |