You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
775 B
C++

#include <bits/stdc++.h>
using namespace std;
struct
{
int x, y, h;
} a[105];
int main()
{
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].h);
for (int i = 0; i < n && a->h == 0; i++)
if (a[i].h)
iter_swap(a + i, a);
for (int i = 0; i <= 100; i++)
for (int j = 0; j <= 100; j++)
{
int pre = a->h + abs(i - a->x) + abs(j - a->y);
bool flag = true;
for (int k = 0; k < n && flag; k++)
if (max(pre - abs(i - a[k].x) - abs(j - a[k].y), 0) != a[k].h)
flag = false;
if (flag)
return printf("%d %d %d", i, j, pre), 0;
}
return 0;
}