Submission #372671

# Submission time Handle Problem Language Result Execution time Memory
372671 2021-03-01T09:21:30 Z ngpin04 산악 구조대 (JOI13_mountain) C++14
0 / 100
6 ms 492 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
const int N = 205;

int target,r,c;

bool ask(int x, int y) {
    if (min(x, y) == 0 || x > r || y > c)
        return false;
    int val = Measure(x, y);
    if (val == target) {
        Pinpoint(x, y);
        exit(0);
    }
    return val > target;
}

void Rescue(int n, int m, int rs, int cs, int x) {
    r = n;
    c = m;
    target = x;
    int i,j;

    /** right */
    i = rs, j = cs;
    while (ask(i, j + 1))
        j++;

    while (true) {
        bool found = false;
        if (ask(i - 1, j)) {
            found = true;
            i--;
        } else if (j - 1 > cs && ask(i - 1, j - 1)) {
            found = true;
            i--;
            j--;
        }
        if (!found)
            break;
    }

    /** top */
    i = rs, j = cs;
    while (ask(i - 1, j))
        i--;

    while (true) {
        bool found = false;
        if (ask(i, j - 1)) {
            found = true;
            j--;
        } else if (i + 1 < rs && ask(i + 1, j - 1)) {
            found = true;
            i++;
            j--;
        }
        if (!found)
            break;
    }
    /** left */
    i = rs, j = cs;
    while (ask(i, j - 1))
        j--;

    while (true) {
        bool found = false;
        if (ask(i + 1, j)) {
            found = true;
            i++;
        } else if (j + 1 < cs && ask(i + 1, j + 1)) {
            found = true;
            i++;
            j++;
        }
        if (!found)
            break;
    }
    /** bot */
    i = rs, j = cs;
    while (ask(i + 1, j))
        i++;

    while (true) {
        bool found = false;
        if (ask(i, j + 1)) {
            found = true;
            j++;
        } else if (i - 1 > rs && ask(i - 1, j + 1)) {
            found = true;
            i--;
            j++;
        }
        if (!found)
            break;
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 492 KB Output is correct
2 Incorrect 6 ms 492 KB Wrong Answer [5]
3 Halted 0 ms 0 KB -