Submission #314080

# Submission time Handle Problem Language Result Execution time Memory
314080 2020-10-18T08:00:38 Z BeanZ Nautilus (BOI19_nautilus) C++14
100 / 100
211 ms 768 KB
// I_Love_LPL
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N = 505;
bitset<N> a[N], dp[N][2];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    if (fopen("A.inp", "r")){
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    }
    ll r, c, m;
    cin >> r >> c >> m;
    for (int i = 1; i <= r; i++){
        for (int j = 1; j <= c; j++){
            char s;
            cin >> s;
            if (s == '.') a[i][j] = 1;
        }
        dp[i][0] = a[i];
        //cout << dp[i][0] << endl;
    }
    string s;
    cin >> s;
    for (int i = 0; i < m; i++){
        for (int j = 1; j <= r; j++){
            if (s[i] == 'N') dp[j][(i + 1) & 1] = dp[j + 1][i & 1];
            if (s[i] == 'W') dp[j][(i + 1) & 1] = dp[j][i & 1] >> 1;
            if (s[i] == 'E') dp[j][(i + 1) & 1] = dp[j][i & 1] << 1;
            if (s[i] == 'S') dp[j][(i + 1) & 1] = dp[j - 1][i & 1];
            if (s[i] == '?') dp[j][(i + 1) & 1] = dp[j - 1][i & 1] | dp[j + 1][i & 1] | (dp[j][i & 1] >> 1) | (dp[j][i & 1] << 1);
            dp[j][(i + 1) & 1] &= a[j];
            //cout << j << " " << i << " " << dp[j][i & 1] << endl;
        }
    }
    ll ans = 0;
    for (int i = 1; i <= r; i++){
        ans = ans + dp[i][m & 1].count();
    }
    cout << ans;
}
/*
2 3 3
..#
#.#
?S?
*/

Compilation message

nautilus.cpp: In function 'int main()':
nautilus.cpp:12:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   12 |         freopen("test.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
nautilus.cpp:13:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   13 |         freopen("test.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 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 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 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 99 ms 640 KB Output is correct
23 Correct 106 ms 640 KB Output is correct
24 Correct 98 ms 640 KB Output is correct
25 Correct 99 ms 768 KB Output is correct
26 Correct 94 ms 640 KB Output is correct
27 Correct 156 ms 744 KB Output is correct
28 Correct 161 ms 640 KB Output is correct
29 Correct 159 ms 764 KB Output is correct
30 Correct 161 ms 640 KB Output is correct
31 Correct 158 ms 640 KB Output is correct
32 Correct 207 ms 640 KB Output is correct
33 Correct 204 ms 640 KB Output is correct
34 Correct 211 ms 760 KB Output is correct
35 Correct 206 ms 640 KB Output is correct
36 Correct 206 ms 640 KB Output is correct