比赛 |
2025新春开学欢乐赛 |
评测结果 |
AAAAAAAAAA |
题目名称 |
t1 |
最终得分 |
100 |
用户昵称 |
wdsjl |
运行时间 |
5.394 s |
代码语言 |
C++ |
内存使用 |
14.77 MiB |
提交时间 |
2025-02-15 17:13:55 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
const int N=1000010,INF=0x3f3f3f3f;
int n;
int t,x,y;
int xxx;
struct node{
int tag,val;
}a[4*N];
void build(int l,int r,int p){
a[p]=(node){0,INF};
if(l==r){
if(l==1) a[p].val=0;
return;
}
int mid=(l+r)/2;
build(l,mid,p*2);
build(mid+1,r,p*2+1);
return;
}
void push_down(int p){
a[p*2].val+=a[p].tag;a[p*2].tag+=a[p].tag;
a[p*2+1].val+=a[p].tag;a[p*2+1].tag+=a[p].tag;
a[p].tag=0;
return;
}
void update(int w,int z,int l,int r,int p){
if(l==w&&w==r){
a[p].val=z;
return;
}
push_down(p);
int mid=(l+r)/2;
if(w<=mid) update(w,z,l,mid,p*2);
else update(w,z,mid+1,r,p*2+1);
return;
}
int q(int w,int l,int r,int p){
if(l==w&&w==r) return a[p].val;
push_down(p);
int mid=(l+r)/2;
if(w<=mid) return q(w,l,mid,p*2);
return q(w,mid+1,r,p*2+1);
}
int main(){
freopen("flurryofblows.in","r",stdin);
freopen("flurryofblows.out","w",stdout);
scanf("%d",&n);
build(1,n,1);
for(int i=1;i<=n;i++){
scanf("%d",&t);
if(t==1){
scanf("%d",&x);
a[1].tag++;
update(x,0,1,n,1);
}
else{
scanf("%d%d",&x,&y);
if(x==y) continue;
xxx=q(x,1,n,1);
update(y,min(xxx,q(y,1,n,1)),1,n,1);
update(x,xxx+1,1,n,1);
}
}
for(int i=1;i<=n;i++){
xxx=q(i,1,n,1);
if(xxx>=INF) printf("-1 ");
else printf("%d ",xxx);
}
return 0;
}