Submission #957252

#TimeUsernameProblemLanguageResultExecution timeMemory
957252n3rm1nNautilus (BOI19_nautilus)C++17
100 / 100
235 ms187004 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; const int MAXN = 515, MAXM = 6e3, MAXCELL = 3e5; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int n, m, t; int a[MAXN][MAXN]; string operations; bitset < MAXCELL > fr; void read() { cin >> n >> m >> t; char s; m += 2; /// border 0 for (int i = 1; i <= n; ++ i) { for (int j = 1; j <= m-2; ++ j) { cin >> s; if(s == '#')a[i][j] = 1; else fr[(i - 1) * m + j] = 1; } } cin >> operations; operations = '+' + operations; } bitset < MAXCELL > bs[MAXM]; void solve() { bs[0] = fr; for (int i = 1; i <= t; ++ i) { bs[i] = 0; if(operations[i] == 'N') { bs[i] = (bs[i-1] >> m); bs[i] = (bs[i] & fr); } if(operations[i] == 'S') { bs[i] = ((bs[i-1] << m) & fr); bs[i] = (bs[i] & fr); } if(operations[i] == 'W' ) { bs[i] = (bs[i-1] >> 1); bs[i] = (bs[i] & fr); } if(operations[i] == 'E') { bs[i] = (bs[i-1] << 1); bs[i] = (bs[i] & fr); } if(operations[i] == '?') { bs[i] = (((bs[i-1] << m) | (bs[i-1] >> 1)) | ((bs[i-1] << 1) | (bs[i-1] >> m))); bs[i] = (bs[i] & fr); } } bs[t] = (bs[t] & fr); cout << bs[t].count() << endl; } int main() { speed(); read(); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...