Submission #367000

#TimeUsernameProblemLanguageResultExecution timeMemory
367000Vince729Nautilus (BOI19_nautilus)C++11
100 / 100
183 ms876 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef complex<double> pt; typedef pair<int, int> pii; #define x() real() #define y() imag() #define smx(a, b) a = max(a, b) #define smn(a, b) a = min(a, b) #define in(mp, v) (mp.find(v) != mp.end()) #define iter(var, n) for (int var = 0; var < n; var++) const int MAXN = 502; const int MOD = 1000000007; typedef bitset<501> bst; vector<bst> def, cur; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int r, c, m; cin >> r >> c >> m; def.resize(r); iter(i, r) { string s; cin >> s; iter(j, c) { def[i][j] = s[j] == '.'; } } cur = def; string ms; cin >> ms; iter(mi, m) { char d = ms[mi]; vector<bst> ncur(r); if (d == 'N') { iter(i, r-1) { ncur[i] = cur[i+1] & def[i]; } } else if (d == 'E') { iter(i, r) { ncur[i] = (cur[i] << 1) & def[i]; } } else if (d == 'S') { iter(i, r-1) { ncur[i+1] = cur[i] & def[i+1]; } } else if (d == 'W') { iter(i, r) { ncur[i] = (cur[i] >> 1) & def[i]; } } else { iter(i, r) { ncur[i] = (cur[i] << 1) | (cur[i] >> 1); if (i > 0) ncur[i] |= cur[i-1]; if (i < r-1) ncur[i] |= cur[i+1]; ncur[i] &= def[i]; } } cur = ncur; } int ans = 0; iter(i, r) { ans += cur[i].count(); } cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...