QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#163697#7105. Pixel Artucup-team1479Compile Error//C++142.7kb2023-09-04 14:09:282023-09-04 14:09:28

Judging History

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

  • [2023-09-04 14:09:28]
  • 评测
  • [2023-09-04 14:09:28]
  • 提交

answer

//prepare for coding{{{
#include<bits/stdc++.h>

#define RELEASE
#ifndef RELEASE
#define FL
#define DB(...) fprintf(stderr,__VA_ARGS__)
#else
#define DB(...) ;
#endif
#define PB push_back

typedef long long LL;

const int N=100000,M=100000,Q=100000;

using namespace std;

inline int Read(){
	char c=getchar();
	int res=0;
	bool b=0;
	while(c>'9'||c<'0')
		b=(c=='-'),c=getchar();
	while(c>='0'&&c<='9')
		res=(res<<3)+(res<<1)+c-'0',c=getchar();
	return b?-res:res;
}

int n,m,q;
LL ans1,ans2,ad1; 
//}}}

//operations{{{
struct OPRT{
	int l,r,id;
	bool op;
	
	inline bool operator<(const OPRT &x)const{
		return op==x.op?l<x.l:op<x.op;
	}

	inline OPRT(int l_,int r_,bool op_,int id_){
		l=l_,r=r_,op=op_,id=id_;
	}
};

vector<OPRT> op[N+10];
//}}}

//set{{{
struct RNG{
	int l,r,id;

	inline RNG(int l_,int r_,int id_){
		l=l_,r=r_,id=id_;
	}

	inline bool operator<(const RNG &x)const{
		return l==x.l?r<x.r:l<x.l;
	}
};

set<RNG> s;
//}}}

//unionable and findable set{{{
struct UFS{
	int f[N+10];

	inline int GetRt(int u){
		return f[u]?f[u]=GetRt(f[u]):u;
	}

	inline void Union(int u,int v){
		u=GetRt(u),v=GetRt(v);
		if(u==v)
			return;
		--ans2;
		f[u]=v;
	}

	inline void Clear(){
		for(int i=1;i<=q;++i)
			f[i]=0;
	}
}ufs;
//}}}

//solve{{{
inline void Query(int l,int r,int id){
	++ans2;
	auto it=s.upper_bound(RNG(l,n+1,0)),ed=s.upper_bound(RNG(r,n+1,0));
	if(it!=s.begin())
		--it;
	if(it!=ed&&it->r<l)
		++it;
	if(n==3&&m==100&&l==1)
		printf("%lld %lld\n",it==s.begin(),ed==s.end());
	cnt=0;
	while(it!=ed)
		ufs.Union((*it).id,id),++it,++cnt;
	if(n==3&&m==100&&l==1)
		printf("%d\n",cnt);
}

inline void Del(int l,int r,int id){
	ad1-=r-l+1;
	s.erase(s.find(RNG(l,r,id)));
}

inline void Add(int l,int r,int id){
	ad1+=r-l+1;
	auto it=s.insert(RNG(l,r,id)).first;
	if(it!=s.begin()&&(--it)->r==l-1)
		ufs.Union(it->id,id);
}
//}}}

//main{{{
inline void Solve(){
	n=Read(),m=Read(),q=Read();
	for(int i=1;i<=q;++i){
		int xx=Read(),xy=Read(),yx=Read(),yy=Read();
		op[xx].PB(OPRT(xy,yy,1,i));
		op[yx+1].PB(OPRT(xy,yy,0,i));
	}
	for(int i=1;i<=n;++i){
		for(OPRT x:op[i])
			if(x.op)
				Query(x.l,x.r,x.id);
		for(OPRT x:op[i]){
			int l=x.l,r=x.r,id=x.id;
			if(x.op)
				Add(l,r,id);
			else
				Del(l,r,id);
		}
		ans1+=ad1;
		printf("%lld %lld\n",ans1,ans2);
	}
	ans1=ans2=ad1=0;
	s.clear();
	ufs.Clear();
	for(int i=1;i<=n+1;++i)
		op[i].clear();
}

int main(){
#ifdef FL
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	int T=Read()+1;
	while(--T)
		Solve();
	return 0;
}
//}}}
//《象》曰:泽灭木,大过。君子以独立不惧,遁世无

Details

answer.code: In function ‘void Query(int, int, int)’:
answer.code:99:28: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘int’ [-Wformat=]
   99 |                 printf("%lld %lld\n",it==s.begin(),ed==s.end());
      |                         ~~~^         ~~~~~~~~~~~~~
      |                            |           |
      |                            |           int
      |                            long long int
      |                         %d
answer.code:99:33: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘int’ [-Wformat=]
   99 |                 printf("%lld %lld\n",it==s.begin(),ed==s.end());
      |                              ~~~^                  ~~~~~~~~~~~
      |                                 |                    |
      |                                 long long int        int
      |                              %d
answer.code:100:9: error: ‘cnt’ was not declared in this scope; did you mean ‘int’?
  100 |         cnt=0;
      |         ^~~
      |         int