제출 #123010

#제출 시각아이디문제언어결과실행 시간메모리
123010model_codeNautilus (BOI19_nautilus)C++17
0 / 100
4 ms376 KiB
#include <iostream> #include <bitset> #include <string> using namespace std; const int maxn = 505; bitset<maxn> grid [maxn]; bitset<maxn> possibles [2][maxn]; int main () { int height, width, message; cin >> height >> width >> message; for (int i = 1; i <= height; i++) { for (int j = 1; j <= width; j++) { char x; cin >> x; if (x == '.') { grid[i][j] = 1; } } } for (int i = 1; i <= height; i++) { possibles[1][i] = grid[i]; } string msg; cin >> msg; for (int i = 0; i < message; i++) { char c = msg[i]; if (c == 'N') { for (int k = 1; k <= height; k++) { possibles[(i % 2)][k] = possibles[!(i % 2)][k + 1] & grid[k]; } } else if (c == 'E') { for (int k = 1; k <= height; k++) { possibles[(i % 2)][k] = (possibles[!(i % 2)][k] << 1) & grid[k]; } } else if (c == 'S') { for (int k = 1; k <= height; k++) { possibles[(i % 2)][k] = possibles[!(i % 2)][k - 1] & grid[k]; } } else if (c == 'W') { for (int k = 1; k <= height; k++) { possibles[(i % 2)][k] = (possibles[!(i % 2)][k] >> 1) & grid[k]; } } else { for (int k = 1; k <= height; k++) { possibles[(i % 2)][k]= ((possibles[!(i % 2)][k] << 1) | (possibles[!(i % 2)][k] >> 1) | possibles[!(i % 2)][k - 1] | possibles[!(i % 2)][k + 1]) & grid[k]; } } /* for (int k = 1; k <= height; k++) { cout << possibles[(i % 2)][k].to_string() << endl; } cout << endl; */ int ans = 0; for (int k = 1; k <= height; k++) { ans += possibles[(i) % 2][k].count(); } cout << ans << endl; } int ans = 0; for (int i = 1; i <= height; i++) { ans += possibles[(message - 1) % 2][i].count(); } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...