| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 80962 | farukkastamonuda | Maxcomp (info1cup18_maxcomp) | C++14 | 353 ms | 25020 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fi first
#define se second
#define lo long long
#define inf 1000000000
#define md 1000000007
#define li 1004
#define mp make_pair
#define pb push_back
#define pii pair<int , pair<int , int> >
using namespace std;
struct node{
int val, x, y;
};
int n, m, A[li][li], vis[li][li], ans = - inf;
int yon1[6] = {1, - 1, 0, 0};
int yon2[6] = {0, 0, 1, - 1};
queue<node> q;
vector< pair<int , pair<int, int> > > v;
int main(){
scanf("%d %d", &n, &m);
for(int i = 1; i <= n; i ++){
for(int j = 1; j <= m; j ++){
scanf("%d", &A[i][j]);
vis[i][j] = - inf;
v.pb(mp(A[i][j], mp(i, j)));
}
}
sort(v.begin(), v.end());
q.push({v.back().fi, v.back().se.fi, v.back().se.se});
v.pop_back();
while(! q.empty()){
node temp = q.front();
q.pop();
int val = temp.val;
int x = temp.x;
int y = temp.y;
if(vis[x][y] > val) continue;
ans = max(ans, val - A[x][y] - 1);
while((int)v.size() && v.back().fi == val){
q.push({v.back().fi, v.back().se.fi, v.back().se.se});
v.pop_back();
}
for(int i = 0; i <= 3 ; i ++){
int dx = x + yon1[i];
int dy = y + yon2[i];
if(dx >= 1 && dx <= n && dy >= 1 && dy <= m && val - 1 > vis[dx][dy]){
vis[dx][dy] = val - 1;
q.push({val - 1, dx, dy});
}
}
}
printf("%d\n", ans);
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... | ||||
