結果

問題 No.488 四角関係
ユーザー 炭酸水炭酸水
提出日時 2022-05-14 22:58:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 339 ms / 5,000 ms
コード長 744 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 10,892 KB
実行使用メモリ 9,276 KB
最終ジャッジ日時 2023-09-30 16:14:00
合計ジャッジ時間 2,753 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
8,612 KB
testcase_01 AC 99 ms
8,788 KB
testcase_02 AC 46 ms
8,700 KB
testcase_03 AC 39 ms
8,680 KB
testcase_04 AC 53 ms
8,688 KB
testcase_05 AC 112 ms
8,864 KB
testcase_06 AC 26 ms
8,576 KB
testcase_07 AC 339 ms
9,276 KB
testcase_08 AC 115 ms
8,844 KB
testcase_09 AC 19 ms
8,560 KB
testcase_10 AC 27 ms
8,580 KB
testcase_11 AC 20 ms
8,516 KB
testcase_12 AC 38 ms
8,656 KB
testcase_13 AC 29 ms
8,560 KB
testcase_14 AC 20 ms
8,524 KB
testcase_15 AC 19 ms
8,608 KB
testcase_16 AC 19 ms
8,604 KB
testcase_17 AC 19 ms
8,616 KB
testcase_18 AC 19 ms
8,492 KB
testcase_19 AC 19 ms
8,600 KB
testcase_20 AC 19 ms
8,588 KB
testcase_21 AC 19 ms
8,604 KB
testcase_22 AC 19 ms
8,564 KB
testcase_23 AC 19 ms
8,576 KB
testcase_24 AC 20 ms
8,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
n, m = map(int, input().split())
g = [[] for _ in range(n)]
for _ in range(m):
    u, v = map(int, input().split())
    g[u].append(v)
    g[v].append(u)
    
count = 0
for i in range(n):
    d_1 = g[i]
    d_2 = deque([])
    d_3 = deque([])
    for j in d_1:
        for k in g[j]:
            if k != i:
                d_2.append([k, j])
    for j in range(len(d_2)):
        now_2 = d_2.pop()
        if i not in g[now_2[0]]:
            for k in g[now_2[0]]:
                if k != now_2[1]:
                    d_3.append([k, now_2[0], now_2[1]])
    for j in range(len(d_3)):
        now_3 = d_3.pop()
        if i in g[now_3[0]] and  now_3[2] not in g[now_3[0]]:
            count += 1

print(count // 8)
0