結果

問題 No.1147 土偶Ⅱ
ユーザー roarisroaris
提出日時 2020-08-05 18:48:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 259 ms / 500 ms
コード長 507 bytes
コンパイル時間 182 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 78,704 KB
最終ジャッジ日時 2024-04-19 18:04:02
合計ジャッジ時間 3,334 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
58,624 KB
testcase_01 AC 39 ms
51,968 KB
testcase_02 AC 40 ms
52,340 KB
testcase_03 AC 36 ms
52,608 KB
testcase_04 AC 110 ms
76,940 KB
testcase_05 AC 61 ms
72,576 KB
testcase_06 AC 187 ms
78,704 KB
testcase_07 AC 147 ms
76,548 KB
testcase_08 AC 72 ms
76,800 KB
testcase_09 AC 170 ms
78,368 KB
testcase_10 AC 114 ms
77,264 KB
testcase_11 AC 198 ms
77,056 KB
testcase_12 AC 116 ms
76,592 KB
testcase_13 AC 80 ms
76,524 KB
testcase_14 AC 259 ms
77,120 KB
testcase_15 AC 151 ms
77,148 KB
testcase_16 AC 91 ms
76,308 KB
testcase_17 AC 47 ms
61,568 KB
testcase_18 AC 67 ms
73,728 KB
testcase_19 AC 179 ms
78,004 KB
testcase_20 AC 46 ms
60,800 KB
testcase_21 AC 37 ms
52,480 KB
testcase_22 AC 163 ms
77,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def check(x, y):
    for z in range(n):
        if z!=x and z!=y and G[z][x]==1 and G[z][y]==1 and G[x][y]==0:
            return False
    
    return True

n, m = map(int, input().split())
G = [[0]*n for _ in range(n)]

for _ in range(m):
    a, b = map(int, input().split())
    G[a-1][b-1] = 1
    G[b-1][a-1] = 1

ans = 0

for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if check(i, j) and check(j, k) and check(k, i):
                ans += 1
    
print(ans)
0