Submission #764639

#TimeUsernameProblemLanguageResultExecution timeMemory
764639Valters07Nautilus (BOI19_nautilus)C++14
100 / 100
129 ms1072 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt") #define fio ios_base::sync_with_stdio(0);cin.tie(0); #define ll long long #define en cin.close();return 0; #define pb push_back #define fi first//printf("%lli\n",cur); #define se second//scanf("%lli",&n); using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int N = 505; bitset<N*N> gr, lft, rgt, cur; int main() { fio // ifstream cin("in.in"); int n, m, k; cin >> n >> m >> k; for(int i = 0;i<n;i++) { for(int j = 0;j<m;j++) { int ind = i*m+j; char c; cin >> c; if(c=='.') { gr[ind]=cur[ind]=1; if(j!=m-1) lft[ind]=1; if(j!=0) rgt[ind]=1; } } } string str; cin >> str; for(auto x:str) { if(x=='N') cur=(cur>>m)&gr; else if(x=='S') cur=(cur<<m)&gr; else if(x=='W') cur=(cur>>1)&lft; else if(x=='E') cur=(cur<<1)&rgt; else cur=((cur>>m)&gr)|((cur<<m)&gr)|((cur>>1)&lft)|((cur<<1)&rgt); } cout << cur.count(); // cin.close(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...