結果
| 問題 |
No.488 四角関係
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-02-25 01:57:26 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,147 ms / 5,000 ms |
| コード長 | 650 bytes |
| コンパイル時間 | 322 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 109,568 KB |
| 最終ジャッジ日時 | 2025-01-03 08:33:52 |
| 合計ジャッジ時間 | 5,653 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
from collections import defaultdict
import itertools
def solve():
n, m = map(int, input().split())
node_pair = []
for _ in range(m):
a, b = map(int, input().split())
node_pair.append([a, b])
node_dict = defaultdict(list)
for pair in node_pair:
node_dict[pair[0]].append(pair[1])
node_dict[pair[1]].append(pair[0])
ans = 0
for square in list(itertools.combinations(range(0, n+1), 4)):
for idx in range(4):
connection_count = 0
for node in node_dict[square[idx]]:
if node in square:
connection_count += 1
if connection_count != 2:
break
else:
ans += 1
print(ans)
if __name__=="__main__":
solve()