Submission #981150

#TimeUsernameProblemLanguageResultExecution timeMemory
981150ShaShiNautilus (BOI19_nautilus)C++17
100 / 100
163 ms1108 KiB
#include <bits/stdc++.h>
// #define int long long
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define kill(x) cout << x << endl, exit(0);
#define endl "\n"

 
using namespace std;
typedef long long ll;
typedef long double ld;
 

const int MAXN = (int)500 + 7;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;


int n, m, q, tmp, tmp2, tmp3, tmp4, ans, k, u, v, w, flag;
int arr[MAXN][MAXN], arr2[MAXN][MAXN];
// bool bad[MAXN][MAXN];
int dx[] = {-1, 1, 0, 0}, dy[] = {0, 0, -1, 1};
int cnt[][4] = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}, {1, 1, 1, 1}};
string s; char ch;

bitset<MAXN*MAXN> bst, bad;



int32_t main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n >> m >> k;
    
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=m; j++) {
            cin >> ch;

            if (ch == '.') bst[(i-1)*(m+1)+j] = bad[(i-1)*(m+1)+j] = 1;
        }
    }

    cin >> s;

    for (int i=0; i<k; i++) {
        if (s[i] == 'N') {
            bst = (bst>>(m+1)) & bad;
        } else if (s[i] == 'S') {
            bst = (bst<<(m+1)) & bad;
        } else if (s[i] == 'E') {
            bst = (bst<<1) & bad;
        } else if (s[i] == 'W') {
            bst = (bst>>1) & bad;
        } else {
            bst = ((bst>>(m+1)) | ((bst<<(m+1))) | (bst<<1) | (bst>>1))&bad;
        }
    }
    
    cout << bst.count() << endl;

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...