Submission #151202

# Submission time Handle Problem Language Result Execution time Memory
151202 2019-09-02T06:55:31 Z dolphingarlic Nautilus (BOI19_nautilus) C++14
100 / 100
200 ms 760 KB
#include <bits/stdc++.h>
#pragma GCC Optimize("O3")
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;

bitset<500> grid[500], curr[500], temp[500];

int main() {
    iostream::sync_with_stdio(false);
    cin.tie(0);
    int r, c, m;
    cin >> r >> c >> m;
    FOR(i, 0, r) FOR(j, 0, c) {
        char k;
        cin >> k;
        if (k == '.') {
            grid[i][c - j - 1] = 1;
            curr[i][c - j - 1] = 1;
        }
    }

    FOR(dir, 0, m) {
        char q;
        cin >> q;
        switch (q) {
            case 'N':
                FOR(i, 1, r) curr[i - 1] = curr[i];
                curr[r - 1].reset();
                break;
            case 'E':
                FOR(i, 0, r) curr[i] >>= 1;
                break;
            case 'S':
                for (int i = r - 1; i > 0; i--) curr[i] = curr[i - 1];
                curr[0].reset();
                break;
            case 'W':
                FOR(i, 0, r) curr[i] <<= 1;
                break;
            default:
                FOR(i, 0, r) temp[i].reset();

                FOR(i, 1, r) temp[i - 1] |= curr[i];
                for (int i = r - 1; i > 0; i--) temp[i] |= curr[i - 1];
                FOR(i, 0, r) temp[i] |= ((curr[i] << 1) | (curr[i] >> 1));

                FOR(i, 0, r) curr[i] = temp[i];
        }
        FOR(i, 0, r) curr[i] &= grid[i];
    }

    int ans = 0;
    FOR(i, 0, r) FOR(j, 0, c) ans += curr[i][j];
    cout << ans;
    return 0;
}

Compilation message

nautilus.cpp:2:0: warning: ignoring #pragma GCC Optimize [-Wunknown-pragmas]
 #pragma GCC Optimize("O3")
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 380 KB Output is correct
6 Correct 0 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 380 KB Output is correct
6 Correct 0 ms 380 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 6 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 3 ms 504 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 380 KB Output is correct
6 Correct 0 ms 380 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 6 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 3 ms 504 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 95 ms 760 KB Output is correct
23 Correct 97 ms 632 KB Output is correct
24 Correct 94 ms 760 KB Output is correct
25 Correct 95 ms 632 KB Output is correct
26 Correct 92 ms 712 KB Output is correct
27 Correct 153 ms 632 KB Output is correct
28 Correct 155 ms 728 KB Output is correct
29 Correct 155 ms 720 KB Output is correct
30 Correct 154 ms 632 KB Output is correct
31 Correct 152 ms 704 KB Output is correct
32 Correct 200 ms 632 KB Output is correct
33 Correct 200 ms 760 KB Output is correct
34 Correct 199 ms 632 KB Output is correct
35 Correct 199 ms 720 KB Output is correct
36 Correct 198 ms 760 KB Output is correct