# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
127275 | E869120 | Maxcomp (info1cup18_maxcomp) | C++14 | 1068 ms | 760 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <cassert>
using namespace std;
#pragma warning (disable: 4996)
int N, M, A[1009][1009], dist[1009][1009];
int main() {
scanf("%d%d", &N, &M);
assert(N * M <= 2500);
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= M; j++) { scanf("%d", &A[i][j]); dist[i][j] = A[i][j] - 1; }
}
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>Q;
for (int i = 1; i <= N; i++) { for (int j = 1; j <= M; j++) Q.push(make_pair(A[i][j], i * 10000 + j)); }
while (!Q.empty()) {
int pos = Q.top().second; Q.pop();
int px = pos / 10000, py = pos % 10000;
int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
for (int i = 0; i < 4; i++) {
int ex = px + dx[i], ey = py + dy[i];
if (ex <= 0 || ey <= 0 || ex > N || ey > M) continue;
if (dist[ex][ey] < dist[px][py] - 1) {
dist[ex][ey] = dist[px][py] - 1;
Q.push(make_pair(dist[ex][ey], ex * 10000 + ey));
}
}
}
int maxn = -1;
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= M; j++) maxn = max(maxn, dist[i][j] - A[i][j]);
}
cout << maxn << endl;
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |