結果

問題 No.488 四角関係
ユーザー kohei2019kohei2019
提出日時 2022-01-30 13:06:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 621 ms / 5,000 ms
コード長 787 bytes
コンパイル時間 409 ms
コンパイル使用メモリ 87,152 KB
実行使用メモリ 78,116 KB
最終ジャッジ日時 2023-09-02 01:32:18
合計ジャッジ時間 6,416 ms
ジャッジサーバーID
(参考情報)
judge12 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 286 ms
77,980 KB
testcase_01 AC 226 ms
77,604 KB
testcase_02 AC 275 ms
77,696 KB
testcase_03 AC 158 ms
77,512 KB
testcase_04 AC 194 ms
77,676 KB
testcase_05 AC 317 ms
77,664 KB
testcase_06 AC 473 ms
77,992 KB
testcase_07 AC 521 ms
77,676 KB
testcase_08 AC 621 ms
78,116 KB
testcase_09 AC 70 ms
71,416 KB
testcase_10 AC 143 ms
77,320 KB
testcase_11 AC 88 ms
76,148 KB
testcase_12 AC 117 ms
77,492 KB
testcase_13 AC 137 ms
77,524 KB
testcase_14 AC 107 ms
77,848 KB
testcase_15 AC 85 ms
76,684 KB
testcase_16 AC 71 ms
71,640 KB
testcase_17 AC 71 ms
71,340 KB
testcase_18 AC 75 ms
75,936 KB
testcase_19 AC 80 ms
76,140 KB
testcase_20 AC 75 ms
71,680 KB
testcase_21 AC 72 ms
71,464 KB
testcase_22 AC 72 ms
71,580 KB
testcase_23 AC 71 ms
71,288 KB
testcase_24 AC 78 ms
76,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools
N,M = map(int,input().split())
lsg = [set() for i in range(N)]
for i in range(M):
    a,b = map(int,input().split())
    lsg[a].add(b)
    lsg[b].add(a)
if N < 4:
    print(0)
    exit()
ans = 0
for i in range(N-3):
    for j in range(i+1,N-2):
        for k in range(j+1,N-1):
            for l in range(k+1,N):
                f = False
                ls = [i,j,k,l]
                lsp = itertools.permutations(ls,4)
                for p in lsp:
                    if p[0] in lsg[p[1]] and p[1] in lsg[p[2]] and p[2] in lsg[p[3]] and p[3] in lsg[p[0]]:
                        if not(p[0] in lsg[p[2]]) and not(p[1] in lsg[p[3]]):
                            f = True
                            break
                if f:
                    ans += 1
print(ans)
0