Submission #310069

# Submission time Handle Problem Language Result Execution time Memory
310069 2020-10-05T13:58:13 Z Pety Nautilus (BOI19_nautilus) C++14
100 / 100
179 ms 888 KB
#include<bits/stdc++.h>
#define pii pair<int, int>

using namespace std;

typedef long long ll;

int n, m, k;
bitset<502>v[502];
bitset<502>dp[2][502];


int main()
{
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      char ch;
      cin >> ch;
      if (ch == '.') {
        dp[1][i][j] = 1;
        v[i][j] = 1;
      }
    }
  string s;
  cin >> s;
  for (int ii = 0; ii < k; ii++) {
    for (int j = 1; j <= n;j++) {
      dp[ii % 2][j] = dp[1 - ii % 2][j];
    }
    for (int j = 1; j <= n; j++) {
      if (s[ii] == 'E')
        dp[ii % 2][j] = (dp[1 - ii % 2][j] << 1);
      if (s[ii] == 'W')
        dp[ii % 2][j] = (dp[1 - ii % 2][j] >> 1);
      if (s[ii] == 'N')
        dp[ii % 2][j] = (dp[1 - ii % 2][j + 1]);
      if (s[ii] == 'S')
        dp[ii % 2][j] = (dp[1 - ii % 2][j - 1]);
      if (s[ii] == '?') {
        dp[ii % 2][j] = (dp[1 - ii % 2][j] << 1);
        dp[ii % 2][j] |= (dp[1 - ii % 2][j] >> 1);
        dp[ii % 2][j] |= (dp[1 - ii % 2][j + 1]);
        dp[ii % 2][j] |= (dp[1 - ii % 2][j - 1]);
      }
      dp[ii % 2][j] &= (v[j]);
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      ans += dp[(k - 1) % 2][i][j];
  cout << ans;
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 103 ms 640 KB Output is correct
23 Correct 106 ms 760 KB Output is correct
24 Correct 101 ms 760 KB Output is correct
25 Correct 99 ms 760 KB Output is correct
26 Correct 101 ms 636 KB Output is correct
27 Correct 144 ms 760 KB Output is correct
28 Correct 145 ms 716 KB Output is correct
29 Correct 145 ms 760 KB Output is correct
30 Correct 144 ms 640 KB Output is correct
31 Correct 142 ms 632 KB Output is correct
32 Correct 177 ms 760 KB Output is correct
33 Correct 177 ms 888 KB Output is correct
34 Correct 179 ms 852 KB Output is correct
35 Correct 176 ms 640 KB Output is correct
36 Correct 177 ms 640 KB Output is correct