Submission #958281

#TimeUsernameProblemLanguageResultExecution timeMemory
958281NomioNautilus (BOI19_nautilus)C++17
66 / 100
9 ms1372 KiB
#include <bits/stdc++.h> using namespace std; int r, c, m; string a[100]; bool f(int x, int y) { if(x >= 0 && x < r && y >= 0 && y < c && a[x][y] == '.') { return true; } return false; } int main() { cin >> r >> c >> m; bool vis[r][c] {}; for(int i = 0; i < r; i++) { cin >> a[i]; for(int j = 0; j < c; j++) { if(a[i][j] == '.') { vis[i][j] = 1; } } } string s; cin >> s; bool Vis[r][c] {}; for(char X : s) { int x, y; if(X == 'W') { for(int i = 0; i < r; i++) { for(int j = 0; j < c; j++) { x = i; y = j; if(vis[x][y]){ y--; if(f(x, y)) { Vis[x][y] = 1; } } } } } if(X == 'E') { for(int i = 0; i < r; i++) { for(int j = 0; j < c; j++) { x = i; y = j; if(vis[x][y]) { y++; if(f(x, y)) { Vis[x][y] = 1; } } } } } if(X == 'N') { for(int i = 0; i < r; i++) { for(int j = 0; j < c; j++) { x = i; y = j; if(vis[x][y]){ x--; if(f(x, y)) { Vis[x][y] = 1; } } } } } if(X == 'S') { for(int i = 0; i < r; i++) { for(int j = 0; j < c; j++) { x = i; y = j; if(vis[x][y]) { x++; if(f(x, y)) { Vis[x][y] = 1; } } } } } if(X == '?') { for(int i = 0; i < r; i++) { for(int j = 0; j < c; j++) { x = i; y = j; if(vis[x][y]) { if(f(x + 1, y)) { Vis[x + 1][y] = 1; } if(f(x - 1, y)) { Vis[x - 1][y] = 1; } if(f(x, y + 1)) { Vis[x][y + 1] = 1; } if(f(x, y - 1)) { Vis[x][y - 1] = 1; } } } } } for(int i = 0; i < r; i++) { for(int j = 0; j < c; j++) { vis[i][j] = Vis[i][j]; Vis[i][j] = 0; } } } int S = 0; for(int i = 0; i < r; i++) { for(int j = 0; j < c; j++) { if(vis[i][j]) { S++; } } } cout << S << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...