답안 #655873

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
655873 2022-11-05T20:23:43 Z 600Mihnea Nautilus (BOI19_nautilus) C++17
100 / 100
158 ms 428 KB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("O2")
#pragma GCC optimize("O1")

using namespace std;

typedef long long ll;

const int N = 500 + 7;
int n;
int m;
int sdim;
bitset<N> valid_place[N];
bitset<N> ok[N];
bitset<N> nok[N];
string s;

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m >> sdim;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    for (int j = 1; j <= m; j++) {
      char ch = s[j - 1];
      valid_place[i][j] = (ch == '.');
    }
  }
  cin >> s;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      ok[i][j] = valid_place[i][j];
    }
  }
  for (int itp = 0; itp < sdim; itp++) {
    char ch = s[itp];
    for (int i = 1; i <= n; i++) {
      nok[i] = 0;
    }
    if (ch == 'N' || ch == '?') {
      for (int i = 1; i <= n; i++) {
        nok[i] |= ok[i + 1];
      }
    }
    if (ch == 'S' || ch == '?') {
      for (int i = 1; i <= n; i++) {
        nok[i] |= ok[i - 1];
      }
    }
    if (ch == 'E' || ch == '?') {
      for (int i = 1; i <= n; i++) {
        nok[i] |= (ok[i] << 1);
      }
    }
    if (ch == 'W' || ch == '?') {
      for (int i = 1; i <= n; i++) {
        nok[i] |= (ok[i] >> 1);
      }
    }
    for (int i = 1; i <= n; i++) {
      ok[i] = nok[i] & valid_place[i];
    }
  }
  int sol = 0;
  for (int i = 1; i <= n; i++) {
    sol += ok[i].count();
  }
  cout << sol << "\n";
  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 340 KB Output is correct
5 Correct 1 ms 340 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 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 220 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 272 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 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 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 220 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 272 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 96 ms 340 KB Output is correct
23 Correct 96 ms 340 KB Output is correct
24 Correct 94 ms 416 KB Output is correct
25 Correct 94 ms 420 KB Output is correct
26 Correct 95 ms 340 KB Output is correct
27 Correct 130 ms 340 KB Output is correct
28 Correct 129 ms 340 KB Output is correct
29 Correct 131 ms 424 KB Output is correct
30 Correct 134 ms 416 KB Output is correct
31 Correct 128 ms 424 KB Output is correct
32 Correct 154 ms 420 KB Output is correct
33 Correct 155 ms 424 KB Output is correct
34 Correct 155 ms 424 KB Output is correct
35 Correct 154 ms 428 KB Output is correct
36 Correct 158 ms 340 KB Output is correct