結果

問題 No.2277 Honest or Dishonest ?
ユーザー 👑 p-adicp-adic
提出日時 2023-06-05 09:58:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 692 ms / 2,000 ms
コード長 330 bytes
コンパイル時間 130 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 17,732 KB
最終ジャッジ日時 2023-08-28 09:26:08
合計ジャッジ時間 25,218 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,904 KB
testcase_01 AC 16 ms
7,832 KB
testcase_02 AC 17 ms
7,836 KB
testcase_03 AC 555 ms
13,376 KB
testcase_04 AC 568 ms
16,584 KB
testcase_05 AC 234 ms
15,700 KB
testcase_06 AC 438 ms
11,372 KB
testcase_07 AC 367 ms
12,000 KB
testcase_08 AC 209 ms
16,868 KB
testcase_09 AC 360 ms
14,992 KB
testcase_10 AC 268 ms
10,372 KB
testcase_11 AC 131 ms
9,408 KB
testcase_12 AC 239 ms
8,460 KB
testcase_13 AC 501 ms
12,136 KB
testcase_14 AC 308 ms
8,240 KB
testcase_15 AC 190 ms
14,272 KB
testcase_16 AC 354 ms
11,912 KB
testcase_17 AC 177 ms
10,000 KB
testcase_18 AC 535 ms
16,472 KB
testcase_19 AC 538 ms
16,304 KB
testcase_20 AC 431 ms
13,980 KB
testcase_21 AC 353 ms
10,016 KB
testcase_22 AC 366 ms
13,328 KB
testcase_23 AC 461 ms
9,976 KB
testcase_24 AC 315 ms
13,296 KB
testcase_25 AC 418 ms
16,392 KB
testcase_26 AC 151 ms
16,252 KB
testcase_27 AC 239 ms
9,408 KB
testcase_28 AC 196 ms
13,728 KB
testcase_29 AC 295 ms
15,388 KB
testcase_30 AC 231 ms
10,428 KB
testcase_31 AC 393 ms
12,368 KB
testcase_32 AC 270 ms
14,992 KB
testcase_33 AC 545 ms
15,676 KB
testcase_34 AC 556 ms
13,916 KB
testcase_35 AC 97 ms
12,960 KB
testcase_36 AC 347 ms
11,876 KB
testcase_37 AC 506 ms
10,944 KB
testcase_38 AC 124 ms
8,496 KB
testcase_39 AC 171 ms
9,300 KB
testcase_40 AC 86 ms
11,832 KB
testcase_41 AC 604 ms
14,348 KB
testcase_42 AC 426 ms
12,872 KB
testcase_43 AC 676 ms
17,684 KB
testcase_44 AC 687 ms
17,628 KB
testcase_45 AC 684 ms
17,632 KB
testcase_46 AC 679 ms
17,664 KB
testcase_47 AC 692 ms
17,628 KB
testcase_48 AC 684 ms
17,640 KB
testcase_49 AC 686 ms
17,592 KB
testcase_50 AC 683 ms
17,732 KB
testcase_51 AC 668 ms
17,644 KB
testcase_52 AC 680 ms
17,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

R=range
def J():
	return map(int,input().split())
N,Q=J()
p=[i for i in R(N*2)]
def r(i):
	m=p[i]
	while i!=m:
		p[i]=i=p[m]
		m=p[i]
	return i
for i in R(Q):
	A,B,C=J()
	A-=1
	B-=1
	for j in R(2):p[r(A+N*j)]=r(B+N*((C+j)%2))
f=[1]*(N*2)
a=1
for i in R(N):
	j,k=r(i),r(i+N)
	if f[j]:a=a*[2,0][j==k]%998244353
	f[j]=f[k]=0
print(a)
0