| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1299633 | TrieTr | Nautilus (BOI19_nautilus) | C++20 | 107 ms | 1068 KiB |
#include<bits/stdc++.h>
using namespace std;
void local() {
#define taskname ""
if (fopen(taskname".inp", "r")) {
freopen(taskname".inp", "r", stdin);
freopen(taskname".out", "w", stdout);
}
}
#define ll long long
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
template<class X, class Y> bool mini(X &a, const Y &b) {return (a > b) ? a = b, true : false;}
template<class X, class Y> bool maxi(X &a, const Y &b) {return (a < b) ? a = b, true : false;}
const int N = 5e2 + 5;
int n, m, k;
bitset<N> vis[2][N];
bitset<N> init[N];
int main() {
fastio; local();
cin >> n >> m >> k;
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
char c; cin >> c;
init[i][j] = (c == '.');
}
}
bool turn = 0;
for(int i = 0; i < n; i++) vis[turn][i] = init[i];
string s; cin >> s;
for(int _ = 0; _ < k; _++) {
char dir = s[_];
turn ^= 1;
for(int i = 0; i < n; i++) vis[turn][i].reset();
if(dir == 'N' || dir == '?') {
for(int i = 1; i < n; i++) {
vis[turn][i - 1] |= vis[turn ^ 1][i];
}
}
if(dir == 'S' || dir == '?') {
for(int i = 0; i < n - 1; i++) {
vis[turn][i + 1] |= vis[turn ^ 1][i];
}
}
if(dir == 'W' || dir == '?') {
for(int i = 0; i < n; i++) {
vis[turn][i] |= (vis[turn ^ 1][i] >> 1);
}
}
if(dir == 'E' || dir == '?') {
for(int i = 0; i < n; i++) {
vis[turn][i] |= (vis[turn ^ 1][i] << 1);
}
}
for(int i = 0; i < n; i++) vis[turn][i] &= init[i];
}
int cnt = 0;
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
cnt += vis[turn][i][j];
}
}
cout << cnt;
}
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... | ||||
