# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
407108 | iulia13 | Tracks in the Snow (BOI13_tracks) | C++14 | 954 ms | 131044 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <map>
#include <vector>
#include <deque>
using namespace std;
const int N = 4005;
char a[N][N];
int lvl[N][N];
int ans = 0;
int dL[4] = {0, 1, 0, -1};
int dC[4] = {1, 0, -1, 0};
struct NOD{
int x, y;
};
deque <NOD> dq;
int main()
{
int n, m, i, j;
cin >> n >> m;
for (i = 1; i <= n; i++)
cin >> a[i] + 1;
dq.push_back({1, 1});
lvl[1][1] = 1;
while (!dq.empty())
{
int x = dq.front().x;
int y = dq.front().y;
ans = max(ans, lvl[x][y]);
dq.pop_front();
for (i = 0; i < 4; i++)
{
int xx = x + dL[i];
int yy = y + dC[i];
if (a[xx][yy] != '.' && xx >= 1 && yy >= 1 && xx <= n && yy <= m && !lvl[xx][yy])
{
if (a[xx][yy] == a[x][y])
{
lvl[xx][yy] = lvl[x][y];
dq.push_front({xx, yy});
}
else
{
lvl[xx][yy] = lvl[x][y] + 1;
dq.push_back({xx, yy});
}
}
}
}
cout << ans;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |