Submission #1000079

#TimeUsernameProblemLanguageResultExecution timeMemory
1000079KactusJackNautilus (BOI19_nautilus)C++17
100 / 100
177 ms157524 KiB
#include<bits/stdc++.h> #define ll long long #define F first #define S second using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, k; cin >> n >> m >> k; vector<bitset<500>> row(n); for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ char c; cin >> c; if(c == '.'){ row[i][j] = 1; } } } string s; cin >> s; vector<vector<bitset<500>>> dp(k+1, vector<bitset<500>> (n)); for(int i = 0; i < n; i++){ dp[0][i] = row[i]; } for(int x = 1; x <= k; x++){ for(int i = 0; i < n; i++){ if(s[x-1] == 'E'){ dp[x][i] = (dp[x-1][i]<<1)&row[i]; } else if(s[x-1] == 'W'){ dp[x][i] = (dp[x-1][i]>>1)&row[i]; } else if(s[x-1] == 'N' && i+1 < n){ dp[x][i] = dp[x-1][i+1]&row[i]; } else if(s[x-1] == 'S' && i-1 >= 0){ dp[x][i] = dp[x-1][i-1]&row[i]; } else if(s[x-1] == '?'){ dp[x][i] |= (dp[x-1][i]<<1); dp[x][i] |= (dp[x-1][i]>>1); if(i+1 < n){ dp[x][i] |= dp[x-1][i+1]; } if(i-1 >= 0){ dp[x][i] |= dp[x-1][i-1]; } dp[x][i] &= row[i]; } } } int ans = 0; for(int i = 0; i < n; i++){ ans += dp[k][i].count(); } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...