結果

問題 No.1147 土偶Ⅱ
ユーザー kozy
提出日時 2020-08-05 09:32:12
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 278 ms / 500 ms
コード長 555 bytes
コンパイル時間 146 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 21,760 KB
最終ジャッジ日時 2025-04-01 16:10:55
合計ジャッジ時間 3,140 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools
X=list()
Y=list()
N,M=map(int,input().split())
L=[[] for j in range(N)]
R=[[] for j in range(N)]
for i in range(M):
    x,y=map(int,input().split())
    L[x-1].append(y)
    L[y-1].append(x)
for i in range(N):
    for j in range(len(L[i])):
        R[i].extend(L[L[i][j]-1])
    R[i]=[l for l in R[i] if l not in L[i]]
R=[list(set(i)) for i in R]
ans=0
p_list = list(itertools.combinations(range(1,N+1), 3))
for i in range(len(p_list)):
  a,b,c=p_list[i]
  if b not in R[a-1] and c not in R[a-1] and b not in R[c-1]:
    ans+=1
print(ans)
0