Submission #958192

# Submission time Handle Problem Language Result Execution time Memory
958192 2024-04-05T06:11:50 Z ezzzay Nautilus (BOI19_nautilus) C++14
100 / 100
181 ms 1240 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];
bitset<NM>fll[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]&=fll[i];
            tmp[i]|=dp[i];
            dp[i]&=fll[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 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 105 ms 764 KB Output is correct
23 Correct 104 ms 860 KB Output is correct
24 Correct 117 ms 1108 KB Output is correct
25 Correct 101 ms 856 KB Output is correct
26 Correct 118 ms 1020 KB Output is correct
27 Correct 142 ms 856 KB Output is correct
28 Correct 147 ms 1240 KB Output is correct
29 Correct 143 ms 1020 KB Output is correct
30 Correct 170 ms 1020 KB Output is correct
31 Correct 141 ms 1024 KB Output is correct
32 Correct 171 ms 1024 KB Output is correct
33 Correct 181 ms 860 KB Output is correct
34 Correct 171 ms 1024 KB Output is correct
35 Correct 170 ms 1020 KB Output is correct
36 Correct 171 ms 1020 KB Output is correct