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 "grader.h"
#include <bits/stdc++.h>
using namespace std;
struct pt{
int x=0, y=0;
pt(int a, int b): x(a), y(b){};
pt(){};
};
typedef pair<pt, int> ppi;
int R, X;
vector<ppi> ans;
int check(pt p){return Measure(p.x, p.y);}
int check(int a, int b){return Measure(a,b);}
void f(pt x){ans.push_back(ppi(x, check(x)));}
pt srh(pt a, pt b){
//a가 작고, b가 크다.
int s, e, m, dx=0, dy=0, d;
if(a.x==b.x)
s=a.y, e=b.y, dy=s<e?1:-1;
else
s=a.x, e=b.x, dx=s<e?1:-1;
pt now;
for(m=(s+e)/2, d=dx+dy; s!=e; m=(s+e+(d<0?1:0))/2){
if(dx==0) now=pt(a.x, m);
else now=pt(m, a.y);
if(check(now)<X) s=m+d;
else e=m;
}
if(dx==0) now=pt(a.x, m);
else now=pt(m, a.y);
//X이상인 점
return now;
}
void Rescue(int R, int C, int RS, int CS, int _X){
X=_X;
pt top=pt(RS, CS);
pt a=srh(pt(1,CS), top), b=srh(pt(RS,1), top), c=srh(pt(R, CS), top), d=srh(pt(RS, C), top);
f(a), f(b), f(c), f(d), f(top);
pt p=pt(a.x,b.y), q=pt(c.x,b.y), r=pt(c.x,d.y), s=pt(a.x,d.y);
f(srh(p,a)), f(srh(p,b)), f(srh(q,b)), f(srh(q,c)), f(srh(r,c)), f(srh(r,d)), f(srh(s,d)), f(srh(s,a));
for(auto& p:ans){
if(p.second==X){
Pinpoint(p.first.x, p.first.y);
return;
}
}
//nope
return;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |