#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;
}
}
Compilation message
mountain.cpp: In function 'bool ask(int, int)':
mountain.cpp:11:15: error: 'Measure' was not declared in this scope
11 | int val = Measure(x, y);
| ^~~~~~~
mountain.cpp:13:9: error: 'Pinpoint' was not declared in this scope
13 | Pinpoint(x, y);
| ^~~~~~~~