Submission #314125

#TimeUsernameProblemLanguageResultExecution timeMemory
314125kimbj0709Nautilus (BOI19_nautilus)C++14
0 / 100
1076 ms384 KiB
#include <bits/stdc++.h> using namespace std; #define maxn 505 int32_t main() { ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); bitset<maxn> dp[maxn][2]; bitset<maxn> arr[maxn]; int n,m,len; cin >> n >> m >> len; string input; char inp; for(int i=1;i<=n;i++){ for(int j=1;i<=m;j++){ cin >> inp; if(inp=='.'){ arr[i][j] = 1; } } dp[i][0] = arr[i]; } cin >> input; for(int i=0;i<len;i++){ for(int a=1;a<=n;a++){ if(input.at(i)=='N'){ dp[a][(i+1)&1] = dp[a+1][i&1]; } if(input.at(i)=='S'){ dp[a][(i+1)&1] = dp[a-1][i&1]; } if(input.at(i)=='W'){ dp[a][(i+1)&1] = dp[a][i&1] >> 1; } if(input.at(i)=='E'){ dp[a][(i+1)&1] = dp[a][i&1] << 1; } if(input.at(i)=='?'){ dp[a][(i+1)&1] = (dp[a][i&1] << 1)|(dp[a][i&1] >> 1)|(dp[a-1][i&1])|(dp[a+1][i&1]); } dp[a][(i+1)&1] &= arr[a]; } } int ans = 0; for(int i=1;i<=n;i++){ ans += dp[i][(input.length())&1].count(); } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...