Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define task "CONSTRUCT"
- #include <iostream>
- #include <cstdio>
- #include <iomanip>
- #include <cassert>
- using namespace std;
- using ll = long long;
- using ld = long double;
- constexpr int N = 1e5 + 5;
- int n;
- ll x[N], y[N];
- ld a[N], b[N];
- void Read()
- {
- cin >> n;
- for (int i = 1; i <= n; ++i)
- cin >> x[i] >> y[i];
- }
- ld SolveEquation(ll c1, ll c2)
- {
- // assert(!((c1 + c2) & 1));
- return (ld)1.0 * (c1 + c2) / 2;
- }
- void Cal(ll x[N], ld a[N], int n)
- {
- ll tmp = 0;
- for (int i = 1; i < n; ++i)
- if (i & 1)
- tmp = tmp + x[i] * 2;
- else
- tmp = tmp - x[i] * 2;
- a[1] = SolveEquation(x[n] * 2, tmp);
- for (int i = 2; i <= n; ++i)
- a[i] = x[i - 1] * 2 - a[i - 1];
- }
- void Constrain_4(ll x[N], ld a[N])
- {
- ld I2 = (x[1] + x[2]) / 2.0,
- I3 = (x[2] + x[3]) / 2.0,
- I4 = (x[3] + x[4]) / 2.0,
- I1 = (x[4] + x[1]) / 2.0,
- I = (x[1] + x[3]) / 2.0;
- // a_1 + I = 2I1 => a_1 = 2I1 - I
- a[1] = 2 * I1 - I;
- a[2] = 2 * I2 - I;
- a[3] = 2 * I3 - I;
- a[4] = 2 * I4 - I;
- }
- void Solve()
- {
- if (n == 4)
- {
- Constrain_4(x, a);
- Constrain_4(y, b);
- for (int i = 1; i <= n; ++i)
- cout << fixed << setprecision(2) << a[i] << " " << b[i] << "\n";
- }
- else
- {
- Cal(x, a, n);
- Cal(y, b, n);
- for (int i = 1; i <= n; ++i)
- cout << fixed << setprecision(2) << a[i] << " " << b[i] << "\n";
- }
- }
- 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();
- Solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement