QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#704497#329. 点分治TheZoneCompile Error//C++202.1kb2024-11-02 20:05:292024-11-02 20:05:30

Judging History

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

  • [2024-11-02 20:05:30]
  • 评测
  • [2024-11-02 20:05:29]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
struct node{
	bool cut;
	int end,nxt,weigh,oppo;
}edge[80100];
bool vis[10000100],ans[128];
int st[40100],fro,ad[40100],adfr,root,fa,fasz;
int n,m,maxn,cnt,head[40100],size[40100],mx[40100],ask[128];
inline void add(int x,int y,int z){
	++cnt;
	edge[cnt]={0,y,head[x],z,0};
	head[x]=cnt;
}
inline void update(){
	for(;adfr;--adfr){
		if(!vis[ad[adfr]]){
			++fro;
			st[fro]=ad[adfr];
			vis[ad[adfr]]=1;
		}
	}
}
inline void clear(){
	for(;fro;--fro){
		vis[st[fro]]=0;
	}
}
void dfs(int x,int y,int tot){
	size[x]=1;
	mx[x]=0;
	for(int i=head[x];i;i=edge[i].nxt){
		if((!edge[i].cut)&&(edge[i].end^y)){
			dfs(edge[i].end,x,tot);
			mx[x]=max(mx[x],size[edge[i].end]);
			size[x]+=size[edge[i].end];
		}
	}
	mx[x]=max(mx[x],tot-size[x]);
	if(mx[x]<=mx[root]){
		root=x;
		fa=y;
		fasz=tot-size[x];
	}
}
void insert(int x,int y,int z){
	for(int i=1;i<=m;++i){
		if(z<=ask[i]&&vis[ask[i]-z])
		ans[i]=1;
	}
	++adfr;
	ad[adfr]=z;
	for(int i=head[x];i;i=edge[i].nxt){
		if((!edge[i].cut)&&(edge[i].end^y)){
			if(z+edge[i].weigh>maxn)
			continue;
			insert(edge[i].end,x,z+edge[i].weigh);
		}
	}
}
void calc(int x,int y){
	root=0;
	dfs(x,0,y);
	x=root;
	int tf=fa,ts=fasz;
	// cout<<x<<" "<<y<<endl;
	for(int i=head[x];i;i=edge[i].nxt){
		if((!edge[i].cut)&&edge[i].weigh<=maxn){
			// cout<<"H"<<endl;
			insert(edge[i].end,x,edge[i].weigh);
			update();
		}
	}
	clear();
	for(int i=head[x];i;i=edge[i].nxt){
		if(!edge[i].cut){
			edge[i].cut=1;
			edge[edge[i].oppo].cut=1;
			if(edge[i].end^tf){
				calc(edge[i].end,size[edge[i].end]);
			}else{
				calc(tf,ts);
			}
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);
	mx[0]=0x3f3f3f3f;
	int ta,tb,tc;
	for(int i=1;i<n;++i){
		scanf("%d%d%d",&ta,&tb,&tc);
		add(ta,tb,tc);
		add(tb,ta,tc);
		edge[cnt-1].oppo=cnt;
		edge[cnt].oppo=cnt-1;
	}
	vis[0]=1;
	for(int i=1;i<=m;++i){
		scanf("%d",&ask[i]);
		maxn=max(maxn,ask[i]);
	}
	calc(1,n);
	for(int i=1;i<=m;++i){
		if(ans[i]){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}
	return 0;
}

详细

answer.code: In function ‘void dfs(int, int, int)’:
answer.code:30:9: error: reference to ‘size’ is ambiguous
   30 |         size[x]=1;
      |         ^~~~
In file included from /usr/include/c++/13/string:53,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from answer.code:1:
/usr/include/c++/13/bits/range_access.h:274:5: note: candidates are: ‘template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])’
  274 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:264:5: note:                 ‘template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)’
  264 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
answer.code:9:30: note:                 ‘int size [40100]’
    9 | int n,m,maxn,cnt,head[40100],size[40100],mx[40100],ask[128];
      |                              ^~~~
answer.code:35:41: error: reference to ‘size’ is ambiguous
   35 |                         mx[x]=max(mx[x],size[edge[i].end]);
      |                                         ^~~~
/usr/include/c++/13/bits/range_access.h:274:5: note: candidates are: ‘template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])’
  274 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:264:5: note:                 ‘template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)’
  264 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
answer.code:9:30: note:                 ‘int size [40100]’
    9 | int n,m,maxn,cnt,head[40100],size[40100],mx[40100],ask[128];
      |                              ^~~~
answer.code:36:25: error: reference to ‘size’ is ambiguous
   36 |                         size[x]+=size[edge[i].end];
      |                         ^~~~
/usr/include/c++/13/bits/range_access.h:274:5: note: candidates are: ‘template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])’
  274 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:264:5: note:                 ‘template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)’
  264 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
answer.code:9:30: note:                 ‘int size [40100]’
    9 | int n,m,maxn,cnt,head[40100],size[40100],mx[40100],ask[128];
      |                              ^~~~
answer.code:36:34: error: reference to ‘size’ is ambiguous
   36 |                         size[x]+=size[edge[i].end];
      |                                  ^~~~
/usr/include/c++/13/bits/range_access.h:274:5: note: candidates are: ‘template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])’
  274 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:264:5: note:                 ‘template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)’
  264 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
answer.code:9:30: note:                 ‘int size [40100]’
    9 | int n,m,maxn,cnt,head[40100],size[40100],mx[40100],ask[128];
      |                              ^~~~
answer.code:39:29: error: reference to ‘size’ is ambiguous
   39 |         mx[x]=max(mx[x],tot-size[x]);
      |                             ^~~~
/usr/include/c++/13/bits/range_access.h:274:5: note: candidates are: ‘template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])’
  274 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:264:5: note:                 ‘template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)’
  264 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
answer.code:9:30: note:                 ‘int size [40100]’
    9 | int n,m,maxn,cnt,head[40100],size[40100],mx[40100],ask[128];
      |                              ^~~~
answer.code:43:26: error: reference to ‘size’ is ambiguous
   43 |                 fasz=tot-size[x];
      |                          ^~~~
/usr/include/c++/13/bits/range_access.h:274:5: note: candidates are: ‘template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])’
  274 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/13/bits/range_access.h:264:5: note:                 ‘template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)’
  264 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
answer.code:9:30: note:                 ‘int size [40100]’
    9 | int n,m,m...