| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 102695 | luciocf | Tracks in the Snow (BOI13_tracks) | C++14 | 1395 ms | 114228 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e3+10;
typedef pair<int, int> pii;
int n, m;
int ans;
char tab[maxn][maxn];
bool mark[maxn][maxn];
int linha[] = {-1, 1, 0, 0};
int coluna[] = {0, 0, -1, 1};
void bfs(void)
{
deque<pair<pii, int>> dq;
ans = 1, mark[0][0] = 1;
dq.push_front({{0, 0}, 1});
while (!dq.empty())
{
int x = dq.front().first.first;
int y = dq.front().first.second;
int t = dq.front().second;
dq.pop_front();
ans = max(ans, t);
for (int i = 0; i < 4; i++)
{
int a = x+linha[i], b = y+coluna[i];
if (a < 0 || a >= n || b < 0 || b >= m || mark[a][b] || tab[a][b] == '.') continue;
if (tab[a][b] != tab[x][y]) dq.push_back({{a, b}, t+1});
else dq.push_front({{a, b}, t});
mark[a][b] = 1;
}
}
}
int main(void)
{
scanf("%d %d", &n, &m);
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
scanf(" %c", &tab[i][j]);
bfs();
printf("%d\n", ans);
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
