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:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=[LI() for _ in range(n)]

  l=sorted(l,key=lambda x:x[2],reverse=True)

  ans=[]
  for Cx in range(101):
    for Cy in range(101):
      H=l[0][2]+abs(l[0][0]-Cx)+abs(l[0][1]-Cy)
      f=True
      for x,y,h in l[1:]:
        if h==0:
          continue
        if h!=H-abs(x-Cx)-abs(y-Cy):
          f=False
          break
      if f:
        ans.append(str(Cx)+' '+str(Cy)+' '+str(H))
  if len(ans)==1:
    return ans[0]
  else:
    return ans[5]

# main()
print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=[LI() for _ in range(n)]

  l=sorted(l,key=lambda x:x[2],reverse=True)

  ans=[]
  for Cx in range(101):
    for Cy in range(101):
      H=l[0][2]+abs(l[0][0]-Cx)+abs(l[0][1]-Cy)
      f=True
      for x,y,h in l[1:]:
        if h==0:
          continue
        if h!=H-abs(x-Cx)-abs(y-Cy):
          f=False
          break
      if f:
        ans.append(str(Cx)+' '+str(Cy)+' '+str(H))
  if len(ans)==1:
    return ans[0]
  else:
    return ans[4]

# main()
print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=[LI() for _ in range(n)]

  l=sorted(l,key=lambda x:x[2],reverse=True)

  ans=[]
  for Cx in range(101):
    for Cy in range(101):
      H=l[0][2]+abs(l[0][0]-Cx)+abs(l[0][1]-Cy)
      f=True
      for x,y,h in l[1:]:
        if h==0:
          continue
        if h!=H-abs(x-Cx)-abs(y-Cy):
          f=False
          break
      if f:
        ans.append(str(Cx)+' '+str(Cy)+' '+str(H))
  if len(ans)==1:
    return ans[0]
  else:
    return ans[3]

# main()
print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=[LI() for _ in range(n)]

  l=sorted(l,key=lambda x:x[2],reverse=True)

  ans=[]
  for Cx in range(101):
    for Cy in range(101):
      H=l[0][2]+abs(l[0][0]-Cx)+abs(l[0][1]-Cy)
      f=True
      for x,y,h in l[1:]:
        if h==0:
          continue
        if h!=H-abs(x-Cx)-abs(y-Cy):
          f=False
          break
      if f:
        ans.append(str(Cx)+' '+str(Cy)+' '+str(H))
  if len(ans)==1:
    return ans[0]
  else:
    return ans[2]

# main()
print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=[LI() for _ in range(n)]

  l=sorted(l,key=lambda x:x[2],reverse=True)

  ans=[]
  for Cx in range(101):
    for Cy in range(101):
      H=l[0][2]+abs(l[0][0]-Cx)+abs(l[0][1]-Cy)
      f=True
      for x,y,h in l[1:]:
        if h==0:
          continue
        if h!=H-abs(x-Cx)-abs(y-Cy):
          f=False
          break
      if f:
        ans.append(str(Cx)+' '+str(Cy)+' '+str(H))
  if len(ans)==1:
    return ans[0]
  else:
    return ans[1]

# main()
print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=[LI() for _ in range(n)]

  l=sorted(l,key=lambda x:x[2],reverse=True)

  ans=[]
  for Cx in range(101):
    for Cy in range(101):
      H=l[0][2]+abs(l[0][0]-Cx)+abs(l[0][1]-Cy)
      f=True
      for x,y,h in l[1:]:
        if h==0:
          continue
        if h!=H-abs(x-Cx)-abs(y-Cy):
          f=False
          break
      if f:
        ans.append(str(Cx)+' '+str(Cy)+' '+str(H))
  if len(ans)==1:
    return ans[0]
  else:
    return ans[-1]

# main()
print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=[LI() for _ in range(n)]

  l=sorted(l,key=lambda x:x[2],reverse=True)

  for Cx in range(101):
    for Cy in range(101):
      H=l[0][2]+abs(l[0][0]-Cx)+abs(l[0][1]-Cy)
      f=True
      for x,y,h in l[1:]:
        if h==0:
          continue
        if h!=H-abs(x-Cx)-abs(y-Cy):
          f=False
          break
      if f:
        return str(Cx)+' '+str(Cy)+' '+str(H)

# main()
print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=[LI() for _ in range(n)]

  l=sorted(l,key=lambda x:x[2],reverse=True)

  for Cx in range(101):
    for Cy in range(101):
      H=l[0][2]+abs(l[0][0]-Cx)+abs(l[0][1]-Cy)
      f=True
      for x,y,h in l[1:]:
        if h!=H-abs(x-Cx)-abs(y-Cy):
          f=False
          break
      if f:
        return str(Cx)+' '+str(Cy)+' '+str(H)

# main()
print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=[LI() for _ in range(n)]

  l=sorted(l,key=lambda x:x[2],reverse=True)

  for Cx in range(101):
    for Cy in range(101):
      H=-inf
      f=True
      for x,y,h in l:
        if h==0:
          continue
        if H==-inf:
          _H=abs(x-Cx)+abs(y-Cy)+h
          if _H>=1:
            H=_H
        else:
          if h!=H-abs(x-Cx)-abs(y-Cy):
            f=False
            break
      if f:
        return str(Cx)+' '+str(Cy)+' '+str(H)

# main()
print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=[LI() for _ in range(n)]

  for Cx in range(101):
    for Cy in range(101):
      H=-inf
      f=True
      for x,y,h in l:
        if h==0:
          continue
        if H==-inf:
          _H=abs(x-Cx)+abs(y-Cy)+h
          if _H>=1 and _H<=100:
            H=_H
        else:
          if h!=H-abs(x-Cx)-abs(y-Cy):
            f=False
            break
      if f:
        return str(Cx)+' '+str(Cy)+' '+str(H)

# main()
print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=[LI() for _ in range(n)]

  for Cx in range(101):
    for Cy in range(101):
      H=-inf
      f=True
      for x,y,h in l:
        if h==0:
          continue
        if H==-inf:
          _H=abs(x-Cx)+abs(y-Cy)+h
          if _H>=1:
            H=abs(x-Cx)+abs(y-Cy)+h
        else:
          if h!=H-abs(x-Cx)-abs(y-Cy):
            f=False
            break
      if f:
        return str(Cx)+' '+str(Cy)+' '+str(H)

# main()
print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=[LI() for _ in range(n)]

  for Cx in range(101):
    for Cy in range(101):
      H=-inf
      f=True
      for x,y,h in l:
        if H==-inf:
          if h==0:
            continue
          H=abs(x-Cx)+abs(y-Cy)+h
        else:
          if h==0:
            continue
          if h!=H-abs(x-Cx)-abs(y-Cy):
            f=False
            break
      if f:
        return str(Cx)+' '+str(Cy)+' '+str(H)

# main()
print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=[LI() for _ in range(n)]

  for Cx in range(101):
    for Cy in range(101):
      H=-inf
      f=True
      for x,y,h in l:
        if h==0:
          continue
        if H==-inf:
          H=abs(x-Cx)+abs(y-Cy)+h
        else:
          if h!=H-abs(x-Cx)-abs(y-Cy):
            f=False
            break
      if f:
        return str(Cx)+' '+str(Cy)+' '+str(H)

# main()
print(main())

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
ok=False
for i in range(n):
  if a[i][2]==0:
    ok=True
for cx in range(101):
  for cy in range(101):
    s=0
    d={}
    for k in range(n):
      if a[k][2]==0:
        s=max(s,abs(a[k][0]-cx)+abs(a[k][1]-cy))
      else:
        if a[k][2]+abs(a[k][0]-cx)+abs(a[k][1]-cy) not in d:
          d[a[k][2]+abs(a[k][0]-cx)+abs(a[k][1]-cy)]=1
    if len(list(d))==1:
      c=list(d)
      if ok:
        if 1<=c[0]<=s:
          print(cx,cy,c[0])
          exit()
      else:
        if 1<=c[0]:
          print(cx,cy,c[0])
          exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
ok=False
for i in range(n):
  if a[i][2]==0:
    ok=True
for cx in range(101):
  for cy in range(101):
    s=1
    d={}
    for k in range(n):
      if a[k][2]==0:
        s=max(s,abs(a[k][0]-cx)+abs(a[k][1]-cy))
      else:
        if a[k][2]+abs(a[k][0]-cx)+abs(a[k][1]-cy) not in d:
          d[a[k][2]+abs(a[k][0]-cx)+abs(a[k][1]-cy)]=1
    if len(list(d))==1:
      c=list(d)
      if ok:
        if 1<=c[0]<=s:
          print(cx,cy,c[0])
          exit()
      else:
        if 1<=c[0]:
          print(cx,cy,c[0])
          exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
x=[];y=[];h=[]
for i in range(N):
    xi,yi,hi=map(int,input().split())
    if hi>0: # （この問題では）hi=0のときは有意な情報がない？
        x.append(xi);y.append(yi);h.append(hi)
n=len(h)

fa=False
for CX in range(101):
    if fa:
        break
    for CY in range(101):
        f=lambda hi,xi,yi:hi+abs(xi-CX)+abs(yi-CY)
        H=f(h[0],x[0],y[0])
        fc=True
        for i in range(1,n):
            if H!=f(h[i],x[i],y[i]):
                fc=False
                break
        if fc:
            print(CX,CY,H)
            fa=True
            break

Submission status: Wrong Answer

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

candidates =[]

for cx in range(101):
    for cy in range(101):
        ch = None
        for x,y,h in xyh:
            if h == 0:
                continue
            if ch == None:
                ch = h + abs(x-cx) + abs(y-cy)
                continue

            if ch != h + abs(x-cx) + abs(y-cy):
                break

            xyh_c = (cx, cy, ch)
            candidates.append(xyh_c)

for xyh_c in candidates:
    cx, cy, ch = xyh_c
    for x,y,h in xyh:
        if h != max(ch - abs(x-cx) - abs(y-cy) ,0):
            break
    else:
        print(cx, cy, ch)
        exit()

Submission status: Wrong Answer

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

candidates =[]

for cx in range(101):
    for cy in range(101):
        ch = None
        okflag = True
        for x,y,h in xyh:
            if h == 0 or okflag == False:
                continue
            if ch == None:
                ch = h + abs(x-cx) + abs(y-cy)
                continue

            if ch != h + abs(x-cx) + abs(y-cy):
                    okflag = False
                    break


        if okflag == True:
            xyh_c = (cx, cy, ch)
            candidates.append(xyh_c)

okflag = True
for xyh_c in candidates:
    cx, cy, ch = xyh_c
    for x,y,h in xyh:
        if h != max(ch - abs(x-cx) - abs(y-cy) ,0):
            okflag = False
            break

    if okflag == True:
        print(cx, cy, ch)
        exit()

Submission status: Wrong Answer

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

candidates =[]

for cx in range(101):
    for cy in range(101):
        ch = None
        okflag = True
        for x,y,h in xyh:
            if ch == None:
                ch = h + abs(x-cx) + abs(y-cy)
                continue
            if ch != h + abs(x-cx) + abs(y-cy):
                okflag = False
                break

        if okflag == True:
            xyh_c = (cx, cy, ch)
            candidates.append(xyh_c)

okflag = True
for xyh_c in candidates:
    cx, cy, ch = xyh_c
    for x,y,h in xyh:
        if h != max(ch - abs(x-cx) - abs(y-cy) ,0):
            okflag = False
            break

    if okflag == True:
        print(cx, cy, ch)
        exit()

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        ch = None
        okflag = True
        for x,y,h in xyh:
            if ch == None:
                ch = h + abs(x-cx) + abs(y-cy)
                continue
            if h == 0:
                if ch > abs(x-cx) + abs(y-cy):
                    okflag = False
                    break
                continue

            if ch != h + abs(x-cx) + abs(y-cy):
                okflag = False
                break

        if okflag == True:
            print(cx, cy, ch)
            exit()

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        ch = None
        okflag = True
        for x,y,h in xyh:
            if h == 0 or okflag == False:
                continue
            if ch == None:
                ch = h + abs(x-cx) + abs(y-cy)
                continue

            if ch != h + abs(x-cx) + abs(y-cy):
                    okflag = False
                    break

        if okflag == True:
            print(cx, cy, ch)
            exit()

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        x0, y0, h0 = xyh[0]
        H = h0 + abs(x0-cx) + abs(y0-cy)
        okflag = True
        for x,y,h in xyh[1:]:
            if H != h + abs(x-cx) + abs(y-cy):
                okflag = False
                break

        if okflag == True:
            print(cx, cy, H)

Submission status: Wrong Answer

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

def calcH(x,y,h,Cx,Cy):
    if h>0:
        return(h+abs(x-Cx)+abs(y-Cy))
    return -1

for Cx in range(100+1):
    for Cy in range(100+1):
        H=-1
        for x,y,h in xyh:
            Hi=calcH(x,y,h,Cx,Cy)
            if Hi==-1:
                if Hi > abs(x-Cx)+abs(y-Cy):
                    break
                continue
            if H==-1:
                H=Hi
            elif Hi!=H:
                break
        else:
            print(Cx,Cy,H)
            exit()

Submission status: Wrong Answer

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

def calcH(x,y,h,Cx,Cy):
    if h>0:
        return(h+abs(x-Cx)+abs(y-Cy))
    return -1

for Cx in range(100+1):
    for Cy in range(100+1):
        H=-1
        for x,y,h in xyh:
            Hi=calcH(x,y,h,Cx,Cy)
            if H==-1:
                H=Hi
            else:
                if Hi==-1:
                    if Hi > abs(x-Cx)+abs(y-Cy):
                        break
                elif Hi!=H:
                    break
        else:
            print(Cx,Cy,H)
            exit()

Submission status: Wrong Answer

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

for Cx in range(100+1):
    for Cy in range(100+1):
        x0,y0,h0=xyh[0]
        H0=h0+abs(x0-Cx)+abs(y0-Cy)
        for i in range(1,len(xyh)):
            xi,yi,hi=xyh[i]
            Hi=hi+abs(xi-Cx)+abs(yi-Cy)
            if Hi!=H0:
                break
        else:
            print(Cx,Cy,H0)
            exit()

Submission status: Wrong Answer

Solution code:
import itertools
import os
import sys

import numpy as np

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

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
X, Y, H = list(zip(*[map(int, sys.stdin.buffer.readline().split()) for _ in range(N)]))
X = np.array(X, dtype=int)
Y = np.array(Y, dtype=int)
H = np.array(H, dtype=int)

# ゼロのやつ使いたくない
idx = (H > 0).argmin()
# 全探索して矛盾がないのを探す
for x, y in itertools.product(range(101), range(101)):
    height = H[idx] + abs(X[idx] - x) + abs(Y[idx] - y)
    ok = np.all(np.maximum(0, height - (np.abs(X - x) + np.abs(Y - y))) == H)
    if ok:
        print(x, y, height)
        exit()

Submission status: Wrong Answer

Solution code:
import itertools
import os
import sys

import numpy as np

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

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
X, Y, H = list(zip(*[map(int, sys.stdin.buffer.readline().split()) for _ in range(N)]))
X = np.array(X, dtype=int)
Y = np.array(Y, dtype=int)
H = np.array(H, dtype=int)

# ゼロのやつ使いたくない
idx = (H > 0).argmin()
# 全探索して矛盾がないのを探す
for x, y in itertools.product(range(101), range(101)):
    height = H[idx] + abs(X[idx] - x) + abs(Y[idx] - y)
    ok = np.all(height - (np.abs(X - x) + np.abs(Y - y)) == H)
    if ok:
        print(x, y, height)
        exit()

Submission status: Wrong Answer

Solution code:
import itertools
import os
import sys

import numpy as np

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

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
X, Y, H = list(zip(*[map(int, sys.stdin.buffer.readline().split()) for _ in range(N)]))
X = np.array(X, dtype=int)
Y = np.array(Y, dtype=int)
H = np.array(H, dtype=int)

# 全探索して矛盾がないのを探す
for x, y in itertools.product(range(101), range(101)):
    height = H[0] + abs(X[0] - x) + abs(Y[0] - y)
    ok = np.all(height - (np.abs(X - x) + np.abs(Y - y)) == H)
    if ok:
        print(x, y, height)
        exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
data = []
for i in range(n):
    x, y, h = map(int, input().split())
    data.append([x,y,h])
data.sort(reverse=True, key = lambda x:x[2])
for Cx in range(0,101):
    for Cy in range(0,101):
        for i in range(len(data)):
            height = data[i][2] + abs(Cx - data[i][0]) + abs(Cy - data[i][1])
            if i == 0:
                preH = height
            if preH != height:
                break
            else:
                preH = height
                if i == len(data) - 1:
                    print("{} {} {}".format(Cx,Cy,height))
                    exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
data = []
for i in range(n):
    x, y, h = map(int, input().split())
    data.append([x,y,h])
for Cx in range(0,101):
    for Cy in range(0,101):
        for i in range(len(data)):
            height = data[i][2] + abs(Cx - data[i][0]) + abs(Cy - data[i][1])
            if height < 0:
                continue
            if i == 0:
                preH = height
            if preH != height:
                break
            else:
                preH = height
                if i == len(data) - 1:
                    print("{} {} {}".format(Cx,Cy,height))
                    exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
data = []
for i in range(n):
    x, y, h = map(int, input().split())
    data.append([x,y,h])
for Cx in range(0,101):
    for Cy in range(0,101):
        for i in range(len(data)):
            height = data[i][2] + abs(Cx - data[i][0]) + abs(Cy - data[i][1])
            if height < 0:
                break
            if i == 0:
                preH = height
            if preH != height:
                break
            else:
                preH = height
                if i == len(data) - 1:
                    print("{} {} {}".format(Cx,Cy,height))
                    exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
data = []
for i in range(n):
    x, y, h = map(int, input().split())
    if h > 0:
        data.append([x,y,h])
for Cx in range(0,101):
    for Cy in range(0,101):
        for i in range(len(data)):
            height = data[i][2] + abs(Cx - data[i][0]) + abs(Cy - data[i][1])
            if i == 0:
                preH = height
            if preH != height:
                break
            else:
                preH = height
                if i == len(data) - 1:
                    print("{} {} {}".format(Cx,Cy,height))
                    exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
data = []
for i in range(n):
    x, y, h = map(int, input().split())
    if h > 0:
        data.append([x,y,h])
for Cx in range(0,101):
    for Cy in range(0,101):
        for i in range(len(data)):
            height = data[i][2] + abs(Cx - data[i][0]) + abs(Cy - data[i][1])
            if i == 0:
                preH = height
            if preH != height:
                break
            else:
                preH = height
            if i == len(data) - 1:
                print("{} {} {}".format(Cx,Cy,height))

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    xn = []
    yn = []
    hn = []
    for i in range(N):
        xi, yi, hi = map(int, input().split())
        xn.append(xi)
        yn.append(yi)
        hn.append(hi)
    for Cx in range(101):
        for Cy in range(101):
            last = None
            flg = True
            for i in range(N):
                if 0 == hn[i]:
                    continue
                H = abs(xn[i] - Cx) + abs(yn[i] - Cy) + hn[i]
                if H < 1:
                    flg = False
                    break
                if last:
                    if H != last:
                        flg = False
                        break
                last = H
            if not flg:
                continue
            for i in range(N):
                if 0 == hn[i]:
                    h = abs(xn[i] - Cx) + abs(yn[i] - Cy)
                    if h != H:
                        flg = False
                        break
            if not flg:
                continue
            print(Cx, Cy, H)
            return


main()

Submission status: Wrong Answer

Solution code:

N = int(input())
C = []

for i in range(N):
  x, y, z = map(int, input().split())
  C.append((x, y, z))

for X in range(101):
  for Y in range(101):

    hs = set()

    for i in range(N):
      x, y, h = map(int, C[i])
      if h > 0:
        hs.add(abs(x-X) + abs(y-Y) + h)
      if i == N - 1 and len(hs) == 1:
        print(X, Y, abs(x-X) + abs(y-Y) + h)

Submission status: Wrong Answer

Solution code:
# 全探索を試みるもWAを解決できず
# ただ、凡ミスというか、復習するほどでもない

N = int(input())
C = []

for i in range(N):
  x, y, z = map(int, input().split())
  C.append((x, y, z))

for X in range(101):
  for Y in range(101):

    hs = set()

    for i in range(N):
      x, y, h = map(int, C[i])
      if h > 0:
        hs.add(abs(x-X) + abs(y-Y) + h)
      if i == N - 1 and len(hs) <= 0:
        if len(hs) == 1 or 0 in hs:
          print(X, Y, abs(x-X) + abs(y-Y) + h)

Submission status: Wrong Answer

Solution code:
# 全探索を試みるもWAを解決できず
# ただ、凡ミスというか、復習するほどでもない

N = int(input())
C = []

for i in range(N):
  x, y, z = map(int, input().split())
  C.append((x, y, z))

for X in range(101):
  for Y in range(101):

    hs = set()
    for i in range(N):
      x, y, h = map(int, C[i])
      hs.add(abs(x-X) + abs(y-Y) + h)
      if i == N - 1 and len(hs) <= 2:
        if len(hs) == 1 or 0 in hs:
          print(X, Y, abs(x-X) + abs(y-Y) + h)

Submission status: Wrong Answer

Solution code:

N = int(input())
C = []

for i in range(N):
  x, y, z = map(int, input().split())
  C.append((x, y, z))

for X in range(101):
  for Y in range(101):

    hs = set()
    for i in range(N):
      x, y, h = map(int, C[i])
      hs.add(abs(x-X) + abs(y-Y) + h)
      if i == N - 1 and len(hs) == 1:
        print(X, Y, abs(x-X) + abs(y-Y) + h)

Submission status: Wrong Answer

Solution code:

N = int(input())
C = []

for i in range(N):
  x, y, z = map(int, input().split())
  C.append((x, y, z))

ans = None

for X in range(101):
  for Y in range(101):

    hs = set()

    for i in range(N):
      x, y, h = map(int, C[i])
      hs.add(abs(x-X) + abs(y-Y) + h)
      if i == N - 1 and len(hs) == 1:
        print(X, Y, abs(x-X) + abs(y-Y) + h)
        exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = []
for i in range(n):
    xyh.append(list(map(int,input().split())))
flag = False
for cx in range(101):
    if flag:
        break
    for cy in range(101):
        h1 = set()
        for x,y,h in xyh:
            if h != 0:
                h1.add(h + abs(cx-x)+abs(cy-y))
        if len(h1) == 1:
            ah = list(h1)[0]
            ax = cx
            ay = cy
            flag = True
            break
print(ax,ay,ah)