結果

問題 No.1641 Tree Xor Query
ユーザー tailstails
提出日時 2021-08-11 10:41:04
言語 cLay
(20240104-1)
結果
AC  
実行時間 33 ms / 5,000 ms
コード長 432 bytes
コンパイル時間 3,247 ms
コンパイル使用メモリ 175,468 KB
実行使用メモリ 17,916 KB
最終ジャッジ日時 2023-09-19 02:33:46
合計ジャッジ時間 5,810 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,516 KB
testcase_01 AC 2 ms
5,396 KB
testcase_02 AC 2 ms
5,392 KB
testcase_03 AC 2 ms
5,452 KB
testcase_04 AC 2 ms
5,404 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,520 KB
testcase_07 AC 2 ms
5,452 KB
testcase_08 AC 2 ms
5,512 KB
testcase_09 AC 2 ms
5,408 KB
testcase_10 AC 2 ms
5,432 KB
testcase_11 AC 2 ms
5,456 KB
testcase_12 AC 2 ms
5,488 KB
testcase_13 AC 33 ms
17,908 KB
testcase_14 AC 33 ms
17,916 KB
testcase_15 AC 2 ms
5,468 KB
testcase_16 AC 3 ms
5,672 KB
testcase_17 AC 3 ms
5,660 KB
testcase_18 AC 3 ms
5,592 KB
testcase_19 AC 2 ms
5,656 KB
testcase_20 AC 17 ms
11,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

int c[2d5],a[],b[],u;
graph g;

void f(int i,int p){
	a[i]=u++;
	rep[g.edge[i]](j,g.es[i]){
		if(j!=p){
			f(j,i);
		}
	}
	b[i]=u;
}

{
	int@n,@q;
	rd(c(n),(a,b)(n-1));

	g.setEdge(n+1,n-1,a,b);
	f(1,1);
	assert(u==n);

	segtree_Point_Xor<int>t;
	t.walloc(u);
	t.setN(u,0,0);
	rep(i,n)t[a[i+1]]=c[i];
	t.build();

	rep(q){
		int@z,@x,@y;
		if(z==1){
			t.change(a[x],t[a[x]]^y);
		}
		if(z==2){
			wt(t.getXor(a[x],b[x]));
		}
	}
}
0