省略
省略
C++に変換後のコードはこちら
int N, D, W, A, B;
{
int i, x, y;
ll res = 0;
unionFind uf1, uf2;
HashMap<pair<int,int>,int> hs;
rd(N,D,W);
uf1.walloc(N,1);
uf2.walloc(N,1);
rep(D) uf1(rd_int()-1, rd_int()-1);
rep(W) uf2(rd_int()-1, rd_int()-1);
hs.init(N);
rep(i,N){
x = uf1(i);
y = uf2(i);
if(hs.exist(make_pair(x,y))) continue;
res += (ll)uf1.size(x) * uf2.size(y);
hs[make_pair(x,y)] = 1;
}
wt(res - N);
}
Current time: 2024年04月24日22時23分54秒
Last modified: 2020年11月21日18時58分41秒 (by laycrs)
Tags: Competitive_Programming_Incomplete yukicoder
トップページに戻る
Logged in as: unknown user (not login)