Submission #493001

# Submission time Handle Problem Language Result Execution time Memory
493001 2021-12-10T02:06:50 Z wiwiho Nautilus (BOI19_nautilus) C++14
66 / 100
1000 ms 1364 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<bitset<SZ>> dp = g;

    for(char d : s){
        vector<bitset<SZ>> dp2(r + 2);
        
        if(d == 'S' || d == '?'){
            for(int i = 1; i <= r; i++) dp2[i] |= dp[i - 1];
        }
        if(d == 'N' || d == '?'){
            for(int i = 1; i <= r; i++) dp2[i] |= dp[i + 1];
        }
        if(d == 'E' || d == '?'){
            for(int i = 1; i <= r; i++) dp2[i] |= dp[i] >> 1;
        }
        if(d == 'W' || d == '?'){
            for(int i = 1; i <= r; i++) dp2[i] |= dp[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++) dp2[i] &= g[i];

        dp.swap(dp2);

        //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[i][j]) ans++;
        }
    }
    cout << ans << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 460 KB Output is correct
2 Correct 3 ms 460 KB Output is correct
3 Correct 2 ms 460 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
# Verdict Execution time Memory Grader output
1 Correct 2 ms 460 KB Output is correct
2 Correct 3 ms 460 KB Output is correct
3 Correct 2 ms 460 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 3 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 3 ms 460 KB Output is correct
12 Correct 5 ms 460 KB Output is correct
13 Correct 5 ms 500 KB Output is correct
14 Correct 5 ms 460 KB Output is correct
15 Correct 6 ms 460 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 496 KB Output is correct
20 Correct 7 ms 460 KB Output is correct
21 Correct 6 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 460 KB Output is correct
2 Correct 3 ms 460 KB Output is correct
3 Correct 2 ms 460 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 3 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 3 ms 460 KB Output is correct
12 Correct 5 ms 460 KB Output is correct
13 Correct 5 ms 500 KB Output is correct
14 Correct 5 ms 460 KB Output is correct
15 Correct 6 ms 460 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 496 KB Output is correct
20 Correct 7 ms 460 KB Output is correct
21 Correct 6 ms 460 KB Output is correct
22 Correct 820 ms 1364 KB Output is correct
23 Correct 811 ms 1260 KB Output is correct
24 Correct 781 ms 1264 KB Output is correct
25 Correct 814 ms 1260 KB Output is correct
26 Correct 805 ms 1256 KB Output is correct
27 Execution timed out 1090 ms 1244 KB Time limit exceeded
28 Halted 0 ms 0 KB -