# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
297441 |
2020-09-11T14:49:38 Z |
JovanK26 |
Aliens (IOI07_aliens) |
C++14 |
|
3 ms |
384 KB |
#include <bits/stdc++.h>
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int n,x,y;
bool check(int x,int y)
{
if(x<=0 || y<=0 || x>n || y>n)return 0;
cout << "examine "<<x<<' '<<y<<endl;
string rep;
cin >> rep;
return (rep=="true");
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> x >> y;
int rim[4];
for(int i=0;i<4;i++)
{
for(int j=0;j<30;j++)
{
if(!check(x+(1ll << j)*dx[i],y+(1ll << j)*dy[i]))
{
int l=0;
if(j)l=1ll << (j-1);
int r=1ll << j;
int m;
while(l<r)
{
m=(l+r)/2;
if(check(x+m*dx[i],y+m*dy[i]))l=m+1;
else
{
r=m;
}
}
rim[i]=max(0,l-1);
break;
}
}
}
x=x+(rim[0]-rim[2])/2;
y=y+(rim[1]-rim[3])/2;
int m=(rim[0]+rim[2]+1);
int ind1,ind2;
if(check(x+2*m,y) && check(x-2*m,y))
{
ind1=2;
if(check(x,y+2*m) && check(x,y-2*m))ind2=2;
else if(check(x,y+2*m) && !check(x,y-2*m))ind2=0;
else
{
ind2=4;
}
}
if(check(x,y+2*m) && check(x,y-2*m))
{
ind2=2;
if(check(x+2*m,y) && check(x-2*m,y))ind1=2;
else if(check(x+2*m,y) && !check(x-2*m,y))ind1=0;
else
{
ind1=4;
}
}
if(check(x+2*m,y) && !check(x-2*m,y) && check(x,y+2*m) && !check(x,y-2*m))
{
if(check(x-m,y-m))
{
ind1=1;
ind2=1;
}
else
{
ind1=0;
ind2=0;
}
}
if(check(x+2*m,y) && !check(x-2*m,y) && !check(x,y+2*m) && check(x,y-2*m))
{
if(check(x-m,y+m))
{
ind1=1;
ind2=3;
}
else
{
ind1=0;
ind2=4;
}
}
if(!check(x+2*m,y) && check(x-2*m,y) && check(x,y+2*m) && !check(x,y-2*m))
{
if(check(x+m,y-m))
{
ind1=3;
ind2=1;
}
else
{
ind1=4;
ind2=0;
}
}
if(!check(x+2*m,y) && check(x-2*m,y) && !check(x,y+2*m) && check(x,y-2*m))
{
if(check(x+m,y+m))
{
ind1=4;
ind2=4;
}
else
{
ind1=3;
ind2=3;
}
}
cout << "solution " <<x+m*(2-ind1) <<' '<<y+m*(2-ind2)<<endl;
return 0;
}
Compilation message
aliens.cpp: In function 'int main()':
aliens.cpp:122:53: warning: 'ind2' may be used uninitialized in this function [-Wmaybe-uninitialized]
122 | cout << "solution " <<x+m*(2-ind1) <<' '<<y+m*(2-ind2)<<endl;
| ~~^~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
384 KB |
Incorrect |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
288 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
2 ms |
384 KB |
Incorrect |
3 |
Halted |
0 ms |
0 KB |
- |