답안 #859803

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
859803 2023-10-10T16:51:59 Z qwusha Nautilus (BOI19_nautilus) C++17
100 / 100
122 ms 1296 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
typedef long double ld;
const ll inf = 1e9;
const ld eps = 1e-8;



signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m, q;
    cin >> n >> m >> q;
    vector<vector<char>> w(n, vector<char>(m));
    for (ll i = 0; i < n; i++) {
        for (ll j = 0; j < m; j++) {
            cin >> w[i][j];
        }
    }
    vector<bitset<502>> a(n), newa, bad(n);
    for (ll i = 0; i < n; i++) {
        for (ll j = 0; j < m; j++) {
            if (w[i][j] == '.') {
                a[i][j + 1] = 1;
            } else {
                bad[i][j + 1] = 1;
            }
        }
        bad[i][0] = 1;
        bad[i][m + 1] = 1;
    }
    for (ll qw = 0; qw < q; qw++) {
        char t;
        cin >> t;
        if (t == 'E') {
            for (ll i = 0; i < n; i++) {
                a[i] <<= 1;
                a[i] &= ~bad[i];
            }
        } else if (t == 'W') {
            for (ll i = 0; i < n; i++) {
                a[i] >>= 1;
                a[i] &= ~bad[i];
            }
        } else if (t == 'N') {
            for (ll i = 0; i < n - 1; i++) {
                a[i] = a[i + 1];
                a[i] &= ~bad[i];
            }
            a[n - 1] = 0;
        } else if (t == 'S') {
            for (ll i = n - 1; i > 0; i--) {
                a[i] = a[i - 1];
                a[i] &= ~bad[i];
            }
            a[0] = 0;
        } else {
            newa = a;
            for (ll i = 0; i < n; i++) {
                newa[i] = (a[i] >> 1);
                newa[i] |= (a[i] << 1);
                if (i > 0) {
                    newa[i] |= a[i - 1];
                }
                if (i < n - 1) {
                    newa[i] |= a[i + 1];
                }
                newa[i] &= ~bad[i];
            }
            a = newa;
        }
        /*for(ll i = 0; i < n; i++) {
            for(ll j = 1; j < m + 1; j++) {
                cout << a[i][j];
            }
            cout << endl;
        }
        cout << endl << endl;*/
    }
    ll res = 0;
    for (ll i = 0; i < n; i++) {
        res += a[i].count();
    }
    cout << res << '\n';

}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 464 KB Output is correct
6 Correct 1 ms 360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 464 KB Output is correct
6 Correct 1 ms 360 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 344 KB Output is correct
13 Correct 1 ms 344 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 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 464 KB Output is correct
6 Correct 1 ms 360 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 344 KB Output is correct
13 Correct 1 ms 344 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 66 ms 1044 KB Output is correct
23 Correct 66 ms 1040 KB Output is correct
24 Correct 70 ms 860 KB Output is correct
25 Correct 64 ms 1112 KB Output is correct
26 Correct 63 ms 1036 KB Output is correct
27 Correct 95 ms 1296 KB Output is correct
28 Correct 97 ms 1040 KB Output is correct
29 Correct 98 ms 860 KB Output is correct
30 Correct 96 ms 860 KB Output is correct
31 Correct 94 ms 1040 KB Output is correct
32 Correct 121 ms 860 KB Output is correct
33 Correct 118 ms 1036 KB Output is correct
34 Correct 122 ms 860 KB Output is correct
35 Correct 118 ms 856 KB Output is correct
36 Correct 121 ms 1112 KB Output is correct