結果

問題 No.2290 UnUnion Find
ユーザー tailstails
提出日時 2023-05-05 21:58:13
言語 cLay
(20240104-1)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 349 bytes
コンパイル時間 4,250 ms
コンパイル使用メモリ 174,124 KB
実行使用メモリ 9,052 KB
最終ジャッジ日時 2023-08-15 04:00:07
合計ジャッジ時間 10,124 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 7 ms
4,872 KB
testcase_03 AC 13 ms
6,664 KB
testcase_04 AC 15 ms
7,068 KB
testcase_05 AC 15 ms
6,880 KB
testcase_06 AC 16 ms
6,836 KB
testcase_07 AC 15 ms
6,888 KB
testcase_08 AC 15 ms
6,976 KB
testcase_09 AC 15 ms
6,872 KB
testcase_10 AC 15 ms
7,028 KB
testcase_11 AC 15 ms
6,928 KB
testcase_12 AC 15 ms
6,912 KB
testcase_13 AC 15 ms
7,152 KB
testcase_14 AC 15 ms
6,932 KB
testcase_15 AC 15 ms
7,120 KB
testcase_16 AC 15 ms
6,928 KB
testcase_17 AC 15 ms
6,952 KB
testcase_18 AC 15 ms
7,156 KB
testcase_19 AC 21 ms
7,260 KB
testcase_20 AC 25 ms
8,868 KB
testcase_21 AC 10 ms
5,364 KB
testcase_22 AC 17 ms
6,260 KB
testcase_23 AC 17 ms
6,384 KB
testcase_24 AC 22 ms
7,820 KB
testcase_25 AC 16 ms
6,108 KB
testcase_26 AC 24 ms
8,488 KB
testcase_27 AC 23 ms
8,020 KB
testcase_28 AC 19 ms
6,628 KB
testcase_29 AC 22 ms
7,664 KB
testcase_30 AC 12 ms
5,452 KB
testcase_31 AC 22 ms
7,340 KB
testcase_32 AC 16 ms
6,008 KB
testcase_33 AC 19 ms
6,780 KB
testcase_34 AC 25 ms
9,052 KB
testcase_35 AC 25 ms
8,380 KB
testcase_36 AC 16 ms
6,128 KB
testcase_37 AC 18 ms
6,504 KB
testcase_38 AC 16 ms
6,100 KB
testcase_39 AC 17 ms
6,432 KB
testcase_40 AC 24 ms
8,304 KB
testcase_41 AC 15 ms
6,020 KB
testcase_42 AC 21 ms
7,280 KB
testcase_43 AC 19 ms
6,968 KB
testcase_44 AC 14 ms
6,932 KB
testcase_45 AC 15 ms
6,916 KB
testcase_46 AC 15 ms
6,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

ll@n,@q,a[n],b[n];
rep(i,n){
	a[i]=i+1;
	b[i]=i-1;
}
a[n-1]=0;
b[0]=n-1;
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[b[x]],b[a[x]])=(a[x],b[x]);
		}
	}
	if(t==2){
		ll@u--;
		u=f(u);
		if(f.size(u)==n){
			wt(-1);
		}else{
			ll x=f(a[u]);
			wt(x+1);
		}
	}
}
0