QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#421628 | #1429. Hit | grass8cow | WA | 1ms | 3844kb | C++17 | 1.8kb | 2024-05-25 22:57:51 | 2024-05-25 22:57:51 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
struct qq{int l,r;}a[301000];
int n,l[301000],r[300100],qc[300100],m;
int F(int x){return lower_bound(qc+1,qc+n+1,x)-qc;}
int nxt[301000],R[301000],sta[301000],le,re,L[300100];
int fo[300100][20];
bool chk(int X){
le=re=1,sta[1]=n+1;
//首先n+1肯定是好点.
nxt[n+1]=n+1;
for(int i=0;i<20;i++)fo[n+1][i]=n+1;
for(int i=n;i>=0;i--){
while(le<=re&&sta[le]>R[i+1])le++;
if(le>re){nxt[i]=-1;continue;}
int nx=sta[le];
for(int j=19;j>=0;j--)if(((X-1)>>j)&1)nx=fo[nx][j];
for(int j=1;j<=X-1;j++)nx=nxt[nx];
if(nx>L[i]){
fo[i][0]=nxt[i]=sta[le],sta[++re]=i;
for(int j=1;j<20;j++)fo[i][j]=fo[fo[i][j-1]][j-1];
}
else nxt[i]=-1;
}
if(nxt[0]==-1)return 0;
vector<int>ans;int u=nxt[0];
while(u<=n)ans.push_back(qc[u]),u=nxt[u];
printf("%d %d ",X,(int)ans.size());
for(int x:ans)printf("%d ",x);puts("");
return 1;
}
int vp[301000];
bool fuc,cu;
void sol(){
n=0;
scanf("%d",&m);
for(int i=1;i<=m;i++)scanf("%d%d",&a[i].l,&a[i].r),qc[++n]=a[i].l,qc[++n]=a[i].r,qc[++n]=a[i].l;
sort(qc+1,qc+n+1);n=unique(qc+1,qc+n+1)-qc-1;
for(int i=1;i<=n+1;i++)R[i]=n+1,L[i]=0;
for(int i=1;i<=m;i++)a[i].l=F(a[i].l),a[i].r=F(a[i].r),R[a[i].l]=min(R[a[i].l],a[i].r),
L[a[i].l]=max(L[a[i].l],a[i].r);
for(int i=n;i;i--)R[i]=min(R[i],R[i+1]);
for(int i=1;i<=n;i++)L[i]=max(L[i-1],L[i]);
sort(a+1,a+m+1,[&](qq x,qq y){return x.r<y.r;});
for(int i=1;i<=n;i++)vp[i]=0;
int j=0,s1=0;
for(int i=1;i<=m;i++)if(j<a[i].l)j=a[i].r,vp[j]=1;
for(int i=1;i<=n;i++)vp[i]+=vp[i-1];
for(int i=1;i<=m;i++)s1=max(s1,vp[a[i].r]-vp[a[i].l-1]);
if(s1==1){chk(s1);return;}
if(chk(s1-1))return;
assert(chk(s1));
}
int main(){
int T;scanf("%d",&T);fuc=(T==18100);
for(int cas=1;cas<=T;cas++)cu=(cas==8630),sol();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3844kb
input:
4 4 0 1 2 3 4 5 3 5 5 0 70 0 10 20 30 40 50 60 70 8 -1 7 -2 -1 -9 -7 -8 9 -9 -7 -2 4 -7 4 3 9 5 0 1 0 2 2 3 3 5 4 5
output:
1 3 1 2 5 3 4 10 30 50 70 2 3 -7 -1 9 2 3 1 3 5
result:
wrong answer test 2: wrong result: declared 3, actual 4