#include <iostream>
#include <map>
#include <cassert>
#include <vector>
#include <algorithm>
#include <deque>
#include <set>
#include <utility>
#include <array>
using namespace std;
#define ALL(x) x.begin(), x.end()
#define ShinLena cin.tie(nullptr)->sync_with_stdio(false);
using ll = long long;
int m, n, x, y, bl, bt, br;
map<pair<int, int>, bool> mp;
bool examine(int x, int y)
{
if (mp.count({x, y})) return mp[{x, y}];
if (x < 1 || x > n || y < 1 || y > n) return false;
cout << "examine " << x << ' ' << y << '\n' << flush;
char s[6]{0};
cin >> s;
return mp[{x, y}] = (s[0] == 't');
}
void solution(int x, int y)
{
cout << "solution " << x << ' ' << y << "\n" << flush;
exit(0);
}
void find_border()
{
bl = -1; bt = -1; br =-1;
int l = 0, r = x-1;
while (l <= r)
{
int o = (l+r)/2;
if (examine(o, y))
{
int oo = (o+x)/2;
if (examine(oo, y))
{
int ooo = (oo+x)/2;
if (examine(ooo, y)) r = o - 1;
else l = ooo + 1, bl = ooo;
}
else l = oo + 1, bl = oo;
}
else l = o + 1, bl = o;
}
l = x+1, r = n+1;
while (l <= r)
{
int o = (l+r)/2;
if (examine(o, y))
{
int oo = (l+o)/2;
if (examine(oo, y))
{
int ooo = (oo + l) / 2;
if (examine(ooo, y)) l = o + 1;
else r = min(ooo - 1, r-1), br = ooo;
}
else r = oo - 1, br = oo;
}
else r = o - 1, br = o;
}
assert(!examine(br, y) && examine(br-1, y));
m = br - bl - 1;
l = 0, r = y - 1;
while (l <= r)
{
int o = (l+r)/2;
if (examine(x, o))
{
int oo = (o+y)/2;
if (examine(x, oo))
{
int ooo = (oo+y)/2;
if (examine(x, ooo)) r = o - 1;
else l = ooo + 1, bt = ooo;
}
else l = oo + 1, bt = oo;
}
else l = o + 1, bt = o;
}
x = bl + 1; y = bt + 1;
}
void find_11()
{
for (; x>2*m && examine(x-2*m, y); x-=2*m);
for (; y>2*m && examine(x, y-2*m); y-=2*m);
for (; x>m&&y>m&&examine(x-m, y-m); x-=m, y-=m);
}
void find_middle()
{
x += 2*m, y += 2*m;
x += m/2, y += m/2;
}
int main()
{
ShinLena;
cin >> n >> x >> y;
find_border();
find_11();
find_middle();
solution(x, y);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
444 KB |
Output is correct |
2 |
Correct |
1 ms |
452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
452 KB |
Output is correct |
2 |
Correct |
1 ms |
448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
704 KB |
Output is correct |
2 |
Correct |
0 ms |
452 KB |
Output is correct |
3 |
Correct |
1 ms |
456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
704 KB |
Output is correct |
2 |
Correct |
1 ms |
456 KB |
Output is correct |
3 |
Correct |
1 ms |
448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
452 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
452 KB |
Output is correct |
2 |
Execution timed out |
3087 ms |
344 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |