結果

問題 No.2531 Coloring Vertices on Namori
ユーザー 👑 p-adicp-adic
提出日時 2023-10-24 10:18:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,216 ms / 2,000 ms
コード長 273 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 11,892 KB
実行使用メモリ 73,944 KB
最終ジャッジ日時 2023-10-24 10:19:01
合計ジャッジ時間 30,599 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,092 KB
testcase_01 AC 27 ms
10,092 KB
testcase_02 AC 27 ms
10,092 KB
testcase_03 AC 27 ms
10,092 KB
testcase_04 AC 27 ms
10,092 KB
testcase_05 AC 912 ms
68,624 KB
testcase_06 AC 27 ms
10,092 KB
testcase_07 AC 884 ms
68,624 KB
testcase_08 AC 1,080 ms
68,624 KB
testcase_09 AC 1,078 ms
68,624 KB
testcase_10 AC 1,072 ms
68,624 KB
testcase_11 AC 1,007 ms
73,944 KB
testcase_12 AC 1,041 ms
73,944 KB
testcase_13 AC 982 ms
73,940 KB
testcase_14 AC 1,032 ms
68,624 KB
testcase_15 AC 1,049 ms
68,620 KB
testcase_16 AC 1,046 ms
68,620 KB
testcase_17 AC 27 ms
10,092 KB
testcase_18 AC 27 ms
10,092 KB
testcase_19 AC 27 ms
10,092 KB
testcase_20 AC 1,200 ms
70,472 KB
testcase_21 AC 1,193 ms
70,472 KB
testcase_22 AC 1,169 ms
70,472 KB
testcase_23 AC 1,168 ms
70,468 KB
testcase_24 AC 1,172 ms
70,452 KB
testcase_25 AC 1,175 ms
70,716 KB
testcase_26 AC 1,216 ms
70,732 KB
testcase_27 AC 1,171 ms
70,468 KB
testcase_28 AC 1,184 ms
70,724 KB
testcase_29 AC 1,200 ms
70,456 KB
testcase_30 AC 1,159 ms
70,468 KB
testcase_31 AC 1,178 ms
70,468 KB
testcase_32 AC 1,165 ms
70,456 KB
testcase_33 AC 1,187 ms
70,468 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