| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 529620 | schse | Nautilus (BOI19_nautilus) | C++17 | 20 ms | 1604 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
bool been[102][102][102];
bool lastpos[502][502];
string dirs;
vector<vector<bool>> field;
void dfs(int n, int x, int y)
{
if (been[n][x][y])
return;
if (!field[y][x])
return;
if (n == dirs.size())
{
lastpos[y][x] = true;
return;
}
been[n][x][y] = true;
if (dirs[n] == 'N')
dfs(n + 1, x, y - 1);
else if (dirs[n] == 'S')
dfs(n + 1, x, y + 1);
else if (dirs[n] == 'W')
dfs(n + 1, x - 1, y);
else if (dirs[n] == 'E')
dfs(n + 1, x + 1, y);
else
{
dfs(n + 1, x, y - 1);
dfs(n + 1, x, y + 1);
dfs(n + 1, x - 1, y);
dfs(n + 1, x + 1, y);
}
}
int main()
{
int R, C, M;
cin >> R >> C >> M;
field.resize(R + 2, vector<bool>(C + 2, 0));
for (int i = 0; i < R; i++)
{
string str;
cin >> str;
for (int e = 0; e < str.size(); e++)
field[i + 1][e + 1] = str[e] == '.';
}
cin >> dirs;
int sum = 0;
for (int x = 0; x < C; x++)
for (int y = 0; y < R; y++)
dfs(0, x + 1, y + 1);
sum = 0;
for (int x = 0; x < C; x++)
{
for (int y = 0; y < R; y++)
{
if (lastpos[y + 1][x + 1])
sum++;
}
}
cout << sum;
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... | ||||
