QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#99785 | #6345. Random Interactive Convex Hull Bot | eyiigjkn | RE | 0ms | 0kb | C++14 | 1.0kb | 2023-04-23 18:21:06 | 2023-04-23 18:21:07 |
Judging History
answer
# include <bits/stdc++.h>
using namespace std;
using iter=vector<int>::iterator;
vector<int> ans;
inline iter Pos(const iter &i){return i==ans.end()?ans.begin():i;}
inline iter pre(const iter &i){return i==ans.begin()?prev(ans.end()):prev(i);}
inline iter nxt(const iter &i){return Pos(next(i));}
bool query(int i,int j,int k)
{
printf("? %d %d %d\n",i,j,k);fflush(stdout);
int x;scanf("%d",&x);
return x>0;
}
void insert(iter pos,int i)
{
auto it=ans.insert(pos,i);
while(query(*pre(it),*pre(pre(it)),i)) it=Pos(ans.erase(pre(it)));
while(query(*nxt(it),i,*nxt(nxt(it)))) it=pre(ans.erase(nxt(it)));
}
int main()
{
int n;
cin>>n;
if(query(1,2,3)) ans={1,2,3};
else ans={1,3,2};
for(int i=4;i<=n;i++)
{
int l=0,r=ans.size()-1,mid;
while(l<r)
{
mid=(l+r+1)/2;
if(query(ans[0],ans[mid],i)) l=mid;
else r=mid-1;
}
if(!l || l+1==ans.size()) insert(ans.end(),i);
else if(query(i,ans[l+1],ans[l])) insert(ans.begin()+l+1,i);
}
cout<<"! "<<ans.size();
for(int i:ans) printf(" %d",i);
return puts(""),0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
5 -1 -1 1 1
output:
? 1 2 3 ? 1 3 4 ? 2 3 4 ? 3 1 4 ? 1 4 4