제출 #1186293

#제출 시각아이디문제언어결과실행 시간메모리
1186293kl0989eNautilus (BOI19_nautilus)C++20
100 / 100
32 ms328 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast") #define ll long long #define fi first #define se second #define pb push_back #define vi vector<int> #define vl vector<ll> #define pi pair<int, int> #define pl pair<ll,ll> #define all(x) (x).begin(),(x).end() const int maxn=500; vector<bitset<maxn>> grid(maxn); vector<bitset<maxn>> tmp(maxn); vector<bitset<maxn>> prv(maxn); bitset<maxn> mty; int main() { ios::sync_with_stdio(0); cin.tie(0); int n,m,q; cin >> n >> m >> q; char c; for (int i=0; i<n; i++) { for (int j=0; j<m; j++) { cin >> c; if (c=='.') { grid[i].set(j,1); } } } prv=grid; for (int i=0; i<q; i++) { cin >> c; if (c=='E') { for (int j=0; j<n; j++) { prv[j]<<=1; prv[j]&=grid[j]; } } else if (c=='W') { for (int j=0; j<n; j++) { prv[j]>>=1; prv[j]&=grid[j]; } } else if (c=='N') { for (int j=0; j<n-1; j++) { prv[j]=prv[j+1]; prv[j]&=grid[j]; } prv[n-1]=mty; } else if (c=='S') { for (int j=n-1; j>0; j--) { prv[j]=prv[j-1]; prv[j]&=grid[j]; } prv[0]=mty; } else { for (int j=0; j<n; j++) { tmp[j]=(prv[j]<<1)|(prv[j]>>1); if (j!=0) { tmp[j]|=prv[j-1]; } if (j!=n-1) { tmp[j]|=prv[j+1]; } tmp[j]&=grid[j]; } swap(tmp,prv); } } int ans=0; for (int i=0; i<n; i++) { ans+=prv[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...