QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#645398 | #8949. 赫露艾斯塔 | DaiRuiChen007 | 0 | 5688ms | 148516kb | C++17 | 4.0kb | 2024-10-16 18:09:12 | 2024-10-16 18:09:32 |
Judging History
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];
void psu(int p) { siz[p]=siz[ls[p]]+siz[rs[p]]+1; }
void psd(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]);
psu(p);
}
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]);
psu(p);
}
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]);
psu(p);
}
int merge(int u,int v) {
if(!u||!v) return u|v;
psd(u),psd(v);
if(pri[u]<pri[v]) return rs[u]=merge(rs[u],v),psu(u),u;
else return ls[v]=merge(u,ls[v]),psu(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;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 9ms
memory: 57208kb
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 179 675 502 151 909 232 192 459 1289 841 1050 1074 1329 1269 1339 1788 3186 7404 4098 8193 262455 524593 1835499 4718801 10486578 17826215 32506469 61866955 271581873 875561069
result:
wrong answer 20th numbers differ - expected: '174', found: '179'
Subtask #2:
score: 0
Wrong Answer
Test #9:
score: 0
Wrong Answer
time: 2140ms
memory: 144212kb
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 565583 0 0 252828 0 0 0 0 135485 0 0 0 0 419 0 0 0 0 0 0 120634 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 76122 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 6135 0 0 0 0 0 0 0 13989 0 0 0 0 0 0 0 0 0 0 ...
result:
wrong answer 3rd numbers differ - expected: '953730', found: '565583'
Subtask #3:
score: 0
Wrong Answer
Test #17:
score: 0
Wrong Answer
time: 5688ms
memory: 148516kb
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 633543 123521 313579 450027 383680 574278 2404 204079 326453 118435 568166 654482 228444 499092 839120 6397326 57128024
result:
wrong answer 3rd numbers differ - expected: '123519', found: '123521'
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%