# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
496450 | Nalrimet | Nautilus (BOI19_nautilus) | C++17 | 204 ms | 157040 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;
const int N = 5 * 1e2 + 5;
const int inf = 1000000000;
#define int long long
#define F first
#define S second
#define pb push_back
#define ppb pop_back
int r, c, m, ans;
char f, s;
bitset<N> dp[N][5005];
main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> r >> c >> m;
for(int i = 1; i <= r; ++i){
for(int j = 1; j <= c; ++j){
dp[i][0][j - 1] = 1;
cin >> f;
if(f == '#') dp[i][0][j - 1] = 0;
}
// cout << dp[i][0] << '\n';
}
for(int k = 1; k <= m; ++k){
cin >> s;
for(int i = 1; i <= r; ++i){
dp[i][k] = dp[i][0];
if(s == 'N'){
dp[i][k] &= dp[i + 1][k - 1];
}
else if(s == 'S'){
dp[i][k] &= dp[i - 1][k - 1];
}
else if(s == 'E'){
dp[i][k] &= dp[i][k - 1] << 1;
}
else if(s == 'W'){
dp[i][k] &= dp[i][k - 1] >> 1;
}
else{
dp[i][k] &= (dp[i][k - 1] << 1) | (dp[i][k - 1] >> 1) | (dp[i - 1][k - 1]) | (dp[i + 1][k - 1]);
}
}
}
// 5 9 7
// ...##....
// ..#.##..#
// ..#....##
// .##...#..
// ....#....
// WS?EE??
for(int i = 1; i <= r; ++i){
// cout << dp[i][m] << '\n';
ans += dp[i][m].count();
}
cout << ans;
return 0;
}
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... |