Submission #533439

# Submission time Handle Problem Language Result Execution time Memory
533439 2022-03-06T04:33:50 Z ddy888 Nautilus (BOI19_nautilus) C++17
0 / 100
23 ms 40648 KB
#undef _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long 
#define pb push_back
#define fi first
#define si second
#define ar array
typedef pair<int,int> pi;
typedef tuple<int,int,int> ti;  
void debug_out() {cerr<<endl;}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {cerr<<" "<<to_string(H);debug_out(T...);}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
// O(RCM)
int R, C, M, dp[510][510][510], ans;
char A[510][510], ops[510];

inline bool can(int x, int y) {
    return A[x][y] == '.';
}

signed main() {
    fast;
    cin >> R >> C >> M;
    assert(M <= 100);
    for (int i = 1; i <= R; ++i) {
        for (int j = 1; j <= C; ++j) {
            cin >> A[i][j];
            dp[i][j][1] = (A[i][j] == '.');
        }
    }
    for (int i = 1; i <= M; ++i) cin >> ops[i];
    for (int k = 2; k <= M; ++k) {
        for (int i = 1; i <= R; ++i) {
            for (int j = 1; j <= C; ++j) {
                if (A[i][j] == '#') continue;
                if (ops[k] == 'N' || ops[k] == '?') dp[i][j][k] += (dp[i - 1][j][k - 1] && can(i - 1, j));
                if (ops[k] == 'E' || ops[k] == '?') dp[i][j][k] += (dp[i][j - 1][k - 1] && can(i, j - 1));
                if (ops[k] == 'W' || ops[k] == '?') dp[i][j][k] += (dp[i][j + 1][k - 1] && can(i, j + 1));
                if (ops[k] == 'S' || ops[k] == '?') dp[i][j][k] += (dp[i + 1][j][k - 1] && can(i + 1, j));
            }
        }
    }
    for (int i = 1; i <= R; ++i) {
        for (int j = 1; j <= C; ++j) {
            ans += (dp[i][j][M] > 0);
        }
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 23 ms 40648 KB Output is correct
2 Correct 23 ms 40560 KB Output is correct
3 Incorrect 23 ms 40616 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 40648 KB Output is correct
2 Correct 23 ms 40560 KB Output is correct
3 Incorrect 23 ms 40616 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 40648 KB Output is correct
2 Correct 23 ms 40560 KB Output is correct
3 Incorrect 23 ms 40616 KB Output isn't correct
4 Halted 0 ms 0 KB -