| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 496276 | kingline | Nautilus (BOI19_nautilus) | C++17 | 3 ms | 332 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.
/*#pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")*/
#include <bits/stdc++.h>
#define file(data) freopen(data".in", "r", stdin); freopen(data".out", "w", stdout);
#define pb push_back
#define all(data) data.begin(), data.end()
#define endl '\n'
#define ll long long
//#define int long long
#define pii pair < int, int >
using namespace std;
const int N = 2e5 + 5;
int n, m, k, use, used[505][505];
char c[505][505];
bool can[505][505];
string s;
void check(int x, int y) {
bool ok = 1;
for(int i = 0; i < s.size(); i++) {
bool cn = 0;
if(s[i] == 'S' && x + 1 <= n && c[x + 1][y] == '.') {
x++;
cn = 1;
}
if(s[i] == 'N' && x - 1 > 0 && c[x - 1][y] == '.') {
x--;
cn = 1;
}
if(s[i] == 'W' && y - 1 > 0 && c[x][y - 1] == '.') {
y--;
cn = 1;
}
if(s[i] == 'E' && y + 1 > 0 && c[x][y + 1] == '.') {
y++;
cn = 1;
}
if(!cn) {
ok = 0;
break;
}
}
if(ok) can[x][y] = 1;
}
main() {
//file("pieaters");
ios_base::sync_with_stdio(0);
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 >> c[i][j];
}
}
cin >> s;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
if(c[i][j] == '.') {
check(i, j);
}
}
}
int ans = 0;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
if(can[i][j]) {
ans++;
}
}
}
cout << ans;
}
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... | ||||
