#include <bits/stdc++.h>
using namespace std;
template<class C>constexpr int len(const C&c){return int(c.size());}
const int DDX[13] = {-2, 0, 2, -1, 1, -2, 0, 2, -1, 1, -2, 0, 2};
const int DDY[13] = {-2, -2, -2, -1, -1, 0, 0, 0, 1, 1, 2, 2, 2};
long long N;
bool rng(long long X){
return 1 <= X && X <= N;
}
map<pair<long long, long long>, bool> memo;
bool query(long long X, long long Y){
if(!rng(X) || !rng(Y)) return false;
if(memo.count(make_pair(X, Y))) return memo[make_pair(X, Y)];
cout << "examine " << X << " " << Y << endl;
string s; cin >> s;
return memo[make_pair(X, Y)] = (s == "true");
}
int main(){
cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
long long XS, YS, X1, Y1, X2, SZ, XC, YC, i = 1; cin >> N >> XS >> YS;
// find offset from center of current square
// find right side
for(X1 = XS; ; i += i){
if(!query(X1 + i, YS)){
X1 += i / 2LL; break;
}
}
long long L = X1, R = X1 + i / 2LL, MID;
while(R - L > 1){
MID = L + (R - L) / 2;
if(query(MID, YS)) L = MID;
else R = MID;
}
// find left side
X1 = L; X2 = XS;
for(i = 1; ; i += i){
if(!query(X2 - i, YS)){
X2 -= i / 2LL; break;
}
}
L = X2 - i / 2LL; R = X2;
while(R - L > 1){
MID = L + (R - L) / 2;
if(query(MID, YS)) R = MID;
else L = MID;
}
// find top side
X2 = R; SZ = X1 - X2 + 1; XC = (X1 + X2) / 2; Y1 = YS;
for(i = 1; ; i += i){
if(!query(XC, Y1 - i)){
Y1 -= i / 2LL; break;
}
}
L = Y1 - i / 2LL; R = Y1;
while(R - L > 1){
MID = L + (R - L) / 2;
if(query(XC, MID)) R = MID;
else L = MID;
}
// bottom side
Y1 = R; YC = Y1 + SZ / 2;
// +41 queries for finding center
for(int i = 0; i < 13; ++i){
X1 = XC + SZ * DDX[i];
Y1 = YC + SZ * DDY[i];
if(!rng(X1) || !rng(Y1)) continue;
int cnt = 0;
for(int j = 0; j < 13; ++j){
XS = X1 + SZ * DDX[j];
YS = Y1 + SZ * DDY[j];
if(rng(XS) && rng(YS) && query(XS, YS)) ++cnt;
else break;
}
if(cnt == 13){
cout << "solution " << X1 << " " << Y1 << endl;
return 0;
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
392 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |