QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#66439#5015. 树aouiCompile Error//C++143.3kb2022-12-08 14:57:492022-12-08 14:57:50

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-08 14:57:50]
  • 评测
  • [2022-12-08 14:57:49]
  • 提交

answer

#include"tree.h"

#include<cstdio>
#include<algorithm>
using namespace std;

#include<vector>
int ask(int u,vector<int> v);
void answer(int u,int v);

#include<cstdlib>
#include<ctime>
const int N=1e3+5;
vector<int> dep[N],to[N];
int bz[N],fa[N],tot,cnt;
pair<int,int> a[N],b[N];
void solver(int n,int A,int B)
{
	srand(time(0));
	int rt=rand()%n+1,ma=0;
	rt=1;
	for(int i=1;i<=n;i++)
		if(rt!=i)
		{
			int d=ask(rt,{i});
			ma=max(ma,d);
			dep[d].push_back(i);
		}
	for(auto i:dep[1])answer(rt,i),fa[i]=rt;
	for(int i=2;i<=ma;i++)
	{
		tot=0;
		for(auto x:dep[i-1])
		{
			int d=ask(x,dep[i-1]);
			a[++tot]={d,x};
		}
		cnt=0;
		for(auto y:dep[i])
		{
			int d=ask(y,dep[i-1])-tot;
			b[++cnt]={d,y};
		}
		sort(a+1,a+1+tot);
		sort(b+1,b+1+cnt);
		for(int j=1,k=1;j<=cnt;j++)
		{
			for(;a[k].first<b[j].first;k++);
			for(int l=k;a[l].first==b[j].first;l++)
				if(ask(b[j].second,{a[l].second})==1)
				{
					answer(b[j].second,a[l].second);
					fa[b[j].second]=a[l].second;
					break;
				}
		}
	}
}#include<cstdio>
#include<algorithm>
using namespace std;

#include<vector>
int ask(int u,vector<int> v);
void answer(int u,int v);

#include<cstdlib>
#include<ctime>
const int N=1e3+5;
vector<int> dep[N],to[N];
int bz[N],fa[N],tot,cnt,tag[N],aa[N];
pair<int,int> a[N],b[N];
void dfs(int y,int d,int x,int dd)
{
	if(dd==d-1)return answer(x,y),fa[y]=x,to[x].push_back(y),void();
	if(to[x].size()==1)return dfs(y,d,to[x][0],dd+1),void();
	int o=d-dd-1,l=0,r=to[x].size()-1,res=0;
	vector<int> b;
	while(l<=r)
	{
		int mid=l+r>>1;
		b.clear();
		for(int i=l;i<=mid;i++)b.push_back(to[x][i]);
		int ddd=ask(y,b);
		if(ddd<(o+2)*(mid-l+1))res=mid,r=mid-1;
		else l=mid+1;
	}
	dfs(y,d,to[x][res],dd+1);
}
void solver(int n,int A,int B)
{
	srand(time(0));
	int rt=rand()%n+1,ma=0;
	rt=1;
	for(int i=1;i<=n;i++)
		if(rt!=i)
		{
			int d=ask(rt,{i});
			ma=max(ma,d);
			dep[d].push_back(i);
		}
	for(auto i:dep[1])answer(rt,i),fa[i]=rt;
	if(A==8500)
	{
		for(int i=2;i<=ma;i++)
		{
			tot=0;
			for(auto x:dep[i-1])
			{
				int d=ask(x,dep[i-1]);
				a[++tot]={d,x};
			}
			cnt=0;
			for(auto y:dep[i])
			{
				int d=ask(y,dep[i-1])-tot;
				b[++cnt]={d,y};
			}
			sort(a+1,a+1+tot);
			sort(b+1,b+1+cnt);
			for(int j=1,k=1;j<=cnt;j++)
			{
				for(;a[k].first<b[j].first;k++);
				for(int l=k;a[l].first==b[j].first;l++)
					if(ask(b[j].second,{a[l].second})==1)
					{
						answer(b[j].second,a[l].second);
						fa[b[j].second]=a[l].second;
						break;
					}
			}
		}
	}
	else
	{
		if(ma*ma<=4*n)
		{
			for(int i=2;i<n;i++)
			{
				if(!dep[i].size())break;
				for(auto y:dep[i])dfs(y,i,rt,0);
			}
		}
		else
		{
			for(int i=1;i<n;i++)
			{
				if(!dep[i].size())break;
				if(!dep[i+1].size())break;
				int v=rand()%dep[i].size(),u=dep[i][v];
				for(int i=1;i<=n;i++)to[i].clear(),tag[i]=0;
				aa[0]=u;
				tag[u]=1;
				for(int i=1;aa[i-1];i++)aa[i]=fa[aa[i-1]],tag[aa[i]]=1;
				for(auto y:dep[i+1])
				{
					int d=ask(u,{y});
					if(d==1)answer(u,y),bz[y]=1,fa[y]=u;
					else to[aa[d-1>>1]].push_back(y);
				}
				for(auto x:dep[i])
				{
					for(int f=x;f;f=fa[f])
					{
						for(auto y:to[f])
							if(!bz[y]&&ask(x,{y})==1)answer(x,y),bz[y]=1,fa[y]=x;
						if(tag[f])break;
					}
				}
			}
		}
	}
}

Details

implementer.cpp: In function ‘void regduj260135279::init()’:
implementer.cpp:32:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   32 |                 scanf("%d",&n);
      |                 ~~~~~^~~~~~~~~
implementer.cpp:45:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   45 |                         scanf("%d%d",&u,&v);
      |                         ~~~~~^~~~~~~~~~~~~~
answer.code:58:2: error: stray ‘#’ in program
   58 | }#include<cstdio>
      |  ^
answer.code:58:3: error: ‘include’ does not name a type
   58 | }#include<cstdio>
      |   ^~~~~~~
answer.code:68:11: error: redefinition of ‘const int N’
   68 | const int N=1e3+5;
      |           ^
answer.code:13:11: note: ‘const int N’ previously defined here
   13 | const int N=1e3+5;
      |           ^
answer.code:69:13: error: redefinition of ‘std::vector<int> dep [1005]’
   69 | vector<int> dep[N],to[N];
      |             ^~~
answer.code:14:13: note: ‘std::vector<int> dep [1005]’ previously declared here
   14 | vector<int> dep[N],to[N];
      |             ^~~
answer.code:69:20: error: redefinition of ‘std::vector<int> to [1005]’
   69 | vector<int> dep[N],to[N];
      |                    ^~
answer.code:14:20: note: ‘std::vector<int> to [1005]’ previously declared here
   14 | vector<int> dep[N],to[N];
      |                    ^~
answer.code:70:5: error: redefinition of ‘int bz [1005]’
   70 | int bz[N],fa[N],tot,cnt,tag[N],aa[N];
      |     ^~
answer.code:15:5: note: ‘int bz [1005]’ previously declared here
   15 | int bz[N],fa[N],tot,cnt;
      |     ^~
answer.code:70:11: error: redefinition of ‘int fa [1005]’
   70 | int bz[N],fa[N],tot,cnt,tag[N],aa[N];
      |           ^~
answer.code:15:11: note: ‘int fa [1005]’ previously declared here
   15 | int bz[N],fa[N],tot,cnt;
      |           ^~
answer.code:70:17: error: redefinition of ‘int tot’
   70 | int bz[N],fa[N],tot,cnt,tag[N],aa[N];
      |                 ^~~
answer.code:15:17: note: ‘int tot’ previously declared here
   15 | int bz[N],fa[N],tot,cnt;
      |                 ^~~
answer.code:70:21: error: redefinition of ‘int cnt’
   70 | int bz[N],fa[N],tot,cnt,tag[N],aa[N];
      |                     ^~~
answer.code:15:21: note: ‘int cnt’ previously declared here
   15 | int bz[N],fa[N],tot,cnt;
      |                     ^~~
answer.code:71:15: error: redefinition of ‘std::pair<int, int> a [1005]’
   71 | pair<int,int> a[N],b[N];
      |               ^
answer.code:16:15: note: ‘std::pair<int, int> a [1005]’ previously defined here
   16 | pair<int,int> a[N],b[N];
      |               ^
answer.code:71:20: error: redefinition of ‘std::pair<int, int> b [1005]’
   71 | pair<int,int> a[N],b[N];
      |                    ^
answer.code:16:20: note: ‘std::pair<int, int> b [1005]’ previously defined here
   16 | pair<int,int> a[N],b[N];
      |                    ^
answer.code:89:6: error: redefinition of ‘void solver(int, int, int)’
   89 | void solver(int n,int A,int B)
      |      ^~~~~~
answer.code:17:6: note: ‘void solver(int, int, int)’ previously defined here
   17 | void solver(int n,int A,int B)
      |      ^~~~~~