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: Wrong Answer

Solution code:
N=int(input())
xyh=[list(map(int,input().split()))for _ in range(N)]
for X in range(101):
    for Y in range(101):
        x,y,h=xyh[0]
        H=h+abs(X-x)+abs(Y-y)
        if all(H==h+abs(X-x)+abs(Y-y)for x,y,h in xyh):
            print(X,Y,H)
            exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
xyh=[list(map(int,input().split()))for _ in range(N)]
for X in range(101):
    for Y in range(101):
        x,y,h=xyh[0]
        H=h+abs(X-x)+abs(Y-y)
        if all(H==h+abs(X-x)+abs(Y-y)for x,y,h in xyh):
            print(X,Y,H)

Submission status: Wrong Answer

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

for i in range(101):
    for j in range(101):
        s = -1
        flag = True
        limit = float('inf')
        for x, y, h in xyh:
            if h != 0:
                H = h + abs(x-i) + abs(y-j)
                if s != -1:
                    if s != H:
                        flag = False
                        break
                s = H
            else:
                limit = min(limit, abs(x-i) + abs(y-j))
        if flag:
            if s != -1:
                print(i, j, s)
                exit()
            elif limit == 1:
                print(i, j, 1)
                exit()

Submission status: Wrong Answer

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

for i in range(101):
    for j in range(101):
        s = -1
        flag = True
        limit = 0
        for x, y, h in xyh:
            if h != 0:
                H = h + abs(x-i) + abs(y-j)
                if s != -1:
                    if s != H:
                        flag = False
                        break
                s = H
            else:
                limit = min(limit, abs(x-i) + abs(y-j))
        if flag:
            if s != -1:
                print(i, j, s)
                exit()
            elif limit == 1:
                print(i, j, 1)
                exit()

Submission status: Wrong Answer

Solution code:
N = int(input()); INF = float("inf")
Z = []
for i in range(N):
  x,y,h = map(int,input().split())
  Z.append((x,y,h))
Z.sort(key=lambda x : x[2],reverse=True)
#print(Z)
for i in range(101):
  for j in range(101):
    Flag = True #0以外があればFalse
    for t in range(N):
      MAX = INF
      #print(Z[t][2])
      if Z[t][2] == 0:
        if i == Z[t][0] and j == Z[t][1]:
          break
        MAX = min(MAX,abs(i-Z[t][0])+abs(j-Z[t][1])+Z[t][2])
      elif Flag:
        ans = abs(i-Z[t][0])+abs(j-Z[t][1])+Z[t][2]
        Flag = False
      else:
        temp = abs(i-Z[t][0])+abs(j-Z[t][1])+Z[t][2]
        #print(temp)
        if temp != ans:
          break
      #print(MAX,ans)
      if t != N-1: #最後じゃないなら続く。
        continue
      #print(MAX)
      if Flag: #全て0
        #if MAX == 1: #MAXが1
        #  ret = [i,j,1]
        #  print(*ret);exit()
        #else: #複数の可能性があってダメ
        break
      else: #少なくとも1以上がある。
        if ans <= MAX:
          ret = [i,j,ans]
          print(*ret);exit()
        else:
          break

Submission status: Wrong Answer

Solution code:
N = int(input()); INF = float("inf")
Z = []
for i in range(N):
  x,y,h = map(int,input().split())
  Z.append((x,y,h))
Z.sort(key=lambda x : x[2],reverse=True)
#print(Z)
for i in range(101):
  for j in range(101):
    Flag = True #0以外があればFalse
    for t in range(N):
      MAX = INF
      #print(Z[t][2])
      if Z[t][2] == 0:
        if i == Z[t][0] and j == Z[t][1]:
          break
        MAX = min(MAX,abs(i-Z[t][0])+abs(j-Z[t][1])+Z[t][2])
      elif Flag:
        ans = abs(i-Z[t][0])+abs(j-Z[t][1])+Z[t][2]
        Flag = False
      else:
        temp = abs(i-Z[t][0])+abs(j-Z[t][1])+Z[t][2]
        #print(temp)
        if temp != ans:
          break
      #print(MAX,ans)
      if t != N-1: #最後じゃないなら続く。
        continue
      #print(MAX)
      if Flag: #全て0
        if MAX == 1: #MAXが1
          ret = [i,j,1]
          print(*ret);exit()
        else: #複数の可能性があってダメ
          break
      else: #少なくとも1以上がある。
        if ans <= MAX:
          ret = [i,j,ans]
          print(*ret);exit()
        else:
          break

Submission status: Wrong Answer

Solution code:
N = int(input())
X = []; Y = []; H = []
for i in range(N):
  x,y,h = map(int,input().split())
  X.append(x);Y.append(y);H.append(h)

for i in range(101):
  for j in range(101):
    for t in range(N):
      if t == 0:
        ans = abs(i-X[t])+abs(j-Y[t])+H[t]
      else:
        temp = abs(i-X[t])+abs(j-Y[t])+H[t]
        if temp != ans:
          break
        if t == N-1:
          ret = [i,j,ans]
          print(*ret);exit()

Submission status: Wrong Answer

Solution code:
import sys
import os
import math
import bisect
import itertools
import collections
import heapq
import queue
import array

# 時々使う
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

# 再帰の制限設定
sys.setrecursionlimit(10000000)


def ii(): return int(sys.stdin.buffer.readline().rstrip())
def il(): return list(map(int, sys.stdin.buffer.readline().split()))
def fl(): return list(map(float, sys.stdin.buffer.readline().split()))
def iln(n): return [int(sys.stdin.buffer.readline().rstrip())
                    for _ in range(n)]


def iss(): return sys.stdin.buffer.readline().decode().rstrip()
def sl(): return list(map(str, sys.stdin.buffer.readline().decode().split()))
def isn(n): return [sys.stdin.buffer.readline().decode().rstrip()
                    for _ in range(n)]


def lcm(x, y): return (x * y) // math.gcd(x, y)


# MOD = 10 ** 9 + 7
MOD = 998244353
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    xyh = [il() for _ in range(N)]

    for cx in range(0, 101):
        for cy in range(0, 101):
            tmp = set()
            for x, y, h in xyh:
                if h == 0:
                    continue
                tmp_h = h + abs(x - cx) + abs(y - cy)
                if tmp_h > 0:
                    tmp.add((cx, cy, tmp_h))
            if len(tmp) == 1:
                x, y, h = list(tmp)[0]
                print(x, y, h)
                exit()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import os
import math
import bisect
import itertools
import collections
import heapq
import queue
import array

# 時々使う
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

# 再帰の制限設定
sys.setrecursionlimit(10000000)


def ii(): return int(sys.stdin.buffer.readline().rstrip())
def il(): return list(map(int, sys.stdin.buffer.readline().split()))
def fl(): return list(map(float, sys.stdin.buffer.readline().split()))
def iln(n): return [int(sys.stdin.buffer.readline().rstrip())
                    for _ in range(n)]


def iss(): return sys.stdin.buffer.readline().decode().rstrip()
def sl(): return list(map(str, sys.stdin.buffer.readline().decode().split()))
def isn(n): return [sys.stdin.buffer.readline().decode().rstrip()
                    for _ in range(n)]


def lcm(x, y): return (x * y) // math.gcd(x, y)


# MOD = 10 ** 9 + 7
MOD = 998244353
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    xyh = []
    x_range = []
    y_range = []
    for _ in range(N):
        x, y, h = il()
        xyh.append([x, y, h])
        x_range.append(x)
        y_range.append(y)

    for cx in range(min(x_range), max(x_range)+1):
        for cy in range(min(y_range), max(y_range)+1):
            tmp = set()
            for x, y, h in xyh:
                tmp_h = h + abs(x - cx) + abs(y - cy)
                tmp.add((cx, cy, tmp_h))

            if len(tmp) == 1:
                x, y, h = list(tmp)[0]
                print(x, y, h)
                exit()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import os
import math
import bisect
import itertools
import collections
import heapq
import queue
import array

# 時々使う
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

# 再帰の制限設定
sys.setrecursionlimit(10000000)


def ii(): return int(sys.stdin.buffer.readline().rstrip())
def il(): return list(map(int, sys.stdin.buffer.readline().split()))
def fl(): return list(map(float, sys.stdin.buffer.readline().split()))
def iln(n): return [int(sys.stdin.buffer.readline().rstrip())
                    for _ in range(n)]


def iss(): return sys.stdin.buffer.readline().decode().rstrip()
def sl(): return list(map(str, sys.stdin.buffer.readline().decode().split()))
def isn(n): return [sys.stdin.buffer.readline().decode().rstrip()
                    for _ in range(n)]


def lcm(x, y): return (x * y) // math.gcd(x, y)


# MOD = 10 ** 9 + 7
MOD = 998244353
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    xyh = []
    x_range = []
    y_range = []
    for _ in range(N):
        x, y, h = il()
        xyh.append([x, y, h])
        x_range.append(x)
        y_range.append(y)

    for cx in range(min(x_range), max(x_range)+1):
        for cy in range(min(y_range), max(y_range)+1):
            tmp = set()
            for x, y, h in xyh:
                tmp_h = h + abs(x - cx) + abs(y - cy)
                if h == 0 or tmp_h == 0:
                    continue
                tmp.add((cx, cy, tmp_h))

            if len(tmp) == 1:
                x, y, h = list(tmp)[0]
                print(x, y, h)
                exit()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import os
import math
import bisect
import itertools
import collections
import heapq
import queue
import array

# 時々使う
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

# 再帰の制限設定
sys.setrecursionlimit(10000000)


def ii(): return int(sys.stdin.buffer.readline().rstrip())
def il(): return list(map(int, sys.stdin.buffer.readline().split()))
def fl(): return list(map(float, sys.stdin.buffer.readline().split()))
def iln(n): return [int(sys.stdin.buffer.readline().rstrip())
                    for _ in range(n)]


def iss(): return sys.stdin.buffer.readline().decode().rstrip()
def sl(): return list(map(str, sys.stdin.buffer.readline().decode().split()))
def isn(n): return [sys.stdin.buffer.readline().decode().rstrip()
                    for _ in range(n)]


def lcm(x, y): return (x * y) // math.gcd(x, y)


# MOD = 10 ** 9 + 7
MOD = 998244353
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    xyh = []
    x_range = []
    y_range = []
    for _ in range(N):
        x, y, h = il()
        xyh.append([x, y, h])
        x_range.append(x)
        y_range.append(y)

    for cx in range(min(x_range), max(x_range)+1):
        for cy in range(min(y_range), max(y_range)+1):
            tmp = set()
            for x, y, h in xyh:
                if h == 0:
                    continue
                tmp_h = h + abs(x - cx) + abs(y - cy)
                tmp.add((cx, cy, tmp_h))

            if len(tmp) == 1:
                x, y, h = list(*tmp)
                print(x, y, h)
                exit()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import os
import math
import bisect
import itertools
import collections
import heapq
import queue
import array

# 時々使う
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

# 再帰の制限設定
sys.setrecursionlimit(10000000)


def ii(): return int(sys.stdin.buffer.readline().rstrip())
def il(): return list(map(int, sys.stdin.buffer.readline().split()))
def fl(): return list(map(float, sys.stdin.buffer.readline().split()))
def iln(n): return [int(sys.stdin.buffer.readline().rstrip())
                    for _ in range(n)]


def iss(): return sys.stdin.buffer.readline().decode().rstrip()
def sl(): return list(map(str, sys.stdin.buffer.readline().decode().split()))
def isn(n): return [sys.stdin.buffer.readline().decode().rstrip()
                    for _ in range(n)]


def lcm(x, y): return (x * y) // math.gcd(x, y)


# MOD = 10 ** 9 + 7
MOD = 998244353
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    xyh = []
    x_range = []
    y_range = []
    for _ in range(N):
        x, y, h = il()
        xyh.append([x, y, h])
        x_range.append(x)
        y_range.append(y)

    for cx in range(min(x_range), max(x_range)+1):
        for cy in range(min(y_range), max(y_range)+1):
            tmp = set()
            for x, y, h in xyh:
                tmp_h = h + abs(x - cx) + abs(y - cy)
                tmp.add((cx, cy, tmp_h))

            if len(tmp) == 1:
                x, y, h = list(*tmp)
                print(x, y, h)
                exit()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import os
import math
import bisect
import itertools
import collections
import heapq
import queue
import array

# 時々使う
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

# 再帰の制限設定
sys.setrecursionlimit(10000000)


def ii(): return int(sys.stdin.buffer.readline().rstrip())
def il(): return list(map(int, sys.stdin.buffer.readline().split()))
def fl(): return list(map(float, sys.stdin.buffer.readline().split()))
def iln(n): return [int(sys.stdin.buffer.readline().rstrip())
                    for _ in range(n)]


def iss(): return sys.stdin.buffer.readline().decode().rstrip()
def sl(): return list(map(str, sys.stdin.buffer.readline().decode().split()))
def isn(n): return [sys.stdin.buffer.readline().decode().rstrip()
                    for _ in range(n)]


def lcm(x, y): return (x * y) // math.gcd(x, y)


# MOD = 10 ** 9 + 7
MOD = 998244353
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    if N == 1:
        print(*il())
        exit()

    xyh = [il() for _ in range(N)]
    for cx in range(0, 101):
        for cy in range(0, 101):
            tmp = set()
            if cx == 32 and cy == 68:
                print(1)
            for x, y, h in xyh:
                if h == 0:
                    continue
                tmp_h = h + abs(x - cx) + abs(y - cy)
                if tmp_h > 0:
                    tmp.add((cx, cy, tmp_h))
            if len(tmp) == 1:
                x, y, h = list(tmp)[0]
                print(x, y, h)
                exit()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import os
import math
import bisect
import itertools
import collections
import heapq
import queue
import array

# 時々使う
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

# 再帰の制限設定
sys.setrecursionlimit(10000000)


def ii(): return int(sys.stdin.buffer.readline().rstrip())
def il(): return list(map(int, sys.stdin.buffer.readline().split()))
def fl(): return list(map(float, sys.stdin.buffer.readline().split()))
def iln(n): return [int(sys.stdin.buffer.readline().rstrip())
                    for _ in range(n)]


def iss(): return sys.stdin.buffer.readline().decode().rstrip()
def sl(): return list(map(str, sys.stdin.buffer.readline().decode().split()))
def isn(n): return [sys.stdin.buffer.readline().decode().rstrip()
                    for _ in range(n)]


def lcm(x, y): return (x * y) // math.gcd(x, y)


# MOD = 10 ** 9 + 7
MOD = 998244353
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    xyh = [il() for _ in range(N)]
    for cx in range(0, 101):
        for cy in range(0, 101):
            tmp = set()
            for x, y, h in xyh:
                if h == 0:
                    continue
                tmp_h = h + abs(x - cx) + abs(y - cy)
                if tmp_h > 0:
                    tmp.add((cx, cy, tmp_h))
            if len(tmp) == 1:
                x, y, h = list(tmp)[0]
                print(x, y, h)
                exit()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import os
import math
import bisect
import itertools
import collections
import heapq
import queue
import array

# 時々使う
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

# 再帰の制限設定
sys.setrecursionlimit(10000000)


def ii(): return int(sys.stdin.buffer.readline().rstrip())
def il(): return list(map(int, sys.stdin.buffer.readline().split()))
def fl(): return list(map(float, sys.stdin.buffer.readline().split()))
def iln(n): return [int(sys.stdin.buffer.readline().rstrip())
                    for _ in range(n)]


def iss(): return sys.stdin.buffer.readline().decode().rstrip()
def sl(): return list(map(str, sys.stdin.buffer.readline().decode().split()))
def isn(n): return [sys.stdin.buffer.readline().decode().rstrip()
                    for _ in range(n)]


def lcm(x, y): return (x * y) // math.gcd(x, y)


# MOD = 10 ** 9 + 7
MOD = 998244353
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    xyh = [il() for _ in range(N)]
    for cx in range(0, 101):
        for cy in range(0, 101):
            tmp = set()
            for x, y, h in xyh:
                tmp_h = h + abs(x - cx) + abs(y - cy)
                if tmp_h > 0:
                    tmp.add((cx, cy, tmp_h))
            if len(tmp) == 1:
                x, y, h = list(tmp)[0]
                print(x, y, h)
                exit()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]
xyh.sort(key=lambda x: x[2], reverse=True)
ans = []

for cx in range(101):
    for cy in range(101):
        x, y, h = xyh[0]
        ch = h + abs(x - cx) + abs(y - cy)
        if all([ch == max(h + abs(x - cx) + abs(y - cy), 0) for x, y, h in xyh[1:]]):
            ans = [cx, cy, ch]
            break
print(*ans, sep=' ')

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]
for cx in range(101):
    for cy in range(101):
        h_list = []
        for x, y, h in xyh:
            if h > 0:
                tmp_h = max(h + abs(x - cx) + abs(y - cy), 0)
                h_list.append(tmp_h)
        if len(set(h_list)) == 1 and h_list[0] > 0:
            print(cx, cy, h_list[0], sep=' ')

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]
for cx in range(101):
    for cy in range(101):
        h_list = []
        for x, y, h in xyh:
            if h > 0:
                tmp_h = max(h + abs(x - cx) + abs(y - cy), 0)
                h_list.append(tmp_h)
        min_h = min(h_list)
        max_h = max(h_list)
        if min_h == max_h and min_h > 0:
            print(cx, cy, min_h, sep=' ')

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]
for cx in range(101):
    for cy in range(101):
        h_list = []
        for x, y, h in xyh:
            if h > 0:
                tmp_h = max(h + abs(x - cx) + abs(y - cy), 0)
                h_list.append(tmp_h)
        if min(h_list) == max(h_list) and h_list[0] != 0:
            print(cx, cy, h_list[0], sep=' ')

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]
for cx in range(101):
    for cy in range(101):
        h_list = []
        for x, y, h in xyh:
            if h > 0:
                tmp_h = max(h + abs(x - cx) + abs(y - cy), 0)
                h_list.append(tmp_h)
        if min(h_list) == max(h_list):
            print(cx, cy, h_list[0], sep=' ')

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]
xyh = sorted(xyh, key=lambda x: x[2], reverse=True)

for cx in range(101):
    for cy in range(101):
        flag = []
        h0 = xyh[0][2] + abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy)
        for x, y, h in xyh[1:]:
            # h=0になっているものは距離が分からないので使用しない
            # if h > 0:
            tmp_h = max(h + abs(x - cx) + abs(y - cy), 0)
            flag.append(h0 == tmp_h)
        if all(flag):
            print(cx, cy, h0, sep=' ')

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]
xyh = sorted(xyh, key=lambda x: x[2], reverse=True)

for cx in range(101):
    for cy in range(101):
        flag = []
        h0 = xyh[0][2] + abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy)
        for x, y, h in xyh[1:]:
            # h=0になっているものは距離が分からないので使用しない
            if h > 0:
                tmp_h = max(h + abs(x - cx) + abs(y - cy), 0)
                flag.append(h0 == tmp_h)
        if all(flag):
            print(cx, cy, h0, sep=' ')

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        flag = True
        h_list = []
        for x, y, h in xyh:
            # h[i]=0になっているものは距離が分からない
            if h > 0:
                h_list.append(max(h + abs(x - cx) + abs(y - cy), 0))
                if min(h_list) != max(h_list):
                    flag = False
                    break
        if flag:
            print(cx, cy, h_list[0], sep=' ')

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]
xyh.sort(reverse=True)
ans = []

for cx in range(101):
    for cy in range(101):
        flag = True
        h0 = abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy) + xyh[0][2]
        for x, y, h in xyh:
            if h > 0:
                tmp_h = abs(x - cx) + abs(y - cy) + h
                if h0 != max(tmp_h, 0):
                    flag = False
                    break
        if flag:
            ans = [cx, cy, h0]

print(*ans, sep=' ')

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]
xyh.sort(reverse=True)
ans = []
for cx in range(101):
    for cy in range(101):
        flag = True
        h0 = abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy) + xyh[0][2]
        for x, y, h in xyh:
            tmp_h = abs(x - cx) + abs(y - cy) + h
            if h0 != max(tmp_h, 0):
                flag = False
                break
        if flag:
            ans = [cx, cy, h0]
print(*ans, sep=' ')

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]
ans = []
for cx in range(101):
    for cy in range(101):
        flag = True
        h0 = abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy) + xyh[0][2]
        for x, y, h in xyh:
            tmp_h = abs(x - cx) + abs(y - cy) + h
            if h0 != max(tmp_h, 0):
                flag = False
                break
        if flag:
            ans = [cx, cy, h0]
print(*ans, sep=' ')

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        h0 = abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy) + xyh[0][2]
        for x, y, h in xyh:
            tmp_h = abs(x - cx) + abs(y - cy) + h
            if h0 != max(tmp_h, 0):
                break
        else:
            print(cx, cy, h0, sep=' ')
            break

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]
xyh.sort(reverse=True, key=lambda x: x[2])

def answer(cx, cy, xyh):
    flag = True
    h0 = abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy) + xyh[0][2]
    for x, y, h in xyh:
        tmp_h = abs(x - cx) + abs(y - cy) + h
        if h0 != max(tmp_h, 0):
            flag = False
            break
    if flag:
        return print(cx, cy, h0, sep=' ')

for cx in range(0, 101):
    for cy in range(0, 101):
        answer(cx, cy, xyh)

Submission status: Wrong Answer

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

def answer(cx, cy, xyh):
    flag = True
    h0 = abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy) + xyh[0][2]
    h0 = max(h0, 0)
    for x, y, h in xyh:
        tmp_h = abs(x - cx) + abs(y - cy) + h
        tmp_h = max(tmp_h, 0)
        if h0 != tmp_h:
            flag = False
            break
    if flag:
        return print(cx, cy, h0, sep=' ')
    else:
        return flag

for cx in range(0, 101):
    for cy in range(0, 101):
        if answer(cx, cy, xyh):
            answer(cx, cy, xyh)
            break

Submission status: Wrong Answer

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

def answer(cx, cy, xyh):
    flag = True
    tmp_h0 = abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy) + xyh[0][2]
    tmp_h0 = max(tmp_h0, 0)
    for x, y, h in xyh:
        tmp_h1 = abs(x - cx) + abs(y - cy) + h
        tmp_h1 = max(tmp_h1, 0)
        if tmp_h0 != tmp_h1:
            flag = False
            break
    if flag:
        return print(cx, cy, tmp_h0, sep=' ')

for cx in range(0, 101):
    for cy in range(0, 101):
        answer(cx, cy, xyh)

Submission status: Wrong Answer

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

def answer(cx, cy, xyh):
    flag = True
    tmp_h0 = abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy) + xyh[0][2]
    for x, y, h in xyh:
        tmp_h1 = abs(x - cx) + abs(y - cy) + h
        if tmp_h0 != tmp_h1:
            flag = False
            break
    if flag:
        return print(cx, cy, tmp_h0, sep=' ')

for cx in range(0, 101):
    for cy in range(0, 101):
        answer(cx, cy, xyh)

Submission status: Wrong Answer

Solution code:
# 解説を参考に作成
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(N, xyh):
    for i in range(101):
        for j in range(101):
            H = -1
            for x, y, h in xyh:
                if h > 0:
                    tmpH = h + abs(x - i) + abs(y - j)
                    if H < 0:
                        H = tmpH
                    elif H != tmpH:
                        break
            else:
                print(i, j ,H)
                return


if __name__ == '__main__':
    N = int(input())
    xyh = [[int(i) for i in input().split()] for _ in range(N)]
    solve(N, xyh)

    # # test
    # from random import randint
    # from func import random_str
    # solve()

Submission status: Wrong Answer

Solution code:

def main():
    N = int(input())
    xyh = [[int(i) for i in input().split()] for _ in range(N)]

    cx = 0
    cy = 0
    tx = xyh[0][0]
    for c in range(0, 101):
        for i in range(N):
            for j in range(N):
                if xyh[i][0] == xyh[j][0]:
                    continue
                if abs(xyh[i][0] - c) == abs(xyh[j][0] - c):
                    cx = c
            if tx != xyh[i][0]:
                txi = i

    if cx == 0:
        x0, y0, h0 = xyh[0]
        x1, y1, h1 = xyh[txi]
        if ((h0 - y0) - (h1 - y1)) * (x0 -x1) > 0:
            cx = 100

    ty = xyh[0][1]
    for c in range(0, 101):
        for i in range(N):
            for j in range(N):
                if xyh[i][1] == xyh[j][1]:
                    continue
                if abs(xyh[i][1] - c) == abs(xyh[j][1] - c):
                    cy = c
            if ty != xyh[i][1]:
                tyi = i
    if cy == 0:
        x0, y0, h0 = xyh[0]
        x1, y1, h1 = xyh[tyi]
        if ((h0 - x0) - (h1 - x1)) * (y0 -y1) > 0:
            cy = 100


    h = xyh[0][2] + abs(cx - xyh[0][0]) + abs(cy - xyh[0][1])
    print(cx, cy, h)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

    cx = 0
    cy = 0
    tx = xyh[0][0]
    for c in range(0, 101):
        for i in range(N):
            for j in range(i + 1, N):
                if xyh[i][0] == xyh[j][0]:
                    continue
                if abs(xyh[i][0] - c) == abs(xyh[j][0] - c):
                    cx = c
            if tx != xyh[i][0]:
                txi = i

    if cx == 0:
        x0, y0, h0 = xyh[0]
        x1, y1, h1 = xyh[txi]
        if ((h0 - y0) - (h1 - y1)) * (x0 -x1) > 0:
            cx = 100

    ty = xyh[0][1]
    for c in range(0, 101):
        for i in range(N):
            for j in range(i + 1, N):
                if xyh[i][1] == xyh[j][1]:
                    continue
                if abs(xyh[i][1] - c) == abs(xyh[j][1] - c):
                    cy = c
            if ty != xyh[i][1]:
                tyi = i
    if cy == 0:
        x0, y0, h0 = xyh[0]
        x1, y1, h1 = xyh[tyi]
        if ((h0 - x0) - (h1 - x1)) * (y0 -y1) > 0:
            cy = 100


    h = xyh[0][2] + abs(cx - xyh[0][0]) + abs(cy - xyh[0][1])
    print(cx, cy, h)


if __name__ == "__main__":
    main()