Submission #890380

#TimeUsernameProblemLanguageResultExecution timeMemory
890380BaizhoNautilus (BOI19_nautilus)C++14
100 / 100
143 ms1368 KiB
#include <bits/stdc++.h> #define endl "\n" #define mp make_pair #define pb push_back #define F first #define S second #define sz size() #define rep(i,k,n) for(int i = k ; i <= n ; ++i) #define per(i,k,n) for(int i = k ; i >= n ; --i) #define Zymraq() ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0) #define all(x) x.begin(),x.end() #define fr(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout) #define toqta return 0 #define PERMUTE next_permutation #define no cout<<"No"<<endl; #define yes cout<<"Yes"<<endl; #define a() a + 1, a + n + 1 using namespace std; typedef long long ll; typedef unsigned long long ull; typedef string S; typedef double ld; typedef long double lld; const int N = 1e6 + 17; const int modd = 1e9 + 7; const int INF = 1e9 - 19; const int P = 37; const ll NN = 1e7 + 17; const ld eps = 1e-19; const double pi = 3.141592653589793238462643383279 ; bool sortbysec(const pair<int,int> &a, const pair<int,int> &b){ return (a.second < b.second); } void pre (ll a) { cout << fixed << setprecision(a); return; } string s[505]; string a; int r, c, m; int ans, el; void solve() { cin >> r >> c >> m; bitset<500> b[r], bad[r], re, down[r], up[r], left[r], right[r]; for (int i = 0; i < 500; i ++) re[i] = 0; for (int i = 0; i < r; i ++) { cin >> s[i]; b[i] = bad[i] = re; for (int j = 0; j < c; j ++) { b[i][j] = (s[i][j] == '.'); bad[i][j] = (s[i][j] == '.'); } } cin >> a; for (int k = 0; k < m; k ++) { if (a[k] == 'W') { for (int i = 0; i < r; i ++) { b[i] = (b[i] >> 1); b[i] = b[i] & bad[i]; } } if (a[k] == 'E') { for (int i = 0; i < r; i ++) { b[i] = (b[i] << 1); b[i] = b[i] & bad[i]; } } if (a[k] == 'N') { for (int i = 0; i < r - 1; i ++) { b[i] = b[i + 1] & bad[i]; } b[r - 1] = re; } if (a[k] == 'S') { for (int i = r - 1; i > 0; i --) { b[i] = b[i - 1] & bad[i]; } b[0] = re; } if (a[k] == '?') { up[0] = re; down[r - 1] = re; for (int i = 0; i < r; i ++) { if (i != 0) up[i] = b[i - 1]; if (i != r - 1) down[i] = b[i + 1]; left[i] = (b[i] >> 1); right[i] = (b[i] << 1); } for (int i = 0; i < r; i ++) { b[i] = (((up[i] | down[i]) | right[i]) | left[i]); b[i] = b[i] & bad[i]; } } } for (int i = 0; i < r; i ++) { for (int j = 0; j < c; j ++) if (b[i][j]) ans ++; } cout << ans; return; } int main() { Zymraq (); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...