QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#99785#6345. Random Interactive Convex Hull BoteyiigjknRE 0ms0kbC++141.0kb2023-04-23 18:21:062023-04-23 18:21:07

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-23 18:21:07]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-04-23 18:21:06]
  • 提交

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

result: