Problem:


Score: 300 points

Problem Statement

In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc.

The pyramid had center coordinates (C_X, C_Y) and height H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0).  

Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information:  

C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1.  

Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i."  

This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.  

Constraints

N is an integer between 1 and 100 (inclusive).

x_i and y_i are integers between 0 and 100 (inclusive).

h_i is an integer between 0 and 10^9 (inclusive).

The N coordinates (x_1, y_1), (x_2, y_2), (x_3, y_3), ..., (x_N, y_N) are all different.

The center coordinates and the height of the pyramid can be uniquely identified.

Input

Input is given from Standard Input in the following format:  

N
x_1 y_1 h_1
x_2 y_2 h_2
x_3 y_3 h_3
:
x_N y_N h_N

Output

Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between.  

Sample Input 1

4
2 3 5
2 1 5
1 2 5
3 2 5

Sample Output 1

2 2 6

In this case, the center coordinates and the height can be identified as (2, 2) and 6.  

Sample Input 2

2
0 0 100
1 1 98

Sample Output 2

0 0 100

In this case, the center coordinates and the height can be identified as (0, 0) and 100.

Note that C_X and C_Y are known to be integers between 0 and 100.

Sample Input 3

3
99 1 191
100 1 192
99 0 192

Sample Output 3

100 0 193

In this case, the center coordinates and the height can be identified as (100, 0) and 193.  



Sample input:
4
2 3 5
2 1 5
1 2 5
3 2 5


Sample output:
2 2 6

Submission status: Runtime Error

Solution code:
n = int(input())

w = [(list(map(int, input().split()))) for i in range(n)]#x,y,h

for cx in range(101):
    for cy in range(101):
        for i in range(n):
            if w[i][2] > 0:
                if i == 0:
                    hcon1 = abs(w[i][0] - cx) + abs(w[i][1] - cy) + w[i][2]
                elif i != 0 and i != n - 1:
                    hcon2 = abs(w[i][0] - cx) + abs(w[i][1] - cy) + w[i][2]
                    if hcon1 != hcon2:
                        break
                    else:
                        hcon1 = hcon2
                else:
                    hcon2 = abs(w[i][0] - cx) + abs(w[i][1] - cy) + w[i][2]
                    if hcon1 != hcon2:
                        break
                    else:
                        print(cx,cy,hcon1)
                        exit()

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
x = np.empty(N,dtype=np.int)
y = np.empty(N,dtype=np.int)
h = np.empty(N,dtype=np.int)
for n in range(N):
    (x[n],y[n],h[n]) = map(int,input().split())

M = 100

grads = np.array([[1,1],[-1,1],[-1,-1],[1,-1]],dtype=np.int)
def height(x,y,h,i,j,d):
    # d=0-3
    return (h + grads[d,0]*(i-x) + grads[d,1]*(j-y))

def quadrant(x,y):
    if x > 0 and y >= 0:
        return 0
    elif y > 0:
        return 1
    elif x < 0:
        return 2
    else:
        return 3

Clist = [(Cx,Cy) for Cy in range(M+1) for Cx in range(M+1)]
k = h.argmax()
for (Cx,Cy) in Clist:
    H = height(x[k],y[k],h[k],Cx,Cy,quadrant(Cx-x[k],Cy-y[k]))
    for n in range(N):
        Hn = height(x[n],y[n],h[n],Cx,Cy,quadrant(Cx-x[n],Cy-y[n]))
        if h[n] == 0:
            if Hn < H:
                break
        else:
            if Hn != H:
                break
    else:
        break

print(i,j,H)

Submission status: Runtime Error

Solution code:
N = int(input())
x = {}
y = {}
h = {}
for i in range(N):
  x[i], y[i], h[i] = map(int, input().split())
  if h[i] != 0:
    x0, y0, h0 = x[i], y[i], h[i]
    break
for cx in range(101):
  for cy in range(101):
    H = h0 + abs(cx - x0) + abs(cy - y0)
    for i in range(N):
      if max(H - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i]:
        break
    else:
      print(cx, cy, H)
      break
    continue
  else:
    continue
  break

Submission status: Runtime Error

Solution code:
N = int(input())
xyh = [tuple(int(i) for i in input().split()) for i in range(N)]


def H(cx, cy, x, y, h):
    return h + abs(x - cx) + abs(y - cy)


def g(l, cx, cy):
    H_max_l = set(H(cx, cy, x, y, h) for x, y, h in xyh if h == 0)
    h_max = min(H_max_l) if any(H_max_l) else 10**9
    
    TH = set(H(cx, cy, x, y, h) for x, y, h in l if h > 0)
    if len(TH) == 1:
        high = TH.pop()
        if high <= h_max:
            return high
    return -1


def f(l):
    for cx in range(0, 101):
        for cy in range(0, 101):
            h = g(l, cx, cy)
            if h > 0:
                return cx, cy, h

cx, cy, h = f(xyh)
print(cx, cy, h)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Describe

TODOs:
- 境界値 (hs=0) に対する扱い (Hは求められないが、条件が加わる)
http://betrue12.hateblo.jp/entry/2018/10/06/224032
"""
import numpy as np

def get_height(xs_, ys_, hs_):
    """Exhaustive search for (cx, cy)
    calculate candidate for each height of the top of pyramid
    and confirm it the same for all sample points
    """

    xs, ys, hs = map(np.array, (xs_, ys_, hs_))

    c_max = 100
    cx = 0
    cy = 0
    d = 0

    for cx in range(1 + c_max):
        for cy in range(1 + c_max):
            h0_max = np.inf
            h0 = -1
            for x, y, h in zip(xs, ys, hs):
                d = abs(x - cx) + abs(y - cy)
                if h == 0:
                    h0_max = min(h_max, d)
                else:
                    h0_tmp = h + d
                    if h0 == -1:
                        h0 = h0_tmp
                    elif h0 == h0_tmp:
                        continue
                    else:
                        h0 = -1 # invalid
                        break
            if h0 > 0 and h0 <= h0_max: # if unique
                return map(str, (cx, cy, h0))
    
    # raise Exception('h_0 not found')
    return -1

def main():
    n = int(input())
    xs, ys, hs = [], [], []
    for i in range(n):
        x_, y_, h_ = map(int, input().split())
        xs.append(x_)
        ys.append(y_)
        hs.append(h_)

    print(" ".join(get_height(xs, ys, hs)))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Describe

TODOs:
- 境界値 (hs=0) に対する扱い (Hは求められないが、条件が加わる)
http://betrue12.hateblo.jp/entry/2018/10/06/224032
"""
import numpy as np

def get_height(xs_, ys_, hs_):
    """Exhaustive search for (cx, cy)
    calculate candidate for each height of the top of pyramid
    and confirm it the same for all sample points
    """

    xs, ys, hs = map(np.array, (xs_, ys_, hs_))

    c_max = 100
    cx = 0
    cy = 0
    d = 0

    for cx in range(1 + c_max):
        for cy in range(1 + c_max):
            h0_max = np.inf
            h0 = -1
            for x, y, h in zip(xs, ys, hs):
                d = abs(x - cx) + abs(y - cy)
                if h == 0:
                    h0_max = min(h_max, d)
                else:
                    h0_tmp = h + d
                    if h0 == -1:
                        h0 = h0_tmp
                    elif h0 == h0_tmp:
                        continue
                    else:
                        h0 = -1 # invalid
                        break
            if h0 > 0 and h0 <= h0_max: # if unique
                return map(str, (cx, cy, h0))
    
    raise Exception('h_0 not found')

def main():
    n = int(input())
    xs, ys, hs = [], [], []
    for i in range(n):
        x_, y_, h_ = map(int, input().split())
        xs.append(x_)
        ys.append(y_)
        hs.append(h_)

    print(" ".join(get_height(xs, ys, hs)))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Describe

TODOs:
- 境界値 (hs=0) に対する扱い (Hは求められないが、条件が加わる)
http://betrue12.hateblo.jp/entry/2018/10/06/224032
"""
import numpy as np

def get_height(xs_, ys_, hs_):
    """Exhaustive search for (cx, cy)
    calculate candidate for each height of the top of pyramid
    and confirm it the same for all sample points
    """

    xs, ys, hs = map(np.array, (xs_, ys_, hs_))

    c_max = 100
    cx = 0
    cy = 0
    d = 0

    for cx in range(1 + c_max):
        for cy in range(1 + c_max):
            h0_max = np.inf
            h0 = -1
            for x, y, h in zip(xs, ys, hs):
                d = abs(x - cx) + abs(y - cy)
                if h == 0:
                    h0_max = min(h_max, d)
                else:
                    h0_tmp = h + d
                    print(cx, cy, x, y, h0_tmp)
                    if h0 == -1:
                        h0 = h0_tmp
                    elif h0 == h0_tmp:
                        continue
                    else:
                        h0 = -1 # invalid
                        break
            if h0 > 0 and h0 <= h0_max: # if unique
                return map(str, (cx, cy, h0))
    
    raise Exception('h_0 not found')

def main():
    n = int(input())
    xs, ys, hs = [], [], []
    for i in range(n):
        x_, y_, h_ = map(int, input().split())
        xs.append(x_)
        ys.append(y_)
        hs.append(h_)

    print(" ".join(get_height(xs, ys, hs)))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Describe
"""
import numpy as np

def get_height(xs_, ys_, hs_):
    """Exhaustive search for (cx, cy)
    calculate candidate for each height of the top of pyramid
    and confirm it the same for all sample points
    """

    xs, ys, hs = map(np.array, (xs_, ys_, hs_))

    c_max = 100
    cx = 0
    cy = 0
    h_0 = np.array([])
    h_candidate = 0


    for cx in range(1 + c_max):
        for cy in range(1 + c_max):

            h_0 = hs + np.absolute(xs - cx) + np.absolute(ys - cy) 
            h_0 = h_0[h_0 >= 1] # remove if h_0 not greater than 1

            if len(set(h_0)) == 1: # if unique
                return map(str, (cx, cy, h_0[0]))
    
    raise Exception('h_0 not found')

def main():
    n = int(input())
    xs, ys, hs = [], [], []
    for i in range(n):
        x_, y_, h_ = map(int, input().split())
        xs.append(x_)
        ys.append(y_)
        hs.append(h_)

    print(" ".join(get_height(xs, ys, hs)))

main()

Submission status: Runtime Error

Solution code:
N = int(input())
xyh = [tuple(int(i) for i in input().split()) for i in range(N)]


def H(cx, cy, x, y, h):
    return h + abs(x - cx) + abs(y - cy)


def g(l, cx, cy):
    H_max_l = set(H(cx, cy, x, y, h) for x, y, h in xyh if h == 0)
    h_max = min(H_max_l) if any(H_max_l) else 10**9
    
    TH = set(H(cx, cy, x, y, h) for x, y, h in l if h > 0)
    if len(TH) == 1:
        high = TH.pop()
        if high <= h_max:
            return high
    return -1



def f(l):
    for cx in range(0, 101):
        for cy in range(0, 101):
            h = g(l, cx, cy)
            if h >= 0:
                return cx, cy, h

cx, cy, h = f(xyh)
print(cx, cy, h)

Submission status: Runtime Error

Solution code:
n = int(input().rstrip())
pl = []
 
def calc_h(p, cx, cy, ch):
    return ch - abs(cx - p[0]) - abs(cy - p[0])
 
for i in range(n):
    pl.append([int(x) for x in input().rstrip().split(' ')])
 
hm = max([p[2] for p in pl)
 
vhpl = [p for p in pl if p[2] > 0]
nvhpl = [p for p in pl if p[2] == 0]
tx = None
ty = None
h = None
if len(vhml) == 0:
    for x,y in itertools.product(range(101), repeat=2):
        c = True
        for p in nvhml:
            if x == p[0] and y == p[1]:
                c = False
                break
        if c:
            tx = x
            ty = y
            h = 1
            break
elif len(vhml) == 1:
    tx, ty, h = vhml[0]
else:
    for x,y in itertools.product(range(101), repeat=2):
        c = True
        h = abs(vhpl[0][0] - x) + abs(vhpl[0][1]) + vlpl[0][2]
        for i in range(1, len(vhpl)):
            if calc_h(vhpl[i], x, y, h) != vhpl[i][2]:
                c = False
                break
        if c:
            for i in range(len(nvhpl)):
                if calc_h(nvhpl[i], x, y, h) != nvhpl[i][2]:
                    c = False
                    break
        if c:
            tx = x
            ty = y
            break
 
print(str(tx) + ' ' + str(ty) + ' ' + str(h))

Submission status: Runtime Error

Solution code:
n = int(input().rstrip())
pl = []
 
def calc_h(p, cx, cy, ch):
    return ch - abs(cx - p[0]) - abs(cy - p[0])
 
for i in range(n):
    pl.append([int(x) for x in input().rstrip().split(' ')])
 
hm = max([p[2] for p in pl)
 
vhpl = [p for p in pl if p[2] > 0]
nvhpl = [p for p in pl if p[2] == 0]
tx = None
ty = None
h = None
if len(vhml) == 0:
      for x,y in itertools.product(range(101), repeat=2):
          c = True
          for p in nvhml:
              if x == p[0] and y == p[1]:
                  c = False
                  break
          if c:
              tx = x
              ty = y
              h = 1
              break
elif len(vhml) == 1:
    tx, ty, h = vhml[0]
else:
    for x,y in itertools.product(range(101), repeat=2):
        c = True
        h = abs(vhpl[0][0] - x) + abs(vhpl[0][1]) + vlpl[0][2]
        for i in range(1, len(vhpl)):
            if calc_h(vhpl[i], x, y, h) != vhpl[i][2]:
                c = False
                break
        if c:
            for i in range(len(nvhpl)):
                if calc_h(nvhpl[i], x, y, h) != nvhpl[i][2]:
                    c = False
                    break
        if c:
            tx = x
            ty = y
            break
 
print(str(tx) + ' ' + str(ty) + ' ' + str(h))
n = int(input().rstrip())
pl = []
 
def calc_h(p, cx, cy, ch):
    return ch - abs(cx - p[0]) - abs(cy - p[0])
 
for i in range(n):
    pl.append([int(x) for x in input().rstrip().split(' ')])
 
hm = max([p[2] for p in pl)
 
vhpl = [p for p in pl if p[2] > 0]
nvhpl = [p for p in pl if p[2] == 0]
tx = None
ty = None
h = None
if len(vhml) == 0:
    for x,y in itertools.product(range(101), repeat=2):
        c = True
        for p in nvhml:
            if x == p[0] and y == p[1]:
                c = False
                break
        if c:
            tx = x
            ty = y
            h = 1
            break
elif len(vhml) == 1:
    tx, ty, h = vhml[0]
else:
    for x,y in itertools.product(range(101), repeat=2):
        c = True
        h = abs(vhpl[0][0] - x) + abs(vhpl[0][1]) + vlpl[0][2]
        for i in range(1, len(vhpl)):
            if calc_h(vhpl[i], x, y, h) != vhpl[i][2]:
                c = False
                break
        if c:
            for i in range(len(nvhpl)):
                if calc_h(nvhpl[i], x, y, h) != nvhpl[i][2]:
                    c = False
                    break
        if c:
            tx = x
            ty = y
            break
    
printf(str(tx) + ' ' + str(ty) + ' ' + str(h))
n = int(input().rstrip())
pl = []
 
def calc_h(p, cx, cy, ch):
    return ch - abs(cx - p[0]) - abs(cy - p[0])
 
for i in range(n):
    pl.append([int(x) for x in input().rstrip().split(' ')])
 
hm = max([p[2] for p in pl)
 
vhpl = [p for p in pl if p[2] > 0]
nvhpl = [p for p in pl if p[2] == 0]
tx = None
ty = None
h = None
if len(vhml) == 0:
      for x,y in itertools.product(range(101), repeat=2):
          c = True
          for p in nvhml:
              if x == p[0] and y == p[1]:
                  c = False
                  break
          if c:
              tx = x
              ty = y
              h = 1
              break
elif len(vhml) == 1:
    tx, ty, h = vhml[0]
else:
    for x,y in itertools.product(range(101), repeat=2):
        c = True
        h = abs(vhpl[0][0] - x) + abs(vhpl[0][1]) + vlpl[0][2]
        for i in range(1, len(vhpl)):
            if calc_h(vhpl[i], x, y, h) != vhpl[i][2]:
                c = False
                break
        if c:
            for i in range(len(nvhpl)):
                if calc_h(nvhpl[i], x, y, h) != nvhpl[i][2]:
                    c = False
                    break
        if c:
            tx = x
            ty = y
            break

print(str(tx) + ' ' + str(ty) + ' ' + str(h))

Submission status: Runtime Error

Solution code:
N = int(input())

xs, ys, hs = [], [], []
for _ in range(N):
    x, y, h = map(int, input().split())
    xs.append(x)
    ys.append(y)
    hs.append(h)

ok = False
for x in range(101):
    for y in range(101):
        if ok:
            break
        cand = []
        for i in range(N):
            h = hs[i] + abs(xs[i] - x) + abs(ys[i] - y)
            if hs[i] == 0:
                cand.append((h, False))
            else:
                cand.append((h, True))

    
        cand2 = set([c[0] for c in cand if c[1]])
        if len(cand2) != 1:
            continue

        assert len(cand2) == 1
        ans = cand2.pop()

        if all([c[0] <= ans for c in cand if not c[1]]):
            print(x, y, ans)
            ok = True





assert ok

Submission status: Runtime Error

Solution code:
N = int(input())

xs, ys, hs = [], [], []
for _ in range(N):
    x, y, h = map(int, input().split())
    xs.append(x)
    ys.append(y)
    hs.append(h)

ok = False
for x in range(101):
    for y in range(101):
        if ok:
            break
        ans = set()
        for i in range(N):
            h = hs[i] + abs(xs[i] - x) + abs(ys[i] - y)
            ans.add(h)

        if len(ans) == 1:
            h = ans.pop()
            if h > 0:
                ok = True
                print(x, y, h)

assert ok

Submission status: Runtime Error

Solution code:
N = int(input())

xs, ys, hs = [], [], []
for _ in range(N):
    x, y, h = map(int, input().split())
    xs.append(x)
    ys.append(y)
    hs.append(h)

ok = False
for x in range(101):
    for y in range(101):
        if ok:
            break
        ans = set()
        for i in range(N):
            h = hs[i] + abs(xs[i] - x) + abs(ys[i] - y)
            ans.add(h)

        if len(ans) == 1 and ok2:
            h = ans.pop()
            if h > 0:
                ok = True
                print(x, y, h)

assert ok

Submission status: Runtime Error

Solution code:
N = int(input())

xs, ys, hs = [], [], []
for _ in range(N):
    x, y, h = map(int, input().split())
    xs.append(x)
    ys.append(y)
    hs.append(h)

ok = False
for x in range(101):
    for y in range(101):
        if ok:
            break
        ans = set()
        for i in range(N):
            h = hs[i] + abs(xs[i] - x) + abs(ys[i] - y)
            assert h != 1
            ans.add(h)

        if len(ans) == 1:
            ok = True
            print(x, y, ans.pop())

Submission status: Runtime Error

Solution code:
n = int(input().rstrip())
pl = []
 
def calc_h(p, cx, cy, ch):
    return ch - abs(cx - p[0]) - abs(cy - p[0])
 
for i in range(n):
    pl.append([int(x) for x in input().rstrip().split(' ')])
 
hm = max([p[2] for p in pl)
 
vhpl = [p for p in pl if p[2] > 0]
nvhpl = [p for p in pl if p[2] == 0]
tx = None
ty = None
h = None
if len(vhml) == 0:
      for x,y in itertools.product(range(101), repeat=2):
          c = True
          for p in nvhml:
              if x == p[0] and y == p[1]:
                  c = False
                  break
          if c:
              tx = x
              ty = y
              h = 1
              break
elif len(vhml) == 1:
    tx, ty, h = vhml[0]
else:
    for x,y in itertools.product(range(101), repeat=2):
        c = True
        h = abs(vhpl[0][0] - x) + abs(vhpl[0][1]) + vlpl[0][2]
        for i in range(1, len(vhpl)):
            if calc_h(vhpl[i], x, y, h) != vhpl[i][2]:
                c = False
                break
        if c:
            for i in range(len(nvhpl)):
                if calc_h(nvhpl[i], x, y, h) != nvhpl[i][2]:
                    c = False
                    break
        if c:
            tx = x
            ty = y
            break
    
printf(str(tx) + ' ' + str(ty) + ' ' + str(h))
n = int(input().rstrip())
pl = []
 
def calc_h(p, cx, cy, ch):
    return ch - abs(cx - p[0]) - abs(cy - p[0])
 
for i in range(n):
    pl.append([int(x) for x in input().rstrip().split(' ')])
 
hm = max([p[2] for p in pl)
 
vhpl = [p for p in pl if p[2] > 0]
nvhpl = [p for p in pl if p[2] == 0]
tx = None
ty = None
h = None
if len(vhml) == 0:
      for x,y in itertools.product(range(101), repeat=2):
          c = True
          for p in nvhml:
              if x == p[0] and y == p[1]:
                  c = False
                  break
          if c:
              tx = x
              ty = y
              h = 1
              break
elif len(vhml) == 1:
    tx, ty, h = vhml[0]
else:
    for x,y in itertools.product(range(101), repeat=2):
        c = True
        h = abs(vhpl[0][0] - x) + abs(vhpl[0][1]) + vlpl[0][2]
        for i in range(1, len(vhpl)):
            if calc_h(vhpl[i], x, y, h) != vhpl[i][2]:
                c = False
                break
        if c:
            for i in range(len(nvhpl)):
                if calc_h(nvhpl[i], x, y, h) != nvhpl[i][2]:
                    c = False
                    break
        if c:
            tx = x
            ty = y
            break

print(str(tx) + ' ' + str(ty) + ' ' + str(h))

Submission status: Runtime Error

Solution code:
n = int(input().rstrip())
pl = []
 
def calc_h(p, cx, cy, ch):
    return ch - abs(cx - p[0]) - abs(cy - p[0])
 
for i in range(n):
    pl.append([int(x) for x in input().rstrip().split(' ')])
 
hm = max([p[2] for p in pl)
 
vhpl = [p for p in pl if p[2] > 0]
nvhpl = [p for p in pl if p[2] == 0]
tx = None
ty = None
h = None
if len(vhml) == 0:
      for x,y in itertools.product(range(101), repeat=2):
          c = True
          for p in nvhml:
              if x == p[0] and y == p[1]:
                  c = False
                  break
          if c:
              tx = x
              ty = y
              h = 1
              break
elif len(vhml) == 1:
    tx, ty, h = vhml[0]
else:
    for x,y in itertools.product(range(101), repeat=2):
        c = True
        h = abs(vhpl[0][0] - x) + abs(vhpl[0][1]) + vlpl[0][2]
        for i in range(1, len(vhpl)):
            if calc_h(vhpl[i], x, y, h) != vhpl[i][2]:
                c = False
                break
        if c:
            for i in range(len(nvhpl)):
                if calc_h(nvhpl[i], x, y, h) != nvhpl[i][2]:
                    c = False
                    break
        if c:
            tx = x
            ty = y
            break
    
printf(str(tx) + ' ' + str(ty) + ' ' + str(h))

Submission status: Runtime Error

Solution code:
n = int(input().rstrip())
pl = []
 
def calc_h(p, cx, cy, ch):
    return ch - abs(cx - p[0]) - abs(cy - p[0])
 
for i in range(n):
    pl.append([int(x) for x in input().rstrip().split(' ')])
 
hm = max([p[2] for p in pl)
 
vhpl = [p for p in pl if p[2] > 0]
nvhpl = [p for p in pl if p[2] == 0]
tx = None
ty = None
h = None
if len(vhml) == 0:
      for x,y in itertools.product(range(101), repeat=2):
          c = True
          for p in nvhml:
              if x == p[0] and y == p[1]:
                  c = False
                  break
          if c:
              tx = x
              ty = y
              h = 1
              break
elif len(vhml) == 1:
    tx, ty, h = vhml[0]
else:
    for x,y in itertools.product(range(101), repeat=2):
        c = True
        h = abs(vhpl[0][0] - x) + abs(vhpl[0][1]) + vlpl[0][2])
        for i in range(1, len(vhpl)):
            if calc_h(vhpl[i], x, y, h) != vhpl[i][2]:
                c = False
                break
        if c:
            for i in range(len(nvhpl)):
                if calc_h(nvhpl[i], x, y, h) != nvhpl[i][2]:
                    c = False
                    break
        if c:
            tx = x
            ty = y
            break
    
printf(str(tx) + ' ' + str(ty) + ' ' + str(h))

Submission status: Runtime Error

Solution code:
n = int(input().rstrip())
pl = []

def calc_h(p, cx, cy, ch):
  return ch - abs(cx - p[0]) - abs(cy - p[0])

for i in range(n):
  pl.append([int(x) for x in input().rstrip().split(' ')])

hm = max([p[2] for p in pl)

vhpl = [p for p in pl if p[2] > 0]
nvhpl = [p for p in pl if p[2] == 0]
tx = None
ty = None
h = None
if len(vhml) == 0:
  for x,y in itertools.product(range(101), repeat=2):
    c = True
    for p in nvhml:
      if x == p[0] and y == p[1]:
        c = False
        break
    if c:
      tx = x
      ty = y
      h = 1
      break
elif len(vhml) == 1:
  tx, ty, h = vhml[0]
else:
  for x,y in itertools.product(range(101), repeat=2):
    c = True
    h = abs(vhpl[0][0] - x) + abs(vhpl[0][1]) + vlpl[0][2])
    for i in range(1, len(vhpl)):
      if calc_h(vhpl[i], x, y, h) != vhpl[i][2]:
        c = False
        break
    if c:
      for i in range(len(nvhpl)):
        if calc_h(nvhpl[i], x, y, h) != nvhpl[i][2]:
          c = False
          break
    if c:
      tx = x
      ty = y
      break
    
printf(str(tx) + ' ' + str(ty) + ' ' + str(h))

Submission status: Runtime Error

Solution code:
import sys
N,M=map(int,input().split())
i=N
if(i%2==1):
    if(M%i==0):
        print(M//i)
        sys.exit(0)
    i+=1
if(M%i==0):
    print(M//i)
    sys.exit(0)
i+=1

    
while(i*2 <=M):
    if(M%i==0):
        break
    i+=2
if(i*2>M):
    i=M
print(M//i)

Submission status: Runtime Error

Solution code:
i=int(input())
for i in range():
  x,y,h=list(map(int,input().strip().split('')))
for j in range(i):
  for cx in range(0,100,1):
    for cy in range(0,100,1):
      X=abs(x[i]-cx)
      Y=abs(y[i]-cy)
      if(X+Y==h[i]):
        break
print(X,Y,X+Y)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().strip().split())

for i in range(M//N,0,-1):
    if M%i==0:
        print(i)
        break

Submission status: Runtime Error

Solution code:
N=int(input().strip())

xyh=[]
for i in range(N):
    xi,yi,hi = map(int, input().split(' '))
    if hi>0:
        xtst=xi
        ytst=yi
        htst=hi
    xyh.append([xi,yi,hi])

for ny in range(101):
    for nx in range(101):
        nh=abs(xtst-nx)+abs(ytst-ny)+htst
        nh=max(nh,0)
        fl=True
        for lis in xyh:
                if lis[2]!=max(0,nh-abs(lis[0]-nx)+abs(lis[1]-ny)):
                    fl=False
        if fl:
            ax=nx
            ay=ny
            ah=nh

print("{} {} {}".format(ax,ay,ah))

Submission status: Runtime Error

Solution code:
N=int(input().strip())

xyh=[]
for i in range(N):
    xi,yi,hi = map(int, input().split(' '))
    if hi>0:
        xyh.append([xi,yi,hi])

fl=False
nh=0
for ny in range(101):
    if fl:
        break
    for nx in range(101):
        if fl:
            break
        nh=abs(xyh[0][0]-nx)+abs(xyh[0][1]-ny)+xyh[0][2]
        nh=max(nh,0)
        fl=True
        for i in range(N):
                if nh!=max(0,abs(xyh[i][0]-nx)+abs(xyh[i][1]-ny)+xyh[i][2]):
                    fl=False
                    break
        if fl:
            ax=nx
            ay=ny
            ah=nh

print("{} {} {}".format(ax,ay,ah))

Submission status: Runtime Error

Solution code:
N=int(input().strip())

xyh=[]
for i in range(N):
    xi,yi,hi = map(int, input().split(' '))
    if hi>0:
        xyh.append([xi,yi,hi])

fl=False
nh=0
for ny in range(101):
    if fl:
        break
    for nx in range(101):
        if fl:
            break
        for i in range(len(xyh)):
            if i==0:
                nh=abs(xyh[i][0]-nx)+abs(xyh[i][1]-ny)+xyh[i][2]
        #        print(abs(xyh[i][0]-nx)+abs(xyh[i][1]-ny)+xyh[i][2])
            elif i==len(xyh)-1:
                if nh!=abs(xyh[i][0]-nx)+abs(xyh[i][1]-ny)+xyh[i][2]:
                    break
                else:
                    fl=True
                    ax=nx
                    ay=ny
                    ah=nh
                    break
            else:
                if nh!=abs(xyh[i][0]-nx)+abs(xyh[i][1]-ny)+xyh[i][2]:
                    break

print("{} {} {}".format(ax,ay,ah))

Submission status: Runtime Error

Solution code:
n = int(input())

info = [[int(x) for x in input().split()] for _ in range(n)]

def height(point, info):
    cx, cy = point[0], point[1]
    ch = None
    for i,p in enumerate(info):
        x, y, h= p[0], p[1], p[2]
        tmp = abs(cx-x) + abs(cy-y) + h
        if ch == None:
            ch = tmp
        else:
            if ch != tmp:
                return None
                break
    return ch

flag = False
ans = None
for x in range(101):
    if flag:
        break
    for y in range(101):
        if flag:
            break
        point = (x,y)
        t = height(point, info)
        if t != None:
            flag = True
            ans = [x,y,t]

print(' '.join(map(str, ans)))

Submission status: Runtime Error

Solution code:
N = int(input())
P = [list(map(int, input().split())) for i in range(N)]

x0, y0, h0 = P[0]
for cy in range(101):
    for cx in range(101):
        h = h0 + abs(cx - x0) + abs(cy - y0)
        for x, y, h1 in P[1:]:
            if h != h1 + abs(cx - x) + abs(cy - y):
                break
        else:
            print(cx, cy, h)
            exit(0)
exit(1)

Submission status: Runtime Error

Solution code:
import sys

N = int(input())
xyh = []
for _ in range(N):
    x, y, h = map(int, input().split())
    xyh.append(tuple(x, y, h))

for X in range(101):
    for Y in range(101):
        flag = True
        H = 0
        for cx, cy, ch in xyh:
            if ch != 0:
                H = ch + abs(X - cx) + abs(Y - cy)
        for cx, cy, ch in xyh:
            h  max(h - abs(X - cx) - abs(Y - cy), 0)
            if ch != h:
                flag = False

        if flag:
            print(X, Y, H)
            sys.exit(0)

Submission status: Runtime Error

Solution code:
N = int(input())
x = [None for _ in range(N)]
y = [None for _ in range(N)]
h = [None for _ in range(N)]
hh = [0 for _ in range(N)]
flag = False
for i in range(N):
    x[i], y[i], h[i] = map(int, input().split())
for cx in range(0, 101):
    for cy in range(0, 101):
        for i in range(N):
            hh[i] = h[i] + abs(x[i] - cx) + abs(y[i] - cy)
            if hh[i] < 1:
                hh[i] = None
        if (min(hh) == max(hh)) and (min(hh) >= 1):
            print(cx, cy, hh[0])
            exit()

Submission status: Runtime Error

Solution code:
N=int(input())
x=[]
y=[]
h=[]
for i in range(N):
    x_n,y_n,h_n=map(int,input().split())
    if h_n >=1:
        x.append(x_n)
        y.append(y_n)
        h.append(h_n)

def all_same(a):
    if all(a[i]==a[i+1] for i in range(0,len(a)-1)):
        return True
    else:
        return False

for C_x in range(101):
    for C_y in range(101):
        H=[]
        for i in range(len(x)):
            H.append(h[i]+abs(x[i]-C_x)+abs(y[i]-C_y))
        H.sort()
        H.remove(0)
        if all_same(H):
            print(C_x,C_y,H[0])

Submission status: Runtime Error

Solution code:
N=int(input())
x=[]
y=[]
h=[]
for i in range(N):
    x_n,y_n,h_n=map(int,input().split())
    if h_n !=0:
        x.append(x_n)
        y.append(y_n)
        h.append(h_n)

def all_same(a):
    if all(a[i]==a[i+1] for i in range(0,len(a)-1)):
        return True
    else:
        return False

for C_x in range(101):
    for C_y in range(101):
        H=[]
        for i in range(len(x)):
            H.append(h[i]+abs(x[i]-C_x)+abs(y[i]-C_y))
        H.sort()
        H.remove(0)
        if all_same(H):
            print(C_x,C_y,H[0])