Submission #1003481

#TimeUsernameProblemLanguageResultExecution timeMemory
1003481anangoNautilus (BOI19_nautilus)C++17
100 / 100
137 ms768 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int maxn = 500; signed main() { #ifndef ONLINE_JUDGE // for getting input from input.txt //freopen("input.txt", "r", stdin); // for writing output to output.txt //freopen("output.txt", "w", stdout); #endif /*#ifdef ONLINE_JUDGE ios_base::sync_with_stdio(false); cin.tie(NULL); #endif*/ //fast IO int n,m,k; cin >> n >> m >> k; bitset<maxn> B; bitset<maxn> all0; vector<bitset<maxn>> grid(n,B); vector<bitset<maxn>> allowed(n,B); for (int i=0; i<n; i++) { string s; cin >> s; bitset<maxn> B1; for (int j=0; j<m; j++) { if (s[j]=='#') { B1[j] = 0; } else { B1[j] = 1; } } grid[i] = allowed[i] = B1; } for (int let=0; let<k; let++) { char c; cin >> c; //cout << let << " " << c << endl; if (c=='N') { for (int i=1; i<n; i++) { allowed[i-1] = allowed[i]; } allowed[n-1] = all0; } else if (c=='S') { for (int i=n-2; i>=0; i--) { //cout << "downing " << i << endl; allowed[i+1] = allowed[i]; } allowed[0] = all0; } else if (c=='W') { for (int i=0; i<n; i++) { allowed[i] >>= 1; } } else if (c=='E') { for (int i=0; i<n; i++) { allowed[i] <<= 1; } } else if (c=='?') { //cout << "d" << let << endl; vector<bitset<maxn>> allowed2(n,all0); //cout << "e" << let << endl; for (int i=0; i<n; i++) { //cout << "doing " << i << endl; allowed2[i] |= allowed[i]>>1; allowed2[i] |= allowed[i]<<1; } for (int i=n-2; i>=0; i--) { //cout << i << endl; allowed2[i+1] |= allowed[i]; } for (int i=1; i<n; i++) { //cout << i << endl; allowed2[i-1] |= allowed[i]; } allowed=allowed2; } else { assert(false); } for (int i=0; i<n; i++) { allowed[i] &= grid[i]; } } int answer = 0; for (int i=0; i<n; i++) { answer+=allowed[i].count(); } cout << answer << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...