| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 945241 | LucaIlie | Nautilus (BOI19_nautilus) | C++17 | 1060 ms | 253212 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 500;
const int MAX_K = 5000;
char mat[MAX_N + 2][MAX_N + 2];
set <pair <int, int>> dp[MAX_K + 1];
int dl[4] = { -1, 0, 1, 0 };
int dc[4] = { 0, -1, 0, 1 };
int dir[256];
int main() {
int n, m, k;
dir['N'] = 0;
dir['W'] = 1;
dir['S'] = 2;
dir['E'] = 3;
cin >> n >> m >> k;
for ( int l = 1; l <= n; l++ ) {
for ( int c = 1; c <= m; c++ )
cin >> mat[l][c];
}
for ( int l = 0; l <= n + 1; l++ )
mat[l][0] = mat[l][m + 1] = '#';
for ( int c = 0; c <= m + 1; c++ )
mat[0][c] = mat[n + 1][c] = '#';
string moves;
cin >> moves;
moves = " " + moves;
for ( int l = 1; l <= n; l++ ) {
for ( int c = 1; c <= m; c++ ) {
if ( mat[l][c] == '.' )
dp[0].insert( { l, c } );
}
}
for ( int i = 1; i <= k; i++ ) {
for ( pair <int, int> p: dp[i - 1] ) {
if ( moves[i] == '?' ) {
for ( int d = 0; d < 4; d++ ) {
int l = p.first + dl[d], c = p.second + dc[d];
if ( mat[l][c] == '.' )
dp[i].insert( { l, c } );
}
} else {
int d = dir[moves[i]];
int l = p.first + dl[d], c = p.second + dc[d];
if ( mat[l][c] == '.' )
dp[i].insert( { l, c } );
}
}
}
cout << dp[k].size();
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... | ||||
