Ideal Pyramid
Gym - 102411I
https://vjudge.net/problem/Gym-102411I/origin
主要突破点在45度,而且这个正方形的边是平行于坐标轴的,让每个柱子全都沿着4个方向摔倒就可以了,然后分别取最大最小值,柱子就在中间
#include <bits/stdc++.h> #define inf 2333333333333333 #define N 1000010 #define p(a) putchar(a) #define For(i,a,b) for(long long i=a;i<=b;++i) //by war //2020.9.21 using namespace std; long long n,l,r,u,d; struct node{ long long x; long long y; long long h; }a[N]; void in(long long &x){ long long y=1;char c=getchar();x=0; while(c<'0'||c>'9'){if(c=='-')y=-1;c=getchar();} while(c<='9'&&c>='0'){ x=(x<<1)+(x<<3)+c-'0';c=getchar();} x*=y; } void o(long long x){ if(x<0){p('-');x=-x;} if(x>9)o(x/10); p(x%10+'0'); } signed main(){ in(n); l=inf;r=-inf;d=inf;u=-inf; For(i,1,n){ in(a[i].x);in(a[i].y);in(a[i].h); l=min(l,a[i].x-a[i].h); r=max(r,a[i].x+a[i].h); d=min(d,a[i].y-a[i].h); u=max(u,a[i].y+a[i].h); } o((l+r)/2);p(' ');o((u+d)/2);p(' '); if(r-l>=u-d) o((r-l+(r-l)%2)/2); else o((u-d+(u-d)%2)/2); return 0; }