結果

問題 No.2531 Coloring Vertices on Namori
ユーザー 👑 p-adicp-adic
提出日時 2023-10-24 10:19:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 476 ms / 2,000 ms
コード長 273 bytes
コンパイル時間 477 ms
コンパイル使用メモリ 81,760 KB
実行使用メモリ 147,656 KB
最終ジャッジ日時 2023-10-24 10:19:29
合計ジャッジ時間 13,733 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
53,460 KB
testcase_01 AC 81 ms
53,460 KB
testcase_02 AC 47 ms
53,460 KB
testcase_03 AC 74 ms
53,460 KB
testcase_04 AC 73 ms
53,460 KB
testcase_05 AC 332 ms
127,340 KB
testcase_06 AC 40 ms
53,472 KB
testcase_07 AC 258 ms
127,912 KB
testcase_08 AC 476 ms
131,680 KB
testcase_09 AC 449 ms
131,764 KB
testcase_10 AC 389 ms
131,768 KB
testcase_11 AC 292 ms
147,516 KB
testcase_12 AC 267 ms
147,520 KB
testcase_13 AC 268 ms
147,656 KB
testcase_14 AC 308 ms
127,732 KB
testcase_15 AC 338 ms
127,736 KB
testcase_16 AC 306 ms
127,728 KB
testcase_17 AC 36 ms
53,476 KB
testcase_18 AC 35 ms
53,476 KB
testcase_19 AC 35 ms
53,476 KB
testcase_20 AC 429 ms
130,636 KB
testcase_21 AC 464 ms
130,656 KB
testcase_22 AC 433 ms
130,584 KB
testcase_23 AC 456 ms
130,604 KB
testcase_24 AC 435 ms
130,616 KB
testcase_25 AC 446 ms
130,468 KB
testcase_26 AC 471 ms
130,652 KB
testcase_27 AC 445 ms
130,440 KB
testcase_28 AC 437 ms
130,612 KB
testcase_29 AC 467 ms
130,624 KB
testcase_30 AC 442 ms
130,620 KB
testcase_31 AC 435 ms
130,476 KB
testcase_32 AC 453 ms
130,636 KB
testcase_33 AC 436 ms
130,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

J=lambda:map(int,input().split())
N,K=J()
L=range(N)
E=[0]+[set()for i in L]
for i in L:
	u,v=J()
	E[u].add(v),E[v].add(u)
l=N
for i in L:
	r=i+1
	while len(E[r])==1:
		l,j=l-1,E[r].pop()
		E[j].remove(r)
		r=j
P=998244353
print(pow(K-1,N-l+1,P)*(pow(K-1,l-1,P)+1-l%2*2)%P)
0