Submission #125560

#TimeUsernameProblemLanguageResultExecution timeMemory
125560eriksuenderhaufNautilus (BOI19_nautilus)C++11
100 / 100
209 ms804 KiB
#include <bits/stdc++.h> char str[505][505], qry[5005]; std::bitset<505> dp[505][2], arr[505]; int main() { int r, c, m, ans = 0; assert(3==scanf("%d %d %d", &r, &c, &m)); for (int i = 1; i <= r && 1==scanf("%s", str[i]+1); i++) for (int j = 1; j <= c; j++) if (str[i][j] == '.') dp[i][0][j] = arr[i][j] = 1; assert(1==scanf("%s", qry+1)); for (int i = 1; i <= m; i++) for (int j = 1; j <= r; j++) if (qry[i] != '?') dp[j][(i&1)]=(qry[i]=='N'||qry[i]=='S') ? (dp[j+1*(qry[i]=='N'?1:-1)][(i&1)^1] & arr[j]) : ((qry[i]=='E') ? ((dp[j][(i&1)^1]<<1) & arr[j]) : ((dp[j][(i&1)^1]>>1) & arr[j])); else dp[j][(i&1)] = (dp[j+1][(i&1)^1] | dp[j-1][(i&1)^1] | (dp[j][(i&1)^1] >> 1) | (dp[j][(i&1)^1] << 1)) & arr[j]; for (int i = 1; i <= r; i++) ans += dp[i][m&1].count(); return !printf("%d\n", ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...