結果

問題 No.488 四角関係
ユーザー ichibanshiboriichibanshibori
提出日時 2017-02-25 00:46:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 906 bytes
コンパイル時間 322 ms
コンパイル使用メモリ 10,868 KB
実行使用メモリ 16,752 KB
最終ジャッジ日時 2023-08-31 01:10:13
合計ジャッジ時間 20,731 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 TLE -
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import combinations

n, m = tuple(int(x) for x in input().split())

ab_lst = []
for _ in range(m):
    a, b = tuple(int(x) for x in input().split())
    ab_lst.append((a, b))

cnt = 0

for n1, n2, n3, n4 in combinations(range(n), 4):
    #print('### {} {} {} {}'.format(n1, n2, n3, n4))

    n_set = {n1, n2, n3, n4}

    lst = [(a, b) for a, b in ab_lst if a in n_set and b in n_set]
    #print(lst)

    if (len(lst) == 4):
        if (n1, n2) in lst and (n2, n3) in lst and (n3, n4) in lst and (n1, n4) in lst:
            #print("*" + str(list(lst)))
            cnt += 1
        elif (n1, n2) in lst and (n1, n3) in lst and (n2, n4) in lst and (n3, n4) in lst:
            #print("*" + str(list(lst)))
            cnt += 1
        elif (n1, n2) in lst and (n1, n4) in lst and (n2, n3) in lst and (n2, n4) in lst:
            #print("*" + str(list(lst)))
            cnt += 1

print(cnt)
0