Submission #1211118

#TimeUsernameProblemLanguageResultExecution timeMemory
1211118dwuyNautilus (BOI19_nautilus)C++20
0 / 100
0 ms320 KiB
#include <bits/stdc++.h>
using namespace std;

const int MX = 10;
int n, m, k;
string s;
string a[MX];
bitset<MX> b[MX];
bitset<MX> vist[2][MX];

int32_t main(){
    ios_base::sync_with_stdio(false);
    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++) b[i][j] = a[i][j] == '.';
        vist[1][i] = b[i];
    }
    cin >> s;

    for(int i=0; i<k; i++){
        int t = i&1;
        if(s[i] == 'E' || s[i] == '?') {
            for(int i=1; i<=n; i++){
                vist[t][i] = vist[t][i] | (vist[!t][i] << 1);
            }
        }
        if(s[i] == 'W' || s[i] == '?'){
            for(int i=1; i<=n; i++){
                vist[t][i] = vist[t][i] | (vist[!t][i] >> 1);
            }    
        }
        if(s[i] == 'S' || s[i] == '?'){
            for(int i=1; i<n; i++){
                vist[t][i + 1] = vist[t][i + 1] | vist[!t][i];
            }
        }
        if(s[i] == 'N' || s[i] == '?'){
            for(int i=1; i<n; i++){
                vist[t][i] = vist[t][i] | vist[!t][i + 1];

            }
        }
        for(int i=1; i<=n; i++){
            vist[t][i] = vist[t][i] & b[i];
            vist[!t][i] = 0;
        } 
    }

    int ans = 0;
    for(int i=1; i<=n; i++){
        ans += vist[(k - 1)&1][i].count();
    }

    cout << ans;

    return 0;
}

/*

4 3 2
...
.#.
.#.
...
DN


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

*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...