Submission #219694

#TimeUsernameProblemLanguageResultExecution timeMemory
219694EntityIT산악 구조대 (JOI13_mountain)C++14
100 / 100
17 ms1024 KiB
#include<bits/stdc++.h>
using namespace std;

#include "grader.h"

#define all(x) (x).begin(), (x).end()
#define sz(x) ( (int)(x).size() )
using LL = long long;

mt19937 rng( (uint32_t)chrono::steady_clock::now().time_since_epoch().count() );

void solve(int lX, int lY, int rX, int rY, bool up, bool right, int X) {
    if (lX > rX || lY > rY) return ;

    int x = up ? rX : lX,
        y = right ? rY : lY;
    int h = Measure(x, y);

    if (h == X) Pinpoint(x, y);
    else if (h < X) {
        if (right) solve(lX, lY, rX, rY - 1, up, right, X);
        else solve(lX, lY + 1, rX, rY, up, right, X);
    }
    else {
        if (up) solve(lX, lY, rX - 1, rY, up, right, X);
        else solve(lX + 1, lY, rX, rY, up, right, X);
    }
}

void Rescue(int R, int C, int RS, int CS, int X) {
    solve(1, 1, RS, CS, 1, 0, X);
    solve(RS, 1, R, CS, 0, 0, X);
    solve(1, CS, RS, C, 1, 1, X);
    solve(RS, CS, R, C, 0, 1, X);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...