Submission #31639

#TimeUsernameProblemLanguageResultExecution timeMemory
31639Diuven산악 구조대 (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); 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; } } Pinpoint(ans[0].first.x, ans[0].first.y); //nope return; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...