이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
int N,M;
map<pair<int,int>,bool>vis;
map<pair<int,int>,string>res;
int r=0;
string check(int x,int y)
{
if (x<=0||x>N||y<=0||y>N)
return "false";
if (res[{x,y}]=="true"||res[{x,y}]=="false")
return res[{x,y}];
cout<<"examine "<<x<<' '<<y<<endl;
r++;
string z;
cin>>z;
res[{x,y}]=z;
return z;
}
vector<pair<int,int>>ind;
void dfs1(int x,int y)
{
if (x>N||y>N||x<=0||y<=0)
return;
if (vis[{x,y}])
return;
vis[{x,y}]=1;
if (check(x,y)=="true")
{
ind.push_back({x,y});
dfs1(x+2*M,y);dfs1(x-2*M,y);dfs1(x,y+2*M);dfs1(x,y-2*M);
}
}
inline void solve()
{
int x,y;
cin>>N>>x>>y;
vis={};
res={};
ind.push_back({x,y});
res[{x,y}]=1;
int st=0,en=2;
while (1)
{
int mid=(st+en)/2;
if (check(x,y+mid)=="true")
en*=2;
else
break;
}
st=0;
while (st+1<en)
{
int mid=(st+en)/2;
if (check(x,y+mid)=="true")
st=mid;
else
en=mid;
}
int ed=st;
st=0,en=2;
while (1)
{
int mid=en/2;
if (check(x,y-mid)=="true")
en*=2;
else
break;
}
st=0;
while (st+1<en)
{
int mid=(st+en)/2;
if (check(x,y-mid)=="true")
st=mid;
else
en=mid;
}
M=ed+en;
y=(y+ed+y-st+1)/2;
st=-(M/2)-1,en=M/2+1;
while (st+1<en)
{
int mid=(st+en)/2;
if (check(x+mid+(M/2),y)=="false")
en=mid;
else
st=mid;
}
ind={};
vis={};
ind.push_back({x+st,y});
dfs1(x+st,y);
sort(begin(ind),end(ind));
cout<<"solution ";
cout<<ind[5].first<<' '<<ind[5].second<<endl;
}
int main()
{
solve();
}
# | 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... |