답안 #493002

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
493002 2021-12-10T02:10:07 Z wiwiho Nautilus (BOI19_nautilus) C++14
66 / 100
1000 ms 1484 KB
#include <bits/stdc++.h>

using namespace std;

const int SZ = 5002;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cerr.tie(0);

    int r, c, m;
    cin >> r >> c >> m;

    vector<bitset<SZ>> g(r + 2);
    for(int i = 1; i <= r; i++){
        string t;
        cin >> t;
        for(int j = 0; j < c; j++){
            if(t[j] == '.') g[i][c - j] = 1;
        }
        //cerr << t << "\n";
        //cerr << g[i] << "\n";
    }

    //for(int i = 0; i <= r + 1; i++) cerr << g[i] << "\n";

    string s;
    cin >> s;
    
    vector<vector<bitset<SZ>>> dp(2, vector<bitset<SZ>>(r + 2));
    int now = 0;
    dp[now] = g;

    for(char d : s){
        now = !now;
        for(int i = 1; i <= r; i++) dp[now][i].reset();
        
        if(d == 'S' || d == '?'){
            for(int i = 1; i <= r; i++) dp[now][i] |= dp[!now][i - 1];
        }
        if(d == 'N' || d == '?'){
            for(int i = 1; i <= r; i++) dp[now][i] |= dp[!now][i + 1];
        }
        if(d == 'E' || d == '?'){
            for(int i = 1; i <= r; i++) dp[now][i] |= dp[!now][i] >> 1;
        }
        if(d == 'W' || d == '?'){
            for(int i = 1; i <= r; i++) dp[now][i] |= dp[!now][i] << 1;
        }
        //cerr << "test " << d << "\n";
        //for(int i = 0; i <= r + 1; i++) cerr << dp2[i] << "\n";

        for(int i = 1; i <= r; i++) dp[now][i] &= g[i];

        //cerr << "test " << d << "\n";
        //for(int i = 0; i <= r + 1; i++) cerr << dp[i] << "\n";
    }

    int ans = 0;
    for(int i = 1; i <= r; i++){
        for(int j = 1; j <= c; j++){
            if(dp[now][i][j]) ans++;
        }
    }
    cout << ans << "\n";

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 460 KB Output is correct
2 Correct 3 ms 460 KB Output is correct
3 Correct 4 ms 560 KB Output is correct
4 Correct 3 ms 460 KB Output is correct
5 Correct 3 ms 460 KB Output is correct
6 Correct 3 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 460 KB Output is correct
2 Correct 3 ms 460 KB Output is correct
3 Correct 4 ms 560 KB Output is correct
4 Correct 3 ms 460 KB Output is correct
5 Correct 3 ms 460 KB Output is correct
6 Correct 3 ms 460 KB Output is correct
7 Correct 4 ms 460 KB Output is correct
8 Correct 4 ms 460 KB Output is correct
9 Correct 4 ms 460 KB Output is correct
10 Correct 4 ms 460 KB Output is correct
11 Correct 4 ms 460 KB Output is correct
12 Correct 6 ms 568 KB Output is correct
13 Correct 6 ms 460 KB Output is correct
14 Correct 6 ms 460 KB Output is correct
15 Correct 6 ms 564 KB Output is correct
16 Correct 6 ms 460 KB Output is correct
17 Correct 7 ms 460 KB Output is correct
18 Correct 7 ms 460 KB Output is correct
19 Correct 7 ms 460 KB Output is correct
20 Correct 7 ms 588 KB Output is correct
21 Correct 6 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 460 KB Output is correct
2 Correct 3 ms 460 KB Output is correct
3 Correct 4 ms 560 KB Output is correct
4 Correct 3 ms 460 KB Output is correct
5 Correct 3 ms 460 KB Output is correct
6 Correct 3 ms 460 KB Output is correct
7 Correct 4 ms 460 KB Output is correct
8 Correct 4 ms 460 KB Output is correct
9 Correct 4 ms 460 KB Output is correct
10 Correct 4 ms 460 KB Output is correct
11 Correct 4 ms 460 KB Output is correct
12 Correct 6 ms 568 KB Output is correct
13 Correct 6 ms 460 KB Output is correct
14 Correct 6 ms 460 KB Output is correct
15 Correct 6 ms 564 KB Output is correct
16 Correct 6 ms 460 KB Output is correct
17 Correct 7 ms 460 KB Output is correct
18 Correct 7 ms 460 KB Output is correct
19 Correct 7 ms 460 KB Output is correct
20 Correct 7 ms 588 KB Output is correct
21 Correct 6 ms 460 KB Output is correct
22 Correct 878 ms 1484 KB Output is correct
23 Correct 960 ms 1484 KB Output is correct
24 Correct 854 ms 1484 KB Output is correct
25 Correct 874 ms 1484 KB Output is correct
26 Correct 862 ms 1484 KB Output is correct
27 Execution timed out 1075 ms 1484 KB Time limit exceeded
28 Halted 0 ms 0 KB -