# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
78625 |
2018-10-06T18:00:08 Z |
Vardanyan |
Aliens (IOI07_aliens) |
C++14 |
|
1000 ms |
532 KB |
#include <bits/stdc++.h>
using namespace std;
bool ask(int x,int y){
cout<<"examine "<<x<<" "<<y<<endl;
fflush(stdout);
string s;
cin>>s;
if(s == "true") return true;
return false;
}
int main(){
int n,x0,y0;
cin>>n>>x0>>y0;
int jmp = 1;
int l,r,up,down;
while(1){
if(x0+jmp<=n){
if(ask(x0+jmp,y0)){
jmp*=2;
continue;
}
break;
}
else break;
}
int x0_right = x0+jmp;
int lo = x0;
int hi = x0_right;
r = x0;
while(lo<=hi){
int mid = (lo+hi)/2;
if(ask(mid,y0)){
r = mid;
lo = mid+1;
}
else hi = mid-1;
}
//cout<<r<<endl;
//cout<<x0_right<<endl;
jmp = 1;
while(1){
if(x0-jmp>=1){
if(ask(x0-jmp,y0)){
jmp*=2;
continue;
}
break;
}
else break;
}
int x0_left = x0-jmp;
lo = x0_left;
hi = x0;
l = x0;
while(lo<=hi){
int mid = (lo+hi)/2;
if(ask(mid,y0)){
l = mid;
hi = mid-1;
}
else lo = mid+1;
}
//cout<<l<<endl;
//cout<<x0_left<<endl;
jmp = 1;
while(1){
if(y0+jmp<=n){
if(ask(x0,y0+jmp)){
jmp*=2;
continue;
}
break;
}
else break;
}
int y0_up = y0+jmp;
lo = y0;
hi = y0_up;
up = y0;
while(lo<=hi){
int mid = (lo+hi)/2;
if(ask(x0,mid)){
up = mid;
lo = mid+1;
}
else hi = mid-1;
}
//cout<<up<<endl;
// cout<<y0_up<<endl;
jmp = 1;
while(1){
if(y0-jmp>=1){
if(ask(x0,y0-jmp)){
jmp*=2;
continue;
}
break;
}
else break;
}
int y0_down = y0-jmp;
lo = y0_down;
hi = y0;
down = y0;
while(lo<=hi){
int mid = (lo+hi)/2;
if(ask(x0,mid)){
hi = mid-1;
down = mid;
}
else{
lo = mid+1;
}
}
int mx = (l+r)/2;
int my = (up+down)/2;
int M = r-l+1;
// cout<<mx<<" "<<my<<endl;
int aj = 0;
if(mx+2*M<=n){ if(ask(mx+2*M,my)) aj++;}
if(mx+4*M<=n){ if(ask(mx+4*M,my)) aj++;}
int dzax = 0;
if(mx-2*M>=1){ if(ask(mx-2*M,my)) dzax++;}
if(mx-4*M>=1){ if(ask(mx-4*M,my)) dzax++;}
int rig = mx+2*aj*M;
int lif = mx-2*dzax*M;
int ansx = (lif+rig)/2;
int verev = 0;
if(my+2*M<=n){ if(ask(mx,my+2*M)) verev++;}
if(my+4*M<=n){ if(ask(mx,my+4*M)) verev++;}
int nerq = 0;
if(my-2*M>=1){ if(ask(mx,my-2*M)) nerq++;}
if(my-4*M>=1){ if(ask(mx,my-4*M)) nerq++;}
int u = my+2*verev*M;
int dow = my-2*nerq*M;
int ansy = (u+dow)/2;
cout<<"solution "<<ansx<<" "<<ansy<<endl;
fflush(stdout);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
452 KB |
Output is correct |
2 |
Correct |
2 ms |
472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
484 KB |
Output is correct |
2 |
Correct |
2 ms |
484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
500 KB |
Output is correct |
2 |
Correct |
2 ms |
500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
500 KB |
Output is correct |
2 |
Correct |
2 ms |
500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
500 KB |
Output is correct |
2 |
Correct |
3 ms |
500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
532 KB |
Output is correct |
2 |
Correct |
3 ms |
532 KB |
Output is correct |
3 |
Correct |
3 ms |
532 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
532 KB |
Output is correct |
2 |
Correct |
3 ms |
532 KB |
Output is correct |
3 |
Correct |
3 ms |
532 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
532 KB |
Output is correct |
2 |
Execution timed out |
1077 ms |
532 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
532 KB |
Output is correct |
2 |
Execution timed out |
1046 ms |
532 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |