# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
89850 | Dat160601 | The Kingdom of JOIOI (JOI17_joioi) | C++17 | 3 ms | 960 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int n, m, mini = 2e9, maxi = 0, a[2007][2007], sv[2007][2007];
bool Check(int x, int n, int m){
int cur = m, mi = 2e9, mx = 0;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= cur; j++){
if(sv[i][j] - mini > x){
cur = j - 1;
break;
}
}
for(int j = cur + 1; j <= m; j++){
mi = min(mi, sv[i][j]), mx = max(mx, sv[i][j]);
}
if(mx - mi > x) return false;
}
return true;
}
bool check(int x){
for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) sv[i][j] = a[i][j];
if(Check(x, n, m)) return true;
for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) sv[i][j] = a[n - i + 1][j];
if(Check(x, n, m)) return true;
for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) sv[j][i] = a[i][j];
if(Check(x, m, n)) return true;
for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) sv[j][i] = a[i][m - j + 1];
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |