結果

問題 No.1147 土偶Ⅱ
ユーザー kozy
提出日時 2020-08-05 09:32:12
言語 Python3
(3.14.2 + numpy 2.4.0 + scipy 1.16.3)
結果
AC  
実行時間 299 ms / 500 ms
コード長 555 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 299 ms
コンパイル使用メモリ 12,160 KB
実行使用メモリ 21,632 KB
最終ジャッジ日時 2026-01-02 05:19:22
合計ジャッジ時間 3,315 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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