Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define task "SPRESCUE"
- #include <iostream>
- #include <cstdio>
- #include <algorithm>
- using namespace std;
- using ll = long long;
- using ld = long double;
- template <class T>
- void read(T &x)
- {
- x = 0;
- register int c;
- while ((c = getchar()) && (c > '9' || c < '0'))
- ;
- for (; c >= '0' && c <= '9'; c = getchar())
- x = x * 10 + c - '0';
- }
- constexpr int N = 1e5 + 5;
- constexpr ll Inf = 1e17;
- int n;
- int x[N], y[N], z[N];
- int ooe;
- void Read()
- {
- //cin >> n;
- read(n);
- for (int i = 1; i <= n; ++i)
- {
- //cin >> x[i] >> y[i] >> z[i];
- read(x[i]);
- read(y[i]);
- read(z[i]);
- }
- x[0] = x[1];
- y[0] = y[1];
- z[0] = z[1];
- }
- bool Check(int p, int q, int r)
- {
- if (abs(p % 2) != abs(x[0] % 2))
- {
- ++p;
- ++q;
- ++r;
- }
- if (abs(q % 2) != abs(y[0] % 2) || abs(r % 2) != abs(z[0] % 2))
- return false;
- return true;
- }
- ll Get(ll p, ll q, ll r)
- {
- return max({abs(x[1] - p), abs(x[n] - p), abs(y[1] - q), abs(y[n] - q), abs(z[1] - r), abs(z[n] - r)});
- }
- void Sub_1()
- {
- sort(x + 1, x + n + 1);
- sort(y + 1, y + n + 1);
- sort(z + 1, z + n + 1);
- int p = (x[n] + x[1]) / 2,
- q = (y[n] + y[1]) / 2,
- r = (z[n] + z[1]) / 2;
- ll ans(Inf);
- for (int i = -100; i <= 100; ++i)
- for (int j = -100; j <= 100; ++j)
- for (int t = -100; t <= 100; ++t)
- if (Check(p + i, q + j, r + t))
- ans = min(ans, Get(p + i, q + j, r + t));
- cout << ans;
- }
- int32_t main()
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- if (fopen(task ".INP", "r"))
- {
- freopen(task ".INP", "r", stdin);
- freopen(task ".OUT", "w", stdout);
- }
- Read();
- Sub_1();
- }
Add Comment
Please, Sign In to add comment