結果
| 問題 |
No.488 四角関係
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-08-30 23:02:56 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 74 ms / 5,000 ms |
| コード長 | 608 bytes |
| コンパイル時間 | 112 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 12,800 KB |
| 最終ジャッジ日時 | 2024-09-13 20:36:55 |
| 合計ジャッジ時間 | 1,795 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
from collections import defaultdict
from itertools import combinations
def solve():
n, m = map(int, input().split())
if n < 4:
return 0
node = defaultdict(set)
for _ in range(m):
a, b = map(int, input().split())
node[a].add(b)
node[b].add(a)
ans = set()
for k, v in node.items():
for a, b in combinations(tuple(v), 2):
if a in node[b]:
continue
for c in node[a] & node[b] - {k}:
if k not in node[c]:
ans.add(frozenset([a, b, c, k]))
return len(ans)
print(solve())