結果

問題 No.488 四角関係
ユーザー roarisroaris
提出日時 2019-12-07 18:44:19
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 458 ms / 5,000 ms
コード長 522 bytes
コンパイル時間 1,131 ms
コンパイル使用メモリ 86,568 KB
実行使用メモリ 77,200 KB
最終ジャッジ日時 2023-08-26 23:09:48
合計ジャッジ時間 6,576 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 248 ms
76,608 KB
testcase_01 AC 203 ms
76,456 KB
testcase_02 AC 252 ms
76,816 KB
testcase_03 AC 148 ms
76,448 KB
testcase_04 AC 179 ms
76,452 KB
testcase_05 AC 286 ms
76,280 KB
testcase_06 AC 417 ms
76,460 KB
testcase_07 AC 458 ms
76,324 KB
testcase_08 AC 445 ms
77,200 KB
testcase_09 AC 69 ms
70,804 KB
testcase_10 AC 126 ms
76,448 KB
testcase_11 AC 83 ms
75,852 KB
testcase_12 AC 106 ms
76,472 KB
testcase_13 AC 121 ms
76,528 KB
testcase_14 AC 93 ms
75,916 KB
testcase_15 AC 78 ms
75,812 KB
testcase_16 AC 71 ms
71,252 KB
testcase_17 AC 70 ms
71,048 KB
testcase_18 AC 75 ms
75,628 KB
testcase_19 AC 81 ms
75,632 KB
testcase_20 AC 72 ms
70,984 KB
testcase_21 AC 71 ms
71,088 KB
testcase_22 AC 71 ms
70,984 KB
testcase_23 AC 70 ms
71,080 KB
testcase_24 AC 79 ms
75,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import *

N, M = map(int, input().split())
adj_mat = [[0]*N for _ in range(N)]

for _ in range(M):
    ai, bi = map(int, input().split())
    adj_mat[ai-1][bi-1] = 1
    adj_mat[bi-1][ai-1] = 1

ans = 0

for c in combinations(range(N), 4):
    for p in permutations(c):
        a, b, c, d = p[0], p[1], p[2], p[3]
        
        if adj_mat[a][b]==1 and adj_mat[b][c]==1 and adj_mat[c][d]==1 and adj_mat[d][a]==1 and adj_mat[a][c]==0 and adj_mat[b][d]==0:
            ans += 1
            break

print(ans)
0