Submission #24896

#TimeUsernameProblemLanguageResultExecution timeMemory
24896youngyojun산악 구조대 (JOI13_mountain)C++11
0 / 100
1091 ms237904 KiB
#include "grader.h" #include <stdio.h> int AnsX, AnsY, X; bool f1(const int& x1, const int& x2, const int& y1, const int& y2) { if(x1 > x2 || y1 > y2) return false; if((x2-x1+1) * (y2-y1+1) <= 5) { for(int x = x1; x <= x2; x++) for(int y = y1; y <= y2; y++) if(X == Measure(x, y)) { AnsX = x; AnsY = y; return true; } return false; } const int midX = (x1+x2)>>1; int s = y1, e = y2; for(int mid; s < e;) { mid = (s+e+1)>>1; const int ret = Measure(midX, mid); if(ret == X) { AnsX = midX; AnsY = mid; return true; } else if(ret < X) s = mid; else e = mid-1; } if(X == Measure(midX, s)) { AnsX = midX; AnsY = s; return true; } return f1(midX+1, x2, y1, s) || f1(x1, midX-1, s+1, y2); } bool f2(const int& x1, const int& x2, const int& y1, const int& y2) { if(x1 > x2 || y1 > y2) return false; if((x2-x1+1) * (y2-y1+1) <= 5) { for(int x = x1; x <= x2; x++) for(int y = y1; y <= y2; y++) if(X == Measure(x, y)) { AnsX = x; AnsY = y; return true; } return false; } const int midX = (x1+x2) >> 1; int s = y1, e = y2; for(int mid; s < e;) { mid = (s+e+1)>>1; const int ret = Measure(midX, mid); if(ret == X) { AnsX = midX; AnsY = mid; return true; } else if(ret < X) s = mid; else e = mid-1; } if(X == Measure(midX, s)) { AnsX = midX; AnsY = s; return true; } return f2(x1, midX-1, y1, s) || f2(midX+1, x2, s+1, y2); } bool f3(const int& x1, const int& x2, const int& y1, const int& y2) { if(x1 > x2 || y1 > y2) return false; if((x2-x1+1) * (y2-y1+1) <= 5) { for(int x = x1; x <= x2; x++) for(int y = y1; y <= y2; y++) if(X == Measure(x, y)) { AnsX = x; AnsY = y; return true; } return false; } const int midX = (x1+x2) >> 1; int s = y1, e = y2; for(int mid; s < e;) { mid = (s+e+1)>>1; const int ret = Measure(midX, mid); if(ret == X) { AnsX = midX; AnsY = mid; return true; } else if(ret >= X) s = mid; else e = mid-1; } if(X == Measure(midX, s)) { AnsX = midX; AnsY = s; return true; } return f3(x1, midX-1, y1, s-1) || f3(midX+1, x2, s, y2); } bool f4(const int& x1, const int& x2, const int& y1, const int& y2) { if(x1 > x2 || y1 > y2) return false; if((x2-x1+1) * (y2-y1+1) <= 5) { for(int x = x1; x <= x2; x++) for(int y = y1; y <= y2; y++) if(X == Measure(x, y)) { AnsX = x; AnsY = y; return true; } return false; } const int midX = (x1+x2) >> 1; int s = y1, e = y2; for(int mid; s < e;) { mid = (s+e+1)>>1; const int ret = Measure(midX, mid); if(ret == X) { AnsX = midX; AnsY = mid; return true; } else if(ret >= X) s = mid; else e = mid-1; } if(X == Measure(midX, s)) { AnsX = midX; AnsY = s; return true; } return f4(x1, midX-1, s, y2) || f4(midX+1, x2, y1, s-1); } void Rescue(int R, int C, int RS, int CS, int _X) { X = _X; if(!(f1(1, RS, 1, CS) || f2(RS+1, R, 1, CS) || f3(1, RS, CS+1, C) || f4(RS+1, R, CS+1, C))) { while(1) puts("FUCK!"); } Pinpoint(AnsX, AnsY); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...