Submission #958190

# Submission time Handle Problem Language Result Execution time Memory
958190 2024-04-05T06:08:10 Z ezzzay Nautilus (BOI19_nautilus) C++14
0 / 100
1 ms 348 KB
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define int long long
#define ss second
#define pb push_back
const int N=5e3+5;
const int NM=501;
char arr[NM][NM];
bitset<NM> dp[NM];
bitset<NM>rck[NM];
signed main(){
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>arr[i][j];
        }
    }
    string s;
    cin>>s;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(arr[i][j]=='#'){
                rck[i][j]=0;
                continue;
            }
            rck[i][j]=1;
            dp[i][j]=1;
            
        }
    }
    for(int l=0;l<k;l++){
        bitset<NM>tmp[NM];
        for(int i=1;i<=n;i++){
            tmp[i]=dp[i];
        }
        
        if(s[l]=='E'){
            for(int i=1;i<=n;i++){
                dp[i]|=(tmp[i]<<1);
                dp[i]&=rck[i];
            }  
        }
        else if(s[l]=='W'){
            for(int i=1;i<=n;i++){
                dp[i]|=(tmp[i]>>1);
                dp[i]&=rck[i];
            }  
        }
        else if(s[l]=='N'){
            for(int i=1;i<=m;i++){
                dp[i-1]|=tmp[i];
                dp[i-1]&=rck[i-1];
            }  
        }
        else if(s[l]=='S'){
            for(int i=1;i<=m;i++){
                dp[i+1]|=tmp[i];
                dp[i+1]&=rck[i+1];
            }  
        }
        else{
            for(int i=1;i<=n;i++){
                dp[i]|=(tmp[i]<<1);
                dp[i]&=rck[i];
            }  
            for(int i=1;i<=n;i++){
                dp[i]|=(tmp[i]>>1);
                dp[i]&=rck[i];
            }  
            for(int i=1;i<=m;i++){
                dp[i-1]|=tmp[i];
                dp[i-1]&=rck[i-1];
            } 
             for(int i=1;i<=m;i++){
                dp[i+1]|=tmp[i];
                dp[i+1]&=rck[i+1];
            }  
        }
        
    }
    
    int cnt=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cnt+= dp[i][j];
        }
    }
    cout<<cnt;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -