QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#860667#9676. AncestorstebiezhichuCompile Error//C++143.0kb2025-01-18 14:26:032025-01-18 14:29:02

Judging History

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

  • [2025-01-18 14:29:02]
  • 评测
  • [2025-01-18 14:26:03]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int n,m,fa[maxn],rt,dep[maxn],top,pre[maxn],x,y,z,C[maxn],ans[maxn];
struct edge{
	int x;
	int y;
	int z;
	int zmax;
	int op;
	int ans;
}st[maxn*100];
vector<int>tu[maxn];
unordered_set<pair<int,int> >s[maxn];
void add(int q,int w){
	if(!pre[q]||dep[q]==dep[w]){
		return;
	}
	top++;
	st[top].x=pre[q];
	st[top].y=q;
	st[top].z=dep[q]-dep[w];
	st[top].op=0;
	st[top].ans=1;
	return;
}
void del(int q,int w){
	if(!pre[q]||dep[q]==dep[w]){
		return;
	}
	top++;
	st[top].x=pre[q];
	st[top].y=q;
	st[top].z=dep[q]-dep[w];
	st[top].op=0;
	st[top].ans=-1;
	return;
}
void merge(int q,int w){
	if(s[q].size()<s[w].size()){
		swap(s[q],s[w]);
	}
	for(auto v:s[w]){
		auto it=s[q].upper_bound(v);
		if(it!=s[q].end()&&(*it).first==v.first){
			del((*it).second,q);
			pre[(*it).second]=v.second;
			add((*it).second,q);
		}
		it=s[q].lower_bound(v);
		if(it!=s[q].begin()){
			it--;
			if((*it).first==v.first){
				del(v.second,q);
				pre[v.second]=(*it).second;
				add(v.second,q);
			}
		}
		s[q].insert(v);
	}
	set<pair<int,int> >().swap(s[w]);
	return;
}
void dfs(int q,int w){
	dep[q]=dep[w]+1;
	s[q].insert({dep[q],q});
	add(q,q);
	for(int i=0;i<tu[q].size();i++){
		dfs(tu[q][i],q);
		merge(q,tu[q][i]);
	}
	return;
}
int cp(edge q,edge w){
	return q.op>w.op;
}
struct node{
	int lowbit(int q){
		return q&(-q);
	}
	void add(int q,int w){
		for(int i=q;i<=n;i+=lowbit(i)){
			C[i]+=w;
		}
		return;
	}
	int query(int q){
		int he=0;
		for(int i=q;i;i-=lowbit(i)){
			he+=C[i];
		}
		return he;
	}
}tree;
int cmp(edge q,edge w){
	if(q.y!=w.y){
		return q.y<w.y;
	}
	return q.op<w.op;
}
int cm(edge q,edge w){
	if(q.x!=w.x){
		return q.x>w.x;
	}
	return q.op<w.op;
}
void cdq(int l,int r){
	if(l>=r){
		return;
	}
	int mid=(l+r)/2;
	cdq(l,mid);
	cdq(mid+1,r);
	int zl=l,zr=mid+1;
	while(zl!=mid+1||zr!=r+1){
		if(zr==r+1||(zl!=mid+1&&st[zl].y<=st[zr].y)){
			if(st[zl].op==0){
				tree.add(st[zl].z,st[zl].ans);
				tree.acc(st[zl].zmax,-st[zl].ans);
			}
			zl++;
		}
		else{
			if(st[zr].op!=0){
				st[zr].ans+=tree.query(st[zr].z);
			}
			zr++;
		}
	}
	for(int i=l;i<=mid;i++){
		if(st[i].op==0){
			tree.add(st[i].z,-st[i].ans);
		}
	}
	inplace_merge(st+l,st+mid+1,st+r+1,cmp);
	return;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>fa[i];
		if(!fa[i]){
			rt=i;
		}
		else{
			tu[fa[i]].push_back(i);
		}
	}
	dfs(rt,0);
	for(int i=1;i<=top;i++){
		st[i].zmax=dep[st[i].y];
	}
	for(int i=1;i<=n;i++){
		top++;
		st[top].x=i;
		st[top].y=i;
		st[top].z=dep[i];
		st[top].zmax=n+1;
		st[top].op=0;
		st[top].ans=1;
	}
	for(int i=1;i<=m;i++){
		cin>>x>>y>>z;
		top++;
		st[top].x=x;
		st[top].y=y;
		st[top].z=z;
		st[top].op=i;
	}
	sort(st+1,st+1+top,cm);
	cdq(1,top);
	sort(st+1,st+1+top,cp);
	for(int i=m;i>=1;i--){
		cout<<st[i].y-st[i].x+1-st[i].ans<<'\n';
	}
	return 0;
}

详细

answer.code:14:36: error: use of deleted function ‘std::unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set() [with _Value = std::pair<int, int>; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]’
   14 | unordered_set<pair<int,int> >s[maxn];
      |                                    ^
In file included from /usr/include/c++/14/unordered_set:41,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:189,
                 from answer.code:1:
/usr/include/c++/14/bits/unordered_set.h:142:7: note: ‘std::unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set() [with _Value = std::pair<int, int>; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]’ is implicitly deleted because the default definition would be ill-formed:
  142 |       unordered_set() = default;
      |       ^~~~~~~~~~~~~
/usr/include/c++/14/bits/unordered_set.h:142:7: error: use of deleted function ‘std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, true, true>]’
In file included from /usr/include/c++/14/bits/unordered_map.h:33,
                 from /usr/include/c++/14/unordered_map:41,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:188:
/usr/include/c++/14/bits/hashtable.h:539:7: note: ‘std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, true, true>]’ is implicitly deleted because the default definition would be ill-formed:
  539 |       _Hashtable() = default;
      |       ^~~~~~~~~~
/usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function ‘std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, true, true>]’
In file included from /usr/include/c++/14/bits/hashtable.h:35:
/usr/include/c++/14/bits/hashtable_policy.h:1726:7: note: ‘std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, true, true>]’ is implicitly deleted because the default definition would be ill-formed:
 1726 |       _Hashtable_base() = default;
      |       ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1726:7: error: use of deleted function ‘std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _ExtractKey = std::__detail::_Identity; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]’
/usr/include/c++/14/bits/hashtable_policy.h: In instantiation of ‘std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<int, int> >]’:
/usr/include/c++/14/bits/hashtable_policy.h:1326:7:   required from here
 1326 |       _Hash_code_base() = default;
      |       ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1243:49: error: use of deleted function ‘std::hash<std::pair<int, int> >::hash()’
 1243 |       _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { }
      |                                                 ^~~~~
In file inc...