Submission #372670

# Submission time Handle Problem Language Result Execution time Memory
372670 2021-03-01T09:20:32 Z two_sides 산악 구조대 (JOI13_mountain) C++17
0 / 100
8 ms 492 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

void Rescue(int r, int c, int rs, int cs, int x) {
    int lim = max({rs + cs - 2, rs - 1 + c - cs,
    r - rs + cs - 1, r - rs + c - cs});
    auto getRand = [&](int d) {
        if (d < 0) return INT_MAX;
        if (d > lim) return INT_MIN;
        for (int i = 1; i <= r; i++)
            for (int j = 1; j <= c; j++)
                if (abs(i - rs) + abs(j - cs) == d)
                    return Measure(i, j);
    };
    int lo = 0, hi = lim, curd;
    while (lo <= hi) {
        int mi = (lo + hi) / 2;
        int lef = getRand(mi - 1);
        int rig = getRand(mi + 1);
        if (x >= lef) hi = mi - 1;
        else if (x <= rig) lo = mi + 1;
        else {
            curd = mi; break;
        }
    }
    int ma = INT_MIN;
    for (int i = 1; i <= r; i++)
        for (int j = 1; j <= c; j++)
            if (abs(i - rs) + abs(j - rs) == curd) {
                int val = Measure(i, j);
                if (val == x) {
                    Pinpoint(i, j); return;
                }
                ma = max(ma, val);
            }
    if (ma < x) curd--; else curd++;
    for (int i = 1; i <= r; i++)
        for (int j = 1; j <= c; j++)
            if (abs(i - rs) + abs(j - rs) == curd) {
                int val = Measure(i, j);
                if (val == x) {
                    Pinpoint(i, j); return;
                }
            }
}

Compilation message

mountain.cpp: In lambda function:
mountain.cpp:16:5: warning: control reaches end of non-void function [-Wreturn-type]
   16 |     };
      |     ^
mountain.cpp: In function 'void Rescue(int, int, int, int, int)':
mountain.cpp:38:34: warning: 'curd' may be used uninitialized in this function [-Wmaybe-uninitialized]
   38 |     if (ma < x) curd--; else curd++;
      |                              ~~~~^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Incorrect 1 ms 364 KB Wrong Answer [5]
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 492 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -