Submission #31702

#TimeUsernameProblemLanguageResultExecution timeMemory
31702Diuven산악 구조대 (JOI13_mountain)C++11
0 / 100
14 ms512 KiB
#include "grader.h"
#include <utility>
#include <vector>
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(d=dx+dy, m=(s+e+(d<0?1:0))/2; 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, s);
	else		now=pt(s, 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);
	for(int i=a.x; i<=c.x; i++){
		f(pt(i, b.y));
		f(pt(i, d.y));
	}
	for(int i=b.y; i<=d.y; i++){
		f(pt(a.x, i));
		f(pt(c.x, i));
	}
	for(auto& p:ans){
		if(p.second==X){
			Pinpoint(p.first.x, p.first.y);
			return;
		}
	}
	Pinpoint(ans[0].first.x, ans[0].first.y);
	//nope
	return;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...