# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
713006 | lukameladze | Nautilus (BOI19_nautilus) | C++14 | 178 ms | 976 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 <bits/stdc++.h>
using namespace std;
#define f first
#define s second
// #define int long long
#define free fre
#define pii pair <int, int>
#define pb push_back
const int N = 3e5 + 5;
int t,n,m,k;
bitset < 505 * 505 > dp, free;
//
main() {
cin>>n>>m>>k;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
char ch; cin>>ch;
if (ch == '.') {
dp[(i - 1) * (m + 2) + j] = 1;
free[(i - 1) * (m + 2) + j] = 1;
}
}
}
string s; cin>>s;
s = "@" + s;
for (int i = 1; i <= k; i++) {
char ch = s[i];
if (ch == 'E') {
dp = (dp << 1) & free;
} else if (ch == 'W') {
dp = (dp >> 1) & free;
} else if (ch == 'S') {
dp = (dp << (m + 2)) & free;
} else if (ch == 'N') {
dp = (dp >> (m + 2)) & free;
} else dp = ((dp << 1) | (dp >> 1) | (dp << (m + 2)) | (dp >> (m + 2))) & free;
}
/*for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (dp[(i - 1) * (m + 2) + j]) cout<<1;else cout<<0;
}
cout<<"\n";
}*/
cout<<dp.count()<<"\n";
}
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... |