Submission #22426

#TimeUsernameProblemLanguageResultExecution timeMemory
22426최숭실 (#40)Young Zebra (KRIII5_YZ)C++14
0 / 7
306 ms136396 KiB
#include<iostream> using namespace std; char Dy[2810][2810]; long long int visit[2810][2810]; char Data[410][410]; long long int ans[410][410]; long long int dir[4][2] = { 0,1,1,0,0,-1,-1,0 }; long long int num = 1; long long int cnt[160010]; long long int flag = 0; long long int n, m; void dfs(long long int y, long long int x, char base) { for (long long int i = 0; i < 4; i++) { if (y + dir[i][0] < 0) { if (Data[n - 1][x%m] == base) flag = 1; continue; } if (y + dir[i][0] == 7 * n) { if (Data[0][x%m] == base) flag = 1; continue; } if (x + dir[i][1] < 0) { if (Data[y%n][m - 1] == base) flag = 1; continue; } if (x + dir[i][1] == 7 * m) { if (Data[y%n][0] == base) flag = 1; continue; } if (Dy[y + dir[i][0]][x + dir[i][1]] == base && visit[y+dir[i][0]][x+dir[i][1]]==0) { cnt[num]++; visit[y + dir[i][0]][x + dir[i][1]] = num; dfs(y + dir[i][0], x + dir[i][1], base); } } } int main() { scanf("%lld %lld", &n, &m); for (long long int i = 0; i < n; i++) scanf("%s", Data[i]); long long int start_n = 3*n; long long int start_m = 3*m; for (long long int i = 0; i < 7 * n; i++) for (long long int j = 0; j < 7 * m; j++) Dy[i][j] = Data[i%n][j%m]; for (long long int i = start_n; i < start_n + n; i++) { for (long long int j = start_m; j < start_m + m; j++) { flag = 0; if (visit[i][j]!=0)continue; cnt[num]++; visit[i][j] = num; dfs(i, j, Dy[i][j]); if (flag) cnt[num] = -1; num++; } } for (long long int i = 0; i < n; i++) { for (long long int j = 0; j < m; j++) { //cout << cnt[visit[i + start_n][j + start_m]] << " "; if (cnt[visit[i + start_n][j + start_m]] == -1) cnt[visit[i + start_n][j + start_m]] = 0; printf("%lld ", cnt[visit[i + start_n][j + start_m]]); } if (i != n - 1) printf("\n"); } return 0; }

Compilation message (stderr)

YZ.cpp: In function 'int main()':
YZ.cpp:51:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld", &n, &m);
                            ^
YZ.cpp:53:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s", Data[i]);
                       ^
#Verdict Execution timeMemoryGrader output
Fetching results...