Submission #493840

#TimeUsernameProblemLanguageResultExecution timeMemory
493840yungyaoNautilus (BOI19_nautilus)C++17
100 / 100
242 ms712 KiB
using namespace std; #include <iostream> #include <algorithm> #include <vector> #include <utility> #include <map> #include <set> #include <stack> #include <queue> typedef long long LL; typedef pair<int,int> pii; #define pb push_back #define mkp make_pair #define F first #define S second #define iter(x) x.begin(),x.end() #define REP(n) for (int __=n;__--;) #define REP0(i,n) for (int i=0;i<n;++i) #define REP1(i,n) for (int i=1;i<=n;++i) #include <bitset> const int maxn = 505, mod = 0; const LL inf = 0; vector <bitset <maxn>> dp, can; void solve(){ int n, m, k; string s; cin >> n >> m >> k; can.resize(n); REP0(i,n) REP0(j,m){ char c; cin >> c; can[i][j] = (c == '.'); } //REP0(i,n) {REP0(j,m) cout << can[i][j]; cout << '\n';} cout << '\n'; dp = can; cin >> s; for (auto c:s){ vector <bitset<maxn>> tr(n); if (c == 'E' or c == '?'){ REP0(i,n) tr[i] = tr[i] | (dp[i] << 1); } if (c == 'W' or c == '?'){ REP0(i,n) tr[i] = tr[i] | (dp[i] >> 1); } if (c == 'N' or c == '?'){ REP0(i,n-1) tr[i] = tr[i] | dp[i+1]; } if (c == 'S' or c == '?'){ REP1(i,n-1) tr[i] = tr[i] | dp[i-1]; } REP0(i, n){ tr[i] = tr[i] & can[i]; } dp.swap(tr); //cout << c << '\n'; REP0(i,n) {REP0(j,m) cout << dp[i][j]; cout << '\n';} cout << '\n'; } int cnt = 0; REP0(i,n) cnt += dp[i].count(); cout << cnt; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...