记录编号 |
598721 |
评测结果 |
AAAWWAAAAA |
题目名称 |
t1 |
最终得分 |
80 |
用户昵称 |
徐诗畅 |
是否通过 |
未通过 |
代码语言 |
C++ |
运行时间 |
2.213 s |
提交时间 |
2025-02-18 19:46:54 |
内存使用 |
10.04 MiB |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
int n,f[N],t,cnt[N];
int main(){
freopen("flurryofblows.in","r",stdin);
freopen("flurryofblows.out","w",stdout);
memset(f,0x3f3f3f3f,sizeof(f));
scanf("%d",&n);
for(int i = 1;i<=n;i++){
int op,x,y; scanf("%d%d",&op,&x);
if(op==1){
f[x]=cnt[x]-t;
t++; cnt[x]++;
}
else{
scanf("%d",&y);
if(f[x]-cnt[x]<f[y]-cnt[y]){
f[y]=f[x]; cnt[y]=cnt[x];
}
if(x!=y) f[x]++;
}
}
for(int i = 1;i<=n;i++)
if(f[i]+t-cnt[i]>1e6) cout<<"-1 ";
else printf("%d ",f[i]+t-cnt[i]);
return 0;
}