結果
問題 | No.488 四角関係 |
ユーザー |
![]() |
提出日時 | 2018-08-07 21:42:48 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 96 ms / 5,000 ms |
コード長 | 741 bytes |
コンパイル時間 | 180 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-09-19 18:30:12 |
合計ジャッジ時間 | 1,887 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
N,M = map(int,input().split()) nodes = [list(map(int,input().split())) for i in range(M)] n_dic = {} for nod in nodes: for i in range(2): n_dic.setdefault(nod[i],[]) n_dic[nod[i]].append(nod[1-i]) cnt = 0 for key,val in n_dic.items(): len_v = len(val) if len_v<2: continue for i in range(len_v-1): val1 = val[i] child1 = n_dic[val1] for j in range(i+1,len_v): val2 = val[j] child2 = n_dic[val2] if val1 in child2 or val2 in child1: continue for k in set(child1)&set(child2): if k==key: continue if key not in n_dic[k]: cnt+=1 print(cnt//4)