# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
857186 | Trisanu_Das | Nautilus (BOI19_nautilus) | C++17 | 163 ms | 1372 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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';
}
컴파일 시 표준 에러 (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... |