QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#466549#5029. 在路上DoqeCompile Error//C++142.7kb2024-07-07 22:03:162024-07-07 22:03:17

Judging History

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

  • [2024-07-07 22:03:17]
  • 评测
  • [2024-07-07 22:03:16]
  • 提交

answer

#include<bits/stdc++.h>
#include "soul.h"
using namespace std;
map<array<int,3>,int>M;
inline int ASK(int x,int y,int z)
{
	if(x==y)return x;
	if(y==z)return y;
	if(x==z)return x;
	array<int,3>a={x,y,z};
	sort(a.begin(),a.end());
	return ask(x,y,z);
//	 if(M.count(a))return M[a];
//	 return M[a]=ask(x,y,z);
}
int n,bn[101000];
mt19937 rnd(43525);
inline bool jud(int x)
{
	if(bn[x])return false;
//	cerr<<"JUDGE: "<<x<<endl;
	vector<int>V;
	for(int i=1;i<=n;++i)if(i!=x){
		if(!V.size())V={i};
		else if(ASK(V.back(),x,i)!=x)V.push_back(i);
		else V.pop_back();}
	int z=V[0],cnt=0;
//	cerr<<z<<endl;
	for(int i=1;i<=n;++i)if(i!=x)
		if(ASK(z,x,i)!=x)++cnt;
//	cerr<<cnt<<endl;
bn[x]=1;
	if(cnt>n/2)return false;
	return true;
}
int ans=0;
int solve()
{
	for(int i=1;i<=n;++i)bn[i]=0;
	int W=0;
	while(1)
	{
		++W;
		int u=rnd()%n+1,v=rnd()%n+1;
		if(u==v)continue;
		vector<int>z,Z;
		int va=0,vb=0;
		for(int i=1;i<=n;++i)
		{
			int w=ASK(u,v,i);
			if(w==i)z.push_back(i);
			if(w==u)++va;
			if(w==v)++vb;
		}
		int op=-1;
		if(n-va<n/2)op=u;
		if(n-vb<n/2)op=v;
		if(op!=-1)
		{
			if(jud(op))return op;
			continue;
		}
		for(int i=1;i<=n;++i)Z.push_back(i);
		int sA=0,sB=0; 
//		cerr<<"START\n";
		while(z.size()>1)
		{
//			cerr<<u<<" "<<v<<" "<<Z.size()<<" "<<z.size()<<endl;
//			assert(Z.size());
			vector<int>A,B;
			int x=Z[rnd()%Z.size()],y=-1;
			for(int k:z)if(ASK(u,k,x)==k)
				if(y==-1||ASK(u,k,y)==y)y=k;
//			cerr<<"MEET: "<<x<<"->"<<y<<endl;
int C=0;
			for(int i:Z)
			{
				int o1=ASK(u,y,i)==y,o2=ASK(y,v,i)==y;
				if(o1&&!o2)A.push_back(i);
				if(o2&&!o1)B.push_back(i);
				if(o1&&o2)++C;
			}
			if(sA+A.size()<=n/2&&sB+B.size()<=n/2)
			{
//				cerr<<"SELECT: "<<y<<" : "<<u<<"~"<<v<<endl;
//				cerr<<"DIV: "<<sA<<" "<<A.size()<<"  "<<sB<<" "<<B.size()<<"  "<<C<<endl;
				if(jud(y))return ans=max(ans,W),y;
				else {z.clear();break;}
			}
//			cerr<<A.size()<<" "<<B.size()<<" "<<C<<"  "<<y<<endl;
			if(sA+A.size()>B.size()+sB)
			{
				Z=A;int r=-1;sB+=B.size()+C;
				for(int k:z)if(k!=y&&ASK(u,y,k)==y)
					if(r==-1||ASK(v,r,k)==r)r=k;u=r;
			}
			else
			{
				Z=B;int r=-1;sA+=A.size()+C;
				for(int k:z)if(k!=y&&ASK(v,y,k)==y)
					if(r==-1||ASK(u,r,k)==r)r=k;v=r;
			}
			vector<int>xx;sort(Z.begin(),Z.end());Z.push_back(100000000);
			for(int k:z)if(*lower_bound(Z.begin(),Z.end(),k)==k)
				xx.push_back(k);z=xx,Z.pop_back(); 
//			cerr<<"ED: "<<Z.size()<<" "<<z.size()<<endl;
		}
		for(int u:z)
			if(jud(u))
			{
				ans=max(ans,W);
				return u;
			}
	}
}
int centroid(int id,int N,int M)
{
	if(id==1)return ask(1,2,3);
	cerr<<"TESTCASE "<<ans<<endl;
	 ::M.clear();
	n=N;return solve();
}

Details

implementer.cpp: In function ‘int main()’:
implementer.cpp:60:14: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   60 |         fread(Interactor::rbuf,1,50000000,stdin);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code:2:10: fatal error: soul.h: No such file or directory
    2 | #include "soul.h"
      |          ^~~~~~~~
compilation terminated.