QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#323094#5015. 树honglan0301Compile Error//C++171.3kb2024-02-08 14:33:322024-02-08 14:33:32

Judging History

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

  • [2024-02-08 14:33:32]
  • 评测
  • [2024-02-08 14:33:32]
  • 提交

answer

#include<bits/stdc++.h>
#include"tree.h"
using namespace std;
typedef vector<int> ve;
int pl[1005],d[1005],n,fa[1005],a[1005],dis[1005],f[1005],h[1005],sz[1005],is[1005],rt;
vector<int> g[1005];
mt19937_64 rng(time(0));
void dp1(int x,int fa){
	sz[x]=is[x],f[x]=0;
	for(int y:g[x]){
		if(y==fa)continue;
		dp1(y,x);
		sz[x]+=sz[y];
		f[x]+=f[y]+sz[y];
	}
}
void dp2(int x,int fa){
	for(int y:g[x]){
		if(y==fa)continue;
		h[y]=h[x]+f[x]-f[y]-sz[y]+sz[rt]-sz[y];
		dp2(y,x);
	}
}
void solver(int n,int A,int B){
	if(n==1)return ;
	rt=rng()%n+1;
	pl[1]=rt;
	int ttt=0;
	for(int i=1;i<=n;i++)if(i!=rt)d[i]=ask(rt,(ve){i}),pl[++tot]=i;
	sort(pl+2,pl+n+1,[](int x,int y){return d[x]<d[y];});
	int tot=0;
	for(int i=2;i<=n;i++){
		int x=pl[i];
		ve might;
		for(int j=1;j<i;j++)if(d[pl[j]]==d[x]-1)might.push_back(pl[j]);
		while(might.size()>1){
			ve ls;
			for(int i=1;i<=n;i++)is[i]=0;
			for(int i=0;i<might.size()/2;i++)ls.push_back(might[i]),is[might[i]]=1;
			int d=ask(x,ls);
			ttt+=ls.size();
			if(ttt>100000) exit(1);
			dp1(rt,0),dp2(rt,0);
			ve nw;
			for(int i:might)if(f[i]+h[i]+ls.size()==d)nw.push_back(i);
			might=nw;
		}
		fa[x]=might[0];
		g[fa[x]].push_back(x);
		g[x].push_back(fa[x]);
		answer(x,fa[x]);
	}
}

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: In function ‘void solver(int, int, int)’:
answer.code:29:65: error: ‘tot’ was not declared in this scope; did you mean ‘ttt’?
   29 |         for(int i=1;i<=n;i++)if(i!=rt)d[i]=ask(rt,(ve){i}),pl[++tot]=i;
      |                                                                 ^~~
      |                                                                 ttt