Submission #948163

# Submission time Handle Problem Language Result Execution time Memory
948163 2024-03-17T17:21:14 Z Darren0724 Nautilus (BOI19_nautilus) C++17
100 / 100
146 ms 856 KB
#include <bits/stdc++.h>
using namespace std;
#define LCBorz ios_base::sync_with_stdio(false); cin.tie(0);
//#define int long long
#define all(x) x.begin(), x.end()
#define endl '\n'
const int N=505;
const int INF=1e9;

int32_t main() {
    LCBorz;
    bitset<N> grid[N],dp[N],dp1[N];
    int n,m,t;cin>>n>>m>>t;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            char c;cin>>c;
            grid[i][j]=dp[i][j]=(c=='.');
        }
    }
    string s;cin>>s;
    for(char c:s){
        for(int i=0;i<n;i++){
            dp1[i].reset();
        }
        if(c=='W'||c=='?'){
            for(int i=0;i<n;i++)dp1[i]|=dp[i]>>1;
        }
        if(c=='E'||c=='?'){
            for(int i=0;i<n;i++)dp1[i]|=dp[i]<<1;
        }
        if(c=='N'||c=='?'){
            for(int i=0;i<n;i++)dp1[i]|=dp[i+1];
        }
        if(c=='S'||c=='?'){
            for(int i=1;i<n;i++)dp1[i]|=dp[i-1];
        }
        for(int i=0;i<n;i++){
            dp[i]=dp1[i]&grid[i];
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        ans+=dp[i].count();
    }
    cout<<ans<<endl;

    
    return 0;
}
# 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 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 1 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 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 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 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 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 552 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 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 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 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 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 552 KB Output is correct
22 Correct 85 ms 792 KB Output is correct
23 Correct 89 ms 856 KB Output is correct
24 Correct 87 ms 604 KB Output is correct
25 Correct 85 ms 600 KB Output is correct
26 Correct 84 ms 600 KB Output is correct
27 Correct 119 ms 788 KB Output is correct
28 Correct 120 ms 792 KB Output is correct
29 Correct 119 ms 604 KB Output is correct
30 Correct 119 ms 604 KB Output is correct
31 Correct 120 ms 852 KB Output is correct
32 Correct 142 ms 604 KB Output is correct
33 Correct 142 ms 784 KB Output is correct
34 Correct 146 ms 600 KB Output is correct
35 Correct 143 ms 788 KB Output is correct
36 Correct 143 ms 784 KB Output is correct