# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
857186 | Trisanu_Das | Nautilus (BOI19_nautilus) | C++17 | 163 ms | 1372 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;
int r,c,m;
vector<string> a;
bool valid_pos(int i, int j){
return !(i < 0 || j < 0 || i >= r || j >= c || a[i][j] == '#');
}
int main(){
cin >> r >> c >> m;
a.resize(r);
for(int i = 0; i < r; ++i) cin >> a[i];
string msg; cin >> msg;
bitset<1000> dp[r],temp[r],aa[r];
for(int i = 0; i < r; ++i){
for(int j = 0; j < c; ++j){
aa[i][j] = a[i][c-1-j] == '.';
dp[i][j] = a[i][c-1-j] == '.';
}
}
for(char w : msg){
for(int i = 0; i < r; ++i){
if(w == 'W') dp[i] = (dp[i]<<1)&aa[i];
if(w == 'E') dp[i] = (dp[i]>>1)&aa[i];
if(w == 'N')
if(i+1 < r) dp[i] = dp[i+1]&aa[i];
else dp[i].reset();
if(w == '?'){
temp[i] = (dp[i]<<1)|(dp[i]>>1);
if(i) temp[i] |= dp[i-1];
if(i+1 < r) temp[i] |= dp[i+1];
temp[i] &= aa[i];
}
}
for(int i = r-1; i >= 0; --i)
if(w == 'S')
if(i) dp[i] = dp[i-1]&aa[i];
else dp[i].reset();
for(int i = 0; i < r; ++i) if(w == '?') dp[i] = temp[i];
}
int ans = 0;
for(int i = 0; i < r; ++i) ans += dp[i].count();
cout << ans << '\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... |