Submission #414988

# Submission time Handle Problem Language Result Execution time Memory
414988 2021-05-31T11:42:03 Z Hideo Nautilus (BOI19_nautilus) C++17
100 / 100
144 ms 984 KB
#include <bits/stdc++.h>
using namespace std;

#define all(s) s.begin(), s.end()
#define ll long long
#define fr first
#define sc second
#define pb push_back
#define mk make_pair

const int N = 507;
const int INF = 1e9 + 7;

string a[N];
string s;
int n, m, k;
bitset < 507 > dp[N][2], b[N];

main (){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        a[i] = ' ' + a[i];
        for (int j = 1; j <= m; j++){
            if (a[i][j] == '.'){
                dp[i][0][j - 1] = 1;
                b[i][j - 1] = 1;
            }
        }
    }
    cin >> s;
    int cur = 0;
    for (int c = 0; c < k; c++){
        cur ^= 1;
        for (int i = 1; i <= n; i++){
            if (s[c] == 'N'){
                dp[i][cur] = dp[i + 1][cur ^ 1];
            }
            if (s[c] == 'W'){
                dp[i][cur] = dp[i][cur ^ 1] >> 1;
                dp[i][cur][m - 1] = 0;
            }
            if (s[c] == 'E'){
                dp[i][cur] = dp[i][cur ^ 1] << 1;
            }
            if (s[c] == 'S'){
                dp[i][cur] = dp[i - 1][cur ^ 1];
            }
            if (s[c] == '?'){
                dp[i][cur] = (dp[i][cur ^ 1] >> 1) ;
                dp[i][cur][m - 1] = 0;
                dp[i][cur] |= dp[i - 1][cur ^ 1];
                dp[i][cur] |= dp[i][cur ^ 1] << 1;
                dp[i][cur] |= dp[i + 1][cur ^ 1];
            }
            dp[i][cur] &= b[i];
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= m; j++){
//            cout << dp[i][cur][j - 1];
            if (dp[i][cur][j - 1])
                ans++;
        }
//        cout << endl;
    }
    cout << ans;
}

//5 9 7
//...##....
//..#.##..#
//..#....##
//.##...#..
//....#....
//WS?EE??

Compilation message

nautilus.cpp:19:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   19 | main (){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 2 ms 332 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 2 ms 332 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 1 ms 332 KB Output is correct
10 Correct 1 ms 464 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 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 340 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 2 ms 332 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 1 ms 332 KB Output is correct
10 Correct 1 ms 464 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 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 340 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
22 Correct 72 ms 928 KB Output is correct
23 Correct 72 ms 984 KB Output is correct
24 Correct 69 ms 844 KB Output is correct
25 Correct 68 ms 844 KB Output is correct
26 Correct 71 ms 860 KB Output is correct
27 Correct 108 ms 936 KB Output is correct
28 Correct 119 ms 932 KB Output is correct
29 Correct 114 ms 844 KB Output is correct
30 Correct 113 ms 932 KB Output is correct
31 Correct 122 ms 844 KB Output is correct
32 Correct 140 ms 928 KB Output is correct
33 Correct 138 ms 964 KB Output is correct
34 Correct 138 ms 844 KB Output is correct
35 Correct 144 ms 936 KB Output is correct
36 Correct 142 ms 916 KB Output is correct