Submission #860689

#TimeUsernameProblemLanguageResultExecution timeMemory
860689Iliya_Nautilus (BOI19_nautilus)C++14
100 / 100
108 ms1112 KiB
//IN THE NAME OF GOD #include<bits/stdc++.h> #pragma GCC optimize("O2,unroll-loops") #define endl '\n' #define F first #define S second using namespace std; typedef long long ll; const int N = 507; bitset<N*N> must,ans,cop; int32_t main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int r,c,m; cin >> r >> c >> m; for(int i=1; i<=r; i++){ for(int j=1; j<=c; j++){ char x; cin >> x; if (x == '.') must[i*N+j] = ans[i*N+j] = 1; else must[i*N+j] = ans[i*N+j] = 0; } } for(int i=1; i<=m; i++){ char x; cin >> x; cop = ans; if (x == 'N') ans = (cop >> N); else if (x == 'S') ans = (cop << N); else if (x == 'E') ans = (cop << 1); else if (x == 'W') ans = (cop >> 1); else ans = ((cop>>N)|(cop<<N)|(cop<<1)|(cop>>1)); ans &= must; } cout << ans.count() << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...