# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1187913 | CrabCNH | Nautilus (BOI19_nautilus) | C++20 | 141 ms | 1052 KiB |
#include <bits/stdc++.h>
#define task "BriantheCrab"
#define int long long
#define pii pair <int, int>
#define fi first
#define se second
#define szf sizeof
#define sz(s) (int)((s).size())
using namespace std;
template <class T> void mini (T &t, T f) {if (t > f) t = f;}
template <class T> void maxi (T &t, T f) {if (t < f) t = f;}
const int maxN = 500 + 5;
const int inf = 1e18 + 7;
const int mod = 1e9 + 7;
int n, m, x;
char a[maxN][maxN];
string s;
bitset <maxN * maxN> dp, ok;
int mask (int i, int j) {
return i * (m + 1) + j;
}
void solve () {
cin >> n >> m >> x;
for (int i = 0; i < n; i ++) {
for (int j = 0; j < m; j ++) {
cin >> a[i][j];
if (a[i][j] == '.') {
ok[mask (i, j)] = 1;
}
}
}
cin >> s;
s = ' ' + s;
dp = ok;
for (auto c : s) {
if (c == '?') {
dp = (dp << 1) | (dp >> 1) | (dp << (m + 1)) | (dp >> (m + 1));
}
if (c == 'E') {
dp <<= 1;
}
if (c == 'W') {
dp >>= 1;
}
if (c == 'S') {
dp <<= (m + 1);
}
if (c == 'N') {
dp >>= (m + 1);
}
dp &= ok;
}
cout << dp.count ();
}
signed main () {
cin.tie (nullptr) -> sync_with_stdio (false);
if (fopen (task".inp", "r")) {
freopen (task".inp", "r", stdin);
freopen (task".out", "w", stdout);
}
int t = 1;
//cin >> t;
while (t --) {
solve ();
}
return 0;
}
// thfdgb
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... |