| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 530140 | c28dnv9q3 | Nautilus (BOI19_nautilus) | C++17 | 1088 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
using namespace std;
const int MAX = 505;
int r, c, m;
bool grid[MAX][MAX], position[MAX][MAX];
string input;
void solve(int x, int y, int i) {
if (x < 0 || x >= c || y < 0 || y >= r || !grid[y][x]) {
return;
}
if (i == input.length()) {
position[y][x] = true;
return;
}
switch (input[i]) {
case 'N':
solve(x, y - 1, i + 1);
break;
case 'E':
solve(x + 1, y, i + 1);
break;
case 'S':
solve(x, y + 1, i + 1);
break;
case 'W':
solve(x - 1, y, i + 1);
break;
case '?':
solve(x, y - 1, i + 1);
solve(x + 1, y, i + 1);
solve(x, y + 1, i + 1);
solve(x - 1, y, i + 1);
break;
}
}
int main() {
cin >> r >> c >> m;
for (int i = 0; i < r; ++i) {
string s;
cin >> s;
for (int j = 0; j < c; ++j) {
grid[i][j] = (s[j] == '.');
}
}
cin >> input;
for (int i = 0; i < r; ++i) {
for (int j = 0; j < c; ++j) {
solve(j, i, 0);
}
}
int result = 0;
for (int i = 0; i < r; ++i) {
for (int j = 0; j < c; ++j) {
result += position[i][j];
}
}
cout << result;
}
컴파일 시 표준 에러 (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... | ||||
