結果

問題 No.488 四角関係
ユーザー ynyn
提出日時 2017-02-26 15:28:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 697 ms / 5,000 ms
コード長 607 bytes
コンパイル時間 344 ms
コンパイル使用メモリ 86,868 KB
実行使用メモリ 105,812 KB
最終ジャッジ日時 2023-09-02 09:58:55
合計ジャッジ時間 7,975 ms
ジャッジサーバーID
(参考情報)
judge16 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 362 ms
92,272 KB
testcase_01 AC 279 ms
86,188 KB
testcase_02 AC 345 ms
89,728 KB
testcase_03 AC 192 ms
81,004 KB
testcase_04 AC 243 ms
84,436 KB
testcase_05 AC 392 ms
93,256 KB
testcase_06 AC 601 ms
105,528 KB
testcase_07 AC 697 ms
100,168 KB
testcase_08 AC 635 ms
105,812 KB
testcase_09 AC 88 ms
71,624 KB
testcase_10 AC 186 ms
79,536 KB
testcase_11 AC 109 ms
77,060 KB
testcase_12 AC 159 ms
78,568 KB
testcase_13 AC 192 ms
79,316 KB
testcase_14 AC 136 ms
77,948 KB
testcase_15 AC 100 ms
77,116 KB
testcase_16 AC 73 ms
71,340 KB
testcase_17 AC 72 ms
71,436 KB
testcase_18 AC 79 ms
76,240 KB
testcase_19 AC 84 ms
76,208 KB
testcase_20 AC 74 ms
71,560 KB
testcase_21 AC 72 ms
71,464 KB
testcase_22 AC 71 ms
71,396 KB
testcase_23 AC 73 ms
71,512 KB
testcase_24 AC 82 ms
76,160 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 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