Submission #496450

# Submission time Handle Problem Language Result Execution time Memory
496450 2021-12-21T08:21:04 Z Nalrimet Nautilus (BOI19_nautilus) C++17
100 / 100
204 ms 157040 KB
#include<bits/stdc++.h>

using namespace std;

const int N = 5 * 1e2 + 5;
const int inf = 1000000000;

#define int long long
#define F first
#define S second
#define pb push_back
#define ppb pop_back

int r, c, m, ans;
char f, s;
bitset<N> dp[N][5005];

 main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> r >> c >> m;

    for(int i = 1; i <= r; ++i){
        for(int j = 1; j <= c; ++j){
            dp[i][0][j - 1] = 1;
            cin >> f;
            if(f == '#') dp[i][0][j - 1] = 0;
        }
//        cout << dp[i][0] << '\n';
    }

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

//    5 9 7
//    ...##....
//    ..#.##..#
//    ..#....##
//    .##...#..
//    ....#....
//    WS?EE??


    for(int i = 1; i <= r; ++i){
//        cout << dp[i][m] << '\n';
        ans += dp[i][m].count();
    }

    cout << ans;

    return 0;

}

Compilation message

nautilus.cpp:18:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   18 |  main() {
      |  ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1356 KB Output is correct
2 Correct 1 ms 1356 KB Output is correct
3 Correct 1 ms 1356 KB Output is correct
4 Correct 1 ms 1356 KB Output is correct
5 Correct 1 ms 1356 KB Output is correct
6 Correct 1 ms 1356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1356 KB Output is correct
2 Correct 1 ms 1356 KB Output is correct
3 Correct 1 ms 1356 KB Output is correct
4 Correct 1 ms 1356 KB Output is correct
5 Correct 1 ms 1356 KB Output is correct
6 Correct 1 ms 1356 KB Output is correct
7 Correct 1 ms 1356 KB Output is correct
8 Correct 1 ms 1356 KB Output is correct
9 Correct 1 ms 1356 KB Output is correct
10 Correct 1 ms 1356 KB Output is correct
11 Correct 1 ms 1356 KB Output is correct
12 Correct 1 ms 1356 KB Output is correct
13 Correct 1 ms 1356 KB Output is correct
14 Correct 1 ms 1356 KB Output is correct
15 Correct 1 ms 1356 KB Output is correct
16 Correct 1 ms 1356 KB Output is correct
17 Correct 1 ms 1356 KB Output is correct
18 Correct 1 ms 1356 KB Output is correct
19 Correct 2 ms 1356 KB Output is correct
20 Correct 2 ms 1356 KB Output is correct
21 Correct 1 ms 1356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1356 KB Output is correct
2 Correct 1 ms 1356 KB Output is correct
3 Correct 1 ms 1356 KB Output is correct
4 Correct 1 ms 1356 KB Output is correct
5 Correct 1 ms 1356 KB Output is correct
6 Correct 1 ms 1356 KB Output is correct
7 Correct 1 ms 1356 KB Output is correct
8 Correct 1 ms 1356 KB Output is correct
9 Correct 1 ms 1356 KB Output is correct
10 Correct 1 ms 1356 KB Output is correct
11 Correct 1 ms 1356 KB Output is correct
12 Correct 1 ms 1356 KB Output is correct
13 Correct 1 ms 1356 KB Output is correct
14 Correct 1 ms 1356 KB Output is correct
15 Correct 1 ms 1356 KB Output is correct
16 Correct 1 ms 1356 KB Output is correct
17 Correct 1 ms 1356 KB Output is correct
18 Correct 1 ms 1356 KB Output is correct
19 Correct 2 ms 1356 KB Output is correct
20 Correct 2 ms 1356 KB Output is correct
21 Correct 1 ms 1356 KB Output is correct
22 Correct 135 ms 156924 KB Output is correct
23 Correct 139 ms 156904 KB Output is correct
24 Correct 134 ms 156932 KB Output is correct
25 Correct 135 ms 156932 KB Output is correct
26 Correct 129 ms 156956 KB Output is correct
27 Correct 177 ms 156948 KB Output is correct
28 Correct 172 ms 156992 KB Output is correct
29 Correct 180 ms 157020 KB Output is correct
30 Correct 192 ms 157040 KB Output is correct
31 Correct 172 ms 156996 KB Output is correct
32 Correct 200 ms 156968 KB Output is correct
33 Correct 204 ms 157028 KB Output is correct
34 Correct 204 ms 156992 KB Output is correct
35 Correct 199 ms 156980 KB Output is correct
36 Correct 202 ms 157016 KB Output is correct