# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
372686 | ngpin04 | 산악 구조대 (JOI13_mountain) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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) {
found = true;
if (ask(i - 1, j - 1))
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) {
found = true;
if (ask(i + 1, j - 1))
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) {
found = true;
if (ask(i + 1, j + 1))
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) {
found = true;
if (ask(i - 1, j + 1))
i--;
j++;
}
if (!found)
break;
}
}