結果

問題 No.488 四角関係
ユーザー nanaenanae
提出日時 2017-03-02 22:53:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 98 ms / 5,000 ms
コード長 713 bytes
コンパイル時間 232 ms
コンパイル使用メモリ 10,824 KB
実行使用メモリ 8,316 KB
最終ジャッジ日時 2023-09-03 21:04:42
合計ジャッジ時間 2,206 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
8,144 KB
testcase_01 AC 40 ms
8,204 KB
testcase_02 AC 47 ms
8,308 KB
testcase_03 AC 26 ms
8,124 KB
testcase_04 AC 32 ms
8,156 KB
testcase_05 AC 57 ms
8,232 KB
testcase_06 AC 80 ms
8,140 KB
testcase_07 AC 98 ms
8,124 KB
testcase_08 AC 79 ms
8,144 KB
testcase_09 AC 15 ms
8,264 KB
testcase_10 AC 22 ms
8,184 KB
testcase_11 AC 16 ms
8,192 KB
testcase_12 AC 20 ms
8,292 KB
testcase_13 AC 23 ms
8,052 KB
testcase_14 AC 17 ms
8,252 KB
testcase_15 AC 16 ms
8,316 KB
testcase_16 AC 14 ms
8,092 KB
testcase_17 AC 15 ms
8,268 KB
testcase_18 AC 15 ms
8,092 KB
testcase_19 AC 15 ms
8,204 KB
testcase_20 AC 15 ms
8,088 KB
testcase_21 AC 16 ms
8,188 KB
testcase_22 AC 15 ms
8,148 KB
testcase_23 AC 15 ms
8,148 KB
testcase_24 AC 16 ms
8,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from itertools import combinations

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    N, M = map(int, input().split())
    Adj = [[0]*N for i in range(N)]
    cnt = 0

    for lp in range(M):
        a, b = map(int, input().split())
        Adj[a][b] = 1
        Adj[b][a] = 1

    for comb in combinations(range(N), 4):
        for u in comb:
            deg = 0
            for v in comb:
                deg += Adj[u][v]
            if deg != 2:
                break
        else:
            cnt += 1

    print(cnt)

if __name__ == '__main__':
    solve()
0