QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#261132 | #6639. Disk Tree | ucup-team1198# | AC ✓ | 941ms | 211992kb | C++20 | 13.2kb | 2023-11-22 18:09:13 | 2023-11-22 18:09:14 |
Judging History
answer
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ld, ld> pld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
mt19937 rr(998244353);
void rs(vector<int>& v) {
for (int i = 1; i < sz(v); ++i) {
int j = rr() % (i + 1);
swap(v[i], v[j]);
}
}
struct pt {
ll x, y;
int id;
pt() {}
pt(ll x, ll y, int id = -1) : x(x), y(y), id(id) {}
bool operator<(const pt& other) const {
if (x != other.x) {
return x < other.x;
}
return y < other.y;
}
pt operator-(const pt& other) const {
return {x - other.x, y - other.y};
}
};
ll cross(const pt& p, const pt& q) {
return p.x * q.y - p.y * q.x;
}
ll dot(const pt& p, const pt& q) {
return p.x * q.x + p.y * q.y;
}
struct triangle {
int e[3];
triangle(int a, int b, int c) {
e[0] = a, e[1] = b, e[2] = c;
}
triangle() {}
};
const int nmax = 2.5e6 + 100;
const int emax = nmax * 3;
pii edges[emax];
int g[emax];
triangle triangles[nmax];
vector<pt> p;
int ptre = 0;
int ptr = 0;
int getOther(int v, int a, int b) {
triangle& t = triangles[v];
for (int i = 0; i < 3; ++i) {
int j = t.e[i];
int u = edges[j].first, v = edges[j].second;
if (u != a && u != b) {
return u;
}
if (v != a && v != b) {
return v;
}
}
assert(false);
}
int getId(int v, int a, int b) {
triangle& t = triangles[v];
for (int i = 0; i < 2; ++i) {
int j = t.e[i];
if (edges[j].first + edges[j].second == a + b) {
return j;
}
}
return t.e[2];
}
int getSide(int a, int u, int v) {
assert(a != u && a != v && a >= 0);
if (u >= 0 && v >= 0) {
ll val = cross(p[a] - p[u], p[v] - p[u]);
return (val > 0 ? 1 : (val == 0 ? 0 : -1));
}
if (u == -1 && v == -2) {
return -1;
}
if (u == -2 && v == -1) {
return 1;
}
int ans = (p[a] < p[max(u, v)] ? 1 : -1);
if (u == - 1 || v == -2) {
ans *= (-1);
}
return ans;
}
bool inside(int i, int a, int b = -3, int c = -1) {
if (i < 0) {
return false;
}
if (b == -3) {
int t = a;
int j = triangles[t].e[0];
a = edges[j].first, b = edges[j].second;
c = getOther(t, a, b);
}
int cnt = 0;
if (a < 0) {
++cnt;
}
if (b < 0) {
++cnt;
}
if (c < 0) {
++cnt;
}
int arr[3];
if (cnt >= 2) {
arr[0] = -1, arr[1] = a + b + c + 3, arr[2] = -2;
} else if (cnt == 0) {
arr[0] = a;
if (cross(p[b] - p[a], p[c] - p[a]) < 0) {
arr[1] = b, arr[2] = c;
} else {
arr[1] = c, arr[2] = b;
}
} else if (cnt == 1) {
if (b < 0) {
swap(a, b);
} else if (c < 0) {
swap(a, c);
}
arr[0] = a;
if (a == -1) {
if (p[c] < p[b]) {
arr[1] = b, arr[2] = c;
} else {
arr[1] = c, arr[2] = b;
}
} else {
if (p[b] < p[c]) {
arr[1] = b, arr[2] = c;
} else {
arr[1] = c, arr[2] = b;
}
}
}
for (int j = 0; j < 3; ++j) {
int u = arr[j], v = arr[(j + 1) % 3];
if (u < 0 && v < 0) {
continue;
}
if (u >= 0 && v >= 0) {
if (cross(p[i] - p[u], p[v] - p[u]) < 0) {
return false;
}
} else if (u == -1) {
if (p[v] < p[i]) {
return false;
}
} else if (v == -1) {
if (p[i] < p[u]) {
return false;
}
} else if (u == -2) {
if (p[i] < p[v]) {
return false;
}
} else if (v == -2) {
if (p[u] < p[i]) {
return false;
}
}
}
return true;
}
bool onSegment(int i, int a, int b) {
pt u = p[a] - p[i], v = p[b] - p[i];
return cross(u, v) == 0 && dot(u, v) <= 0;
}
bool onEdge(int i, int id) {
int u = edges[id].first, v = edges[id].second;
if (u >= 0 && v >= 0) {
return onSegment(i, u, v);
}
return false;
}
struct edgeInfo {
int t[2];
int pos[2];
edgeInfo() {
t[0] = t[1] = pos[0] = pos[1] = -1;
}
edgeInfo(int x, int y) {
t[0] = x, pos[0] = y;
t[1] = pos[1] = -1;
}
};
edgeInfo info[emax];
void change(int e, int tOld, int t, int pos) {
if (info[e].t[0] == tOld) {
info[e].t[0] = t;
info[e].pos[0] = pos;
} else {
info[e].t[1] = t;
info[e].pos[1] = pos;
}
}
bool inside(const pt& a, const pt& b, const pt& c, const pt& d) {
pt u1 = a - c, v1 = b - c;
pt u2 = a - d, v2 = b - d;
return ld(abs(cross(u1, v1))) * dot(u2, v2) + ld(abs(cross(u2, v2))) * dot(u1, v1) < 0;
}
queue<int> qu;
int common;
void legalize() {
while (!qu.empty()) {
int id = qu.front();
qu.pop();
if (info[id].t[1] == -1) {
continue;
}
int i, j, k, l;
i = edges[id].first, j = edges[id].second;
int t1 = info[id].t[0], t2 = info[id].t[1];
k = getOther(t1, i, j), l = getOther(t2, i, j);
int a = getId(t1, i, k);
int b = getId(t1, j, k);
int c = getId(t2, i, l);
int d = getId(t2, j, l);
bool flip = false;
if (i < 0 || j < 0) {
if (inside(i, j, k, l) || inside(j, i, k, l)) {
continue;
}
} else {
int sgn1 = getSide(i, k, l), sgn2 = getSide(j, k, l);
if (sgn1 == 0 || sgn2 == 0 || sgn1 == sgn2) {
continue;
}
}
if (i < 0 || j < 0 || k < 0 || l < 0) {
if (min(i, j) < min(k, l)) {
flip = true;
}
} else {
if (inside(p[i], p[j], p[k], p[l])) {
flip = true;
}
}
if (flip) {
edges[ptre++] = {k, l};
triangles[ptr++] = {ptre - 1, a, c};
change(a, t1, ptr - 1, 1);
change(c, t2, ptr - 1, 2);
change(ptre - 1, -1, ptr - 1, 0);
triangles[ptr++] = {ptre - 1, b, d};
change(b, t1, ptr - 1, 1);
change(d, t2 , ptr - 1, 2);
change(ptre - 1, -1, ptr - 1, 0);
g[t1 * 3] = ptr - 2;
g[t1 * 3 + 1] = ptr - 1;
g[t2 * 3] = ptr - 2;
g[t2 * 3 + 1] = ptr - 1;
if (common == k) {
qu.push(c);
qu.push(d);
} else {
qu.push(a);
qu.push(b);
}
}
}
}
ll dist2(const pt& a, const pt& b) {
return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}
struct edge {
int u, v;
ll cost;
bool operator<(const edge& other) const {
return cost < other.cost;
}
};
vector<int> parent;
vector<int> ssize;
vector<vector<int> > subtree;
vector<vector<int> > w;
vector<pii> zapr;
vector<array<int, 2>> solve(vector<array<int, 2>> pt_) {
int n = pt_.size();
memset(g, -1, sizeof(g));
ptr = 0;
ptre = 0;
p.resize(n);
vector<int> newId(n);
for (int i = 0; i < n; ++i) {
p[i].x = pt_[i][0];
p[i].y = pt_[i][1];
p[i].id = i;
}
sort(all(p));
reverse(all(p));
for (int i = 0; i < n; ++i) {
newId[p[i].id] = i;
}
edges[ptre++] = {-1, 0};
edges[ptre++] = {0, -2};
edges[ptre++] = {-2, -1};
triangles[ptr++] = {0, 1, 2};
info[0] = {0, 0};
info[1] = {0, 1};
info[2] = {0, 2};
vector<int> perm;
for (int i = 1; i < n; ++i) {
perm.pb(i);
}
rs(perm);
for (int i = 0; i < sz(perm); ++i) {
int v = 0;
while (g[v * 3] != -1) {
if (g[v * 3 + 2] == -1) {
int id = g[v * 3];
int j = triangles[id].e[0];
int a = edges[j].first, b = edges[j].second;
int c = getOther(id, a, b);
int sgn1 = getSide(perm[i], a, b);
int sgn2 = getSide(c, a, b);
if (sgn1 == 0 || sgn1 == sgn2) {
v = id;
} else {
v = g[v * 3 + 1];
}
} else {
bool done = false;
for (int z = 0; z + 1 < 3; ++z) {
int to = g[v * 3 + z];
if (inside(perm[i], to)) {
done = true;
v = to;
break;
}
}
if (!done) {
v = g[v * 3 + 2];
}
}
}
int on = -1;
for (int z = 0; z < 3; ++z) {
int j = triangles[v].e[z];
if (onEdge(perm[i], j)) {
on = j;
break;
}
}
if (on == -1) {
int j = triangles[v].e[0];
int a, b, c;
a = edges[j].first, b = edges[j].second;
c = getOther(v, a, b);
edges[ptre++] = {perm[i], a};
edges[ptre++] = {perm[i], b};
edges[ptre++] = {perm[i], c};
int k = ptre;
triangles[ptr++] = {triangles[v].e[0], k - 2, k - 3};
change(k - 2, -1, ptr - 1, 1);
change(k - 3, -1, ptr - 1, 2);
change(triangles[v].e[0], v, ptr - 1, 0);
triangles[ptr++] = {getId(v, b, c), k - 1, k - 2};
change(k - 1, -1, ptr - 1, 1);
change(k - 2, -1, ptr - 1, 2);
change(getId(v, b, c), v, ptr - 1, 0);
triangles[ptr++] = {getId(v, c, a), k - 3, k - 1};
change(k - 3, -1, ptr - 1, 1);
change(k - 1, -1, ptr - 1, 2);
change(getId(v, c, a), v, ptr - 1, 0);
g[v * 3] = ptr - 1;
g[v * 3 + 1] = ptr - 2;
g[v * 3 + 2] = ptr - 3;
for (int z = 0; z < 3; ++z) {
qu.push(triangles[v].e[z]);
}
} else {
int a = edges[on].first, b = edges[on].second;
int u = info[on].t[1] + info[on].t[0] - v;
int c = getOther(v, a, b);
int d = getOther(u, a, b);
edges[ptre++] = {perm[i], a};
edges[ptre++] = {perm[i], b};
edges[ptre++] = {perm[i], c};
edges[ptre++] = {perm[i], d};
int k = ptre;
vector<int> vctx = {v, u};
vector<int> vctz = {c, d};
vector<int> vct = {a, b};
for (int j = 0; j < 2; ++j) {
int x = vctx[j];
int z = vctz[j];
for (int q = 0; q < 2; ++q) {
int id = getId(x, vct[q], z);
triangles[ptr++] = {k - 2 + j, k - 4 + q, id};
g[x * 3 + q] = ptr - 1;
change(id, x, ptr - 1, 2);
change(k - 4 + q, -1, ptr - 1, 1);
change(k - 2 + j, -1, ptr - 1, 0);
}
}
qu.push(getId(v, a, c));
qu.push(getId(v, c, b));
qu.push(getId(u, a, d));
qu.push(getId(u, b, d));
}
common = perm[i];
legalize();
}
vector<array<int, 2>> ee;
for (int v = 0; v < ptr; ++v) {
if (g[v * 3] != -1) {
continue;
}
for (int z = 0; z < 3; ++z) {
int j = triangles[v].e[z];
int u = edges[j].first, v = edges[j].second;
if (u < 0 || v < 0) {
continue;
}
ee.pb({p[u].id, p[v].id});
}
}
return ee;
}
const int MAXN = 2e5 + 100;
int dsu_p[MAXN], dsu_sz[MAXN];
int dsu_get(int v) {
return v == dsu_p[v] ? v : dsu_p[v] = dsu_get(dsu_p[v]);
}
bool join(int u, int v) {
u = dsu_get(u); v = dsu_get(v);
if (u == v) return false;
if (dsu_sz[u] < dsu_sz[v]) swap(u, v);;
dsu_sz[u] += dsu_sz[v];
dsu_p[v] = u;
return true;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<array<int, 2>> pt(n);
vector<int> r(n);
for (int i = 0; i < n; ++i) {
cin >> pt[i][0] >> pt[i][1] >> r[i];
}
auto res = solve(pt);
auto get_len = [&](int i, int j) {
ll dx = (pt[i][0] - pt[j][0]);
ll dy = (pt[i][1] - pt[j][1]);
return dx * dx + dy * dy - 1ll * r[i] * r[i] - 1ll * r[j] * r[j];
};
sort(res.begin(), res.end(), [&](array<int, 2> a, array<int, 2> b) {
return get_len(a[0], a[1]) < get_len(b[0], b[1]);
});
iota(dsu_p, dsu_p + n, 0);
fill(dsu_sz, dsu_sz + n, 1);
cout << "YES\n";
for (auto elem : res) {
if (join(elem[0], elem[1])) {
cout << pt[elem[0]][0] << " " << pt[elem[0]][1] << " ";
cout << pt[elem[1]][0] << " " << pt[elem[1]][1] << "\n";
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 153124kb
input:
3 1 0 3 10 10 6 0 5 1
output:
YES 1 0 0 5 0 5 10 10
result:
ok answer = 1
Test #2:
score: 0
Accepted
time: 3ms
memory: 153024kb
input:
2 1 1 1 3 3 1
output:
YES 1 1 3 3
result:
ok answer = 1
Test #3:
score: 0
Accepted
time: 4ms
memory: 155332kb
input:
5 10 10 10 2 0 1 20 20 1 3 20 1 20 0 1
output:
YES 3 20 10 10 2 0 10 10 10 10 20 20 20 0 10 10
result:
ok answer = 1
Test #4:
score: 0
Accepted
time: 11ms
memory: 155172kb
input:
10 29 29 2 28 55 10 99 81 4 17 82 10 45 88 10 48 68 10 0 8 10 98 95 10 34 0 10 17 24 10
output:
YES 17 24 29 29 98 95 99 81 48 68 45 88 17 24 0 8 48 68 28 55 28 55 29 29 45 88 17 82 34 0 17 24 48 68 99 81
result:
ok answer = 1
Test #5:
score: 0
Accepted
time: 7ms
memory: 155216kb
input:
100 490 783 12 666 460 55 561 245 6 223 323 25 3 520 77 225 161 24 514 190 16 997 914 100 412 265 100 374 610 36 296 854 39 601 901 2 307 21 100 390 422 24 940 414 32 332 438 35 553 992 100 235 775 3 656 901 37 770 417 22 649 305 100 448 84 3 375 939 77 910 847 9 776 357 37 743 97 100 371 502 39 508...
output:
YES 770 417 749 401 809 794 811 693 255 263 267 249 448 84 447 40 95 208 76 226 255 263 195 241 951 132 975 153 412 265 422 163 833 250 837 286 137 156 133 115 601 901 553 992 899 204 964 284 32 773 81 790 563 635 533 734 787 237 833 250 160 703 235 775 448 84 482 132 769 474 846 495 865 52 897 76 9...
result:
ok answer = 1
Test #6:
score: 0
Accepted
time: 0ms
memory: 155232kb
input:
200 2948 9798 687 3897 647 35 3918 587 28 1262 2717 206 1315 9524 20 2381 305 1000 4344 6858 20 6234 8949 53 5168 4772 85 5044 6109 158 72 7670 132 7300 1213 837 5427 2263 1000 1785 3009 276 6136 1421 43 1629 5620 29 6445 9489 242 8443 3141 1000 4118 4307 63 1874 5238 291 1964 5785 73 7794 3934 18 3...
output:
YES 8808 4438 9278 4357 3897 647 3918 587 6125 9979 6062 9827 9598 2086 9940 2103 9881 5238 9965 5083 1756 8604 2704 8279 4946 6252 5044 6109 3427 769 3524 778 9434 2844 9514 2928 2981 8806 2975 8690 3881 5104 3074 4508 7018 8858 7259 8795 4344 6858 4160 6939 8791 6984 8868 7083 3731 790 3524 778 61...
result:
ok answer = 1
Test #7:
score: 0
Accepted
time: 12ms
memory: 153336kb
input:
300 42942 37079 222 49441 21821 1695 61023 31153 561 86630 26307 352 36940 78253 213 7841 81086 626 47425 22290 374 17694 68695 648 38259 64794 998 43599 46942 9662 9204 2816 1965 38652 83568 4057 4046 29001 1034 72591 63214 587 75984 64859 1112 70005 72177 576 34522 52126 652 56627 48785 1747 78820...
output:
YES 97653 50419 97975 50437 66345 83699 65601 83613 60208 7681 59945 7276 48642 86091 49759 86207 38589 38309 39086 38101 77511 65089 77469 64494 888 90680 649 91204 27731 53830 26217 53454 26217 53454 26810 54901 73117 73768 73572 71685 80020 86672 81812 87290 83090 83694 80629 84138 10530 82824 11...
result:
ok answer = 1
Test #8:
score: 0
Accepted
time: 8ms
memory: 153268kb
input:
1000 558504245 246224785 100000000 971981730 913036757 1821458 198791767 482624549 5998171 540520619 353988177 8924682 183178222 46223569 9859905 118485076 22129062 7497235 274928891 417171180 372954 230079763 468235825 289869 859092765 562864738 5551376 129036518 743777318 3969979 265158223 3092933...
output:
YES 741963125 249632478 749654230 245631243 299731657 172180704 299412197 169909676 744268608 502811255 749780007 500202962 719129758 362901109 718859247 362033902 637773206 344877200 637256234 344115816 506923531 47961807 496800989 56076643 802986231 620294429 801971917 620730756 781123049 61470226...
result:
ok answer = 1
Test #9:
score: 0
Accepted
time: 8ms
memory: 155480kb
input:
3000 442876143 334276354 3627270 526253918 947313397 2498956 566692880 229330019 4243066 497859604 658736917 13012787 315969653 65582717 1400013 394215653 932651144 1655676 58249045 973232518 860150 860773683 959388251 1594726 23803673 921365885 5926749 730359196 818999592 1521282 971839312 22835235...
output:
YES 390223036 962557192 395065091 961684986 278141533 211881820 279342544 211481944 403421973 160674394 388540598 156256536 20056939 793312760 23989584 790455936 370084895 524700222 370053752 526851391 83605887 493352547 174473105 535104153 264607878 236174923 264565844 235783795 799403583 515048991...
result:
ok answer = 1
Test #10:
score: 0
Accepted
time: 16ms
memory: 154144kb
input:
7000 601805179 978984160 464352 918208048 607538668 2214109 328147216 806677103 3901695 961794394 719893281 1114470 453816635 992288784 274949 778724702 692479905 1170018 169287513 886715521 576156 812072299 118324465 93778 726229729 150105801 3593039 368683874 642143790 1277375 40087476 151799345 4...
output:
YES 147132881 538273755 124294320 540614604 382625944 278906969 382515546 278713564 697337247 794958320 696633780 793111357 992855761 910338438 987588473 906458142 704574232 313018143 704454970 314676892 564617520 977122934 560644939 974602541 15064352 99341679 13828463 98607732 669134218 735724279 ...
result:
ok answer = 1
Test #11:
score: 0
Accepted
time: 33ms
memory: 155960kb
input:
10000 645 4710 5 1554 4072 7 6505 2760 1 6125 8212 11 9802 9537 3 6584 4356 6 1104 6649 23 4580 2623 20 3107 2460 1 4689 1662 2 7815 161 14 8718 3658 28 2900 63 15 1741 7296 44 8380 4608 50 2212 8514 4 7919 3069 17 1638 6057 3 504 9867 18 7869 8021 14 866 9239 5 3452 8042 4 9049 7222 4 4447 1004 5 9...
output:
YES 5031 7923 5034 7922 6548 2638 6545 2639 9183 8362 9182 8365 1872 6231 1873 6228 2420 5385 2423 5386 5944 3595 5945 3599 2936 3267 2937 3263 6972 4187 6971 4183 2542 2107 2542 2110 4845 6849 4847 6846 2028 8861 2031 8864 4626 3789 4628 3786 8 141 9 136 4404 4604 4399 4603 970 9908 972 9912 2416 9...
result:
ok answer = 1
Test #12:
score: 0
Accepted
time: 401ms
memory: 181144kb
input:
100000 956095525 596102106 2 461544095 587257542 118 884402350 357055086 14228 547768407 186052059 263162 827807425 303694996 474924 692537425 44608243 131609 504660936 451030143 15134 207539367 899608364 20283 919236289 724317925 6 386476373 727023405 323 781914406 792770865 1064 411548762 2476126 ...
output:
YES 737182558 31629185 737205369 31606130 892696561 422861520 892145544 423239295 430638901 427457801 430648820 427446762 744488111 310224678 744495274 310246137 468728091 140185254 468718121 140164034 685322409 737069869 685305440 737074349 801637807 582451012 801681587 582450259 790259785 35554795...
result:
ok answer = 1
Test #13:
score: 0
Accepted
time: 936ms
memory: 210256kb
input:
200000 267774456 105702394 770 297991198 776424841 124 703700092 120262616 341808 212663821 221756923 367 195031049 705083745 66 692227605 63745620 1221 615879799 481139131 3053 93198187 239262367 141042 645539116 89213985 1679 312339485 547897747 2701 546940040 418847605 2 100457345 231142218 2 290...
output:
YES 163889476 458842538 163891615 458842028 358705832 491934961 358692903 491935195 719221461 705196880 719214287 705150980 420658973 241541045 420643702 241791571 132961695 944858198 132964006 944845277 124856885 154197112 124875617 154225385 403067710 904620546 403057447 904610511 180791485 507855...
result:
ok answer = 1
Test #14:
score: 0
Accepted
time: 936ms
memory: 211216kb
input:
200000 890760596 387635202 407021 845949678 865384827 250 298937825 444813049 30 257079208 603496538 24935 825947861 514433442 276 664047255 283065064 651111 481691537 759981944 616 953630211 233077236 207 716089940 174481709 876827 807394429 737990862 50258 9195111 176890156 946 209723712 839382384...
output:
YES 59157956 682658775 59137802 682714019 431661469 606950792 431664219 606947680 37424970 868633844 37425213 868638263 427359412 569407263 427356553 569412856 261325389 716730504 261317312 716722482 42875854 979775233 42869667 979779769 537699436 574021509 537706783 574024305 350569395 599780348 35...
result:
ok answer = 1
Test #15:
score: 0
Accepted
time: 941ms
memory: 210560kb
input:
200000 21940906 14228149 878 947616612 637746482 278 490310177 117451293 1714712 278642428 651582650 1 214397046 727562852 3 314365021 93147008 158746 367463298 30253119 650745 816993648 678947261 4384 503557517 182822048 1116 61881753 989787068 109052 632366340 971129473 26 870552310 805607887 5436...
output:
YES 651139377 352466867 651143559 352449533 563131562 15846284 563124826 15857612 341068183 885553276 341030340 885500742 906053958 526829681 906068588 526837851 326919810 781590564 326952582 782461575 900593420 202127323 900608717 202130723 611594653 687639225 611588232 687652845 295108631 80629811...
result:
ok answer = 1
Test #16:
score: 0
Accepted
time: 922ms
memory: 211476kb
input:
200000 81117 91365 1 68731 21152 3 37456 24002 2 37581 56006 3 52472 65837 1 68592 30967 2 37017 58189 11 21553 64504 95 94147 72332 80 82905 892 21 37593 40659 5 83451 10026 2 24925 11872 13 84418 48948 156 52378 43742 51 27379 10720 162 37042 54394 1 92324 20573 1 69506 96945 133 87826 40634 3 962...
output:
YES 59202 87553 59201 87555 29653 57147 29655 57145 43380 3898 43381 3901 30819 56218 30825 56217 64157 58502 64162 58501 48923 94799 48923 94795 31100 85233 31102 85227 64282 12876 64288 12878 21354 27574 21358 27576 54295 76742 54298 76738 386 95065 385 95061 14686 9123 14688 9116 59245 39601 5924...
result:
ok answer = 1
Test #17:
score: 0
Accepted
time: 24ms
memory: 154544kb
input:
10000 126758371 588314899 812231 238086622 378023315 890058 477126060 14900711 1191393 511712433 35095827 204725 651796639 43378716 2018310 308442866 596282834 2328087 42294570 231322805 1602825 168464157 357054887 2277954 224671652 693289331 2062259 616695889 175688410 1253251 385431057 29127383 18...
output:
YES 217879509 43380606 217827870 49054754 469400737 651069977 469387041 645397745 357064448 42290912 351317762 42119768 344394269 525085212 350011516 525567493 371040645 420043048 365380233 420093491 232368285 266114482 232326691 260271185 449291442 483938555 455147661 483312868 560958114 617164119 ...
result:
ok answer = 1
Test #18:
score: 0
Accepted
time: 140ms
memory: 163000kb
input:
40000 290669648 662085507 804601 669033554 119055358 638805 105668336 570987547 641107 70398923 679676225 1151529 67163601 217283316 655911 266292842 490670500 288695 332954119 213678087 316383 133514562 301390490 1150957 189198028 430695918 498385 52533444 508154472 662055 675557474 175423882 71076...
output:
YES 630142151 514500404 630170052 511619062 63314166 178503394 63480942 175676698 679211500 308695311 679535718 311526254 486517407 420567120 483687427 420371714 290629392 273688668 291105690 276509416 290826441 542521190 290777520 539648720 465751006 98675654 465627885 101516943 389136492 18154644 ...
result:
ok answer = 1
Test #19:
score: 0
Accepted
time: 308ms
memory: 174300kb
input:
79806 675311888 175949323 45152 668303725 415877398 705454 526993355 106652475 101518 306843353 465414670 733685 235164634 54490010 250702 237718215 128806833 416572 47406184 660535125 231461 217980403 334240174 311035 438155656 608919183 741482 175786440 138973185 691587 383453409 420621369 23780 1...
output:
YES 265157855 477556415 267138014 477739352 146249195 30169566 146065096 32173130 146401730 108908862 148415088 109129130 230073400 190485654 230134586 188450377 161269230 86938192 163297178 86766467 579286122 531837914 581293635 531873135 269883037 322048085 269836884 324059145 331912211 133939178 ...
result:
ok answer = 1
Test #20:
score: 0
Accepted
time: 931ms
memory: 211208kb
input:
199809 330527920 105087498 120223 601378677 222559216 191284 604605920 449476822 241005 435487497 286817733 303877 682929431 10980946 280834 393289259 673421713 256371 217818174 324382996 403684 307178253 324362921 334561 321290021 314861063 288503 661144513 394874427 31218 664021225 319719526 14923...
output:
YES 361974433 299416427 361976973 300671605 391763233 19099771 391621055 20363768 134699333 87705756 134742299 86440904 457450644 159737498 457471835 158477618 310378121 228731849 311637317 228689818 602913600 9708674 603072119 10963553 346096309 222371697 346189778 221106455 197501195 634535306 197...
result:
ok answer = 1
Test #21:
score: 0
Accepted
time: 658ms
memory: 201068kb
input:
200000 500000000 500000000 450000000 950000002 500000000 1 950000002 500014137 1 950000001 500028274 1 950000000 500042412 1 949999998 500056549 1 949999996 500070686 1 949999994 500084823 1 949999991 500098961 1 949999988 500113098 1 949999984 500127235 1 949999980 500141372 1 949999975 500155510 1...
output:
YES 758900943 868062907 758912505 868054774 758912505 131945226 758900943 131937093 97407994 701046459 97401679 701033812 97407994 298953541 97401679 298966188 730549507 886454301 730537367 886461543 730549507 113545699 730537367 113538457 777601494 854171445 777590368 854180165 777601494 145828555 ...
result:
ok answer = 1
Test #22:
score: 0
Accepted
time: 306ms
memory: 182724kb
input:
200000 1666 1666 1666 6664 1666 1666 11662 1666 1666 16660 1666 1666 21658 1666 1666 26656 1666 1666 31654 1666 1666 36652 1666 1666 41650 1666 1666 46648 1666 1666 51646 1666 1666 56644 1666 1666 61642 1666 1666 66640 1666 1666 71638 1666 1666 76636 1666 1666 81634 1666 1666 86632 1666 1666 91630 1...
output:
YES 889090888 1666 889085890 1666 12081832 1666 12076834 1666 12081832 1666 12086830 1666 107928478 1666 107933476 1666 827910370 1666 827905372 1666 760652284 1666 760657282 1666 174946660 1666 174941662 1666 174946660 1666 174951658 1666 706279042 1666 706274044 1666 706279042 1666 706284040 1666 ...
result:
ok answer = 1
Test #23:
score: 0
Accepted
time: 898ms
memory: 211200kb
input:
200000 1276 2177 1666 6143 1271 1666 12177 1577 1666 17105 1415 1666 21414 1758 1666 27078 1291 1666 31751 1856 1666 36681 2166 1666 42165 1914 1666 46298 2207 1666 51434 1925 1666 56782 1717 1666 61708 1408 1666 66612 1280 1666 71599 2168 1666 76405 1971 1666 81489 1694 1666 86696 2187 1666 91352 1...
output:
YES 811207609 1471 811211499 1462 657384161 1609 657388057 1495 39790200 2034 39786301 2129 383457674 1302 383453777 1498 49987213 1288 49991113 1431 392004261 1179 392000357 1160 861611331 1793 861607428 1921 807134239 1791 807138129 2135 149136434 1981 149132529 1870 864391311 1204 864395218 1216 ...
result:
ok answer = 1
Test #24:
score: 0
Accepted
time: 790ms
memory: 211016kb
input:
200000 1666 1666 1666 6588 2534 1666 11510 3402 1666 16432 4270 1666 21354 5138 1666 26276 6005 1666 31198 6873 1666 36120 7741 1666 41043 8609 1666 45965 9477 1666 50887 10345 1666 55809 11213 1666 60731 12081 1666 65653 12949 1666 70575 13817 1666 75497 14684 1666 80419 15552 1666 85341 16420 1666...
output:
YES 689937943 121656047 689942865 121656914 293155182 51692540 293150260 51691673 598904274 105604355 598909196 105605222 439138831 77433396 439133909 77432529 336036249 59253629 336031327 59252762 839258755 147985334 839253833 147984467 822971628 145113475 822976550 145114342 396533401 69920910 396...
result:
ok answer = 1
Test #25:
score: 0
Accepted
time: 305ms
memory: 187084kb
input:
200000 1666 1666 1666 1666 6664 1666 1666 11662 1666 1666 16660 1666 1666 21658 1666 1666 26656 1666 1666 31654 1666 1666 36652 1666 1666 41650 1666 1666 46648 1666 1666 51646 1666 1666 56644 1666 1666 61642 1666 1666 66640 1666 1666 71638 1666 1666 76636 1666 1666 81634 1666 1666 86632 1666 1666 91...
output:
YES 1666 889090888 1666 889085890 1666 12081832 1666 12076834 1666 12081832 1666 12086830 1666 107928478 1666 107933476 1666 827910370 1666 827905372 1666 760652284 1666 760657282 1666 174946660 1666 174941662 1666 174946660 1666 174951658 1666 706279042 1666 706274044 1666 706279042 1666 706284040 ...
result:
ok answer = 1
Test #26:
score: 0
Accepted
time: 914ms
memory: 211992kb
input:
200000 1238 1279 1666 1911 6266 1666 1278 11483 1666 1657 16880 1666 1637 22064 1666 1629 26455 1666 2087 31415 1666 1150 36477 1666 2020 41228 1666 1277 46249 1666 1331 51188 1666 1274 56871 1666 1709 61810 1666 1509 66281 1666 1922 71932 1666 2188 76257 1666 1947 81675 1666 2124 86511 1666 1231 91...
output:
YES 1441 805498786 1481 805494895 1360 786471398 1575 786467509 1654 728495702 1631 728499598 1167 772991800 1194 772987900 1266 7208229 1148 7204330 1942 807684010 2081 807687910 1308 639665146 1245 639661242 2203 712900840 2158 712896935 1653 924802141 1507 924806045 1390 893248670 1768 893244779 ...
result:
ok answer = 1
Test #27:
score: 0
Accepted
time: 0ms
memory: 155208kb
input:
2 1000000000 1000000000 1000000000 0 0 1
output:
YES 0 0 1000000000 1000000000
result:
ok answer = 1
Test #28:
score: 0
Accepted
time: 12ms
memory: 155080kb
input:
2 1000000000 1000000000 500000000 0 1000000000 499999999
output:
YES 0 1000000000 1000000000 1000000000
result:
ok answer = 1
Test #29:
score: 0
Accepted
time: 12ms
memory: 155380kb
input:
2 0 1000000000 499999999 0 0 500000000
output:
YES 0 0 0 1000000000
result:
ok answer = 1
Test #30:
score: 0
Accepted
time: 8ms
memory: 153152kb
input:
2 1000000000 1000000000 499999999 1000000000 0 500000000
output:
YES 1000000000 0 1000000000 1000000000
result:
ok answer = 1