Submission #372711

# Submission time Handle Problem Language Result Execution time Memory
372711 2021-03-01T10:55:46 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 >> 1;
        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);
}

Compilation message

mountain.cpp: In function 'void check(int, int, int, int, int, int, int)':
mountain.cpp:27:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   27 |         int mid = L + R >> 1;
      |                   ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1516 KB Output is correct
2 Incorrect 2 ms 1516 KB Wrong Answer [5]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1900 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -