結果
問題 | No.488 四角関係 |
ユーザー |
|
提出日時 | 2017-09-02 04:15:35 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 101 ms / 5,000 ms |
コード長 | 901 bytes |
コンパイル時間 | 272 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-11-06 18:06:05 |
合計ジャッジ時間 | 2,139 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
N,M=map(int,input().split())D=[[int(i==j)*2 for i in range(N)]for j in range(N)]#for d in D:print(*d)for _ in range(M):a,b=(x for x in map(int,input().split()))D[a][b]=D[b][a]=1#for d in D:print(*d)G={}for x in D: G[x.index(2)]=[i for i in range(N) if x[i]==1]#print(G)ans=0for k,v in G.items():for i in range(len(v)):for j in range(i+1,len(v)):if D[v[i]][v[j]]==1:continue # v[i] and v[j] makes trianglecommon=set(G[v[i]])&set(G[v[j]])if k in common and len(common)==1:continue# print(k,v[i],v[j],'common',common)for c in common:if k==c:continueif k not in G[c]:# print('found!',k,c,G[c])ans+=1else:continue# print('triangle!',k,c,G[c])print(ans//4)