样例能过,但0分。这shi山代码佬们能看看问题在哪吗
查看原帖
样例能过,但0分。这shi山代码佬们能看看问题在哪吗
1267285
ash2333楼主2024/5/7 17:16
s = {}
N,M = map(int,input().split())
for i in range(1,N+1):
    a,b = map(int,input().split())
    if a not in s:
        s[a] = [b]
    if b not in s:
        s[b] = [a]
    if a in s and b not in s[a]:
        s[a] += [b]
    if b in s and a not in s[b]:
        s[b] += [a]
p = s.keys()
w = 0
for i in p:
    for j in s[i]:
        if i == j:
            continue
        for k in s[j]:
            if k in [i,j]:

                continue
            w += 1
print(w)
2024/5/7 17:16
加载中...