답안 #920737

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
920737 2024-02-03T01:32:28 Z 12345678 Nautilus (BOI19_nautilus) C++17
100 / 100
186 ms 1104 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=505;
int r, c, m, cnt;
char mp[nx][nx];
bitset<nx> dp[2][nx], w[nx];
string s;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>r>>c>>m;
    for (int i=1; i<=r; i++) for (int j=1; j<=c; j++) cin>>mp[i][j], w[i][j]=(mp[i][j]!='#'), dp[0][i][j]=w[i][j];
    cin>>s;
    for (int i=1; i<=m; i++)
    {
        int cr=i%2, pv=1-cr;
        for (int j=1; j<=r; j++) dp[cr][j]=0;
        if (s[i-1]=='N'||s[i-1]=='?') for (int j=1; j<=r-1; j++) dp[cr][j]|=dp[pv][j+1];
        if (s[i-1]=='S'||s[i-1]=='?') for (int j=2; j<=r; j++) dp[cr][j]|=dp[pv][j-1];
        if (s[i-1]=='E'||s[i-1]=='?') for (int j=1; j<=r; j++) dp[cr][j]|=dp[pv][j]<<1;
        if (s[i-1]=='W'||s[i-1]=='?') for (int j=1; j<=r; j++) dp[cr][j]|=dp[pv][j]>>1;
        for (int j=1; j<=r; j++) dp[cr][j]&=w[j];
    }
    for (int i=1; i<=r; i++) for (int j=1; j<=c; j++) cnt+=dp[m%2][i][j];
    cout<<cnt;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 348 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 348 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 2 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 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 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 348 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 348 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 2 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 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 348 KB Output is correct
22 Correct 125 ms 860 KB Output is correct
23 Correct 128 ms 1064 KB Output is correct
24 Correct 126 ms 856 KB Output is correct
25 Correct 133 ms 860 KB Output is correct
26 Correct 117 ms 1040 KB Output is correct
27 Correct 156 ms 1104 KB Output is correct
28 Correct 159 ms 1040 KB Output is correct
29 Correct 159 ms 1040 KB Output is correct
30 Correct 156 ms 1104 KB Output is correct
31 Correct 161 ms 1060 KB Output is correct
32 Correct 176 ms 1044 KB Output is correct
33 Correct 182 ms 860 KB Output is correct
34 Correct 186 ms 856 KB Output is correct
35 Correct 178 ms 1040 KB Output is correct
36 Correct 181 ms 860 KB Output is correct