Submission #449946

# Submission time Handle Problem Language Result Execution time Memory
449946 2021-08-02T10:10:34 Z zxcvbnm Nautilus (BOI19_nautilus) C++14
0 / 100
90 ms 6340 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
char mat[505][505];
bool vis[5005][505][505];
int n, m, k;
string str;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
#define NORTH 0
#define EAST 1
#define SOUTH 2
#define WEST 3
bool isValid(int x, int y) {
    if (x >= n || x < 0 || y >= m || y < 0) return false;
    if (mat[x][y] == '#') return false;
    return true;
}
void go(int curr, int x, int y) {
    if (!isValid(x, y) || vis[curr][x][y]) return;
    vis[curr][x][y] = true;
    if (curr == k) return;

    if (str[curr] == '?') {
        for(int i = 0; i < 4; i++) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (isValid(nx, ny)) {
                go(curr+1, nx, ny);
            }
        }
    } else {
        switch(str[curr]) {
        case 'N':
            go(curr+1, x+dx[NORTH], y+dy[NORTH]);
            break;
        case 'E':
            go(curr+1, x+dx[EAST], y+dy[EAST]);
            break;
        case 'S':
            go(curr+1, x+dx[SOUTH], y+dy[SOUTH]);
            break;
        case 'W':
            go(curr+1, x+dx[WEST], y+dy[WEST]);
            break;
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m >> k;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            cin >> mat[i][j];
        }
    }
    cin >> str;

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            go(0, i, j);
        }
    }

    int cnt = 0;
    for(int p = 0; p <= k; p++) {
    if (p != 0) cout << str[p-1] << "\n";

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            cout << vis[p][i][j] << "";
        }
        cout << "\n";
    }
    cout << "\n";
    }
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            cnt += vis[k][i][j];
        }
    }
    cout << cnt << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 90 ms 6340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 90 ms 6340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 90 ms 6340 KB Output isn't correct
2 Halted 0 ms 0 KB -