이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"
int n;
bool ask (int x, int y) { /// if the grass on (x, y) is flattened
if (x <= 0 || y <= 0 || x > n || y > n)
return false;
cout << "extract " << x << " " << y << endl;
string answer;
cin >> answer;
if (answer == "true")
return true;
return false;
}
int main() {
int xn, yn;
cin >> n >> xn >> yn;
int sz = 0;
int x = xn, y = yn;
while (ask (x, y + (1 << sz)))
sz++;
sz--;
int y2 = y;
while (sz >= 0) {
if (ask (x, y2 + (1 << sz)))
y2 += (1 << sz);
sz--;
}
sz = 0;
while (ask (x, y - (1 << sz)))
sz++;
sz--;
int y1 = y;
while (sz >= 0) {
if (ask (x, y2 - (1 << sz)))
y2 -= (1 << sz);
sz--;
}
sz = 0;
while (ask (x + (1 << sz), y))
sz++;
sz--;
int x2 = x;
while (sz >= 0) {
if (ask (x2 + (1 << sz), y))
x2 += (1 << sz);
sz--;
}
sz = 0;
while (ask (x - (1 << sz), y))
sz++;
sz--;
int x1 = x;
while (sz >= 0) {
if (ask (x1 - (1 << sz), y))
x1 -= (1 << sz);
sz--;
}
int m = x2 - x1 + 1;
int x_mid = (x2 - x1 + 1) / 2;
int y_mid = (y2 - y1 + 1) / 2;
if (ask (x_mid + 2 * m, y_mid))
x_mid += m;
if (ask (x_mid - 2 * m, y_mid))
x_mid -= m;
if (ask (x_mid, y_mid + 2 * m))
y_mid += m;
if (ask (x_mid, y_mid - 2 * m))
y_mid -= m;
cout << "solution " << x_mid << " " << y_mid << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |