Problem p03240 (python)

Fixed submission:
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]

xyh.sort(key=lambda x:x[2], reverse=True)
for cx in range(101):
    for cy in range(101):
        x, y, h = xyh[0]
        H = abs(x - cx) + abs(y - cy) + h
        f = True

        for i in range(1, n):
            x, y, h = xyh[i]
            h2 = max(0, H - abs(x - cx) - abs(y - cy))
            if h != h2:
                f = False
                break

        if f:
            ans = (cx, cy, H)

print(ans[0], ans[1], ans[2])

Buggy submission (verdict: Runtime Error):
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]

xyh.sort(key=lambda x:x[2], reverse=True)


for cx in range(101):
    for cy in range(101):
        x, y, h = xyh[0]
        H = abs(x - cx) + abs(y - cy) + h
        f = True

        for i in range(1, n):
            x, y, h = xyh[i]
            HH = abs(x - cx) + abs(y - cy) + h
            if HH != H:
                f = False
                break

        if f:
            ans = (cx, cy, H)

print(ans[0], ans[1], ans[2])

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

for cx in range(101):
    for cy in range(101):
        flag = True
        flag_init = True
        for _n in range(n):
            if s[_n][2] != 0:
                H = s[_n][2] + abs(s[_n][0] - cx) + abs(s[_n][1] - cy)
                if flag_init:
                    H0 = H
                    flag_init = False
                else:
                    if H != H0:
                        flag = False
        if flag == True and h >= 1:
            print(cx, cy, H)
            break

    else:
        continue
    break

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

for cx in range(101):
    for cy in range(101):
        # flag = True
        flag_init = True
        for _n in range(n):
            if s[_n][2] != 0:
                H = s[_n][2] + abs(s[_n][0] - cx) + abs(s[_n][1] - cy)
                if flag_init:
                    H0 = H
                    flag_init = False
                else:
                    if H != H0:
                        flag = False
        if flag == True:
            print(cx, cy, H)

Buggy submission (verdict: Runtime Error):
for cx in range(101):
    for cy in range(101):
        flag = True
        for _n in range(n):
            if s[_n][2] != 0:
                H = s[_n][2] + abs(s[_n][0] - cx) + abs(s[_n][1] - cy)
                if _n == 0:
                    H0 = H

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

for cx in range(101):
    for cy in range(101):
        flag = True
        for _n in range(n):
            if s[_n][2] != 0:
                H = s[_n][2] + abs(s[_n][0] - cx) + abs(s[_n][1] - cy)
                if _n == 0:
                    H0 = H
                else:
                    if H != H0:
                        flag = False

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

for cx in range(101):
    for cy in range(101):
        flag = True
        for _n in range(n):
            if s[_n][2] != 0:
                H = s[_n][2] + abs(s[_n][0] - cx) + abs(s[_n][1] - cy)
                if _n == 0:
                    H0 = H
                else:
                    if H != H0:
                        flag = False
            if _n == n-1 and flag == True:
                print(cx, cy, H)

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

for cx in range(101):
    for cy in range(101):
        flag_success = 0
        for _n in range(n):
            if s[_n][2] != 0:
                H = s[_n][2] + abs(s[_n][0] - cx) + abs(s[_n][1] - cy)
                if _n == 0:
                    H0 = H
                else:
                    if H != H0:
                        flag_success = 1 # miss break
                        break
            if _n == n-1:
                print(cx, cy, H)
                flag_success = 2 # sucess break

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

for cx in range(101):
    for cy in range(101):
        flag_success = 0
        for _n in range(n):
            if s[_n][2] != 0:
                H = s[_n][2] + abs(s[_n][0] - cx) + abs(s[_n][1] - cy)
                if _n == 0:
                    H0 = H
                else:
                    if H != H0:
                        flag_success = 1 # miss break
                        break
            if _n == n-1:
                print(cx, cy, H)
                flag_success = 2 # sucess break

        if flag_success == 2:
            break
    if flag_success == 2:
        break

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

for cx in range(101):
    for cy in range(101):
        flag_success = 0
        for _n in range(n):
            if s[_n][2] != 0:
                H = s[_n][2] + abs(s[_n][0] - cx) + abs(s[_n][1] - cy)
                if _n == 0:
                    H0 = H
                else:
                    if H != H0:
                        flag_success = 1 # miss break
            if _n == n-1:
                print(cx, cy, H)
                flag_success = 2 # sucess break

            if flag_success == 1 or flag_success == 2:
                break

        if flag_success == 2:
            break
    if flag_success == 2:
        break