답안 #372712

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
372712 2021-03-01T10:57:23 Z hoanghq2004 산악 구조대 (JOI13_mountain) C++17
0 / 100
8 ms 1900 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

int height[210][210];

int ask(int i, int j, int X) {
    if (height[i][j] != -1) return height[i][j];
    height[i][j] = Measure(i, j);
    if (height[i][j] == X) Pinpoint(i, j);
    return height[i][j];
}

void check(int x, int y, int u, int v, int RS, int CS, int X) {
    map <int, vector <pair <int, int> > > mp;
    vector <pair <int, int> > block[210 * 210];
    for (int i = u; i <= v; ++i) {
        for (int j = u; j <= v; ++j) {
            mp[abs(i - RS) + abs(j - CS)].push_back({i, j});
        }
    }
    int sz = 0;
    for (auto [id, vcell]: mp) block[sz++] = vcell;
    int L = 0, R = sz - 1;
    while (R - L > 1) {
        int mid = (L + R) / 2;
        if (ask(block[mid].front().first, block[mid].front().second, X) < X) R = mid;
        else L = mid;
    }
    for (auto [i, j]: block[L]) ask(i, j, X);
    for (auto [i, j]: block[R]) ask(i, j, X);
}

void Rescue(int n, int m, int RS, int CS, int X) {
    memset(height, -1, sizeof(height));
    check(1, 1, RS, CS, RS, CS, X);
    check(RS + 1, CS + 1, n, m, RS, CS, X);
    check(1, CS + 1, RS, m, RS, CS, X);
    check(RS + 1, 1, n, CS, RS, CS, X);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1520 KB Output is correct
2 Incorrect 2 ms 1516 KB Wrong Answer [5]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 1900 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -