QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#99774 | #6345. Random Interactive Convex Hull Bot | eyiigjkn | RE | 2ms | 3768kb | C++14 | 1.1kb | 2023-04-23 17:56:30 | 2023-04-23 17:56:32 |
Judging History
answer
# include <bits/stdc++.h>
using namespace std;
using iter=vector<int>::iterator;
vector<int> ans;
inline iter pre(const iter &i){return i==ans.begin()?prev(ans.end()):prev(i);}
inline iter nxt(const iter &i){return i==prev(ans.end())?ans.begin():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)) ans.erase(pre(it));
while(query(*nxt(it),i,*nxt(nxt(it)))) 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(ans.begin()+1,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: 2ms
memory: 3768kb
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: -100
Runtime Error
input:
50 -1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 1 -1 -1 1 -1 -1 -1 -1 1 1 1 1
output:
? 1 2 3 ? 1 4 3 ? 1 2 4 ? 2 3 4 ? 1 4 3 ? 1 5 3 ? 1 2 5 ? 5 2 3 ? 3 1 5 ? 2 5 4 ? 1 6 3 ? 1 2 6 ? 1 5 6 ? 6 2 5 ? 5 3 6 ? 2 6 4 ? 1 7 3 ? 1 4 7 ? 3 7 5 ? 1 8 7 ? 1 6 8 ? 1 3 8 ? 1 5 8 ? 8 6 5 ? 5 3 8 ? 8 3 8