Submission #362959

#TimeUsernameProblemLanguageResultExecution timeMemory
362959Kenzo_1114Nautilus (BOI19_nautilus)C++17
100 / 100
223 ms748 KiB
#include<bits/stdc++.h> using namespace std; const int MAXN = 510; int n, m, q; char cur; bitset<MAXN> dp[2][MAXN], base[MAXN]; int main () { scanf("%d %d %d", &n, &m, &q); for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) { scanf(" %c", &cur); dp[0][i][j] = base[i][j] = (cur == '.'); } for(int K = 1, k; K <= q; K++) { k = K & 1; scanf(" %c", &cur); for(int i = 1; i <= n; i++) { if(cur == 'N') dp[k][i] = dp[!k][i + 1]; if(cur == 'E') dp[k][i] = dp[!k][i] << 1; if(cur == 'S') dp[k][i] = dp[!k][i - 1]; if(cur == 'W') dp[k][i] = dp[!k][i] >> 1; if(cur == '?') dp[k][i] = dp[!k][i + 1] | (dp[!k][i] >> 1) | dp[!k][i - 1] | (dp[!k][i] << 1); dp[k][i] &= base[i]; } } int ans = 0; for(int i = 1; i <= n; i++) ans += dp[q & 1][i].count(); printf("%d\n", ans); }

Compilation message (stderr)

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