結果
問題 |
No.1566 All Even
|
ユーザー |
![]() |
提出日時 | 2025-06-12 15:01:23 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,883 bytes |
コンパイル時間 | 202 ms |
コンパイル使用メモリ | 82,308 KB |
実行使用メモリ | 54,480 KB |
最終ジャッジ日時 | 2025-06-12 15:01:36 |
合計ジャッジ時間 | 2,193 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 11 WA * 17 |
ソースコード
MOD = 998244353 def main(): import sys input = sys.stdin.read().split() ptr = 0 N = int(input[ptr]) ptr += 1 M = int(input[ptr]) ptr += 1 if N >= 3: for _ in range(M): x = int(input[ptr]) ptr += 1 y = int(input[ptr]) ptr += 1 z = int(input[ptr]) ptr += 1 if (x + y) % 2 != z: print(0) return print(1 % MOD) elif N == 2: fixed = {} has_conflict = False for _ in range(M): x = int(input[ptr]) ptr += 1 y = int(input[ptr]) ptr += 1 z = int(input[ptr]) ptr += 1 if (x, y) in fixed: if fixed[(x, y)] != z: has_conflict = True else: fixed[(x, y)] = z if has_conflict: print(0) return sum_fixed = 0 for val in fixed.values(): sum_fixed += val F = 4 - len(fixed) if F == 0: if sum_fixed % 2 == 0: print(1) else: print(0) else: ways = pow(2, F - 1, MOD) print(ways) elif N == 1: if M == 0: print(2 % MOD) else: z_list = [] for _ in range(M): x = int(input[ptr]) ptr += 1 y = int(input[ptr]) ptr += 1 z = int(input[ptr]) ptr += 1 if x != 1 or y != 1: print(0) return z_list.append(z) z_set = set(z_list) if len(z_set) == 1: print(1 % MOD) else: print(0) if __name__ == '__main__': main()