結果
問題 | No.488 四角関係 |
ユーザー |
![]() |
提出日時 | 2025-03-20 20:30:39 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 154 ms / 5,000 ms |
コード長 | 915 bytes |
コンパイル時間 | 201 ms |
コンパイル使用メモリ | 82,536 KB |
実行使用メモリ | 76,528 KB |
最終ジャッジ日時 | 2025-03-20 20:31:29 |
合計ジャッジ時間 | 2,768 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
import itertoolsn, 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] = Trueadj[b][a] = Truecount = 0# Iterate through all possible quartets of 4 distinct nodesfor quartet in itertools.combinations(range(n), 4):# Check if there are exactly 4 edges within the quartetedge_count = 0for u, v in itertools.combinations(quartet, 2):if adj[u][v]:edge_count += 1if edge_count != 4:continue# Check each node in the quartet has exactly two edges within the quartetvalid = Truefor node in quartet:connections = 0for other in quartet:if other != node and adj[node][other]:connections += 1if connections != 2:valid = Falsebreakif valid:count += 1print(count)