結果

問題 No.488 四角関係
ユーザー Mr.FukuMr.Fuku
提出日時 2018-08-07 21:42:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 109 ms / 5,000 ms
コード長 741 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 11,928 KB
実行使用メモリ 10,364 KB
最終ジャッジ日時 2023-10-19 22:30:35
合計ジャッジ時間 2,054 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,176 KB
testcase_01 AC 53 ms
10,208 KB
testcase_02 AC 41 ms
10,192 KB
testcase_03 AC 39 ms
10,188 KB
testcase_04 AC 42 ms
10,192 KB
testcase_05 AC 55 ms
10,212 KB
testcase_06 AC 32 ms
10,180 KB
testcase_07 AC 109 ms
10,244 KB
testcase_08 AC 70 ms
10,364 KB
testcase_09 AC 30 ms
10,160 KB
testcase_10 AC 32 ms
10,180 KB
testcase_11 AC 30 ms
10,164 KB
testcase_12 AC 35 ms
10,184 KB
testcase_13 AC 33 ms
10,180 KB
testcase_14 AC 31 ms
10,168 KB
testcase_15 AC 30 ms
10,160 KB
testcase_16 AC 29 ms
10,160 KB
testcase_17 AC 29 ms
10,160 KB
testcase_18 AC 30 ms
10,160 KB
testcase_19 AC 29 ms
10,160 KB
testcase_20 AC 29 ms
10,160 KB
testcase_21 AC 30 ms
10,160 KB
testcase_22 AC 29 ms
10,160 KB
testcase_23 AC 30 ms
10,160 KB
testcase_24 AC 30 ms
10,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0