QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#865205 | #9982. Staircase Museum | yhddd | WA | 3ms | 8008kb | C++20 | 1.6kb | 2025-01-21 16:03:48 | 2025-01-21 16:03:49 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define mod 998244353ll
#define pii pair<int,int>
#define fi first
#define se second
#define mems(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define db double
using namespace std;
const int maxn=200010;
const int inf=1e18;
inline int read(){
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch-48);ch=getchar();}
return x*f;
}
bool Mbe;
int n,l[maxn],r[maxn],m;
pii a[maxn];
int lsh[maxn],len;
#define lb(x) (x&(-x))
int tree[maxn];
void upd(int x,int w){
while(x<=len)tree[x]=max(tree[x],w),x+=lb(x);
}
int que(int x){
int res=0;
while(x)res=max(res,tree[x]),x-=lb(x);
return res;
}
void work(){
n=read();int ans=0;
a[m=1]={0,2};
for(int i=1;i<=n;i++){
l[i]=read()*2,r[i]=read()*2;
}
for(int i=1;i<=n;i++){
if(r[i+1]>r[i])a[++m]={2*i,r[i]+1};
if(l[i+1]>l[i])a[++m]={2*i+1,l[i+1]};
}
sort(a+1,a+m+1);
// for(int i=1;i<=m;i++)cout<<a[i].fi<<" "<<a[i].se<<"\n";
len=0;for(int i=1;i<=m;i++)lsh[++len]=a[i].se;
sort(lsh+1,lsh+len+1),len=unique(lsh+1,lsh+len+1)-lsh-1;
for(int i=1;i<=m;i++)a[i].se=lower_bound(lsh+1,lsh+len+1,a[i].se)-lsh;
for(int i=1;i<=len;i++)tree[i]=0;
for(int i=1;i<=m;i++){
int dp=que(a[i].se-1)+1;
upd(a[i].se,dp);
ans=max(ans,dp);
}
printf("%lld\n",ans);
}
// \
444
bool Med;
int T;
signed main(){
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
// ios::sync_with_stdio(0);
// cin.tie(0);cout.tie(0);
// cerr<<(&Mbe-&Med)/1048576.0<<" MB\n";
T=read();
while(T--)work();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 7880kb
input:
4 3 1 2 1 3 1 3 3 1 2 2 3 3 3 3 1 1 1 3 3 3 4 1 2 2 3 3 4 4 5
output:
2 3 3 4
result:
ok 4 number(s): "2 3 3 4"
Test #2:
score: 0
Accepted
time: 0ms
memory: 8008kb
input:
1 1 1 1000000000
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: -100
Wrong Answer
time: 3ms
memory: 7880kb
input:
9653 1 1 1 2 1 1 1 1 3 1 1 1 1 1 1 4 1 1 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 1 1 6 1 1 1 1 1 1 1 1 1 1 1 1 6 1 2 1 2 1 2 1 2 1 2 2 2 6 1 1 1 1 1 1 1 1 1 1 1 2 6 1 2 1 2 1 2 1 2 1 2 2 3 5 1 2 1 2 1 2 1 2 2 2 6 1 2 1 2 1 2 1 2 2 2 2 2 6 1 3 1 3 1 3 1 3 2 3 3 3 6 1 2 1 2 1 2 1 2 2 2 2 3 6 1 3 1 3 1 3 1 3 2 3...
output:
1 1 1 1 1 1 2 2 2 3 2 3 3 3 4 2 2 3 3 3 3 2 2 3 3 3 3 3 3 4 2 3 3 3 4 3 4 4 4 5 3 3 4 4 4 4 3 3 4 4 4 4 4 4 4 2 2 3 3 3 3 3 3 3 2 3 3 3 3 3 3 3 5 3 3 4 4 3 3 4 4 4 4 3 3 3 4 4 3 3 4 4 4 4 5 3 4 4 4 4 3 4 4 4 4 4 2 3 2 3 3 3 3 3 3 3 4 3 4 4 4 4 4 4 4 5 3 3 4 4 3 3 4 4 4 4 4 3 4 4 4 4 4 4 4 4 4 5 3 4 ...
result:
wrong answer 10th numbers differ - expected: '2', found: '3'