# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
730662 | gagik_2007 | Nautilus (BOI19_nautilus) | C++17 | 128 ms | 972 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.
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <chrono>
#include <ctime>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <limits>
#include <iomanip>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <functional>
#include <random>
#include <cassert>
#include <bitset>
using namespace std;
typedef long long ll;
typedef long double ld;
#pragma GCC optimize("Ofast")
#define ff first
#define ss second
ll ttt;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ll N = 507;
const ll LG = 21;
ll n, m, k;
char a[N][N];
string s;
bitset<N> dp[N];
bitset<N> lst[N];
bitset<N> b[N];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m >> k;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> a[i][j];
if (a[i][j] == '.') {
b[i][j] = true;
dp[i][j] = true;
}
}
}
cin >> s;
for (int c = 0; c < s.size(); c++) {
for (int i = 1; i <= n; i++) {
lst[i] = dp[i];
dp[i] = 0;
}
for (int i = 1; i <= n; i++) {
if (s[c] == 'N' || s[c] == '?') {
dp[i - 1] |= (lst[i] & b[i - 1]);
}
if (s[c] == 'E' || s[c] == '?') {
dp[i] |= ((lst[i] << 1) & b[i]);
}
if (s[c] == 'S' || s[c] == '?') {
dp[i + 1] |= (lst[i] & b[i + 1]);
}
if (s[c] == 'W' || s[c] == '?') {
dp[i] |= ((lst[i] >> 1) & b[i]);
}
}
}
int cnt = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cnt += dp[i][j];
}
}
cout << cnt << endl;
}
/// ---- - -------- ------ -------- -- - - -
/// Just a reminder. Ubuntu password is I O I
/// ---- - -------- ------ -------- -- - - -
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... |