# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
827683 |
2023-08-16T16:23:47 Z |
nnin |
Aliens (IOI07_aliens) |
C++14 |
|
1 ms |
208 KB |
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
using namespace std;
bool interact(int x,int y) {
printf("examine %d %d\n", x, y);
string s;
cin>>s;
return s[0]=='t';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, x0, y0, m;
cin>>n>>x0>>y0;
int l, r;
l = 1;
r = x0;
while(l<r) {
int mid = (l+r)/2;
if(interact(mid, y0)) r = mid;
else l = mid+1;
}
int left = l;
l = x0;
r = n;
while(l<r) {
int mid = (l+r+1)/2;
if(interact(mid, y0)) l = mid;
else r = mid-1;
}
int right = l;
l = 1;
r = y0;
while(l<r) {
int mid = (l+r)/2;
if(interact(x0, mid)) r = mid;
else l = mid+1;
}
int bottom = l;
l = y0;
r = n;
while(l<r) {
int mid = (l+r+1)/2;
if(interact(x0, mid)) l = mid;
else r = mid-1;
}
int top = l;
int disl, disr;
int mid = (left+x0)/2;
if(interact(mid, y0)) {
mid = (mid+left)/2;
if(interact(mid, y0)) {
disl = 0;
} else {
disl = 4;
}
} else {
disl = 2;
}
mid = (right+x0)/2;
if(interact(mid, y0)) {
mid = (mid+right)/2;
if(interact(mid, y0)) {
disr = 0;
} else {
disr = 4;
}
} else {
disr = 2;
}
m = (right+1-left)/(disl+disr+1);
left += disl*m;
right -= disr*m;
mid = (bottom+y0)/2;
if(interact(x0, mid)) {
mid = (mid+bottom)/2;
if(!interact(x0, mid)) {
bottom += 4*m;
}
} else {
bottom += 2*m;
}
mid = (top+y0)/2;
if(interact(x0, mid)) {
mid = (mid+top)/2;
if(!interact(x0, mid)) {
top -= 4*m;
}
} else {
top -= 2*m;
}
int xc = (left+right)/2;
int yc = (top+bottom)/2;
if(xc+(4*m)<=n && interact(xc+(4*m), yc)) {
xc += 2*m;
if(yc+(4*m)<=n && interact(xc, yc+(4*m))) {
yc += 2*m;
} else if(yc-(4*m)<=n && interact(xc, yc-(4*m))) {
yc -= 2*m;
}
} else if(xc-(4*m)>=1 && interact(xc-(4*m), yc)) {
xc -= 2*m;
if(yc+(4*m)<=n && interact(xc, yc+(4*m))) {
yc += 2*m;
} else if(yc-(4*m)<=n && interact(xc, yc-(4*m))) {
yc -= 2*m;
}
} else if(xc+(2*m)<=n && xc-(2*m)>=1) {
bool bl = interact(xc-(2*m), yc);
bool br = interact(xc+(2*m), yc);
if(bl && !br) {
xc -= m;
if(yc+(3*m)<=n && interact(xc, yc+(3*m))) {
yc += m;
} else if(yc-(3*m)<=n && interact(xc, yc-(3*m))) {
yc -= m;
}
} else if(br && !bl) {
xc += m;
if(yc+(3*m)<=n && interact(xc, yc+(3*m))) {
yc += m;
} else if(yc-(3*m)<=n && interact(xc, yc-(3*m))) {
yc -= m;
}
}
}
printf("solution %d %d", xc, yc);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1 ms |
208 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1 ms |
208 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1 ms |
208 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1 ms |
208 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1 ms |
208 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1 ms |
208 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
0 ms |
208 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1 ms |
208 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1 ms |
208 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
0 ms |
208 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |