Codeforces Round #600 DIV2 D問題 (1750pt)
Problem description
省略
省略
C++に変換後のコードはこちら
//no-unlocked
int N, M, A, B;
int mx[2d5];
{
int i, j, res = 0;
unionFind uf;
rd(N,M);
uf.malloc(N);
uf.init(N);
rep(M){
rd(A--,B--);
uf(A,B);
}
rep(i,N) mx[uf(i)] = i;
rep(i,N){
j = mx[uf(i)];
while(i < j){
if(uf(i) != uf(i+1)){
res++;
j >?= mx[uf(i+1)];
uf(i, i+1);
}
i++;
}
}
wt(res);
}
Current time: 2024年03月28日18時00分56秒
Last modified: 2019年11月23日18時50分46秒 (by laycrs)
Tags: Competitive_Programming_Incomplete Codeforces CF600 CF_Div2_D
トップページに戻る
Logged in as: unknown user (not login)