Submission #945320

# Submission time Handle Problem Language Result Execution time Memory
945320 2024-03-13T15:58:15 Z LucaIlie Nautilus (BOI19_nautilus) C++17
0 / 100
1 ms 2652 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 500;
const int MAX_M = 9;
const int MAX_K = 5000;
char mat[MAX_N + 2][MAX_M];
bitset<MAX_M> dp[MAX_K + 1][MAX_N + 2], line[MAX_N + 2];
int dl[4] = { -1, 0, 1, 0 };
int dc[4] = { 0, -1, 0, 1 };
int dir[256];

int main() {
    int n, m, k;

    dir['N'] = 0;
    dir['W'] = 1;
    dir['S'] = 2;
    dir['E'] = 3;

    cin >> n >> m >> k;
    for ( int l = 1; l <= n; l++ ) {
        for ( int c = 0; c < m; c++ )
            cin >> mat[l][c];
    }
    string moves;
    cin >> moves;
    moves = " " + moves;

    for ( int l = 1; l <= n; l++ ) {
        for ( int c = 0; c < m; c++ ) {
            if ( mat[l][c] == '.' )
                dp[0][l][c] = line[l][c] = true;
        }
    }
    for ( int i = 1; i <= k; i++ ) {
        for ( int l = 1; l <= n; l++ ) {
            dp[i][l].reset();
            if ( moves[i] == 'N' )
                dp[i][l] |= dp[i - 1][l + 1];
            else if ( moves[i] == 'S' )
                dp[i][l] |= dp[i - 1][l - 1];
            else if ( moves[i] == 'W' )
                dp[i][l] |= (dp[i - 1][l] >> 1);
            else if ( moves[i] == 'E' )
                dp[i][l] |= (dp[i - 1][l] << 1);
            else {
                dp[i][l] |= dp[i - 1][l + 1];
                dp[i][l] |= dp[i - 1][l - 1];
                dp[i][l] |= (dp[i - 1][l] >> 1);
                dp[i][l] |= (dp[i - 1][l] << 1);
            }
            dp[i][l] &= line[l];
        }
    }

    int ans = 0;
    for ( int l = 1; l <= n; l++ )
        ans += dp[k][l].count();
    cout << ans;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -