QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#829909 | #8949. 赫露艾斯塔 | 275307894a | 0 | 3980ms | 436836kb | C++14 | 5.0kb | 2024-12-24 14:42:50 | 2024-12-24 14:42:51 |
Judging History
answer
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=2e6+5,M=N*4+5,K=1000+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(28382);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
#ifdef LOCAL
#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
#else
#define gdb(...) void()
#endif
}using namespace Debug;
int n,m,A[N],B[N],C[N],D[N],ti[N];
namespace FHQ{
int l[N],r[N],rd[N],siz[N],cnt;
pii val[N];pii tag[N];
void Pf(int v,pii w){
if(!v) return;
if(w.fi) val[v].fi=tag[v].fi=w.fi;
if(w.se) val[v].se=tag[v].se=w.se;
}
void P(int v){
if(tag[v].fi||tag[v].se) Pf(l[v],tag[v]),Pf(r[v],tag[v]),tag[v]=make_pair(0,0);
}
void up(int v){
siz[v]=siz[l[v]]+siz[r[v]]+1;
}
void splitx(int x,int v,int &a,int &b){
// gdb(x,v,val[v].fi,l[v],r[v]);
if(!v){a=b=0;return;}
P(v);
if(val[v].fi<=x) a=v,splitx(x,r[v],r[a],b);
else b=v,splitx(x,l[v],a,l[b]);
up(v);
}
void splity(int y,int v,int &a,int &b){
if(!v){a=b=0;return;}
P(v);
if(val[v].se<=y) a=v,splity(y,r[v],r[a],b);
else b=v,splity(y,l[v],a,l[b]);
up(v);
}
void split(pii w,int v,int &a,int &b){
if(!v){a=b=0;return;}
P(v);
if(val[v]<=w) a=v,split(w,r[v],r[a],b);
else b=v,split(w,l[v],a,l[b]);
up(v);
}
int merge(int x,int y){
if(!x||!y) return x+y;
P(x);P(y);
if(rd[x]<rd[y]) return r[x]=merge(r[x],y),up(x),x;
else return l[y]=merge(x,l[y]),up(y),y;
}
int newnode(pii x){
val[++cnt]=x;rd[cnt]=rnd();siz[cnt]=1;
return cnt;
}
int rt;
void modify(int x,int y,int op){
int r1,r2,r3;
splitx(-x-1,rt,r1,r2);splity(y,r2,r2,r3);
Pf(r2,op==1?make_pair(0,y):make_pair(-x,0));
rt=merge(r1,merge(r2,r3));
}
int query(int y,int v){
if(!v) return 0;
if(val[v].se<=y) return 1+siz[l[v]]+query(y,r[v]);
return query(y,l[v]);
}
int qry(int x,int y){
int r1,r2,r3;
splitx(-x-1,rt,r1,r2);
int w=query(y,r2);
// gdb(val[r2].fi,val[r2].se,val[6].fi,val[6].se,val[2].fi,val[2].se);
rt=merge(r1,r2);
return w;
}
void ins(int x,int y){
int r1,r2;
split(make_pair(-x,y),rt,r1,r2);
rt=merge(merge(r1,newnode(make_pair(-x,y))),r2);
}
}
int id[N];
namespace Tree{
#define ls v<<1
#define rs v<<1|1
vector<int> f[M];
void add(int x,int id,int l=1,int r=n,int v=1){
f[v].push_back(id);
if(l==r) return;
int m=l+r>>1;x<=m?add(x,id,l,m,ls):add(x,id,m+1,r,rs);
}
void modify(int x,int y,int z,int op,int id,int l=1,int r=n,int v=1){
if(x<=l&&r<=y){
while(!f[v].empty()){
int u=f[v].back();
if(B[u]>z) break;
f[v].pop_back();
if(ti[u]) continue;
if(op==1) FHQ::ins(A[u],z);
else FHQ::ins(y,B[u]);
ti[u]=id;
// gdb(u,id);
}
return;
}
int m=l+r>>1;x<=m&&(modify(x,y,z,op,id,l,m,ls),0);y>m&&(modify(x,y,z,op,id,m+1,r,rs),0);
}
}
int ans[N];
struct ques{
int x,y,id,op;
}Q[2*N];
int Qh;
namespace bit{
int f[N];
void add(int x){while(x<=n) f[x]++,x+=x&-x;}
int qry(int x){int ans=0;while(x) ans+=f[x],x-=x&-x;return ans;}
void clr(int x){while(x<=n&&f[x]) f[x]=0,x+=x&-x;}
}
void calc(int l,int r){
if(l==r) return;
int m=l+r>>1;
calc(l,m);calc(m+1,r);
int R=m+1;
for(int i=l;i<=m;i++)if(Q[i].op){
while(R<=r&&Q[R].x<=Q[i].x){
if(!Q[R].op)bit::add(Q[R].y);
R++;
}
ans[Q[i].id]+=bit::qry(Q[i].y);
}
while(R>m+1){
R--;
if(!Q[R].op) bit::clr(Q[R].y);
}
inplace_merge(Q+l,Q+m+1,Q+r+1,[](ques x,ques y){return x.x<y.x;});
}
void Solve(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++) scanf("%d%d",&A[i],&B[i]);
iota(id+1,id+n+1,1);
sort(id+1,id+n+1,[](int x,int y){return B[x]<B[y];});
for(int i=n;i;i--) Tree::add(A[id[i]],id[i]);
for(int i=1;i<=m;i++){
int op,x,y;
scanf("%d%d%d%d%d",&op,&x,&y,&C[i],&D[i]);
FHQ::modify(x,y,op);
Tree::modify(1,x,y,op,i);
ans[i]=FHQ::qry(C[i],D[i]);
// gdb(ans[i]);
}
for(int i=1;i<=n;i++) if(!ti[i]) ti[i]=m+1;
for(int i=1;i<=n;i++){
Q[++Qh]=(ques){A[i],B[i],ti[i]-1,0};
}
for(int i=1;i<=m;i++) Q[++Qh]=(ques){C[i],D[i],i,1};
sort(Q+1,Q+Qh+1,[](ques x,ques y){return make_pair(x.id,-x.op)<make_pair(y.id,-y.op);});
calc(1,Qh);
/*for(int i=1;i<=n;i++){
for(int j=1;j<ti[i];j++) if(A[i]<=C[j]&&B[i]<=D[j]) ans[j]++;
}*/
for(int i=1;i<=m;i++) printf("%d\n",ans[i]);
}
int main(){
int t=1;
// scanf("%d",&t);
while(t--) Solve();
cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 36ms
memory: 192892kb
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 174 660 467 76 754 77 3 144 974 526 415 439 694 507 577 258 120 243 3 2 319 313 498 218 828 433 623 981 700 120 55 70 499 375 283 387 128 317 139 220 410 22 547 3 385 430 168 32 0 178 625 677 561 488 672 577 64 144 537 235 54...
result:
wrong answer 672nd numbers differ - expected: '176', found: '178'
Subtask #2:
score: 0
Wrong Answer
Test #9:
score: 20
Accepted
time: 3645ms
memory: 435156kb
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 953730 0 0 512663 0 0 0 0 407467 0 0 0 0 420 0 0 0 0 0 0 513245 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 349438 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 8602 0 0 0 0 0 0 0 15717 0 0 0 0 0 0 0 0 0 0...
result:
ok 999996 numbers
Test #10:
score: 20
Accepted
time: 3793ms
memory: 435340kb
input:
999999 999998 593840 81071 226822 360556 984658 495723 774168 212723 961202 460976 425364 312068 135686 76747 312878 654073 77701 260718 263549 822714 513429 976716 926207 374094 338002 624578 897648 332005 630931 241967 134312 551284 743455 355739 997122 435568 642662 63663 795243 94444 696789 3776...
output:
491984 0 125735 422908 0 226183 0 0 0 2158 0 0 280064 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 0 0 0 0 0 0 19502 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 0 0 0 0 0 0 0 0 747 0 0 0 0 0 0 0 0 0 0 0 0 59265 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 ...
result:
ok 999998 numbers
Test #11:
score: 20
Accepted
time: 3379ms
memory: 436836kb
input:
1000000 1000000 883777 318082 13863 878428 601471 340063 593065 648191 228224 432858 585884 205059 770071 963599 897140 940808 68907 32537 396365 642545 822913 211348 629556 82339 190410 157689 907562 173596 271125 337580 145399 606492 749603 897091 193876 205903 678121 530830 947890 589055 721497 7...
output:
261157 0 0 52244 0 0 0 0 4610 0 20801 505827 0 0 0 655799 0 0 0 0 0 163473 0 0 113182 0 0 556199 0 0 0 282902 197726 0 0 0 521870 0 0 0 0 0 0 0 0 0 0 146288 0 136329 0 0 0 0 0 91372 0 0 0 0 0 522077 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 0 0 0 0 0 0 0 0 0 0 181410 0 0 0 0 0 0 ...
result:
ok 1000000 numbers
Test #12:
score: 20
Accepted
time: 3676ms
memory: 433400kb
input:
999999 999998 510701 119376 730813 348187 969509 347009 150616 323014 602592 62582 356110 705851 244692 610953 398605 700401 220533 880308 10280 261179 57162 967936 642021 39765 410482 274103 869979 489138 673553 368275 889697 840948 383673 63696 607963 107808 875626 9630 793170 959823 798227 760130...
output:
65013 21415 692431 0 388141 0 0 0 0 0 0 0 0 0 0 42859 0 0 0 0 0 0 0 0 0 0 8862 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 172112 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 1215 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 0 0 0 0 0 0 0 0 6288 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 999998 numbers
Test #13:
score: 20
Accepted
time: 3709ms
memory: 432396kb
input:
999995 999997 148480 214663 902145 539206 771718 173309 708903 967479 984809 352800 21198 668703 879442 719279 593199 82759 286519 788269 873747 641026 246815 368469 585243 532758 177189 437376 566499 996874 663718 794807 847945 784546 68802 611025 636042 793005 656312 200282 90301 316758 516692 913...
output:
408393 0 0 210017 0 0 0 0 0 0 0 0 0 0 0 0 0 0 34271 0 0 0 0 0 0 0 0 0 0 31774 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 624290 27190 0 0 0 0 0 0 0 0 2486 0 0 0 0 0 0 0 0 0 844 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10393 0 0 0 0 0 0 0 0 0 0 0 0 49019 0 0 0 19256 0 0 0 0 0 0 62458 0 0 0 0 0 0 ...
result:
ok 999997 numbers
Test #14:
score: 0
Wrong Answer
time: 3980ms
memory: 433732kb
input:
999997 999999 21022 22383 798350 250307 186761 593014 213847 210545 769838 227750 113146 776982 163493 384752 89954 142451 392976 865128 131868 401967 725617 848954 553332 555884 864058 712711 390463 443782 552326 132864 92265 612350 758766 28175 452611 460112 344799 865045 46279 695425 971996 40084...
output:
418555 110151 3026 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 33746 0 0 0 0 63321 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 60309 0 0 0 0 0 0 6997 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 3366 0 0 0 0 0 0 0 0 0 2...
result:
wrong answer 223214th numbers differ - expected: '21', found: '22'
Subtask #3:
score: 0
Time Limit Exceeded
Test #17:
score: 0
Time Limit Exceeded
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:
result:
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%