# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
735757 | MODDI | Nautilus (BOI19_nautilus) | C++14 | 219 ms | 716 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
int r, c, n;
string str;
bitset<501> mat[501];
bitset<501> dp[2][501];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin>>r>>c>>n;
memset(dp, 0, sizeof dp);
memset(mat, 0, sizeof mat);
for(int i = 0; i < r; i++){
string s;
cin>>s;
for(int j = 0; j < c; j++){
if(s[j] == '.'){
mat[i][j] = 1;
dp[0][i][j] = 1;
}
}
}
cin>>str;
// for(int i = 0; i < r; i++){
// for(int j = 0; j < c; j++){
// cout<<dp[0][i][j]<<" ";
// }
// cout<<endl;
// }
// cout<<endl;
// assert(false);
for(int step = 1; step <= n; step++){
for(int i = 0; i < r; i++){
dp[step%2][i] = 0;
}
for(int i = 0; i < r; i++){
if (str[step - 1] == 'E' || str[step - 1] == '?') dp[step % 2][i] |= (dp[(step - 1) % 2][i] << 1 & mat[i]);
if (str[step - 1] == 'W' || str[step - 1] == '?') dp[step % 2][i] |= (dp[(step - 1) % 2][i] >> 1 & mat[i]);
if ((str[step - 1] == 'S' || str[step - 1] == '?') && i > 0) dp[step % 2][i] |= (dp[(step - 1) % 2][i - 1] & mat[i]);
if ((str[step - 1] == 'N' || str[step - 1] == '?') && i < n - 1) dp[step % 2][i] |= (dp[(step - 1) % 2][i + 1] & mat[i]);
}
}
ll ans = 0;
for(int i = 0; i < r; i++){
ans += dp[n%2][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... |