Submission #1151561

#TimeUsernameProblemLanguageResultExecution timeMemory
1151561tntNautilus (BOI19_nautilus)C++20
29 / 100
3 ms584 KiB
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")

#define pb push_back                    
#define ll long long
#define all(v) v.begin(),v.end()

int mod = 1e8;
const int N = 1e6;
const int inf = 2e9;
pair <int,int> w[300][300];
signed main(){
    //freopen("shuffle.in", "r", stdin);
    //freopen("shuffle.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n,m,d;
    cin >> n >> m >> d;
    char a[n + 1][m + 1];
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            cin >> a[i][j];
            w[i][j].first = i,w[i][j].second = j;
        }
    }
    string s;
    cin >> s;
    for(int t = 0; t < s.size(); t++){
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= m; j++){
                int x = w[i][j].first,y = w[i][j].second;
                if(a[i][j] == '#' || x == -1) continue;
                if(s[t] == 'E'){
                    if(y + 1 > m || a[x][y + 1] == '#') w[i][j].first = -1;
                    else w[i][j].second++;
                }
                else if(s[t] == 'W'){
                    if(y - 1 < 1 || a[x][y - 1] == '#') w[i][j].first = -1;
                    else w[i][j].second--;
                }
                else if(s[t] == 'N'){
                    if(x - 1 < 1 || a[x - 1][y] == '#') w[i][j].first = -1;
                    else w[i][j].first--;
                }
                else{
                    if(x + 1 > n || a[x + 1][y] == '#') w[i][j].first = -1;
                    else w[i][j].first++;
                }
            }
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(a[i][j] == '#' || w[i][j].first == -1) continue;
            ans++;
        }
    }
    cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...