QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#77462#1878. No Rest for the WickedXZTmaxsmall67Compile Error//C++231.7kb2023-02-14 19:10:022023-02-14 19:10:05

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-14 19:10:05]
  • 评测
  • [2023-02-14 19:10:02]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=2e5+100;
struct MERGE
{
	stack<tuple<int,int,int> >st;
	int fa[N],hmx[N],mx[N],siz[N]; 
	void clear(){for(int i=0;i<N;i++)fa[i]=i,hmx[i]=mx[i]=0,siz[i]=1;}
	MERGE(){clear();}
	int get(int x){return fa[x]==x?x:get(fa[x]);}
	void merge(int x,int y)
	{
		x=get(x);y=get(y);
		if(x==y)return;
		if(siz[x]<siz[y])swap(x,y);
		st.push(make_tuple(x,y,mx[x]));fa[y]=x;
		mx[x]=max({mx[x],mx[y],hmx[y]});hmx[x]=max(hmx[x],mx[x]);
	}
	void del()
	{
		int x,y,Mx;
		tie(x,y,Mx)=st.top();st.pop();
		hmx[y]=max(hmx[y],hmx[x]);
		fa[y]=y;mx[x]=Mx;siz[x]-=siz[y];
	}
	void gback(int time){while(st.size()>time)del();}
}M;
void solve(vector<tuple<int,int,int,int,int>>&vt,int L,int R)
{
	if(L>R||vt.empty())return;
	int mid=L+R>>1,time=M.st.size(),ttot=tot;
	vector<tuple<int,int,int,int,int>>lv,rv;
	for(auto y:vt)
	{
		int tp,l,r,u,v;
		tie(tp,l,r,u,v)=y;
		if(l<=L&&R<=r)
		{
			if(!tp)M.merge(u,v);
			else 
			{
				M.st.emplace(u,0,M.mx[u]);
				M.mx[u]=max(M.mx[u],M.hmx[v]);
				M.hmx[u]=max(M.hmx[u],M.mx[u]);
			}
		}
		else 
		{
			if(l<=mid)lv.push_back(y);
			if(r>mid)rv.push_back(y);
		}
	}
	solve(rv,mid+1,R),solve(lv,L,mid);
	return M.gback(time);
}
int n,m;
int c[N],t[N];
int main()
{
	scanf("%d%d",&n,&m);tot=n;
	vector<tuple<int,int,int,int,int> >vt;
	for(int i=1;i<=n;i++)scanf("%d%d%d",&c[i],&t[i],&M.mx[i]),M.hmx[i]=M.mx[i];
	for(int i=1,u,v;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		if(c[u]>c[v])swap(u,v);
		int l=max(c[u],c[v]),r=min(t[u],t[v]);
		if(l<=r)vt.push_back(make_tuple(0,l,r,u,v));
		l=c[u],r=min(t[u],c[v]-1);
		if(l<=r)vt.push_back(make_tuple(1,l,r,u,v));
	}
	solve(vt,1,1e9);
	for(int i=1;i<=n;i++)printf("%d ",M.hmx[i]);
	return 0;
}

Details

answer.code: In function ‘void solve(std::vector<std::tuple<int, int, int, int, int> >&, int, int)’:
answer.code:31:46: error: ‘tot’ was not declared in this scope; did you mean ‘ttot’?
   31 |         int mid=L+R>>1,time=M.st.size(),ttot=tot;
      |                                              ^~~
      |                                              ttot
answer.code: In function ‘int main()’:
answer.code:60:29: error: ‘tot’ was not declared in this scope
   60 |         scanf("%d%d",&n,&m);tot=n;
      |                             ^~~
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);tot=n;
      |         ~~~~~^~~~~~~~~~~~~~
answer.code:62:35: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   62 |         for(int i=1;i<=n;i++)scanf("%d%d%d",&c[i],&t[i],&M.mx[i]),M.hmx[i]=M.mx[i];
      |                              ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code:65:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   65 |                 scanf("%d%d",&u,&v);
      |                 ~~~~~^~~~~~~~~~~~~~