QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#261216#6639. Disk Treeucup-team1198AC ✓1081ms213152kbC++2013.1kb2023-11-22 19:09:562023-11-22 19:09:57

Judging History

你现在查看的是最新测评结果

  • [2023-11-22 19:09:57]
  • 评测
  • 测评结果:AC
  • 用时:1081ms
  • 内存:213152kb
  • [2023-11-22 19:09:56]
  • 提交

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 sqrtl((ld)dx * dx + dy * dy) - r[i] - 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;
}

詳細信息

Test #1:

score: 100
Accepted
time: 12ms
memory: 153456kb

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: 4ms
memory: 153280kb

input:

2
1 1 1
3 3 1

output:

YES
1 1 3 3

result:

ok answer = 1

Test #3:

score: 0
Accepted
time: 0ms
memory: 153100kb

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: 10ms
memory: 151520kb

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
98 95 99 81
48 68 45 88
17 24 29 29
17 24 0 8
48 68 28 55
45 88 17 82
34 0 17 24
28 55 17 24
45 88 98 95

result:

ok answer = 1

Test #5:

score: 0
Accepted
time: 16ms
memory: 155400kb

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
560 422 649 305
468 868 375 939
742 210 743 97
204 512 92 366
448 84 447 40
205 100 307 21
964 284 837 286
809 794 811 693
293 965 375 939
865 52 981 11
296 854 375 939
374 610 304 613
563 635 445 639
252 629 160 703
899 204 964 284
160 703 119 603
508 524 458 464
116 850 67 952
95 208 76 226
13...

result:

ok answer = 1

Test #6:

score: 0
Accepted
time: 3ms
memory: 153072kb

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
3841 6121 4160 6939
1566 4450 1828 4099
5901 4668 5710 4771
7300 1213 6334 1443
4278 321 4775 842
4344 6858 4160 6939
4718 3379 4284 3385
9940 2103 9446 2407
7634 8387 8040 7929
8914 1613 8591 1690
2381 305 2395 2085
8844 424 9671 1058
8914 1613 8844 424
63 2852 147 1148
6908 4386 7502 5454
6908...

result:

ok answer = 1

Test #7:

score: 0
Accepted
time: 8ms
memory: 153140kb

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
59945 7276 59944 148
26217 53454 15549 49146
27055 9398 30743 15955
54720 46175 54156 44092
46373 81005 42729 76361
48642 86091 49555 87747
48642 86091 49759 86207
90608 87653 83657 87664
84773 93522 90608 87653
44439 62520 47866 62872
52186 6439 41631 8042
31302 83896 31276 94106
94134 62000 95...

result:

ok answer = 1

Test #8:

score: 0
Accepted
time: 24ms
memory: 155356kb

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
935651301 194859808 969959032 159770753
387522770 540197621 407855873 545059764
709709305 895610707 803699647 926616709
957410466 524462618 951999910 625259461
805699634 244675073 842117276 266665723
21557591 472068545 9506894 429721563
703832774 417735074 606567077 439287468
931839380 369935766...

result:

ok answer = 1

Test #9:

score: 0
Accepted
time: 16ms
memory: 155432kb

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
290472947 49435962 281268489 57797275
338210244 314788266 336396685 305520991
504627632 484355357 511679958 472770476
381063725 888883942 385991211 898942427
109415638 638809020 106386194 648286633
445317829 548859629 443740179 557407886
43444734 915079984 34366085 912644950
239102406 146013267 ...

result:

ok answer = 1

Test #10:

score: 0
Accepted
time: 28ms
memory: 155816kb

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
948962033 192473096 952741689 195407765
335978465 621454749 302136515 662205213
181702051 225543777 191910423 222317550
112166501 828136227 108639664 832228566
360578188 879715637 367657522 874112964
660724674 691603733 655570370 704845685
254575690 688033302 252674008 690568763
324824173 575139...

result:

ok answer = 1

Test #11:

score: 0
Accepted
time: 31ms
memory: 157992kb

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
8379 5377 8980 5036
3934 629 3270 702
1698 6223 1697 6744
3511 4090 2832 3345
7950 3959 7500 3958
7062 3959 7500 3958
7501 4394 7500 3958
5924 7630 5549 7629
8576 4074 8575 4441
8362 3787 8576 4074
415 2477 234 2188
693 2181 1295 2987
3511 4090 4516 4088
538 3645 1295 2987
5596 5993 5943 6933
46...

result:

ok answer = 1

Test #12:

score: 0
Accepted
time: 469ms
memory: 183420kb

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
892696561 422861520 892145544 423239295
737182558 31629185 737205369 31606130
790259785 35554795 791386989 34057684
575900390 197298321 576712653 196103190
871840112 672618377 871778107 671901046
972388111 699494151 971859066 699788760
607697634 947278085 606473337 946634089
268325283 605404505 ...

result:

ok answer = 1

Test #13:

score: 0
Accepted
time: 1070ms
memory: 210004kb

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
73480409 112707894 75807544 112300029
974169585 619209298 976452843 619556934
730568325 616291877 732071653 615357564
180791485 507855412 182294625 509124843
902284179 882065660 902126642 881325390
420658973 241541045 420643702 241791571
70202096 599247436 70259530 599116568
870390405 306105841 ...

result:

ok answer = 1

Test #14:

score: 0
Accepted
time: 1070ms
memory: 210752kb

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
701175461 366336859 700926819 363782478
258911614 139798076 259664312 140583575
572864108 412884598 571382827 413589615
59157956 682658775 59137802 682714019
892414809 926001644 890443024 926016890
631227659 780874910 632442573 782295890
917708835 849128591 917748361 850287970
392781170 94486009...

result:

ok answer = 1

Test #15:

score: 0
Accepted
time: 1080ms
memory: 213152kb

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
568354398 675585065 569112950 674044827
429430280 411122054 430172210 411030216
326919810 781590564 326952582 782461575
631053962 32398092 631594179 32612462
467251791 126240740 467468968 127421520
192143717 610724525 191720861 609273318
312918516 94606999...

result:

ok answer = 1

Test #16:

score: 0
Accepted
time: 1049ms
memory: 211792kb

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
23430 54471 23525 54295
56282 3687 56476 3688
76931 74403 77122 74437
82844 85747 82675 85836
6389 98610 6577 98611
39514 66149 39401 66000
82270 20536 82103 20535
5669 32227 5740 32096
49411 67798 49347 67669
26496 82804 26410 82691
64797 98255 64656 98254
734 69863 874 69862
9187 80898 9159 80...

result:

ok answer = 1

Test #17:

score: 0
Accepted
time: 32ms
memory: 156032kb

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
560958114 617164119 560494445 623074186
217879509 43380606 217827870 49054754
449291442 483938555 455147661 483312868
589328535 693506727 595298590 693094619
561301690 400090826 567256064 399531498
232368285 266114482 232326691 260271185
357064448 42290912 351317762 42119768
315579140 92223614 3...

result:

ok answer = 1

Test #18:

score: 0
Accepted
time: 157ms
memory: 163064kb

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
679211500 308695311 679535718 311526254
389136492 18154644 392052205 18003654
245332148 409612345 245478707 406693327
651602297 66919393 654527956 67086937
290629392 273688668 291105690 276509416
63314166 178503394 63480942 175676698
616054293 455012454 61...

result:

ok answer = 1

Test #19:

score: 0
Accepted
time: 341ms
memory: 174764kb

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
230073400 190485654 230134586 188450377
146249195 30169566 146065096 32173130
331912211 133939178 333929066 133580336
161269230 86938192 163297178 86766467
146401730 108908862 148415088 109129130
193367222 628566097 195424253 628642356
265157855 477556415 267138014 477739352
275006770 591212881 ...

result:

ok answer = 1

Test #20:

score: 0
Accepted
time: 1081ms
memory: 210508kb

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
391763233 19099771 391621055 20363768
278751941 228774360 277455310 228822213
491738636 571704586 490433726 571671782
134699333 87705756 134742299 86440904
333558515 169436030 333804906 170698191
629830991 258615725 631123797 258610720
53271247 430845238 51980457 430859195
667119868 127066375 66...

result:

ok answer = 1

Test #21:

score: 0
Accepted
time: 720ms
memory: 201900kb

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
500000000 500000000 820100409 183715746
820100409 816284254 500000000 500000000
500000000 500000000 195908774 168294517
500000000 500000000 195908774 831705483
779001277 146930193 500000000 500000000
500000000 500000000 779001277 853069807
819394128 183002536 500000000 500000000
819394128 816997...

result:

ok answer = 1

Test #22:

score: 0
Accepted
time: 361ms
memory: 183168kb

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: 1031ms
memory: 210448kb

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: 887ms
memory: 210500kb

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: 347ms
memory: 183900kb

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: 1054ms
memory: 210696kb

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: 8ms
memory: 155136kb

input:

2
1000000000 1000000000 1000000000
0 0 1

output:

YES
0 0 1000000000 1000000000

result:

ok answer = 1

Test #28:

score: 0
Accepted
time: 7ms
memory: 155204kb

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: 152980kb

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: 153156kb

input:

2
1000000000 1000000000 499999999
1000000000 0 500000000

output:

YES
1000000000 0 1000000000 1000000000

result:

ok answer = 1