結果

問題 No.1147 土偶Ⅱ
ユーザー Akijin_007Akijin_007
提出日時 2022-10-14 18:09:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 116 ms / 500 ms
コード長 930 bytes
コンパイル時間 513 ms
コンパイル使用メモリ 87,060 KB
実行使用メモリ 77,744 KB
最終ジャッジ日時 2023-09-08 19:48:40
合計ジャッジ時間 4,257 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
70,940 KB
testcase_01 AC 72 ms
71,112 KB
testcase_02 AC 73 ms
70,860 KB
testcase_03 AC 71 ms
71,080 KB
testcase_04 AC 94 ms
76,236 KB
testcase_05 AC 85 ms
76,320 KB
testcase_06 AC 113 ms
77,336 KB
testcase_07 AC 103 ms
76,152 KB
testcase_08 AC 86 ms
76,284 KB
testcase_09 AC 111 ms
77,480 KB
testcase_10 AC 91 ms
76,176 KB
testcase_11 AC 107 ms
76,200 KB
testcase_12 AC 97 ms
76,180 KB
testcase_13 AC 87 ms
76,128 KB
testcase_14 AC 104 ms
76,308 KB
testcase_15 AC 100 ms
76,376 KB
testcase_16 AC 90 ms
76,008 KB
testcase_17 AC 71 ms
71,248 KB
testcase_18 AC 85 ms
75,648 KB
testcase_19 AC 116 ms
77,744 KB
testcase_20 AC 72 ms
71,120 KB
testcase_21 AC 71 ms
71,068 KB
testcase_22 AC 108 ms
77,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#int(input())
#map(int, input().split())
#list(map(int, input().split()))

N, M = map(int, input().split())
to = [set() for i in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    to[a-1].add(b-1)
    to[b-1].add(a-1)

ans = 0

good = [set() for i in range(N)]

for i in range(N-1):
    for j in range(i+1, N):
        if j in to[i]:
            good[i].add(j)
            good[j].add(i)
            continue
        f = 1
        for k in range(N):
            if (k-i)*(k-j) == 0:
                continue
            if k in to[i] and k in to[j]:
                f = 0
                break
        if f == 1:
            good[i].add(j)
            good[j].add(i)

ans = 0
# print(good)

for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            if i in good[j] and j in good[k] and k in good[i]:
                ans += 1
                # print(i, j, k)

print(ans)



0