이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
pair< int,int > st;
pair< int,int > lft;
pair< int,int > rgt;
pair< int,int > up;
pair< int,int > lftup;
bool ask(pair< int,int > a,bool ret = false)
{
cout << "examine " << a.first << " " << a.second << endl;
cin >> ret;
return ret;
}
void ans(pair< int,int > a)
{
cout<<"solution "<<a.first<<" "<<a.second<<endl;
}
int main()
{
int n,big;
cin >> n >> st.first >> st.second;
//get up
up = st,big = -1;
for(int i=0;i<=30;i++)
{
if(up.second+(1<<i)>n||!ask({up.first,up.second+(1<<i)})) break;
big = i;
}
if(big!=-1) up.second+=(1<<big);
for(int i=big-1;i>=0;i--)
{
if(up.second+(1<<i)>n||!ask({up.first,up.second+(1<<i)})) continue;
up.second+=(1<<i);
}
//get right
rgt = st,big = -1;
for(int i=0;i<=30;i++)
{
if(rgt.first+(1<<i)>n||!ask({rgt.first+(1<<i),rgt.second})) break;
big = i;
}
if(big!=-1) rgt.first+=(1<<big);
for(int i=big-1;i>=0;i--)
{
if(rgt.first+(1<<i)>n||!ask({rgt.first+(1<<i),rgt.second})) continue;
rgt.first+=(1<<i);
}
//get left
lft = st,big = -1;
for(int i=0;i<=30;i++)
{
if(lft.first-(1<<i)<=0||!ask({lft.first-(1<<i),lft.second})) break;
big = i;
}
if(big!=-1) lft.first-=(1<<big);
for(int i=big-1;i>=0;i--)
{
if(lft.first-(1<<i)<=0||!ask({lft.first-(1<<i),lft.second})) continue;
lft.first-=(1<<i);
}
int m = rgt.first-lft.first+1;
lftup = {lft.first,up.second};
while(1)
{
if(lftup.first-2*m<=0||!ask({lftup.first-2*m,lftup.second})) break;
lftup.first-=2*m;
}
while(1)
{
if(lftup.second+2*m>n||!ask({lftup.first,lftup.second+2*m})) break;
lftup.second+=2*m;
}
ans({lftup.first+2*m+m/2,lftup.second-2*m-m/2});
return 0;
}
/*
19 7 4
examine 7 3
1
examine 7 2
1
examine 7 1
0
examine 8 4
0
examine 6 4
1
examine 5 4
1
examine 3 4
0
examine 4 4
0
3
examine 5 8
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |