Submission #493002

#TimeUsernameProblemLanguageResultExecution timeMemory
493002wiwihoNautilus (BOI19_nautilus)C++14
66 / 100
1075 ms1484 KiB
#include <bits/stdc++.h> using namespace std; const int SZ = 5002; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cerr.tie(0); int r, c, m; cin >> r >> c >> m; vector<bitset<SZ>> g(r + 2); for(int i = 1; i <= r; i++){ string t; cin >> t; for(int j = 0; j < c; j++){ if(t[j] == '.') g[i][c - j] = 1; } //cerr << t << "\n"; //cerr << g[i] << "\n"; } //for(int i = 0; i <= r + 1; i++) cerr << g[i] << "\n"; string s; cin >> s; vector<vector<bitset<SZ>>> dp(2, vector<bitset<SZ>>(r + 2)); int now = 0; dp[now] = g; for(char d : s){ now = !now; for(int i = 1; i <= r; i++) dp[now][i].reset(); if(d == 'S' || d == '?'){ for(int i = 1; i <= r; i++) dp[now][i] |= dp[!now][i - 1]; } if(d == 'N' || d == '?'){ for(int i = 1; i <= r; i++) dp[now][i] |= dp[!now][i + 1]; } if(d == 'E' || d == '?'){ for(int i = 1; i <= r; i++) dp[now][i] |= dp[!now][i] >> 1; } if(d == 'W' || d == '?'){ for(int i = 1; i <= r; i++) dp[now][i] |= dp[!now][i] << 1; } //cerr << "test " << d << "\n"; //for(int i = 0; i <= r + 1; i++) cerr << dp2[i] << "\n"; for(int i = 1; i <= r; i++) dp[now][i] &= g[i]; //cerr << "test " << d << "\n"; //for(int i = 0; i <= r + 1; i++) cerr << dp[i] << "\n"; } int ans = 0; for(int i = 1; i <= r; i++){ for(int j = 1; j <= c; j++){ if(dp[now][i][j]) ans++; } } cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...