QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#864920#9905. 哈夫曼树konata2828Compile Error//C++982.0kb2025-01-21 11:15:452025-01-21 11:15:47

Judging History

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

  • [2025-01-21 11:15:47]
  • 评测
  • [2025-01-21 11:15:45]
  • 提交

answer

// Hydro submission #678f115f3e10c2b5101f12a8@1737429343917
#include<bits/stdc++.h>
using namespace std;
namespace ax_by_c{
typedef long long ll;
typedef pair<ll,ll> pii;
const int N=2e5+5;
int n,m;
ll a[N];
int ls[N],rs[N],fa[N],rt,de[N];
ll sum[N];
void dfs(int u){
	sum[u]=a[u];
	if(ls[u])de[ls[u]]=de[u]+1,dfs(ls[u]),sum[u]+=sum[ls[u]];
	if(rs[u])de[rs[u]]=de[u]+1,dfs(rs[u]),sum[u]+=sum[rs[u]];
}
pii val[N];
struct QWQ{
	multiset<pii>s;
	int cnt;
	void ins(pii x){
		s.insert(x);
		auto it=s.find(x),it2=it;
		if(it!=s.begin()){
			it--;
			if(x.first<it->second)cnt++;
			it2++;
			if(it2!=s.end()){
				if(it2->first<x.second)cnt++;
				if(it2->first<it->second)cnt--;
			}
		}
		else{
			it2++;
			if(it2!=s.end())if(it2->first<x.second)cnt++;
		}
	}
	void rm(pii x){
		auto it=s.find(x),it2=it;
		if(it!=s.begin()){
			it--;
			if(x.first<it->second)cnt--;
			it2++;
			if(it2!=s.end()){
				if(it2->first<x.second)cnt--;
				if(it2->first<it->second)cnt++;
			}
		}
		else{
			it2++;
			if(it2!=s.end())if(it2->first<x.second)cnt--;
		}
		s.erase(s.find(x));
	}
	bool Q(){
		return cnt==0;
	}
}qwq;
void main(){
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(int i=n+1;i<=n*2-1;i++)scanf("%d %d",&ls[i],&rs[i]),fa[ls[i]]=fa[rs[i]]=i;
	for(int i=1;i<=n*2-1;i++)if(!fa[i])rt=i;
	dfs(rt);
	for(int i=1;i<=n*2-1;i++){
		if(de[i]>75){
			for(int j=0;j<m;j++)puts("NO");
			return ;
		}
	}
	for(int i=n+1;i<=n*2-1;i++)qwq.ins(val[i]={min(sum[ls[i]],sum[rs[i]]),max(sum[ls[i]],sum[rs[i]])});
	if(qwq.Q())puts("YES");else puts("NO");
	int pos;
	ll v;
	for(int i=1;i<m;i++){
		scanf("%d %lld",&pos,&v);
		sum[pos]=a[pos]=v;
		pos=fa[pos];
		while(pos){
			qwq.rm(val[pos]);
			sum[pos]=a[pos]+sum[ls[pos]]+sum[rs[pos]];
			qwq.ins(val[pos]={min(sum[ls[pos]],sum[rs[pos]]),max(sum[ls[pos]],sum[rs[pos]])});
			pos=fa[pos];
		}
		if(qwq.Q())puts("YES");else puts("NO");
	}
}
}
int main(){
	ax_by_c::main();
	return 0;
}

详细

answer.code: In member function ‘void ax_by_c::QWQ::ins(ax_by_c::pii)’:
answer.code:23:22: error: ‘it’ does not name a type; did you mean ‘int’?
   23 |                 auto it=s.find(x),it2=it;
      |                      ^~
      |                      int
answer.code:24:20: error: ‘it’ was not declared in this scope; did you mean ‘rt’?
   24 |                 if(it!=s.begin()){
      |                    ^~
      |                    rt
answer.code:27:25: error: ‘it2’ was not declared in this scope
   27 |                         it2++;
      |                         ^~~
answer.code:34:25: error: ‘it2’ was not declared in this scope
   34 |                         it2++;
      |                         ^~~
answer.code: In member function ‘void ax_by_c::QWQ::rm(ax_by_c::pii)’:
answer.code:39:22: error: ‘it’ does not name a type; did you mean ‘int’?
   39 |                 auto it=s.find(x),it2=it;
      |                      ^~
      |                      int
answer.code:40:20: error: ‘it’ was not declared in this scope; did you mean ‘rt’?
   40 |                 if(it!=s.begin()){
      |                    ^~
      |                    rt
answer.code:43:25: error: ‘it2’ was not declared in this scope
   43 |                         it2++;
      |                         ^~~
answer.code:50:25: error: ‘it2’ was not declared in this scope
   50 |                         it2++;
      |                         ^~~
answer.code: In function ‘void ax_by_c::main()’:
answer.code:71:105: warning: extended initializer lists only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions]
   71 |         for(int i=n+1;i<=n*2-1;i++)qwq.ins(val[i]={min(sum[ls[i]],sum[rs[i]]),max(sum[ls[i]],sum[rs[i]])});
      |                                                                                                         ^
answer.code:71:105: warning: extended initializer lists only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions]
answer.code:82:104: warning: extended initializer lists only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions]
   82 |                         qwq.ins(val[pos]={min(sum[ls[pos]],sum[rs[pos]]),max(sum[ls[pos]],sum[rs[pos]])});
      |                                                                                                        ^
answer.code:82:104: warning: extended initializer lists only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions]
answer.code:60:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   60 |         scanf("%d %d",&n,&m);
      |         ~~~~~^~~~~~~~~~~~~~~
answer.code:61:35: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   61 |         for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
      |                              ~~~~~^~~~~~~~~~~~~~
answer.code:62:41: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   62 |         for(int i=n+1;i<=n*2-1;i++)scanf("%d %d",&ls[i],&rs[i]),fa[ls[i]]=fa[rs[i]]=i;
      |                                    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
answer.code:76:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   76 |                 scanf("%d %lld",&pos,&v);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~