Submission #22709

#TimeUsernameProblemLanguageResultExecution timeMemory
22709최숭실 (#40)Young Zebra (KRIII5_YZ)C++11
2 / 7
36 ms14936 KiB
#include <cstdio> #define LIM 0 #define EDGE_MIN (LIM - LIM) #define EDGE_MAX (LIM * 2) int n, m; char map[410][410]; int check[410 * (LIM * 2+1)][410 * (LIM * 2 + 1)]; int id[410 * (LIM * 2 + 1)][410 * (LIM * 2 + 1)]; int count[410 * 410]; int xx[] = { 1,-1,0,0 }; int yy[] = { 0,0,1,-1 }; char get_col(int xi, int yi) { return map[xi % n][yi % m]; } int dfs(int xi, int yi, char col, int idx) { if (id[xi][yi] != 0) return 0; if(count[idx] != -1) count[idx]++; id[xi][yi] = idx; for (int i = 0; i < 4; i++) { int ni = xi + xx[i], mi = yi + yy[i]; if (ni < 0) ni += n; if (ni >= n) ni -= n; if (mi < 0) mi += m; if (mi >= m) mi -= m; if (get_col(xi, yi) == get_col(ni, mi)) { int val = dfs(ni, mi, col, idx); if (val == -1) count[idx] = -1; } } return 0; } int main() { scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) { scanf("%s", map[i]); } int myid = 1; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { dfs(i, j, map[i][j], myid++); } } for (int i = 0; i < n; i++, printf("\n")) { for (int j = 0; j < m; j++) { printf("%d ", count[id[i][j]]); } } }

Compilation message (stderr)

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