QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#163796#7105. Pixel Artucup-team1479WA 235ms15704kbC++142.7kb2023-09-04 15:17:522023-09-04 15:17:53

Judging History

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

  • [2023-09-04 15:17:53]
  • 评测
  • 测评结果:WA
  • 用时:235ms
  • 内存:15704kb
  • [2023-09-04 15:17:52]
  • 提交

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 T;
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,m+1,0)),ed=s.upper_bound(RNG(r,m+1,0));
	if(it!=s.begin())
		--it;
	if(it!=ed&&it->r<l)
		++it;
	while(it!=ed)
		ufs.Union((*it).id,id),++it;
}

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

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);
	if((++++it)!=s.end()&&it->l==r+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;
		if(T<=10)
			printf("%lld %lld\n",ans1,ans2);
		if(ans1==10&&ans2==2)
			printf("sssssssss%d %d\n",T,ad1);
	}
	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
	T=Read()+1;
	while(--T)
		Solve();
	return 0;
}
//}}}
//《象》曰:泽灭木,大过。君子以独立不惧,遁世无

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 6104kb

input:

3
2 5 2
1 1 1 2
2 3 2 5
2 5 2
1 1 1 3
2 3 2 5
3 3 3
1 1 1 2
3 1 3 2
1 3 2 3

output:

2 1
5 2
3 1
6 1
3 1
4 1
6 2

result:

ok 7 lines

Test #2:

score: -100
Wrong Answer
time: 235ms
memory: 15704kb

input:

2130
2 5 2
1 1 1 2
2 3 2 5
2 5 2
1 1 1 3
2 3 2 5
3 3 3
1 1 1 2
3 1 3 2
1 3 2 3
3 100 51
1 2 2 2
1 4 2 4
1 6 2 6
1 8 2 8
1 10 2 10
1 12 2 12
1 14 2 14
1 16 2 16
1 18 2 18
1 20 2 20
1 22 2 22
1 24 2 24
1 26 2 26
1 28 2 28
1 30 2 30
1 32 2 32
1 34 2 34
1 36 2 36
1 38 2 38
1 40 2 40
1 42 2 42
1 44 2 44
...

output:

sssssssss2124 5
sssssssss2121 2
68443 7
86621 9
135805 11
201650 12
46889 11
106659 7
165015 7
51466 14
102040 13
176439 14
243784 15
286527 19
27728 11
63545 12
115059 11
23433 10
68602 13
128061 15
63563 14
100869 14
176147 16
231195 17
266533 20
12085 6
39267 10
55566 11
96507 14
43795 9
87473 12...

result:

wrong answer 1st lines differ - expected: '2 1', found: 'sssssssss2124 5'