結果

問題 No.1147 土偶Ⅱ
ユーザー trineutrontrineutron
提出日時 2020-08-11 20:32:08
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 254 ms / 500 ms
コード長 678 bytes
コンパイル時間 240 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-19 18:07:22
合計ジャッジ時間 2,793 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,624 KB
testcase_01 AC 29 ms
10,752 KB
testcase_02 AC 32 ms
10,496 KB
testcase_03 AC 28 ms
10,624 KB
testcase_04 AC 52 ms
10,752 KB
testcase_05 AC 32 ms
10,624 KB
testcase_06 AC 75 ms
10,880 KB
testcase_07 AC 155 ms
10,752 KB
testcase_08 AC 35 ms
10,624 KB
testcase_09 AC 65 ms
10,752 KB
testcase_10 AC 43 ms
10,624 KB
testcase_11 AC 254 ms
10,752 KB
testcase_12 AC 87 ms
10,624 KB
testcase_13 AC 41 ms
10,752 KB
testcase_14 AC 205 ms
10,880 KB
testcase_15 AC 84 ms
10,752 KB
testcase_16 AC 45 ms
10,624 KB
testcase_17 AC 32 ms
10,752 KB
testcase_18 AC 34 ms
10,624 KB
testcase_19 AC 90 ms
10,880 KB
testcase_20 AC 29 ms
10,496 KB
testcase_21 AC 28 ms
10,624 KB
testcase_22 AC 66 ms
10,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
isfriend = [[False] * n for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    isfriend[a-1][b-1] = True
    isfriend[b-1][a-1] = True
isgood = [[True] * n for i in range(n)]
for k in range(n):
    for i in range(n):
        for j in range(n):
            if i == j:
                continue
            if isfriend[i][j]:
                continue
            if isfriend[i][k] and isfriend[k][j]:
                isgood[i][j] = False
ans = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if isgood[i][j] and isgood[j][k] and isgood[i][k]:
                ans += 1
print(ans)
0