이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
int pos[9000001][2];
int pref[3001][3001];
int r,c,h,w;
bool check(int x){
FOR(i,0,3000){
FOR(j,0,3000){
pref[i][j] = 0;
}
}
FOR(i,1,x+1){
int a = pos[i][0]; int b=pos[i][1];
FORNEG(j,a,max(-1, a-h)){
pref[j][b+1] -= 1;
}
b = max(0, b-(w-1));
FORNEG(j,a,max(-1, a-h)){
pref[j][b] += 1;
}
}
FOR(i,0,r){
FOR(j,1,c){
pref[i][j] += pref[i][j-1];
if (pref[i][j]> int(h*w/2)) return true;
}
}
return false;
}
int rectangle(int R, int C, int H, int W, int Q[3001][3001]) {
r = R; c = C; h = H; w = W;
FOR(i,0,R){
FOR(j,0,C){
pos[Q[i][j]][0] = i;
pos[Q[i][j]][1] = j;
}
}
int lo = 0;
int hi = int(R*C/2)+1;
while (lo < hi) {
int mid = lo + (hi - lo) / 2;
if (check(mid)) {
hi = mid;
} else {
lo = mid + 1;
}
}
return lo;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |