Problem p03575 (python)

Fixed submission:
def wf(this_graf):
    s = len(graf)
    for k in range(s):
        for i in range(s):
            for j in range(s):
                this_graf[i][j] = min(this_graf[i][j], this_graf[i][k] + this_graf[k][j])
    return this_graf

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(m)]
graf = [[10 ** 10 for i in range(n)] for j in range(n)]

for i, j in ab:
    graf[i - 1][j - 1] = 1
    graf[j - 1][i - 1] = 1

import copy
cnt = 0

for i, j in ab:
    this_graf = copy.deepcopy(graf)
    tmp = 0
    this_graf[i - 1][j - 1] = 10 ** 10
    this_graf[j - 1][i - 1] = 10 ** 10
    this_graf = wf(this_graf)
    for i in range(n):
        for j in range(n):
            if this_graf[i][j] == 10 ** 10:
                tmp = 1
                break
        if tmp:
            break
    cnt += tmp

print(cnt)

Buggy submission (verdict: Runtime Error):
def ABC075C():
    N, M = map(int, input().split())
    graf = [[10000000 for i in range(N)] for j in range(N)]
    for i in range(M):
        graf[i][i] = 0
    inputs = []
    for i in range(M):
        a, b = map(int, input().split())
        inputs.append([a, b])
        graf[a - 1][b - 1] = 1
        graf[b - 1][a - 1] = 1
    import copy
    ans = 0
    for l in range(M):
        key = 1
        this_graf = copy.deepcopy(graf)
        this_graf[inputs[l][0] - 1][inputs[l][1] - 1] = 10000000
        this_graf[inputs[l][1] - 1][inputs[l][0] - 1] = 10000000
        for k in range(N):
            for i in range(N):
                for j in range(N):
                    this_graf[i][j] = min(this_graf[i][j], this_graf[i][k] + this_graf[k][j])
        for i in range(N):
            for j in range(N):
                if this_graf[i][j] >= 100000:
                    ans += 1
                    key = 1
                    break
            if key == 1:
                break

    print(ans)
ABC075C()

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]

def DFS(v, ab_list, DFS_list):
    DFS_list[v] = True
    for j in ab_list[v]:
        if not DFS_list[j]:
            DFS(j, ab_list, DFS_list)

ans = 0
for i in range(M):
    ab_list = [[] for i in range(N)]
    for j in range(M):
        if i != j:
            k = ab[j]
            ab_list[k[0] - 1].append(k[1] - 1)
            ab_list[k[1] - 1].append(k[0] - 1)
            
    DFS_list = [False] * N
    
    DFS(i, ab_list, DFS_list)
    
    if False in DFS_list:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]

ans = 0
for i in range(M):
    ab_list = [[] for i in range(N)]
    for j in range(M):
        if i != j:
            k = ab[j]
            ab_list[k[0] - 1].append(k[1] - 1)
            ab_list[k[1] - 1].append(k[0] - 1)
            
    DFS_list = [False] * N
    
    def DFS(v):
        DFS_list[v] = True
        for j in ab_list[v]:
            if not DFS_list[j]:
                DFS(j)
    DFS(i)
    if False in DFS_list:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]

ans = 0
for i in range(M):
    ab_list = [[] for i in range(N)]
    for j in range(M):
        if i != j:
            k = ab[j]
            ab_list[k[0] - 1].append(k[1] - 1)
            ab_list[k[1] - 1].append(k[0] - 1)
            
    DFS_list = [False for j in range(N)]
    
    def DFS(v):
        DFS_list[v] = True
        for j in ab_list[v]:
            if not DFS_list[j]:
                DFS(j)
    DFS(i)
    if False in DFS_list:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]

ans = 0
for i in range(M):
    ab_list = [[] for i in range(N)]
    for j in range(M):
        if i != j:
            k = ab[j]
            ab_list[k[0] - 1].append(k[1] - 1)
            ab_list[k[1] - 1].append(k[0] - 1)
            
    DFS_list = [0 for j in range(N)]
    DFS_list[i] = 0
    def DFS(v):
        DFS_list[v] = 1
        for j in ab_list[v]:
            if DFS_list[j] == 0:
                DFS(j)
    DFS(i)
    if sum(DFS_list) != N:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]

ans = 0
for i in range(M):
    ab_list = [[] for i in range(N)]
    for j in range(M):
        if i != j:
            k = ab[j]
            ab_list[k[0] - 1].append(k[1] - 1)
            ab_list[k[1] - 1].append(k[0] - 1)
            
    DFS_list = [0 for j in range(N)]
    DFS_list[i] = 0
    def DFS(v):
        for j in ab_list[v]:
            if DFS_list[j] == 0:
                DFS_list[j] = 1
                DFS(j)
    DFS(i)
    if sum(DFS_list) != N:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
i = 0
while:
  i += 1

Buggy submission (verdict: Runtime Error):
while:
  1

Buggy submission (verdict: Runtime Error):
a

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]

ans = 0
for i in range(M):
    ab_list = [[] for i in range(N)]
    for j in range(M):
        if i != j:
            k = ab[j]
            ab_list[k[0] - 1].append(k[1] - 1)
            ab_list[k[1] - 1].append(k[0] - 1)
            
    DFS_list = [0 for i in range(N)]
    DFS_list[i] = 0
    def DFS(v):
        for j in ab_list[v]:
            if DFS_list[j] == 0:
                DFS_list[j] = 1
                DFS(j)
    DFS(i)
    if sum(DFS_list) != N:
        ans += 1
print(ans)