제출 #1095454

#제출 시각아이디문제언어결과실행 시간메모리
1095454MateiKing80Nautilus (BOI19_nautilus)C++17
100 / 100
176 ms1372 KiB
#include <bits/stdc++.h> using namespace std; int r, c, m; vector<string> grid; bool valid_pos(int i, int j) { return !(i < 0 || j < 0 || i >= r || j >= c || grid[i][j] == '#'); } int main() { cin >> r >> c >> m; grid.resize(r); for(int i = 0; i < r; i ++) cin >> grid[i]; string msg; cin >> msg; bitset<1000> reach[r], tmp[r], sea[r]; for(int i = 0; i < r; i ++) for(int j = 0; j < c; j ++) { sea[i][j] = grid[i][c-1-j] == '.'; reach[i][j] = grid[i][c-1-j] == '.'; } for(char w : msg) { for(int i = 0; i < r; i ++) { if(w == 'W') reach[i] = (reach[i]<<1)&sea[i]; if(w == 'E') reach[i] = (reach[i]>>1)&sea[i]; if(w == 'N') if(i+1 < r) reach[i] = reach[i+1] & sea[i]; else reach[i].reset(); if(w == '?') { tmp[i] = (reach[i]<<1)|(reach[i]>>1); if(i) tmp[i] |= reach[i-1]; if(i+1 < r) tmp[i] |= reach[i+1]; tmp[i] &= sea[i]; } } for(int i = r-1; i >= 0; i --) if(w == 'S') if(i) reach[i] = reach[i-1] & sea[i]; else reach[i].reset(); for(int i = 0; i < r; i ++) if(w == '?') reach[i] = tmp[i]; } int ans = 0; for(int i = 0; i < r; i ++) ans += reach[i].count(); cout << ans << '\n'; }

컴파일 시 표준 에러 (stderr) 메시지

nautilus.cpp: In function 'int main()':
nautilus.cpp:35:15: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   35 |             if(w == 'N')
      |               ^
nautilus.cpp:51:15: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   51 |             if(w == 'S')
      |               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...