Submission #857164

#TimeUsernameProblemLanguageResultExecution timeMemory
857164Trisanu_DasNautilus (BOI19_nautilus)C++17
Compilation error
0 ms0 KiB
#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 < n; 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'; }

Compilation message (stderr)

nautilus.cpp: In function 'int main()':
nautilus.cpp:25:24: error: 'n' was not declared in this scope
   25 |     for(int i = 0; i < n; i++) cin >> a[i];
      |                        ^