Submission #130972

#TimeUsernameProblemLanguageResultExecution timeMemory
130972IOrtroiiiNautilus (BOI19_nautilus)C++14
100 / 100
223 ms1064 KiB
#include <bits/stdc++.h> using namespace std; const int N = 505; using Val = bitset<N>; Val org[N]; Val now[N]; Val nxt[N]; int main() { ios_base::sync_with_stdio(false); int n, m, k; cin >> n >> m >> k; vector<string> brd(n); for (int i = 0; i < n; ++i) { cin >> brd[i]; for (int j = 0; j < m; ++j) { if (brd[i][j] == '.') { org[i].set(j); } } now[i] = org[i]; } string mvs; cin >> mvs; for (char c : mvs) { for (int i = 0; i < n; ++i) { nxt[i] = {}; } if (c == 'N' || c == '?') { for (int i = 0; i + 1 < n; ++i) { nxt[i] |= now[i + 1]; } } if (c == 'E' || c == '?') { for (int i = 0; i < n; ++i) { nxt[i] |= (now[i] << 1); } } if (c == 'S' || c == '?') { for (int i = 1; i < n; ++i) { nxt[i] |= now[i - 1]; } } if (c == 'W' || c == '?') { for (int i = 0; i < n; ++i) { nxt[i] |= (now[i] >> 1); } } for (int i = 0; i < n; ++i) { now[i] = nxt[i] & org[i]; } } int ans = 0; for (int i = 0; i < n; ++i) { ans += now[i].count(); } cout << ans << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...