# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
221382 | Leonardo_Paes | Nautilus (BOI19_nautilus) | C++17 | 59 ms | 512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
const int maxn = 510;
int r, c, m, ans = 0;
bitset<maxn> dp[maxn], mat[maxn], tfg[maxn];
string s;
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
cin >> r >> c >> m;
for(int i=0; i<r; i++){
for(int j=0; j<c; j++){
char a;
cin >> a;
if(a == '.') mat[i][c-j-1] = dp[i][c-j-1] = 1;
}
}
cin >> s;
for(int j=0; j<s.size(); j++){
if(s[j] == 'N'){
for(int i=0; i<r; i++){
if(i+1 < r) dp[i] = (dp[i+1] & mat[i]);
else dp[i].reset();
}
}
if(s[j] == 'S'){
for(int i=r-1; i>=0; i--){
if(i) dp[i] = (dp[i-1] & mat[i]);
else dp[i].reset();
}
}
if(s[j] == 'E'){
for(int i=0; i<r; i++){
dp[i] = ((dp[i] >> 1) & mat[i]);
}
}
if(s[j] == 'W'){
for(int i=0; i<r; i++){
dp[i] = ((dp[i] << 1) & mat[i]);
}
}
if(s[j] == '?'){
for(int i=0; i<r; i++){
tfg[i] = (dp[i] << 1)|(dp[i] >> 1);
if(i) tfg[i] |= dp[i-1];
if(i+1 < r) tfg[i] |= dp[i+1];
tfg[i] &= mat[i];
}
for(int i=0; i<r; i++){
dp[i] = tfg[i];
}
}
}
for(int i=0; i<r; i++) ans += dp[i].count();
cout << ans << endl;
return 0;
}
컴파일 시 표준 에러 (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... |