結果

問題 No.2290 UnUnion Find
ユーザー tailstails
提出日時 2023-05-05 21:44:10
言語 cLay
(20240104-1)
結果
WA  
実行時間 -
コード長 264 bytes
コンパイル時間 3,231 ms
コンパイル使用メモリ 174,232 KB
実行使用メモリ 7,424 KB
最終ジャッジ日時 2024-05-02 15:42:54
合計ジャッジ時間 7,423 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 9 ms
5,376 KB
testcase_03 AC 13 ms
5,888 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 21 ms
7,296 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 20 ms
7,040 KB
testcase_27 AC 19 ms
6,784 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 20 ms
7,424 KB
testcase_35 AC 20 ms
6,912 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

ll@n,@q,a[n];
rep(i,n-1){
	a[i]=i+1;
}
a[n-1]=0;
unionFind f('m',n,1);
rep(q){
	ll@t;
	if(t==1){
		ll@u--,@v--;
		u=f(u);
		v=f(v);
		if(f(u,v)){
			ll r=f(u);
			ll x=r^u^v;
			a[x]=r;
		}
	}
	if(t==2){
		ll@u--;
		u=f(u);
		ll x=f(a[u]);
		wt(x==u?-1:x+1);
	}
}
0