제출 #99447

#제출 시각아이디문제언어결과실행 시간메모리
99447mzhaoDango Maker (JOI18_dango_maker)C++11
13 / 100
3 ms512 KiB
#include <bits/stdc++.h> using namespace std; #ifdef DEBUG #define D(x...) printf(x) #else #define D(x...) #endif int R, C, G[3100][3100], ans; bool f[3100][3100][2]; // 0 is horizontal, 1 is vertical bool vis[3100][3100][2]; int col[2]; void dfs(int x, int y, int z, int c) { assert(x >= 0 && x < R && y >= 0 && y < C); if (vis[x][y][z]) return; vis[x][y][z] = 1; col[c]++; if (z) { if (f[x][y][0]) dfs(x, y, 0, !c); if (y > 0 && f[x+1][y-1][0]) dfs(x+1, y-1, 0, !c); if (y > 1 && f[x+2][y-2][0]) dfs(x+2, y-2, 0, !c); } else { if (f[x][y][1]) dfs(x, y, 1, !c); if (x > 0 && f[x-1][y+1][1]) dfs(x-1, y+1, 1, !c); if (x > 1 && f[x-2][y+2][1]) dfs(x-2, y+2, 1, !c); } } int main() { scanf("%d%d", &R, &C); for (int i = 0; i < R; i++) { char A; scanf("\n"); for (int j = 0; j < C; j++) { scanf("%c", &A); if (A == 'G') G[i][j] = 1; if (A == 'W') G[i][j] = 2; } } for (int i = 0; i < R; i++) { for (int j = 0; j < C; j++) { if (i < R-2 && G[i][j] == 0 && G[i+1][j] == 1 && G[i+2][j] == 2) f[i][j][1] = 1; if (j < C-2 && G[i][j] == 0 && G[i][j+1] == 1 && G[i][j+2] == 2) f[i][j][0] = 1; } } for (int i = 0; i < R; i++) { for (int j = 0; j < C; j++) D("%d", f[i][j][0]); D("\n"); } D("\n"); for (int i = 0; i < R; i++) { for (int j = 0; j < C; j++) D("%d", f[i][j][1]); D("\n"); } D("\n"); for (int i = 0; i < R; i++) { for (int j = 0; j < C; j++) { for (int k = 0; k < 2; k++) { if (!vis[i][j][k] && f[i][j][k]) { col[0] = col[1] = 0; dfs(i, j, k, 0); ans += max(col[0], col[1]); } } } } printf("%d\n", ans); }

컴파일 시 표준 에러 (stderr) 메시지

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:33:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &R, &C);
  ~~~~~^~~~~~~~~~~~~~~~
dango_maker.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("\n");
   ~~~~~^~~~~~
dango_maker.cpp:38:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%c", &A);
    ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...