Submission #868629

# Submission time Handle Problem Language Result Execution time Memory
868629 2023-11-01T03:31:58 Z NeroZein Nautilus (BOI19_nautilus) C++17
100 / 100
112 ms 1104 KB
#include "bits/stdc++.h"
using namespace std;

#ifdef Nero
#include "Deb.h"
#else
#define deb(...)
#endif

const int N = 501;

char c[N][N]; 
bitset<N> dp[N], ndp[N], ok[N]; 

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> c[i][j];
      ok[i][j] = (c[i][j] == '.'); 
    }
  }
  string s;
  cin >> s; 
  for (int i = 1; i <= n; ++i) {
    dp[i] = ok[i]; 
  }
  for (int p = 0; p < k; ++p) {
    for (int i = 1; i <= n; ++i) {
      if (s[p] == 'W') {
        ndp[i] |= dp[i] >> 1; 
      } else if (s[p] == 'E') {
        ndp[i] |= dp[i] << 1; 
      } else if (s[p] == 'N') {
        ndp[i - 1] |= dp[i]; 
      } else if (s[p] == 'S') {
        ndp[i + 1] |= dp[i]; 
      } else {
        ndp[i] |= (dp[i] >> 1) | (dp[i] << 1); 
        ndp[i - 1] |= dp[i];
        ndp[i + 1] |= dp[i];
      }
    }
    for (int i = 1; i <= n; ++i) {
      ndp[i] &= ok[i]; 
      dp[i] = ndp[i];
      ndp[i].reset();
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    ans += dp[i].count();
  }
  cout << ans << '\n'; 
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 536 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 536 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 472 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 600 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 536 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 472 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 600 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 73 ms 1036 KB Output is correct
23 Correct 75 ms 1040 KB Output is correct
24 Correct 72 ms 860 KB Output is correct
25 Correct 73 ms 860 KB Output is correct
26 Correct 72 ms 856 KB Output is correct
27 Correct 93 ms 856 KB Output is correct
28 Correct 96 ms 860 KB Output is correct
29 Correct 93 ms 860 KB Output is correct
30 Correct 104 ms 1036 KB Output is correct
31 Correct 93 ms 1036 KB Output is correct
32 Correct 110 ms 856 KB Output is correct
33 Correct 107 ms 856 KB Output is correct
34 Correct 112 ms 1104 KB Output is correct
35 Correct 107 ms 860 KB Output is correct
36 Correct 110 ms 860 KB Output is correct