# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
163415 | iefnah06 | The Kingdom of JOIOI (JOI17_joioi) | C++11 | 260 ms | 93840 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
namespace from_kczno1 {
const int ch_top=4e6*11+1e6;
char ch[ch_top],*now_r=ch-1;
#define c (*now_r)
#define gc (*++now_r)
int read()
{
while(gc<'-');
int x=c-'0';
while(gc>='0')x=x*10+c-'0';
return x;
}
#undef gc
#undef c
}
using namespace from_kczno1;
const int INF = 1.1e9;
const int MAXX = 2010;
const int MAXY = 2010;
short X, Y;
int A[MAXX][MAXY];
int gmi, gma;
int mi, ma;
bool is_good(int v) {
int lhi = gmi + v;
int rlo = gma - v;
short prv = Y;
for (short x = 0; x < X; x++) {
short cur = 0;
while (cur < prv && A[x][cur] <= lhi) {
cur++;
}
for (short i = cur; i < Y; i++) {
if (A[x][i] < rlo) return false;
}
prv = cur;
}
return true;
}
// keep the upper bound
void go() {
mi = -1;
while (ma - mi > 1) {
int md = (mi + ma) / 2;
if (is_good(md)) {
ma = md;
} else {
mi = md;
}
}
}
int main() {
fread(ch,1,ch_top,stdin);
X = read(), Y = read();
gmi = INF, gma = -INF;
for (short x = 0; x < X; x++) {
for (short y = 0; y < Y; y++) {
A[x][y] = read();
gmi = min(gmi, A[x][y]);
gma = max(gma, A[x][y]);
}
}
ma = gma - gmi;
go();
for (short x = 0; x < X; x++) {
reverse(A[x], A[x] + Y);
}
go();
for (short y = 0; y < Y; y++) {
for (short x = 0; x < X / 2; x++) {
swap(A[x][y], A[X - 1 - x][y]);
}
}
go();
for (short x = 0; x < X; x++) {
reverse(A[x], A[x] + Y);
}
go();
cout << ma << '\n';
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... |