結果

問題 No.488 四角関係
ユーザー ynyn
提出日時 2017-02-26 15:22:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 631 ms / 5,000 ms
コード長 619 bytes
コンパイル時間 432 ms
コンパイル使用メモリ 87,140 KB
実行使用メモリ 105,788 KB
最終ジャッジ日時 2023-09-02 09:57:15
合計ジャッジ時間 7,233 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 358 ms
92,196 KB
testcase_01 AC 272 ms
86,212 KB
testcase_02 AC 335 ms
89,956 KB
testcase_03 AC 187 ms
81,052 KB
testcase_04 AC 235 ms
84,572 KB
testcase_05 AC 383 ms
93,128 KB
testcase_06 AC 593 ms
105,640 KB
testcase_07 AC 631 ms
100,316 KB
testcase_08 AC 582 ms
105,788 KB
testcase_09 AC 72 ms
71,636 KB
testcase_10 AC 167 ms
79,796 KB
testcase_11 AC 100 ms
77,012 KB
testcase_12 AC 131 ms
78,612 KB
testcase_13 AC 160 ms
79,416 KB
testcase_14 AC 118 ms
78,128 KB
testcase_15 AC 90 ms
77,076 KB
testcase_16 AC 71 ms
71,384 KB
testcase_17 AC 72 ms
71,732 KB
testcase_18 AC 78 ms
76,500 KB
testcase_19 AC 85 ms
76,444 KB
testcase_20 AC 70 ms
71,644 KB
testcase_21 AC 69 ms
71,516 KB
testcase_22 AC 72 ms
71,392 KB
testcase_23 AC 71 ms
71,740 KB
testcase_24 AC 80 ms
76,168 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:
    cnt = 0
    x = list(itertools.permutations([i,j,k,l]))

    for loop in range(len(x)):
        x1 = x[loop][0]
        x2 = x[loop][1]
        x3 = x[loop][2]
        x4 = x[loop][3]

        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