Submission #958172

# Submission time Handle Problem Language Result Execution time Memory
958172 2024-04-05T05:18:28 Z ezzzay Nautilus (BOI19_nautilus) C++14
66 / 100
468 ms 250832 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];
bool dp[NM][NM][NM];
bitset<N>vis[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]=='#')continue;
            dp[0][i][j]=1;
        }
    }
    for(int l=0;l<k;l++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(arr[i][j]=='#')continue;
                if(s[l]=='N'){ 
                    dp[l+1][i][j]|=dp[l][i+1][j];
                }
                if(s[l]=='E'){ 
                    dp[l+1][i][j]|=dp[l][i][j-1];
                }
                if(s[l]=='S'){ 
                    dp[l+1][i][j]|=dp[l][i-1][j];
                }
                if(s[l]=='W'){ 
                    dp[l+1][i][j]|=dp[l][i][j+1];
                }
                if(s[l]=='?'){
                    dp[l+1][i][j]|=dp[l][i+1][j];
                    dp[l+1][i][j]|=dp[l][i][j+1];
                    dp[l+1][i][j]|=dp[l][i-1][j];
                    dp[l+1][i][j]|=dp[l][i][j-1];
                }
            }
        } 
    }
    int cnt=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(arr[i][j]=='#')continue;
            if(dp[k][i][j])cnt++;
        }
    }
    cout<<cnt;
}
# Verdict Execution time Memory Grader output
1 Correct 9 ms 26972 KB Output is correct
2 Correct 7 ms 27172 KB Output is correct
3 Correct 9 ms 26972 KB Output is correct
4 Correct 9 ms 26972 KB Output is correct
5 Correct 7 ms 26972 KB Output is correct
6 Correct 4 ms 26972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 26972 KB Output is correct
2 Correct 7 ms 27172 KB Output is correct
3 Correct 9 ms 26972 KB Output is correct
4 Correct 9 ms 26972 KB Output is correct
5 Correct 7 ms 26972 KB Output is correct
6 Correct 4 ms 26972 KB Output is correct
7 Correct 7 ms 23900 KB Output is correct
8 Correct 8 ms 22108 KB Output is correct
9 Correct 8 ms 15452 KB Output is correct
10 Correct 6 ms 14172 KB Output is correct
11 Correct 4 ms 19036 KB Output is correct
12 Correct 6 ms 17500 KB Output is correct
13 Correct 7 ms 12124 KB Output is correct
14 Correct 9 ms 9052 KB Output is correct
15 Correct 5 ms 8900 KB Output is correct
16 Correct 3 ms 7260 KB Output is correct
17 Correct 6 ms 7256 KB Output is correct
18 Correct 6 ms 7260 KB Output is correct
19 Correct 7 ms 7260 KB Output is correct
20 Correct 5 ms 7256 KB Output is correct
21 Correct 2 ms 3164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 26972 KB Output is correct
2 Correct 7 ms 27172 KB Output is correct
3 Correct 9 ms 26972 KB Output is correct
4 Correct 9 ms 26972 KB Output is correct
5 Correct 7 ms 26972 KB Output is correct
6 Correct 4 ms 26972 KB Output is correct
7 Correct 7 ms 23900 KB Output is correct
8 Correct 8 ms 22108 KB Output is correct
9 Correct 8 ms 15452 KB Output is correct
10 Correct 6 ms 14172 KB Output is correct
11 Correct 4 ms 19036 KB Output is correct
12 Correct 6 ms 17500 KB Output is correct
13 Correct 7 ms 12124 KB Output is correct
14 Correct 9 ms 9052 KB Output is correct
15 Correct 5 ms 8900 KB Output is correct
16 Correct 3 ms 7260 KB Output is correct
17 Correct 6 ms 7256 KB Output is correct
18 Correct 6 ms 7260 KB Output is correct
19 Correct 7 ms 7260 KB Output is correct
20 Correct 5 ms 7256 KB Output is correct
21 Correct 2 ms 3164 KB Output is correct
22 Runtime error 468 ms 250832 KB Execution killed with signal 11
23 Halted 0 ms 0 KB -