QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#645505#8949. 赫露艾斯塔DaiRuiChen0070 1501ms150540kbC++174.5kb2024-10-16 18:47:292024-10-16 18:47:30

Judging History

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

  • [2024-10-16 18:47:30]
  • 评测
  • 测评结果:0
  • 用时:1501ms
  • 内存:150540kb
  • [2024-10-16 18:47:29]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
namespace IO {
int ow,olim=(1<<23)-100;
char buf[1<<21],*p1=buf,*p2=buf,obuf[1<<23];
#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
int read() {
	int x=0; char c=gc();
	while(!isdigit(c)) c=gc();
	while(isdigit(c)) x=x*10+(c^48),c=gc();
	return x;
}
void flush() {
	fwrite(obuf,ow,1,stdout),ow=0;
}
void write(int x) {
	if(!x) obuf[ow++]='0';
	else {
		int t=ow;
		for(;x;x/=10) obuf[ow++]=(x%10)^48;
		reverse(obuf+t,obuf+ow);
	}
	if(ow>=olim) flush();
}
void putc(char c) {
	obuf[ow++]=c;
	if(ow>=olim) flush();
}
#undef gc
}
const int MAXN=1e6+5;
inline void chkmin(int &x,const int &y) { x=x<y?x:y; }
inline void chkmax(int &x,const int &y) { x=x>y?x:y; }
mt19937 rnd(time(0));
struct Treap {
	int x[MAXN],y[MAXN],tx[MAXN],ty[MAXN],pri[MAXN],ls[MAXN],rs[MAXN],siz[MAXN];
	inline void psd(const int &p) {
		if(tx[p]) x[ls[p]]=tx[ls[p]]=x[rs[p]]=tx[rs[p]]=tx[p],tx[p]=0;
		if(ty[p]) y[ls[p]]=ty[ls[p]]=y[rs[p]]=ty[rs[p]]=ty[p],ty[p]=0;
	}
	void splix(int p,const int &k,int &u,int &v) {
		if(!p) return u=v=0,void();
		psd(p);
		if(x[p]<=k) u=p,splix(rs[p],k,rs[p],v);
		else v=p,splix(ls[p],k,u,ls[p]);
		siz[p]=siz[ls[p]]+siz[rs[p]]+1;
	}
	void spliy(int p,const int &k,int &u,int &v) {
		if(!p) return u=v=0,void();
		psd(p);
		if(y[p]>=k) u=p,spliy(rs[p],k,rs[p],v);
		else v=p,spliy(ls[p],k,u,ls[p]);
		siz[p]=siz[ls[p]]+siz[rs[p]]+1;
	}
	void spliz(int p,const int &k,int &u,int &v) {
		if(!p) return u=v=0,void();
		psd(p);
		if(x[p]-y[p]<=k) u=p,spliz(rs[p],k,rs[p],v);
		else v=p,spliz(ls[p],k,u,ls[p]);
		siz[p]=siz[ls[p]]+siz[rs[p]]+1;
	}
	int merge(int u,int v) {
		if(!u||!v) return u|v;
		psd(u),psd(v);
		if(pri[u]<pri[v]) return siz[u]+=siz[v],rs[u]=merge(rs[u],v),u;
		else return siz[v]+=siz[u],ls[v]=merge(u,ls[v]),v;
	}
	inline int szx(int p,const int &k) {
		int ans=0;
		while(p) {
			psd(p);
			if(x[p]>k) p=ls[p];
			else ans+=siz[ls[p]]+1,p=rs[p];
		}
		return ans;
	}
	inline int szy(int p,const int &k) {
		int ans=0;
		while(p) {
			psd(p);
			if(y[p]<k) p=ls[p];
			else ans+=siz[ls[p]]+1,p=rs[p];
		}
		return ans;
	}
}	T;
int n,m,ax[MAXN],ay[MAXN],ux[MAXN],uy[MAXN],qx[MAXN],qy[MAXN],op[MAXN],ans[MAXN];
struct poi {
	int x,y,id;
	inline friend bool operator <(const poi &u,const poi &v) {
		return u.x^v.x?u.x>v.x:u.id>v.id;
	}
};
vector <int> ins[MAXN];
struct Bit1 {
	int tr[MAXN],s;
	void init() { fill(tr+1,tr+n+1,m+1); }
	inline void upd(int x,const int &v) { for(;x;x&=x-1) chkmin(tr[x],v); }
	inline int qry(int x) { for(s=m+1;x<=n;x+=x&-x) chkmin(s,tr[x]); return s; }
}	Tmn;
struct Bit2 {
	int tr[MAXN],s;
	inline void upd(int x,const int &v) { for(;x;x&=x-1) chkmax(tr[x],v); }
	inline int qry(int x) { for(s=0;x<=n;x+=x&-x) chkmax(s,tr[x]); return s; }
}	Tmx;
struct Bit3 {
	int tr[MAXN],s;
	inline void add(int x,const int &v) { for(;x;x&=x-1) tr[x]+=v; }
	inline int qry(int x) { for(s=0;x<=n;x+=x&-x) s+=tr[x]; return s; }
}	To,Tx,Ty;
signed main() {
	n=IO::read(),m=IO::read();
	vector <poi> Q;
	for(int i=1;i<=n;++i) ax[i]=IO::read(),ay[i]=IO::read(),Q.push_back({ax[i],ay[i],i});
	for(int i=1;i<=m;++i) {
		op[i]=IO::read(),ux[i]=IO::read(),uy[i]=IO::read();
		qx[i]=IO::read(),qy[i]=IO::read();
		Q.push_back({ux[i],uy[i],i+n});
	}
	sort(Q.begin(),Q.end());
	Tmn.init();
	for(auto o:Q) {
		if(o.id>n) Tmn.upd(o.y,o.id-n);
		else ins[Tmn.qry(o.y)].push_back(o.id);
	}
	Q.clear();
	for(int i=1;i<=n;++i) Q.push_back({ax[i],ay[i],i});
	for(int i=1;i<=m;++i) Q.push_back({qx[i],qy[i],i+n});
	sort(Q.begin(),Q.end());
	for(auto o:Q) {
		if(o.id>n) ans[o.id-n]=To.qry(o.y+1);
		else To.add(o.y,1);
	}
	for(int i=1;i<=n;++i) Tx.add(ax[i],1),Ty.add(ay[i],1);
	int rt=0;
	for(int i=1,ot=n;i<=m;++i) {
		int u,o1,o2,o3;
		T.splix(rt,ux[i],o1,o2);
		T.spliy(o1,uy[i]+1,o3,u);
		if(op[i]==2) T.x[u]=T.tx[u]=ux[i];
		else T.y[u]=T.ty[u]=uy[i];
		rt=T.merge(T.merge(o3,u),o2);
		for(int j:ins[i]) {
			Tx.add(ax[j],-1),Ty.add(ay[j],-1),--ot;
			op[i]==2?ax[j]=ux[i]:ay[j]=uy[i];
			T.spliz(rt,ax[j]-ay[j],o1,o2);
			T.x[j]=ax[j],T.y[j]=ay[j],T.pri[j]=rnd(),T.siz[j]=1;
			rt=T.merge(T.merge(o1,j),o2);
		}
		Tmx.upd(ux[i],uy[i]);
		if(Tmx.qry(qx[i]+1)>qy[i]) { IO::putc('0'),IO::putc('\n'); continue; }
		int tmp=T.szx(rt,ux[i]);
		T.splix(rt,ux[i],o1,o2);
		assert(tmp==T.siz[o1]);
		T.spliy(o1,uy[i]+1,o3,u);
		ans[i]+=ot+T.siz[u];
		ans[i]-=Tx.qry(qx[i]+1)+Ty.qry(qy[i]+1);
		IO::write(ans[i]),IO::putc('\n');
	}
	IO::flush();
	return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 10ms
memory: 63080kb

input:

995 996
950 481
376 18
141 776
711 966
130 727
468 529
47 39
857 563
832 821
776 472
154 914
825 279
332 415
470 361
968 440
45 560
299 755
703 785
744 387
547 382
3 549
344 573
778 424
784 765
280 115
251 434
695 98
463 506
379 38
610 486
305 623
703 244
856 365
117 360
772 847
331 723
663 991
900 ...

output:

423
473
758
313
694
232
333
784
821
154
247
244
504
54
200
368
870
780
734
172
656
465
72
750
73
1
140
972
522
411
437
690
505
572
255
115
238
5
2
315
306
491
213
823
424
614
976
691
114
43
58
487
363
271
375
122
304
126
207
397
9
533
5
368
413
151
21
0
161
608
660
544
478
655
560
47
126
519
223
43
...

result:

wrong answer 16th numbers differ - expected: '370', found: '368'

Subtask #2:

score: 0
Wrong Answer

Test #9:

score: 0
Wrong Answer
time: 1501ms
memory: 144120kb

input:

999996 999996
921339 140126
955508 363759
958698 342406
280137 955674
907511 75721
189876 946586
152058 168837
541857 557702
84498 865987
185574 809224
704828 701026
815379 548000
989515 518951
335439 336866
745570 790616
766723 212893
926629 859003
51261 40866
592510 556235
324926 700261
320946 798...

output:

0
0
803382
0
0
181281
0
0
0
0
63382
0
0
0
0
420
0
0
0
0
0
0
18395
0
0
0
0
0
0
0
0
0
0
0
11756
0
0
7822
0
0
0
0
22726
0
0
0
8233
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
13818
1351
0
0
0
0
0
0
6803
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4678
0
0
0
0
0
0
0
12532
0
0
0
0
0
0
0
0
0
0
0
0...

result:

wrong answer 3rd numbers differ - expected: '953730', found: '803382'

Subtask #3:

score: 0
Wrong Answer

Test #17:

score: 0
Wrong Answer
time: 1148ms
memory: 150540kb

input:

999995 999997
261379 334440
985281 986034
549380 718157
670003 253925
533027 437989
326806 983213
965935 756259
229069 686789
331338 684961
957559 390618
937820 959719
338153 779814
582581 965418
634156 421264
308778 938878
913059 390904
481477 431492
739774 793015
901442 934600
256704 991485
366691...

output:

160637
633543
123518
313576
450012
383635
574183
2373
203698
326070
117989
567271
652818
199774
380309
380369
105872
373850
788335
703167
609790
648149
367052
497968
57973
478834
745041
75928
543052
251827
769808
436477
480956
235825
509613
757170
763474
396829
262666
2240
267161
165774
558946
16523...

result:

wrong answer 1st numbers differ - expected: '160635', found: '160637'

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%