結果

問題 No.488 四角関係
ユーザー ynyn
提出日時 2017-02-26 15:59:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 610 ms / 5,000 ms
コード長 505 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 87,060 KB
実行使用メモリ 105,816 KB
最終ジャッジ日時 2023-09-02 10:00:03
合計ジャッジ時間 6,815 ms
ジャッジサーバーID
(参考情報)
judge14 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 348 ms
91,856 KB
testcase_01 AC 268 ms
85,600 KB
testcase_02 AC 338 ms
89,640 KB
testcase_03 AC 211 ms
81,044 KB
testcase_04 AC 244 ms
84,276 KB
testcase_05 AC 377 ms
92,960 KB
testcase_06 AC 575 ms
105,816 KB
testcase_07 AC 610 ms
100,120 KB
testcase_08 AC 562 ms
105,272 KB
testcase_09 AC 76 ms
71,572 KB
testcase_10 AC 167 ms
79,644 KB
testcase_11 AC 104 ms
76,720 KB
testcase_12 AC 132 ms
78,124 KB
testcase_13 AC 160 ms
79,032 KB
testcase_14 AC 120 ms
77,588 KB
testcase_15 AC 99 ms
76,664 KB
testcase_16 AC 79 ms
71,592 KB
testcase_17 AC 76 ms
71,484 KB
testcase_18 AC 84 ms
76,384 KB
testcase_19 AC 88 ms
76,128 KB
testcase_20 AC 77 ms
71,288 KB
testcase_21 AC 76 ms
71,076 KB
testcase_22 AC 75 ms
71,496 KB
testcase_23 AC 74 ms
71,472 KB
testcase_24 AC 86 ms
76,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

n, m = map(int, input().split())
graph = [[0] * n for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    graph[a][b] = 1
    graph[b][a] = 1

c = list(itertools.combinations(range(n), 4))
ans = 0
for i,j,k,l in c:
    x = list(itertools.permutations([i,j,k,l]))

    for x1,x2,x3,x4 in x:
        if graph[x1][x2] == graph[x2][x3] == graph[x3][x4] == graph[x4][x1] == 1 and graph[x1][x3] == graph[x2][x4] == 0:
            ans += 1
            break

print(ans)
0