QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#508341 | #6345. Random Interactive Convex Hull Bot | ucup-team052 | WA | 1ms | 3792kb | C++23 | 2.1kb | 2024-08-07 13:40:28 | 2024-08-07 13:40:29 |
Judging History
answer
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define SZ(x) ((int)(x).size())
using namespace std;
using LL=long long;
int ccw(int x,int y,int z)
{
printf("? %d %d %d\n",x,y,z);
fflush(stdout);
int ret;
scanf("%d",&ret);
return ret==1;
}
int main(){
#ifdef xay5421
freopen("a.in","r",stdin);
#endif
int n;
cin>>n;
vector<int> ans;
if(ccw(1,2,3)) ans={1,2,3};
else ans={1,3,2};
for(int i=4;i<=n;i++)
{
int l=1,r=(int)ans.size()-1,pos=-1;
while(l<=r)
{
int mid=(l+r)/2;
if(ccw(ans[0],ans[mid],i)) pos=mid,r=mid-1;
else l=mid+1;
}
if(pos>1)
{
if(ccw(ans[pos],ans[pos-1],i)) {}
else
{
vector<int> nw;
for(int j=0;j<pos;j++) nw.push_back(ans[j]);
while(nw.size()>=2)
{
if(ccw(nw[(int)nw.size()-1],nw[(int)nw.size()-2],i)) break;
else nw.pop_back();
}
int tpos=pos;
while(tpos+1<(int)ans.size())
{
if(ccw(ans[tpos],ans[tpos+1],i)==0) break;
else tpos++;
}
nw.push_back(i);
for(int j=tpos;j<(int)ans.size();j++) nw.push_back(ans[j]);
ans=nw;
}
}
else if(pos==1)
{
vector<int> nw;
nw.push_back(i);
int tpos=1;
while(tpos+1<(int)ans.size())
{
if(ccw(ans[tpos],ans[tpos+1],i)==0) break;
else tpos++;
}
for(int i=tpos;i<(int)ans.size();i++) nw.push_back(ans[i]);
nw.push_back(ans[0]);
while(nw.size()>=3)
{
if(ccw(nw[(int)nw.size()-1],nw[(int)nw.size()-2],i)) break;
else nw.pop_back();
}
ans=nw;
}
else
{
vector<int> nw;
nw.push_back(i);
int tpos=0;
while(tpos+1<(int)ans.size())
{
if(ccw(ans[tpos],ans[tpos+1],i)==0) break;
else tpos++;
}
for(int i=tpos;i<(int)ans.size();i++) nw.push_back(ans[i]);
while(nw.size()>=3)
{
if(ccw(nw[(int)nw.size()-1],nw[(int)nw.size()-2],i)) break;
else nw.pop_back();
}
ans=nw;
}
}
printf("! %d ",(int)ans.size());
for(int i=0;i<(int)ans.size();i++) printf("%d%c",ans[i]," \n"[i==(int)ans.size()-1]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3792kb
input:
5 -1 -1 -1 -1 1 -1 -1 -1 1
output:
? 1 2 3 ? 1 3 4 ? 1 2 4 ? 1 3 4 ? 2 3 4 ? 4 3 5 ? 4 2 5 ? 4 1 5 ? 2 3 5 ! 5 5 4 1 3 2
result:
wrong answer incorrect hull, 9 queries