Submission #256237

#TimeUsernameProblemLanguageResultExecution timeMemory
256237BlagojceNautilus (BOI19_nautilus)C++11
100 / 100
251 ms768 KiB
#include <bits/stdc++.h> #define fr(i, n, m) for(int i = (n); i < (m); i ++) #define pb push_back #define st first #define nd second #define pq priority_queue #define all(x) begin(x), end(x) #include <time.h> #include <cmath> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; const int i_inf = 1e4; const ll inf = 1e17; const ll mod = 1000000007; const ld eps = 1e-13; const ld pi = 3.14159265359; mt19937 _rand(time(NULL)); clock_t timer = clock(); const int mxn = 200005; int n, m, k; bitset<500> dp[500]; bitset<500> cop[500]; bitset<500> mapa[500]; bitset<500> rem; bitset<500> emp; void solve(){ cin >> n >> m >> k; fr(i, 0, m) rem[i] = 1; fr(i, 0, n){ fr(j, 0, m){ char c; cin >> c; if(c == '.') dp[i][j] = 1; if(c == '.') mapa[i][j] = 1; } } string s; cin >> s; fr(i, 0, k){ if(s[i] == 'W'){ fr(j, 0, n){ dp[j] >>= 1; } } else if(s[i] == 'E'){ fr(j, 0, n){ dp[j] <<= 1; } } else if(s[i] == 'N'){ fr(j, 0, n-1){ dp[j] = dp[j+1]; } dp[n-1].reset(); } else if(s[i] == 'S'){ for(int j = n-1; j > 0; j --){ dp[j] = dp[j-1]; } dp[0].reset(); } else{ fr(j, 0, n){ if(j == 0) cop[j] = dp[j+1]; else if(j == n-1) cop[j] = dp[j-1]; else cop[j] = dp[j-1]|dp[j+1]; } fr(j, 0, n){ dp[j] = cop[j]|(dp[j]>>1)|(dp[j]<<1); } } fr(j, 0, n) dp[j] = dp[j]&mapa[j]; } int ans = 0; fr(i, 0, n) ans += dp[i].count(); cout<<ans<<endl; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...