답안 #1012317

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1012317 2024-07-01T23:37:44 Z andro Nautilus (BOI19_nautilus) C++14
0 / 100
6 ms 8540 KB
#include <bits/stdc++.h>

#define int long long

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, q;
    cin >> n >> m >> q;
    char a[n + 1][m + 1];
    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= m; j++) {
            a[i][j] = '#';
        }
    }
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            cin >> a[i][j];
        }
    }
    char b[q + 1];
    for(int i = 1; i <= q; i++) {
        cin >> b[i];
    }
    int dp[q + 1][n + 1][m + 1];
    for(int i = 0; i <= q; i++) {
        for(int j = 0; j <= n; j++) {
            for(int k = 0; k <= m; k++) {
                dp[i][j][k] = 0;
            }
        }
    }
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            if(a[i][j] == '.') {
                dp[0][i][j] = 1;
            }
        }
    }
    for(int i = 1; i <= q; i++) {
        if(b[i] == '?') {
            for(int j = 1; j <= n; j++) {
                for(int k = 1; k <= m; k++) {
                    if(a[j][k] == '#') {
                        continue;
                    }
                    if(a[j - 1][k] != '#') dp[i][j][k] |= dp[i - 1][j - 1][k];
                    if(a[j + 1][k] != '#') dp[i][j][k] |= dp[i - 1][j + 1][k];
                    if(a[j][k - 1] != '#') dp[i][j][k] |= dp[i - 1][j][k - 1];
                    if(a[j][k + 1] != '#') dp[i][j][k] |= dp[i - 1][j][k + 1];
                }
            }
        }
        else {
            if(b[i] == 'N') {
                for(int j = 1; j <= n; j++) {
                    for(int k = 1; k <= m; k++) {
                        if(a[j][k] == '#') {
                            continue;
                        }
                        if(a[j - 1][k] != '#') dp[i][j][k] |= dp[i - 1][j - 1][k];
                    }
                }
            }
            else if(b[i] == 'W') {
                for(int j = 1; j <= n; j++) {
                    for(int k = 1; k <= m; k++) {
                        if(a[j][k] == '#') {
                            continue;
                        }
                        if(a[j][k - 1] != '#') dp[i][j][k] |= dp[i - 1][j][k - 1];
                    }
                }
            }
            else if(b[i] == 'S') {
                for(int j = 1; j <= n; j++) {
                    for(int k = 1; k <= m; k++) {
                        if(a[j][k] == '#') {
                            continue;
                        }
                        if(a[j + 1][k] != '#') dp[i][j][k] |= dp[i - 1][j + 1][k];
                    }
                }
            }
            else {
                for(int j = 1; j <= n; j++) {
                    for(int k = 1; k <= m; k++) {
                        if(a[j][k] == '#') {
                            continue;
                        }
                        if(a[j][k + 1] != '#') dp[i][j][k] |= dp[i - 1][j][k + 1];
                    }
                }
            }
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            //cout << dp[q][i][j] << " ";
            ans += dp[q][i][j];
        }
        //cout << endl;
    }
    cout << ans;
    // levo ispod
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 8540 KB Output is correct
2 Incorrect 6 ms 8436 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 8540 KB Output is correct
2 Incorrect 6 ms 8436 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 8540 KB Output is correct
2 Incorrect 6 ms 8436 KB Output isn't correct
3 Halted 0 ms 0 KB -