답안 #802022

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
802022 2023-08-02T09:09:01 Z Soumya1 Nautilus (BOI19_nautilus) C++17
100 / 100
139 ms 668 KB
#include <bits/stdc++.h>
#ifdef __LOCAL__
  #include <debug_local.h>
#endif
using namespace std;
using bs = bitset<501>;
void testCase() {
  int r, c, m;
  cin >> r >> c >> m;
  vector<bs> ok(r);
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      char c;
      cin >> c;
      if (c == '.') ok[i][j] = 1;
    }
  }
  string s;
  cin >> s;
  vector<bs> dp = ok, ndp(r);
  for (int i = 0; i < m; i++) {
    for (int i = 0; i < r; i++) ndp[i].reset();
    if (s[i] == 'E' || s[i] == '?') {
      for (int i = 0; i < r; i++) {
        ndp[i] |= dp[i] << 1;
      }
    }
    if (s[i] == 'W' || s[i] == '?') {
      for (int i = 0; i < r; i++) {
        ndp[i] |= dp[i] >> 1;
      }
    }
    if (s[i] == 'N' || s[i] == '?') {
      for (int i = 0; i < r - 1; i++) {
        ndp[i] |= dp[i + 1];
      }
    }
    if (s[i] == 'S' || s[i] == '?') {
      for (int i = 1; i < r; i++) {
        ndp[i] |= dp[i - 1];
      }
    }
    for (int i = 0; i < r; i++) {
      ndp[i] &= ok[i];
    }
    swap(dp, ndp);
  }
  int ans = 0;
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) ans += dp[i][j];
  }
  cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  testCase();
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 324 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 304 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 1 ms 324 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 324 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 304 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 1 ms 324 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 72 ms 660 KB Output is correct
23 Correct 74 ms 652 KB Output is correct
24 Correct 78 ms 656 KB Output is correct
25 Correct 82 ms 656 KB Output is correct
26 Correct 69 ms 652 KB Output is correct
27 Correct 102 ms 656 KB Output is correct
28 Correct 117 ms 652 KB Output is correct
29 Correct 103 ms 656 KB Output is correct
30 Correct 103 ms 596 KB Output is correct
31 Correct 101 ms 608 KB Output is correct
32 Correct 128 ms 660 KB Output is correct
33 Correct 131 ms 668 KB Output is correct
34 Correct 139 ms 660 KB Output is correct
35 Correct 131 ms 668 KB Output is correct
36 Correct 128 ms 596 KB Output is correct