結果

問題 No.1420 国勢調査 (Easy)
ユーザー 👑 NachiaNachia
提出日時 2021-03-12 16:00:16
言語 cLay
(20240104-1)
結果
MLE  
実行時間 -
コード長 458 bytes
コンパイル時間 3,952 ms
コンパイル使用メモリ 164,408 KB
実行使用メモリ 814,156 KB
最終ジャッジ日時 2023-09-19 02:15:26
合計ジャッジ時間 4,546 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 MLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

VI V(100000,-1),X(100000,0);
int root(int a){
	if(V[a]<0) return a;
	int p=V[a], r=root(p);
	V[a]=r; X[a]^=X[p];
	return r;
}
int merge(int r,int c,int y){
	int rr=root(r), rc=root(c);
	if(rr==rc) return X[r]^X[c]^y;
	if(V[rr]>V[rc]) swap(rr,rc); else if(V[rr]==V[rc]) V[rr]--;
	V[rc]=r; X[rc]=y^X[c];
	return 0;
}

int main(){
	int @N,@M;
	REP(M){
		int @a,@b,@y;
		if(merge(a-1,b-1,y)) printf("-1\n"), return 0;
	}
	rep(i,N) root(i),wt(X[i]);
	return 0;
}
0