| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 850432 | thisistotallymyusername | Tracks in the Snow (BOI13_tracks) | C++14 | 448 ms | 135200 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <cstring>
#include <algorithm>
#include <deque>
using namespace std;
typedef pair<int, int> PII;
#define F first
#define S second
const int N = 4010, INF = 0x3f3f3f3f;
char g[N][N];
int n, m, res, d[N][N], dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
void bfs() {
deque<PII> q; q.emplace_back(0, 0);
memset(d, 0x3f, sizeof d); d[0][0] = 1;
while (!q.empty()) {
PII t = q.front(); q.pop_front();
for (int i = 0; i < 4; i++) {
int x = t.F + dx[i], y = t.S + dy[i];
if (0 <= x && x < n && 0 <= y && y < m && g[x][y] != '.') {
int tmp = (g[x][y] != g[t.F][t.S]);
if (d[x][y] > d[t.F][t.S] + tmp) {
d[x][y] = d[t.F][t.S] + tmp;
if (tmp) {
q.emplace_back(x, y);
} else {
q.emplace_front(x, y);
}
}
}
}
}
}
int main() {
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++) scanf("%s", g[i]);
bfs();
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
if (d[i][j] != INF)
res = max(res, d[i][j]);
printf("%d\n", res);
return 0;
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
