Submission #402940

# Submission time Handle Problem Language Result Execution time Memory
402940 2021-05-12T15:03:43 Z rama_pang Nautilus (BOI19_nautilus) C++17
100 / 100
189 ms 660 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);

  int R, C, M;
  cin >> R >> C >> M;
  vector<bitset<505>> A(R, 0);
  for (int i = 0; i < R; i++) {
    for (int j = 0; j < C; j++) {
      char c;
      cin >> c;
      if (c == '.') {
        A[i][j] = 1;
      }
    }
  }

  string S;
  cin >> S;
  vector<bitset<505>> dp = A;
  for (auto s : S) {
    vector<bitset<505>> ndp(R, 0);
    if (s == 'N' || s == '?') {
      for (int i = 0; i < R - 1; i++) {
        ndp[i] |= dp[i + 1];
      }
    }
    if (s == 'S' || s == '?') {
      for (int i = 1; i < R; i++) {
        ndp[i] |= dp[i - 1];
      }
    }
    if (s == 'E' || s == '?') {
      for (int i = 0; i <= R + 1; i++) {
        ndp[i] |= dp[i] << 1;
      }
    }
    if (s == 'W' || s == '?') {
      for (int i = 0; i < R; i++) {
        ndp[i] |= dp[i] >> 1;
      }
    }
    for (int i = 0; i < R; i++) {
      ndp[i] &= A[i];
    }
    dp = ndp;
  }

  int ans = 0;
  for (int i = 0; i < R; i++) {
    ans += dp[i].count();
  }
  cout << ans << '\n';
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 328 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 2 ms 324 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 328 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 2 ms 324 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
22 Correct 99 ms 656 KB Output is correct
23 Correct 102 ms 588 KB Output is correct
24 Correct 98 ms 588 KB Output is correct
25 Correct 99 ms 644 KB Output is correct
26 Correct 97 ms 660 KB Output is correct
27 Correct 140 ms 588 KB Output is correct
28 Correct 141 ms 588 KB Output is correct
29 Correct 142 ms 648 KB Output is correct
30 Correct 145 ms 652 KB Output is correct
31 Correct 140 ms 648 KB Output is correct
32 Correct 174 ms 588 KB Output is correct
33 Correct 175 ms 648 KB Output is correct
34 Correct 189 ms 644 KB Output is correct
35 Correct 177 ms 588 KB Output is correct
36 Correct 172 ms 588 KB Output is correct