Submission #951165

# Submission time Handle Problem Language Result Execution time Memory
951165 2024-03-21T09:37:02 Z LOLOLO Nautilus (BOI19_nautilus) C++17
100 / 100
72 ms 159280 KB
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef long long ll;
char mat[505][505];
bitset<505> is[505],dp[5005][505];
int main(){
    std::ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    int r,c,m;
    cin>>r>>c>>m;
    for(int i=1;i<=r;i++){
        for(int j=1;j<=c;j++){
            cin>>mat[i][j];
            is[i][j]=(mat[i][j]=='.');
            dp[0][i][j]=is[i][j];
        }
    }

    string s;
    cin>>s;
    s='a'+s;

    for(int t=1;t<=m;t++){
        for(int i=1;i<=r;i++){
            if(s[t]=='?')
                dp[t][i]=(dp[t-1][i+1]|dp[t-1][i-1]|(dp[t-1][i]<<1)|(dp[t-1][i]>>1))&is[i];
            if(s[t]=='N')
                dp[t][i]=dp[t-1][i+1]&is[i];
            if(s[t]=='S')
                dp[t][i]=dp[t-1][i-1]&is[i];
            if(s[t]=='E')
                dp[t][i]=(dp[t-1][i]<<1)&is[i];
            if(s[t]=='W')
                dp[t][i]=(dp[t-1][i]>>1)&is[i];
        }
    }

    int cnt=0;

    for(int i=1;i<=r;i++){
        cnt+=dp[m][i].count();
    }

    cout<<cnt<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 2 ms 4700 KB Output is correct
4 Correct 1 ms 4692 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 1 ms 4696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 2 ms 4700 KB Output is correct
4 Correct 1 ms 4692 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 1 ms 4696 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 1 ms 4696 KB Output is correct
9 Correct 1 ms 4696 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 2 ms 4700 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4700 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4700 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4700 KB Output is correct
20 Correct 1 ms 4700 KB Output is correct
21 Correct 1 ms 4700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 2 ms 4700 KB Output is correct
4 Correct 1 ms 4692 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 1 ms 4696 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 1 ms 4696 KB Output is correct
9 Correct 1 ms 4696 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 2 ms 4700 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4700 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4700 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4700 KB Output is correct
20 Correct 1 ms 4700 KB Output is correct
21 Correct 1 ms 4700 KB Output is correct
22 Correct 72 ms 159020 KB Output is correct
23 Correct 51 ms 159056 KB Output is correct
24 Correct 50 ms 159140 KB Output is correct
25 Correct 49 ms 159004 KB Output is correct
26 Correct 48 ms 159060 KB Output is correct
27 Correct 55 ms 159060 KB Output is correct
28 Correct 60 ms 159280 KB Output is correct
29 Correct 61 ms 159060 KB Output is correct
30 Correct 67 ms 159092 KB Output is correct
31 Correct 57 ms 159064 KB Output is correct
32 Correct 58 ms 159056 KB Output is correct
33 Correct 62 ms 159056 KB Output is correct
34 Correct 60 ms 159060 KB Output is correct
35 Correct 58 ms 158952 KB Output is correct
36 Correct 57 ms 159052 KB Output is correct