結果
問題 |
No.488 四角関係
|
ユーザー |
![]() |
提出日時 | 2025-03-20 18:42:06 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 160 ms / 5,000 ms |
コード長 | 915 bytes |
コンパイル時間 | 196 ms |
コンパイル使用メモリ | 82,104 KB |
実行使用メモリ | 76,876 KB |
最終ジャッジ日時 | 2025-03-20 18:42:13 |
合計ジャッジ時間 | 2,879 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
import itertools n, m = map(int, input().split()) adj = [[False] * n for _ in range(n)] for _ in range(m): a, b = map(int, input().split()) adj[a][b] = True adj[b][a] = True count = 0 # Iterate through all possible quartets of 4 distinct nodes for quartet in itertools.combinations(range(n), 4): # Check if there are exactly 4 edges within the quartet edge_count = 0 for u, v in itertools.combinations(quartet, 2): if adj[u][v]: edge_count += 1 if edge_count != 4: continue # Check each node in the quartet has exactly two edges within the quartet valid = True for node in quartet: connections = 0 for other in quartet: if other != node and adj[node][other]: connections += 1 if connections != 2: valid = False break if valid: count += 1 print(count)