QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#645367#8949. 赫露艾斯塔DaiRuiChen0070 4761ms148652kbC++174.0kb2024-10-16 17:58:472024-10-16 17:58:48

Judging History

This is the latest submission verdict.

  • [2024-10-16 17:58:48]
  • Judged
  • Verdict: 0
  • Time: 4761ms
  • Memory: 148652kb
  • [2024-10-16 17:58:47]
  • Submitted

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;
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(const 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(const 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(const 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(const int &u,const 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;
	}
}	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; };
vector <int> ins[MAXN];
struct Bit1 {
	int tr[MAXN],s;
	void init() { fill(tr+1,tr+n+1,m+1); }
	void upd(int x,int v) { for(;x;x&=x-1) tr[x]=min(tr[x],v); }
	int qry(int x) { for(s=m+1;x<=n;x+=x&-x) s=min(s,tr[x]); return s; }
}	Tmn;
struct Bit2 {
	int tr[MAXN],s;
	void upd(int x,int v) { for(;x;x&=x-1) tr[x]=max(tr[x],v); }
	int qry(int x) { for(s=0;x<=n;x+=x&-x) s=max(s,tr[x]); return s; }
}	Tmx;
struct Bit3 {
	int tr[MAXN],s;
	void add(int x,int v) { for(;x;x&=x-1) tr[x]+=v; }
	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(),[&](poi u,poi v){ return u.x^v.x?u.x>v.x:u.id>v.id; });
	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(),[&](poi u,poi v){ return u.x^v.x?u.x>v.x:u.id>v.id; });
	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(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; }
		T.splix(rt,qx[i],o1,o2);
		T.spliy(o1,qy[i]+1,o3,u);
		ans[i]+=ot+T.siz[u]-Tx.qry(qx[i]+1)-Ty.qry(qy[i]+1);
		IO::write(ans[i]),IO::putc('\n');
		rt=T.merge(T.merge(o3,u),o2);
	}
	IO::flush();
	return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 4ms
memory: 53136kb

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
370
872
782
734
178
678
509
166
940
263
192
522
1352
904
1177
1201
1456
1396
1466
1531
3697
8427
4098
8193
262455
590128
2359785
4718800
9962289
17301926
31982180
61342666
237503153
807927915
1814560810

result:

wrong answer 20th numbers differ - expected: '174', found: '178'

Subtask #2:

score: 0
Wrong Answer

Test #9:

score: 0
Wrong Answer
time: 1712ms
memory: 144160kb

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
540272
0
0
232562
0
0
0
0
115205
0
0
0
0
419
0
0
0
0
0
0
94388
0
0
0
0
0
0
0
0
0
0
0
11755
0
0
7821
0
0
0
0
22725
0
0
0
8232
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
13817
55101
0
0
0
0
0
0
6802
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
5996
0
0
0
0
0
0
0
13145
0
0
0
0
0
0
0
0
0
0
0...

result:

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

Subtask #3:

score: 0
Wrong Answer

Test #17:

score: 0
Wrong Answer
time: 4761ms
memory: 148652kb

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:

160635
633545
123525
313579
450023
383666
574248
2404
203889
326263
118245
568166
654866
212574
462744
708560
3513743
126465111
1225787244

result:

wrong answer 2nd numbers differ - expected: '633543', found: '633545'

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%