比赛 |
2025新春开学欢乐赛 |
评测结果 |
AAAAAAAAAA |
题目名称 |
t1 |
最终得分 |
100 |
用户昵称 |
┭┮﹏┭┮ |
运行时间 |
1.664 s |
代码语言 |
C++ |
内存使用 |
10.83 MiB |
提交时间 |
2025-02-15 16:49:46 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define db double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F(i,l,r) for(int i = (l);i <= (r);++i)
#define D(i,r,l) for(int i = (r);i >= (l);--i)
#define vi vector<int>
#define mem(a,x) memset(a,x,sizeof a)
#define fi first
#define in inline
#define se second
#define pb push_back
#define bug cerr<<"LINE:"<<__LINE__<<" "
mt19937 rd(std::chrono::steady_clock::now().time_since_epoch().count());
constexpr int N = 2e6+10;
constexpr ll inf = 1e18;
ll read(){
ll x = 0,f = 1;char c = getchar();
for(;c < '0' || c > '9';c = getchar())if(c == '-')f = -1;
for(;c >= '0' && c <= '9';c = getchar())x = (x<<1) + (x<<3) + c-'0';
return x * f;
}
void cmax(ll &x,ll y){x = max(x,y);}
void cmin(ll &x,ll y){x = min(x,y);}
int n;
ll f[N],add,mi;
int cnt[N];
void solve(){
n = read();
mi = add = f[1] = 0;
cnt[f[1]]++;
F(i,2,n)f[i] = 1e6 + 10,cnt[f[i]]++;
F(i,1,n){
int op = read(),x = read();
if(op == 1){
cnt[f[x] + add]--;
f[x] = --mi,add++;
cnt[f[x] + add]++;
}
else{
int y = read();
if(x == y)continue;
cnt[f[y] + add]--;
f[y] = min(f[y],f[x]);
cnt[f[y] + add]++;
if(mi == f[x] && cnt[mi + add] == 1)mi++;
cnt[f[x] + add]--,f[x]++;
cnt[f[x] + add]++;
}
}
F(i,1,n)
if(f[i] + add > 1e6)printf("-1 ");
else printf("%d ",f[i] + add);
printf("\n");
}
int main(){
freopen("flurryofblows.in","r",stdin);
freopen("flurryofblows.out","w",stdout);
int t = 1;
while(t--)solve();
return 0;
}