답안 #651010

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
651010 2022-10-16T12:32:14 Z dooompy Nautilus (BOI19_nautilus) C++17
66 / 100
137 ms 64968 KB
#include "bits/stdc++.h"

using namespace std;

void abc() {cout << endl;}
template <typename T, typename ...U> void abc(T a, U ...b) {
    cout << a << ' ', abc(b...);
}
template <typename T> void printv(T l, T r) {
    while (l != r) cout << *l << " \n"[++l == r];
}
template <typename A, typename B> istream& operator >> (istream& o, pair<A, B> &a) {
    return o >> a.first >> a.second;
}
template <typename A, typename B> ostream& operator << (ostream& o, pair<A, B> a) {
    return o << '(' << a.first << ", " << a.second << ')';
}
template <typename T> ostream& operator << (ostream& o, vector<T> a) {
    bool is = false;
    for (T i : a) {o << (is ? ' ' : '{'), is = true, o << i;}
    return o << '}';
}



using ll = long long;

bitset<505> dp[505][1005], water[505];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);
    int r, c, m; cin >> r >> c >> m;

    for (int i = 1; i <= r; i++) {
        for (int j = 1; j <= c; j++) {
            char cur; cin >> cur;

            if (cur == '.') {
                water[i].set(j, 1);
                dp[i][0].set(j, 1);
            }
        }
    }

    string command; cin >> command;

    for (int i = 1; i <= m; i++) {
        for (int row = 1; row <= r; row++) {
            switch (command[i -1]) {
                case 'N':
                    dp[row][i] = dp[row + 1][i-1] & water[row];
                    break;
                case 'E':
                    dp[row][i] = (dp[row][i-1] << 1) & water[row];
                    break;
                case 'S':
                    dp[row][i] = dp[row - 1][i-1] & water[row];
                    break;
                case 'W':
                    dp[row][i] = (dp[row][i-1] >> 1) & water[row];
                    break;
                case '?':
                    dp[row][i] = (dp[row + 1][i - 1] | (dp[row][i - 1] << 1) | dp[row - 1][i - 1] | (dp[row][i - 1] >> 1)) & water[row];
                    break;
            }
        }
    }

    int ans = 0;

    for (int i = 1; i <= r; i++) {
        for (int j = 1; j <= c; j++) {
            if (dp[i][m].test(j)) ans++;
        }
    }

    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1360 KB Output is correct
2 Correct 2 ms 1364 KB Output is correct
3 Correct 1 ms 1364 KB Output is correct
4 Correct 1 ms 1360 KB Output is correct
5 Correct 1 ms 1364 KB Output is correct
6 Correct 1 ms 1364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1360 KB Output is correct
2 Correct 2 ms 1364 KB Output is correct
3 Correct 1 ms 1364 KB Output is correct
4 Correct 1 ms 1360 KB Output is correct
5 Correct 1 ms 1364 KB Output is correct
6 Correct 1 ms 1364 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 2 ms 1364 KB Output is correct
9 Correct 2 ms 1360 KB Output is correct
10 Correct 2 ms 1364 KB Output is correct
11 Correct 2 ms 1364 KB Output is correct
12 Correct 2 ms 1360 KB Output is correct
13 Correct 2 ms 1364 KB Output is correct
14 Correct 2 ms 1364 KB Output is correct
15 Correct 2 ms 1364 KB Output is correct
16 Correct 2 ms 1356 KB Output is correct
17 Correct 2 ms 1356 KB Output is correct
18 Correct 2 ms 1364 KB Output is correct
19 Correct 2 ms 1364 KB Output is correct
20 Correct 2 ms 1364 KB Output is correct
21 Correct 2 ms 1364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1360 KB Output is correct
2 Correct 2 ms 1364 KB Output is correct
3 Correct 1 ms 1364 KB Output is correct
4 Correct 1 ms 1360 KB Output is correct
5 Correct 1 ms 1364 KB Output is correct
6 Correct 1 ms 1364 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 2 ms 1364 KB Output is correct
9 Correct 2 ms 1360 KB Output is correct
10 Correct 2 ms 1364 KB Output is correct
11 Correct 2 ms 1364 KB Output is correct
12 Correct 2 ms 1360 KB Output is correct
13 Correct 2 ms 1364 KB Output is correct
14 Correct 2 ms 1364 KB Output is correct
15 Correct 2 ms 1364 KB Output is correct
16 Correct 2 ms 1356 KB Output is correct
17 Correct 2 ms 1356 KB Output is correct
18 Correct 2 ms 1364 KB Output is correct
19 Correct 2 ms 1364 KB Output is correct
20 Correct 2 ms 1364 KB Output is correct
21 Correct 2 ms 1364 KB Output is correct
22 Runtime error 137 ms 64968 KB Execution killed with signal 11
23 Halted 0 ms 0 KB -