QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#564959 | #8949. 赫露艾斯塔 | Kevin5307# | 0 | 4931ms | 204440kb | C++23 | 5.3kb | 2024-09-15 18:16:29 | 2024-09-15 18:16:29 |
Judging History
answer
//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
mt19937_64 rng(20210448);
int n,q;
int x[1001000],y[1001000];
int op[1001000],a[1001000],b[1001000],X[1001000],Y[1001000];
int tim[1001000];
vector<pii> vq1[1001000],vq2[1001000];
namespace bit1
{
int bit[1001000];
inline void update(int p,int v)
{
while(p<1001000)
{
bit[p]=min(bit[p],v);
p+=(p&(-p));
}
}
inline int query(int p)
{
int ans=0x3f3f3f3f;
while(p)
{
ans=min(ans,bit[p]);
p-=(p&(-p));
}
return ans;
}
}
namespace bit2
{
int bit[1001000];
inline void update(int p,int v)
{
while(p<1001000)
{
bit[p]+=v;
p+=(p&(-p));
}
}
inline int query(int p)
{
int ans=0;
while(p)
{
ans+=bit[p];
p-=(p&(-p));
}
return ans;
}
}
int ans[1001000];
array<int,3> vect[2002000];
int vs;
int qlist[1001000];
void solve(int l,int r,int ql,int qr)
{
if(ql>qr) return ;
if(l==r) return ;
int mid=(l+r)/2;
vector<int> v1,v2;
int p=ql;
while(p<=qr&&tim[qlist[p]]<=mid) p++;
solve(l,mid,ql,p-1);
solve(mid+1,r,p,qr);
vs=0;
for(int i=p;i<=qr;i++)
vect[vs++]={x[qlist[i]],y[qlist[i]],0};
for(int i=l;i<=mid;i++)
vect[vs++]={X[i],Y[i],i};
sort(vect,vect+vs);
for(int i=0;i<vs;i++)
{
auto arr=vect[i];
if(arr[2])
ans[arr[2]]+=bit2::query(arr[1]);
else
bit2::update(arr[1],1);
}
for(int i=0;i<vs;i++)
if(!vect[i][2])
bit2::update(vect[i][1],-1);
}
namespace treap
{
ull prior[1001000];
int x[1001000],y[1001000];
int tagx[1001000],tagy[1001000];
int siz[1001000];
int ls[1001000],rs[1001000];
inline void pushdown(int u)
{
if(tagx[u])
{
x[u]=tagx[u];
if(ls[u]) tagx[ls[u]]=tagx[u];
if(rs[u]) tagx[rs[u]]=tagx[u];
tagx[u]=0;
}
if(tagy[u])
{
y[u]=tagy[u];
if(ls[u]) tagy[ls[u]]=tagy[u];
if(rs[u]) tagy[rs[u]]=tagy[u];
tagy[u]=0;
}
}
inline void pushup(int u)
{
siz[u]=siz[ls[u]]+siz[rs[u]]+1;
}
int merge(int u,int v)
{
if(!u||!v) return u+v;
if(prior[u]>prior[v])
{
pushdown(u);
rs[u]=merge(rs[u],v);
pushup(u);
return u;
}
else
{
pushdown(v);
ls[v]=merge(u,ls[v]);
pushup(v);
return v;
}
}
void splitx(int u,int sx,int &a,int &b)
{
if(!u)
{
a=b=0;
return ;
}
pushdown(u);
if(x[u]<=sx)
{
a=u;
splitx(rs[u],sx,rs[a],b);
pushup(a);
return ;
}
else
{
b=u;
splitx(ls[u],sx,a,ls[b]);
pushup(b);
return ;
}
}
void splity(int u,int sy,int &a,int &b)
{
if(!u)
{
a=b=0;
return ;
}
pushdown(u);
if(y[u]>=sy)
{
a=u;
splity(rs[u],sy,rs[a],b);
pushup(a);
return ;
}
else
{
b=u;
splity(ls[u],sy,a,ls[b]);
pushup(b);
return ;
}
}
void splitxy(int u,int sx,int sy,int &a,int &b)
{
if(!u)
{
a=b=0;
return ;
}
pushdown(u);
if((y[u]>sy)||(y[u]==sy&&x[u]<sx))
{
a=u;
splitxy(rs[u],sx,sy,rs[a],b);
pushup(a);
return ;
}
else
{
b=u;
splitxy(ls[u],sx,sy,a,ls[b]);
pushup(b);
return ;
}
}
}
vector<int> vind[1001000];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>q;
for(int i=1;i<=n;i++)
cin>>x[i]>>y[i];
for(int i=1;i<=q;i++)
cin>>op[i]>>a[i]>>b[i]>>X[i]>>Y[i];
for(int i=1;i<=q;i++)
vq1[a[i]].pb(b[i],i);
for(int i=1;i<=n;i++)
vq2[x[i]].pb(y[i],i);
memset(bit1::bit,0x3f,sizeof(bit1::bit));
for(int i=n;i>=1;i--)
{
for(auto pr:vq1[i])
bit1::update(n+1-pr.first,pr.second);
for(auto pr:vq2[i])
tim[pr.second]=bit1::query(n+1-pr.first);
}
for(int i=1;i<=n;i++)
if(tim[i]>q)
tim[i]=q+1;
for(int i=1;i<=n;i++)
qlist[i]=i;
sort(qlist+1,qlist+n+1,[&](int a,int b){return tim[a]<tim[b];});
// solve(1,q+1,1,n);
for(int i=1;i<=n;i++)
vind[tim[i]].pb(i);
int rt=0;
using treap::tagx;
using treap::tagy;
using treap::prior;
using treap::siz;
using treap::pushdown;
using treap::merge;
using treap::splitx;
using treap::splity;
using treap::splitxy;
for(int i=1;i<=q;i++)
{
int A,B,C;
splity(rt,b[i]+1,A,B);
splitx(B,a[i],B,C);
if(B)
{
if(op[i]==2)
tagx[B]=a[i];
else
tagy[B]=b[i];
pushdown(B);
rt=merge(A,merge(B,C));
}
else
rt=merge(A,C);
for(auto ind:vind[i])
{
int xx=x[ind],yy=y[ind];
if(op[i]==2)
xx=a[i];
else
yy=b[i];
int A,B;
splitxy(rt,xx,yy,A,B);
prior[ind]=rng();
tagx[ind]=tagy[ind]=0;
siz[ind]=1;
treap::x[ind]=xx;
treap::y[ind]=yy;
rt=merge(A,merge(ind,B));
}
splity(rt,Y[i]+1,A,B);
splitx(B,X[i],B,C);
ans[i]+=siz[B];
rt=merge(A,merge(B,C));
}
for(int i=1;i<=q;i++)
cout<<ans[i]<<'\n';
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: 6ms
memory: 37176kb
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:
0 0 0 0 0 0 0 0 0 0 1 1 2 2 2 2 2 2 2 4 4 4 4 4 4 2 4 4 4 4 4 4 5 5 5 5 6 0 0 7 7 8 8 9 9 9 9 10 12 12 12 12 12 12 12 13 13 13 13 13 14 15 0 17 17 17 11 0 17 17 17 17 17 17 17 18 18 19 19 11 20 20 20 21 22 0 22 0 22 21 22 23 24 24 0 25 25 25 25 25 25 25 25 10 25 0 25 2 26 10 26 26 29 29 29 29 29 29 ...
result:
wrong answer 1st numbers differ - expected: '423', found: '0'
Subtask #2:
score: 0
Wrong Answer
Test #9:
score: 0
Wrong Answer
time: 2163ms
memory: 178968kb
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 481730 0 0 331382 0 0 0 0 344085 0 0 0 0 0 0 0 0 0 0 0 494850 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 348087 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 3924 0 0 0 0 0 0 0 3185 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
wrong answer 3rd numbers differ - expected: '953730', found: '481730'
Subtask #3:
score: 0
Wrong Answer
Test #17:
score: 0
Wrong Answer
time: 4931ms
memory: 204440kb
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:
0 1 1 0 3 3 3 0 5 5 6 6 7 5 8 5 4 8 13 11 12 12 7 8 6 17 14 7 12 10 20 12 10 10 14 18 15 14 14 1 12 13 17 11 16 14 24 28 10 17 24 8 7 34 20 40 35 31 29 13 32 18 42 43 54 39 57 24 26 44 35 61 26 57 39 67 55 27 59 66 66 60 54 10 47 59 51 30 60 74 72 40 53 73 71 70 70 56 50 50 32 71 74 63 54 77 61 79 5...
result:
wrong answer 1st numbers differ - expected: '160635', found: '0'
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%