Submission #957796

# Submission time Handle Problem Language Result Execution time Memory
957796 2024-04-04T10:40:14 Z batsukh2006 Nautilus (BOI19_nautilus) C++17
0 / 100
1 ms 344 KB
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<map>
#include<string>
#include<algorithm>
#include<vector>
#include<string.h>
#include<utility>
#include<set>
#include<cmath>
#include<queue>
#include<deque>
#include<functional>
#include<stack>
#include<limits.h>
#include<iomanip>
#include<unordered_map> 
#include<numeric>
#include<tuple>
#include<bitset>
using namespace std;
 
#define MOD 1000000007
#define int long long
#define ss second
#define ff first
#define endl '\n'
typedef pair<int,int> pp;
signed main(){
    // freopen("file.in", "r", stdin);
    // freopen("file.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int r,c,m; cin>>r>>c>>m;
    bitset<500> a[500],dp[500];
    for(int i=0; i<r; i++){
    	for(int j=0; j<c; j++){
    		char c; cin>>c;
    		if(c=='#'){
				a[i][j]=0;
			}else{
    			a[i][j]=1;
    			dp[i][j]=1;
    		}
    	}
    }
    string s; cin>>s;
    for(int k=0; k<m; k++){
    	if(s[k]=='E'){
    		for(int i=0; i<r; i++){
    			dp[i]=(a[i]&(dp[i]>>1));
    		}
    	}else if(s[k]=='N'){
    		for(int i=0; i<r-1; i++){
    			dp[i]=(a[i]&dp[i+1]);
    		}
    	}else if(s[k]=='W'){
    		for(int i=0; i<r; i++){
    			dp[i]=(a[i]&(dp[i]<<1));
    		}
    	}else if(s[k]=='S'){
    		for(int i=r-1; i>0; i--){
    			dp[i]=(a[i]&dp[i-1]);
    		}
    	}else{
    		bitset<500> tmp[500];
    		for(int i=0; i<r; i++){
    			tmp[i]|=(a[i]&(dp[i]>>1));
    		}
    		for(int i=0; i<r-1; i++){
    			tmp[i]|=(a[i]&dp[i+1]);
    		}
    		for(int i=0; i<r; i++){
    			tmp[i]|=(a[i]&(dp[i]<<1));
    		}
    		for(int i=r-1; i>0; i--){
    			tmp[i]|=(a[i]&dp[i-1]);
    		}
    		for(int i=0; i<r; i++){
    			dp[i]=tmp[i];
    		}
    	}
    }
    int ans=0;
    for(int i=0; i<r; i++){
    	for(int j=0; j<c; j++){
    		if(dp[i][j]==1) ans++;
    	}
    }
    cout<<ans;
    return 0;
}

























# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -