QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#99784 | #6345. Random Interactive Convex Hull Bot | eyiigjkn | WA | 144ms | 3772kb | C++14 | 1.1kb | 2023-04-23 18:20:06 | 2023-04-23 18:20: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++)
{
if(query(ans[0],i,ans[1])) insert(next(ans.begin()),i);
else
{
int l=1,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+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: 100
Accepted
time: 3ms
memory: 3744kb
input:
5 -1 1 -1 1 -1 -1 -1 1 -1 -1
output:
? 1 2 3 ? 1 4 3 ? 1 2 4 ? 3 4 2 ? 2 4 1 ? 1 5 4 ? 1 2 5 ? 5 2 4 ? 4 1 5 ? 2 5 1 ! 4 1 4 5 2
result:
ok OK, 10 queries, 4 point in hull
Test #2:
score: 0
Accepted
time: 4ms
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