Submission #857165

# Submission time Handle Problem Language Result Execution time Memory
857165 2023-10-05T13:27:07 Z Trisanu_Das Nautilus (BOI19_nautilus) C++17
0 / 100
5 ms 4188 KB
#include<bits/stdc++.h>
using namespace std;
int r, c, m, dp[100][100][100], res[100][100];
char a[100][100];
string s;
 
int dx[4] = {0, 0, -1, 1};
int dy[4] = {1, -1, 0, 0};
 
void dfs(int x, int y, int far) {
    if(!(0 <= x && x < r && 0 <= y && y < c && a[x][y] == '.')) return;
    if(far == m) {
        res[x][y] = 1; return;
    }
    if(dp[x][y][far]) return;
    dp[x][y][far] = 1;
    if(s[far] == 'E') dfs(x, y + 1, far + 1);
    else if(s[far] == 'W') dfs(x, y - 1, far + 1);
    else if(s[far] == 'N') dfs(x - 1, y, far + 1);
    else if(s[far] == 'S') dfs(x + 1, y, far + 1);
    else for(int i = 0; i < 4; i++) dfs(x + dx[i], y + dy[i], far + 1);
}
int main() {
    cin >> r >> c >> m;
    for(int i = 0; i < r; i++) cin >> a[i];
    cin >> s;
    for(int i = 0; i < r; i++) for(int j = 0; j < c; j++) if(a[i][j] == '.') dfs(i, j, 0);
    int ans = 0;
    for(int i = 0; i < r; i++) for(int j = 0; j < c; j++) if(a[i][j]) ans++; 
    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 4188 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 4188 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 4188 KB Output isn't correct
2 Halted 0 ms 0 KB -