QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#71803#246. 通道He_Ren100 ✓1342ms186708kbC++239.1kb2023-01-12 01:19:062023-01-12 01:20:19

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-12 01:20:19]
  • 评测
  • 测评结果:100
  • 用时:1342ms
  • 内存:186708kb
  • [2023-01-12 01:19:06]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MAXN = 1e5 + 5;
const int LB = 17 + 2;
const ll linf = 0x3f3f3f3f3f3f3f3f;

namespace FastIO {
const int SIZ1 = 1 << 23;
char buf1[SIZ1], *s1 = buf1, *t1 = buf1;
inline char gc(void) {
    return s1 == t1 && (t1 = buf1 + fread(buf1, 1, SIZ1, stdin)) == (s1 = buf1) ? EOF : *s1++;
}
template<typename T>
void read(T &res) {
    res = 0;
    char c = gc();

    while (c < '0' || c > '9')
        c = gc();

    while (c >= '0' && c <= '9')
        res = res * 10 + c - '0', c = gc();
}
} using FastIO::read;

template<typename T>
T max3(const T &a, const T &b, const T &c) {
    return max(max(a, b), c);
}
template<typename T>
T max4(const T &a, const T &b, const T &c, const T &d) {
    return max(max(a, b), max(c, d));
}


int lb[MAXN * 2];

ll ans = 0;
inline void chk_ans(ll k) {
    if (k > ans)
        ans = k;
}

struct Data {
    ll k;
    int u, v;
    Data(void) {}
    Data(ll _k, int _u, int _v): k(_k), u(_u), v(_v) {}
    bool operator < (const Data &oth) const {
        return k < oth.k;
    }
    inline bool one(void) const {
        return u == v;
    }
};

struct Tree {
    int n, orin;
    vector< pair<int, ll>> g[MAXN * 2];
    Tree *OT;
    void add_edge(int u, int v, ll w) {
        g[u].emplace_back(v, w);
        g[v].emplace_back(u, w);
    }
    void read_self(int _n) {
        n = orin = _n;

        for (int i = 1; i < n; ++i) {
            int u, v;
            ll w;
            read(u);
            read(v);
            read(w);
            add_edge(u, v, w);
        }
    }

    int dfn[MAXN], seq[MAXN * 2], curdfn;
    int nume[MAXN];
    ll dep[MAXN];
    pii mn[MAXN * 2][LB];
    void dfs_tree(int u, int fa) {
        seq[++curdfn] = u;
        dfn[u] = curdfn;

        for (auto it : g[u])
            if (it.first != fa) {
                int v = it.first;
                ll w = it.second;
                dep[v] = dep[u] + w;
                nume[v] = nume[u] + 1;
                dfs_tree(v, u);
                seq[++curdfn] = u;
            }
    }
    inline int lca(int u, int v) {
        u = dfn[u];
        v = dfn[v];

        if (u > v)
            swap(u, v);

        int k = lb[v - u + 1];
        return min(mn[u][k], mn[v - (1 << k) + 1][k]).second;
    }
    inline ll dist(int u, int v) {
        return dep[u] + dep[v] - 2 * dep[lca(u, v)];
    }

    static ll global_val[MAXN * 2];
    static int global_clr[MAXN * 2], global_pool[MAXN * 2];

    void build1(void) {
        curdfn = 0;
        dfs_tree(1, 0);

        for (int i = curdfn; i >= 1; --i) {
            mn[i][0] = {nume[seq[i]], seq[i]};

            for (int j = 1; i + (1 << j) - 1 <= curdfn; ++j)
                mn[i][j] = min(mn[i][j - 1], mn[i + (1 << (j - 1))][j - 1]);
        }
    }
    void build2(void) {
        using Func = function<void(int, int)>;

        static vector< pair<int, ll>> ng[MAXN * 2];
        auto add_ng = [&](int u, int v, ll w) {
            ng[u].emplace_back(v, w);
            ng[v].emplace_back(u, w);
        };
        orin = n;
        Func dfs = [&](int u, int fa) {
            int cur = u;

            for (auto it : g[u])
                if (it.first != fa) {
                    int v = it.first;
                    ll w = it.second;
                    ++n;
                    add_ng(cur, n, 0);
                    add_ng(n, v, w);
                    cur = n;
                    dfs(v, u);

                }
        };
        dfs(1, 0);

        for (int i = 1; i <= n; ++i)
            g[i] = ng[i];

        memset(global_clr, -1, sizeof(global_clr));

        function<int *(int, int *)> divid = [&](int rt, int *pl) {
            static bool del[MAXN * 2];
            static int siz[MAXN * 2], mxsiz[MAXN * 2];

            Func dfs_siz = [&](int u, int fa) {
                siz[u] = 1;

                for (auto it : g[u])
                    if (it.first != fa && !del[it.first]) {
                        int v = it.first;
                        dfs_siz(v, u);
                        siz[u] += siz[v];
                    }
            };
            dfs_siz(rt, 0);

            int tot_siz = siz[rt];
            int u1 = -1, u2 = -1;
            ll midw = -1;
            Func dfs_u1u2 = [&](int u, int fa) {
                siz[u] = 1;

                for (auto it : g[u])
                    if (it.first != fa && !del[it.first]) {
                        int v = it.first;
                        mxsiz[v] = max(siz[v], tot_siz - siz[v]);

                        if (u1 == -1 || mxsiz[v] < mxsiz[u1])
                            u1 = v, u2 = u, midw = it.second;

                        dfs_u1u2(v, u);
                    }
            };
            dfs_u1u2(rt, 0);

            if (u1 == -1) {
                if (rt <= orin)
                    *pl++ = OT -> dfn[rt];

                return pl;
            }

            del[u2] = 1;
            int *pm = divid(u1, pl);
            del[u2] = 0;
            del[u1] = 1;
            int *pr = divid(u2, pm);
            del[u1] = 0;

            if (pl == pm || pm == pr)
                return pr;

            if (pr - pl <= 500)
                sort(pl, pr);
            else
                inplace_merge(pl, pm, pr);

            Func dfs_global = [&](int u, int fa) {
                for (auto it : g[u])
                    if (it.first != fa && !del[it.first]) {
                        int v = it.first;
                        global_clr[v] = global_clr[u];
                        global_val[v] = global_val[u] + it.second;
                        dfs_global(v, u);
                    }
            };

            global_clr[u1] = 0;
            global_val[u1] = 0;
            global_clr[u2] = 1;
            global_val[u2] = midw;
            dfs_global(u1, u2);
            dfs_global(u2, u1);

            OT -> build3(pl, pr);

            while (pl < pr)
                global_clr[OT -> seq[*pl++]] = -1;

            return pr;
        };
        divid(1, global_pool);
    }
    void build3(int *pl, int *pr) {
        if (pl + 1 >= pr)
            return;

        static ll curval[MAXN];
        auto calc = [&](int u, int v) {
            return OT -> dist(u, v)
                   + curval[u] + curval[v];
        };
        auto make = [&](int u, int v) {
            return Data(calc(u, v), u, v);
        };
        auto merge = [&](const Data & x, const Data & y) {
            if (x.k == -linf)
                return y;

            if (y.k == -linf)
                return x;

            return max3(x, y,
                        x.one() && y.one() ? make(x.u, y.u) :
                        x.one() ? max(make(x.u, y.u), make(x.u, y.v)) :
                        y.one() ? max(make(x.u, y.u), make(x.v, y.u)) :
                        max4(make(x.u, y.u), make(x.u, y.v), make(x.v, y.u), make(x.v, y.v))
                       );
        };

        static array<Data, 2> h[MAXN];
        auto makenew = [&](int u) {
            h[u][0] = h[u][1] = Data(-linf, 1, 1);

            if (global_clr[u] != -1)
                h[u][global_clr[u]] = make(u, u);
        };
        auto aply = [&](int u, int v) {
            auto upd = [&](const Data & x, const Data & y) {
                if (x.k == -linf || y.k == -linf)
                    return;

                chk_ans((
                            x.one() && y.one() ? calc(x.u, y.u) :
                            x.one() ? max(calc(x.u, y.u), calc(x.u, y.v)) :
                            y.one() ? max(calc(x.u, y.u), calc(x.v, y.u)) :
                            max4(calc(x.u, y.u), calc(x.u, y.v), calc(x.v, y.u), calc(x.v, y.v))
                        ) - 2 * dep[u]);
            };
            upd(h[u][0], h[v][1]);
            upd(h[u][1], h[v][0]);
            h[u] = {merge(h[u][0], h[v][0]), merge(h[u][1], h[v][1])};
        };

        static int sta[MAXN];
        int tp = 1;
        sta[1] = 1;
        makenew(1);

        while (pl < pr) {
            int u = seq[*pl++], uv = lca(sta[tp], u);
            curval[u] = global_val[u] + dep[u];
            --tp;

            while (tp && nume[sta[tp]] >= nume[uv])
                aply(sta[tp], sta[tp + 1]), --tp;

            if (sta[++tp] != uv) {
                makenew(uv);
                aply(uv, sta[tp]);
                sta[tp] = uv;
            }

            if (uv != u) {
                makenew(u);
                sta[++tp] = u;
            }
        }

        while (--tp)
            aply(sta[tp], sta[tp + 1]);
    }
} A, B, C;

ll Tree::global_val[MAXN * 2];
int Tree::global_clr[MAXN * 2], Tree::global_pool[MAXN * 2];

int main(void) {
    lb[0] = -1;

    for (int i = 1; i < MAXN * 2; ++i)
        lb[i] = lb[i >> 1] + 1;

    int n;
    read(n);
    A.read_self(n);
    B.read_self(n);
    C.read_self(n);

    A.OT = &B;
    B.OT = &C;
    B.build1();
    C.build1();
    A.build2();

    printf("%lld", ans);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 6
Accepted

Test #1:

score: 6
Accepted
time: 11ms
memory: 114120kb

input:

100
30 18 1
97 86 1
59 6 1
21 66 1
75 9 1
44 70 1
96 49 1
76 47 1
98 91 1
72 86 1
23 64 1
99 22 1
12 24 1
30 88 1
83 32 1
13 67 1
1 89 1
27 37 1
73 3 1
22 34 1
14 83 1
67 26 1
33 76 1
74 56 1
42 19 1
83 77 1
99 45 1
7 75 1
74 14 1
48 80 1
40 54 1
25 79 1
41 22 1
69 53 1
2 19 1
5 58 1
45 44 1
77 65 1...

output:

60

result:

ok 1 number(s): "60"

Test #2:

score: 0
Accepted
time: 23ms
memory: 115600kb

input:

100
36 18 764400639319
6 82 965370388469
98 56 328686845230
77 71 666659813016
48 8 612512140999
60 12 535238066104
50 64 183914993593
17 42 314347337129
73 94 750496153345
48 95 526027758993
48 33 343993724484
60 7 81676899941
29 42 867180722090
2 36 709041391542
26 7 875419023554
69 55 26162372073...

output:

28839383713177

result:

ok 1 number(s): "28839383713177"

Test #3:

score: 0
Accepted
time: 20ms
memory: 115536kb

input:

100
17 38 516345893761
61 43 800047425088
61 90 892027762023
28 63 82861509594
39 19 539023565558
17 31 516016284995
14 74 909210321126
1 59 446526063367
30 36 572284974967
76 29 559342888529
90 87 783022046397
77 74 212141810464
91 41 440702967454
37 90 447183549575
34 14 743250991349
33 73 1919562...

output:

29034145092818

result:

ok 1 number(s): "29034145092818"

Test #4:

score: 0
Accepted
time: 36ms
memory: 116960kb

input:

3000
2273 1274 1
1105 333 1
2812 1400 1
1675 2358 1
879 1124 1
81 172 1
737 194 1
2022 2814 1
1526 2531 1
1918 2806 1
2530 2328 1
1136 2805 1
1839 1659 1
1521 465 1
2784 1250 1
2216 896 1
2707 735 1
2576 384 1
1080 333 1
279 2099 1
1597 527 1
2889 1274 1
1274 830 1
1915 1960 1
1409 739 1
2079 1882 1...

output:

1374

result:

ok 1 number(s): "1374"

Test #5:

score: 0
Accepted
time: 36ms
memory: 116992kb

input:

3000
2452 2192 1
644 2612 1
2595 933 1
288 543 1
1264 1935 1
1079 1993 1
49 333 1
222 320 1
955 1696 1
1305 719 1
262 365 1
180 2195 1
2101 1079 1
241 1570 1
1333 2897 1
1778 1084 1
619 74 1
1136 2973 1
1609 729 1
760 2628 1
1496 2825 1
2656 2608 1
1072 2938 1
1992 1901 1
2117 2955 1
2163 655 1
1219...

output:

505

result:

ok 1 number(s): "505"

Test #6:

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

input:

3000
2452 2192 113682126551
644 2612 245124539322
2595 933 648579665589
288 543 644767834741
1264 1935 304991555894
1079 1993 465709110936
49 333 21149003221
222 320 957518812946
955 1696 367259582174
1305 719 622667985923
262 365 832697451706
180 2195 6256439354
2101 1079 308361891209
241 1570 7919...

output:

260227449564365

result:

ok 1 number(s): "260227449564365"

Test #7:

score: 0
Accepted
time: 33ms
memory: 117080kb

input:

3000
1285 1357 946993769110
945 2606 452708275229
1865 1783 318328933337
2916 2135 295276586794
24 2272 171835109769
880 2598 199999462549
2295 2133 289327444476
330 2541 101220064299
2907 2329 143218863002
931 1143 528558182366
982 2469 434338685566
709 2106 700125340433
767 597 623447351531
1283 5...

output:

961141735746406

result:

ok 1 number(s): "961141735746406"

Subtask #2:

score: 3
Accepted

Test #8:

score: 3
Accepted
time: 577ms
memory: 186708kb

input:

100000
34240 34239 272074692821
5033 5032 77913724980
24795 24794 526969139707
19234 19233 612978877731
74574 74575 939868775394
54407 54406 39298474908
50302 50303 7684922585
25748 25749 338691982142
53062 53063 311351193040
86507 86506 848724815374
41651 41652 967687200600
23178 23177 283455595065...

output:

149585023636574946

result:

ok 1 number(s): "149585023636574946"

Subtask #3:

score: 10
Accepted

Dependency #2:

100%
Accepted

Test #9:

score: 10
Accepted
time: 823ms
memory: 167708kb

input:

100000
68879 80762 650581276562
68879 70471 87319165587
34110 65508 226550471548
47813 96799 850591349682
96799 9363 730222889682
76718 56304 478710326407
44968 64822 599694053165
52203 29016 788591471552
609 28228 922793395662
24915 24231 312991810927
39645 68879 700550291353
72529 71210 6831319185...

output:

5607727879956726

result:

ok 1 number(s): "5607727879956726"

Test #10:

score: 0
Accepted
time: 879ms
memory: 170620kb

input:

100000
96286 45970 871746966499
17459 8428 954271847777
53992 7268 184576974194
22988 90758 173267980761
99700 19389 885757588916
75985 37272 506155120831
58308 12423 878338631126
79832 76243 290198531648
43908 30423 448650219921
64313 80676 737428897151
24053 94457 306399943324
1991 49766 721248680...

output:

43499460165553425

result:

ok 1 number(s): "43499460165553425"

Test #11:

score: 0
Accepted
time: 840ms
memory: 170580kb

input:

100000
50442 91326 807312750909
65431 90274 44358992506
38691 82681 532220709872
92684 33107 20046023007
16049 60224 110758605948
29985 67862 753287624483
3188 43620 369355816121
11790 1056 386153901166
16352 17394 344580775329
83236 43536 768517437228
38544 25238 820929668536
53289 94157 3116835987...

output:

33192863625633651

result:

ok 1 number(s): "33192863625633651"

Subtask #4:

score: 16
Accepted

Dependency #3:

100%
Accepted

Test #12:

score: 16
Accepted
time: 408ms
memory: 139232kb

input:

50000
15573 42113 1
48656 21453 1
8016 9473 1
42113 4453 1
48152 26000 1
26692 38361 1
41783 3973 1
5234 34388 1
28007 13961 1
13284 12780 1
47324 24416 1
13086 41121 1
2323 18079 1
26000 39969 1
3521 11922 1
47473 36094 1
321 25581 1
26000 26 1
25553 429 1
34657 22814 1
21714 42113 1
27943 34697 1
...

output:

108053

result:

ok 1 number(s): "108053"

Test #13:

score: 0
Accepted
time: 431ms
memory: 143856kb

input:

50000
37313 28352 297109201700
43122 3134 503423353179
30070 15978 768718647068
95 31947 226771628067
10384 2291 64430271374
21825 13867 785862850645
29483 31817 603314359964
40878 39721 816372197145
38381 18201 928889714354
5701 31161 813967183573
31179 730 518205119448
2749 14314 913319820089
4385...

output:

58182813691314995

result:

ok 1 number(s): "58182813691314995"

Test #14:

score: 0
Accepted
time: 877ms
memory: 170076kb

input:

100000
63569 18586 494948807237
63569 25616 690530217233
78522 77428 634125774509
6111 73630 575511184822
94875 44355 656124873001
68442 57048 480374907267
78903 15128 693031831293
1250 32520 258034304239
27736 78542 108599198867
21890 79175 317381343600
7023 114 15288477699
73630 72770 476548154246...

output:

103618969191653786

result:

ok 1 number(s): "103618969191653786"

Subtask #5:

score: 11
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Test #15:

score: 11
Accepted
time: 517ms
memory: 141776kb

input:

50000
14571 32750 1
20225 42031 1
1514 14424 1
14571 20686 1
47598 34180 1
13865 17028 1
4525 12292 1
39152 30136 1
18291 40835 1
36102 23931 1
5778 22066 1
21358 42812 1
34260 26099 1
47356 35763 1
8865 10586 1
3541 42812 1
3689 33483 1
18076 35759 1
46053 40835 1
2710 4764 1
6983 1205 1
36202 1880...

output:

32053

result:

ok 1 number(s): "32053"

Test #16:

score: 0
Accepted
time: 536ms
memory: 142504kb

input:

50000
13808 1684 501382717492
10620 31442 504760356651
30874 25285 499968540869
21692 27284 938064714570
38546 44776 719819740663
34715 39590 681914856813
42086 24358 128298106765
19304 14986 976801829520
31887 24931 907322524180
30668 46232 703664937817
42441 26010 842290930945
24273 2908 193438133...

output:

10032744408264853

result:

ok 1 number(s): "10032744408264853"

Test #17:

score: 0
Accepted
time: 1188ms
memory: 170348kb

input:

100000
38902 10718 357590796915
14130 38902 728735665479
22844 78151 799023285167
46143 38902 442273910381
20910 2443 446515674547
5507 59790 293844456906
39722 13500 333638689573
59790 31299 361015115724
26919 5233 662150191381
38902 7115 949809588496
25726 4326 37160007472
10424 38902 748836307195...

output:

17233532972163524

result:

ok 1 number(s): "17233532972163524"

Subtask #6:

score: 15
Accepted

Dependency #3:

100%
Accepted

Test #18:

score: 15
Accepted
time: 471ms
memory: 141136kb

input:

50000
23402 6819 1
42455 15413 1
23843 48041 1
18601 43275 1
28668 6449 1
27038 38317 1
906 43994 1
21899 21475 1
34987 2659 1
29454 46863 1
26984 45566 1
29263 36883 1
21430 43142 1
29810 15994 1
5255 40038 1
37486 47856 1
28321 21589 1
48178 18997 1
47028 41282 1
27130 10266 1
49989 11954 1
31495 ...

output:

105107

result:

ok 1 number(s): "105107"

Test #19:

score: 0
Accepted
time: 456ms
memory: 140636kb

input:

50000
2098 41758 780259816953
361 49984 911242565309
48535 88 576181910272
15557 9636 214298019802
44998 16036 792980353079
44418 4175 654827122401
9483 11240 258307336945
14889 14196 568739520376
4397 36802 35593510213
16176 2201 798032283327
27105 26568 952969271745
21939 11216 599428759198
12496 ...

output:

53017348038863624

result:

ok 1 number(s): "53017348038863624"

Test #20:

score: 0
Accepted
time: 1156ms
memory: 166828kb

input:

100000
28962 60894 1
41981 7712 1
48888 41583 1
67610 3925 1
50715 35404 1
54801 33999 1
40943 16560 1
51636 51406 1
74964 7655 1
43617 16142 1
49759 45481 1
25429 8353 1
22510 92502 1
18236 14193 1
20551 11034 1
19878 76135 1
70368 68688 1
82055 36205 1
89489 47882 1
72792 10341 1
23883 9960 1
5881...

output:

221677

result:

ok 1 number(s): "221677"

Test #21:

score: 0
Accepted
time: 1075ms
memory: 171148kb

input:

100000
22032 81945 711463523315
39590 56913 579925912966
420 86464 583634667909
45840 20924 250170738646
32336 2329 214952379308
11654 77492 343065862168
47726 54909 986009520743
8477 72616 614480907720
15149 7031 174174173974
29575 54865 770317464239
93693 75123 8843652534
38735 98892 209558516329
...

output:

110982475402008320

result:

ok 1 number(s): "110982475402008320"

Subtask #7:

score: 13
Accepted

Dependency #6:

100%
Accepted

Test #22:

score: 13
Accepted
time: 502ms
memory: 141084kb

input:

50000
42324 31858 1
25167 11460 1
35235 29251 1
26182 20840 1
28733 35885 1
41684 21435 1
20382 30570 1
40744 38522 1
31663 299 1
8772 47351 1
35273 14185 1
34058 41606 1
4362 10854 1
5629 17301 1
47639 38928 1
13005 32949 1
37439 5706 1
38383 5800 1
28016 44543 1
32395 12368 1
16689 32141 1
7860 99...

output:

71017

result:

ok 1 number(s): "71017"

Test #23:

score: 0
Accepted
time: 466ms
memory: 143136kb

input:

50000
46051 19054 637398872350
36787 13767 449752580175
6395 15784 670584382731
18570 14942 907194017385
11521 30539 697127397016
12414 13767 677880525680
43690 28422 924605317646
2849 15784 808930687066
15784 11244 720810891484
48607 15784 345865304980
12160 13767 235518235693
46612 109 88899667928...

output:

31971778230458647

result:

ok 1 number(s): "31971778230458647"

Test #24:

score: 0
Accepted
time: 1342ms
memory: 166880kb

input:

100000
28355 94047 1
39984 26263 1
78593 15252 1
64630 80166 1
57084 50600 1
70498 43467 1
68050 66630 1
79794 48615 1
48237 77222 1
49322 98180 1
41923 56940 1
91749 65803 1
55217 57652 1
55179 26704 1
57957 38984 1
95303 11800 1
41782 28950 1
90771 18997 1
25538 79762 1
19464 5837 1
14118 78152 1
...

output:

139797

result:

ok 1 number(s): "139797"

Test #25:

score: 0
Accepted
time: 1151ms
memory: 169056kb

input:

100000
99570 43214 938915807434
22486 5302 183548456649
75208 93230 47825695897
96201 93519 768059203530
65171 7379 965316098143
9481 47995 850503795505
12166 19383 743611422000
84595 66817 747920435321
14101 60549 307871288502
3389 99917 219014253787
79362 52201 980907771512
8981 93332 87066815173
...

output:

56144624446629915

result:

ok 1 number(s): "56144624446629915"

Subtask #8:

score: 26
Accepted

Test #26:

score: 26
Accepted
time: 502ms
memory: 138748kb

input:

50000
30967 24381 1
34287 29639 1
30009 26335 1
19251 18579 1
47627 32209 1
33524 26759 1
35659 36891 1
48851 23630 1
38099 49242 1
44427 38457 1
30681 47140 1
22194 30310 1
4570 45239 1
47245 4295 1
13316 2639 1
40278 35760 1
8162 37359 1
34287 23122 1
47483 3145 1
45990 4191 1
38373 25099 1
14256 ...

output:

23494

result:

ok 1 number(s): "23494"

Test #27:

score: 0
Accepted
time: 525ms
memory: 141264kb

input:

50000
36243 12994 221852616813
38665 31455 259467030152
3400 36243 704954898318
10281 30203 182252672400
38665 22906 850281381899
38665 21045 228859606075
29239 11249 878601554540
6793 22593 973567665178
39474 20459 737995169109
35291 2827 967329283087
27672 29833 825318536265
35329 1225 74244984838...

output:

10323683045861801

result:

ok 1 number(s): "10323683045861801"

Test #28:

score: 0
Accepted
time: 1306ms
memory: 165716kb

input:

100000
71058 41914 1
41087 95920 1
68564 26720 1
50317 18014 1
71722 44090 1
27639 98457 1
17511 44444 1
44392 69365 1
27757 32504 1
80282 11798 1
70658 56363 1
61257 91194 1
93224 98505 1
51035 26720 1
92988 7461 1
26321 2343 1
76905 15902 1
19231 53012 1
31597 36893 1
59424 78052 1
4517 70480 1
44...

output:

33447

result:

ok 1 number(s): "33447"

Test #29:

score: 0
Accepted
time: 1208ms
memory: 167876kb

input:

100000
10447 63188 479772426814
12410 40141 214732398034
82806 75172 595270682409
3555 44353 247750387918
72049 8019 814721288552
86610 15950 283782850807
10500 10036 203282026682
56457 73354 878841319503
2402 74064 545474630711
39412 58991 950030121696
2038 30103 668905478740
87325 74408 9666510034...

output:

17411504279678081

result:

ok 1 number(s): "17411504279678081"

Test #30:

score: 0
Accepted
time: 1236ms
memory: 171132kb

input:

100000
1357 38389 946176282148
52096 53148 918394577890
73016 39142 196454811082
90152 48238 806433127747
77631 25873 723794540834
39142 61437 805498849671
20414 62187 795204357846
39142 95224 435108363120
54881 21127 456324571386
54881 845 598265074658
25873 79134 948969203815
16333 11189 954971583...

output:

12465466385930189

result:

ok 1 number(s): "12465466385930189"

Test #31:

score: 0
Accepted
time: 1190ms
memory: 167600kb

input:

100000
68519 31809 974290851908
26015 64089 132490834667
14818 92426 474661521774
51536 4291 188764838448
42865 58448 85991518758
36370 88005 353998441415
99983 58951 234351893298
88684 88540 28635756450
69552 21877 173038013853
81875 8234 991723805714
32560 47084 74557781353
35685 65405 60652715241...

output:

14149163748841351

result:

ok 1 number(s): "14149163748841351"

Extra Test:

score: 0
Extra Test Passed