QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#99774#6345. Random Interactive Convex Hull BoteyiigjknRE 2ms3768kbC++141.1kb2023-04-23 17:56:302023-04-23 17:56:32

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 17:56:32]
  • 评测
  • 测评结果:RE
  • 用时:2ms
  • 内存:3768kb
  • [2023-04-23 17:56:30]
  • 提交

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;
}

詳細信息

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

result: