# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
314080 | BeanZ | Nautilus (BOI19_nautilus) | C++14 | 211 ms | 768 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// I_Love_LPL
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N = 505;
bitset<N> a[N], dp[N][2];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
if (fopen("A.inp", "r")){
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
}
ll r, c, m;
cin >> r >> c >> m;
for (int i = 1; i <= r; i++){
for (int j = 1; j <= c; j++){
char s;
cin >> s;
if (s == '.') a[i][j] = 1;
}
dp[i][0] = a[i];
//cout << dp[i][0] << endl;
}
string s;
cin >> s;
for (int i = 0; i < m; i++){
for (int j = 1; j <= r; j++){
if (s[i] == 'N') dp[j][(i + 1) & 1] = dp[j + 1][i & 1];
if (s[i] == 'W') dp[j][(i + 1) & 1] = dp[j][i & 1] >> 1;
if (s[i] == 'E') dp[j][(i + 1) & 1] = dp[j][i & 1] << 1;
if (s[i] == 'S') dp[j][(i + 1) & 1] = dp[j - 1][i & 1];
if (s[i] == '?') dp[j][(i + 1) & 1] = dp[j - 1][i & 1] | dp[j + 1][i & 1] | (dp[j][i & 1] >> 1) | (dp[j][i & 1] << 1);
dp[j][(i + 1) & 1] &= a[j];
//cout << j << " " << i << " " << dp[j][i & 1] << endl;
}
}
ll ans = 0;
for (int i = 1; i <= r; i++){
ans = ans + dp[i][m & 1].count();
}
cout << ans;
}
/*
2 3 3
..#
#.#
?S?
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |