Submission #12947

#TimeUsernameProblemLanguageResultExecution timeMemory
12947gs14004산악 구조대 (JOI13_mountain)C++98
100 / 100
21 ms944 KiB
#include "grader.h"

void Rescue(int R, int C, int RS, int CS, int X){
    int px = 1, py = CS;
    while (px <= RS && py) {
        int t = Measure(px,py);
        if(t < X){
            px++;
        }
        else if(t > X){
            py--;
        }
        else{
            Pinpoint(px,py);
            return;
        }
    }
    px = R, py = CS;
    while (px >= RS && py) {
        int t = Measure(px,py);
        if(t < X){
            px--;
        }
        else if(t > X){
            py--;
        }
        else{
            Pinpoint(px,py);
            return;
        }
    }
    px = 1, py = CS;
    while (px <= RS && py <= C) {
        int t = Measure(px,py);
        if(t < X){
            px++;
        }
        else if(t > X){
            py++;
        }
        else{
            Pinpoint(px,py);
            return;
        }
    }
    px = R, py = CS;
    while (px >= RS && py <= C) {
        int t = Measure(px,py);
        if(t < X){
            px--;
        }
        else if(t > X){
            py++;
        }
        else{
            Pinpoint(px,py);
            return;
        }
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...