Submission #723460

#TimeUsernameProblemLanguageResultExecution timeMemory
723460lovrotNautilus (BOI19_nautilus)C++17
66 / 100
1077 ms1200 KiB
#include <cstdio> #include <cstring> #pragma GCC optimize("Ofast") using namespace std; const int N = 510; const int lx[4] = {1, -1, 0, 0}; const int ly[4] = {0, 0, -1, 1}; int n, m, q; bool dp[2][N][N], mat[N][N]; int main() { scanf("%d%d%d", &n, &m, &q); for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) { char c; scanf(" %c", &c); dp[0][i][j] = c == '.'; mat[i][j] = !dp[0][i][j]; } bool flag = 1; for(int t = 0; t < q; t++) { char c; scanf(" %c", &c); // printf("%c\n", c); int x = -1; if(c == 'S') x = 1; if(c == 'N') x = 0; if(c == 'W') x = 3; if(c == 'E') x = 2; if(x == -1) { memset(dp[flag], 0, sizeof(dp[flag])); for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) for(int k = 0; k < 4; k++) dp[flag][i][j] |= !mat[i][j] && dp[!flag][i + lx[k]][j + ly[k]]; } else { for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) dp[flag][i][j] = !mat[i][j] && dp[!flag][i + lx[x]][j + ly[x]]; } flag ^= 1; } int sol = 0; for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) sol += dp[!flag][i][j]; printf("%d\n", sol); return 0; }

Compilation message (stderr)

nautilus.cpp: In function 'int main()':
nautilus.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  scanf("%d%d%d", &n, &m, &q);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
nautilus.cpp:20:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |    scanf(" %c", &c);
      |    ~~~~~^~~~~~~~~~~
nautilus.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |   scanf(" %c", &c);
      |   ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...