QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#18100#2178. Robotnamelessgugugu#100 ✓373ms58548kbC++142.7kb2022-01-16 11:05:352022-05-04 17:04:40

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-04 17:04:40]
  • 评测
  • 测评结果:100
  • 用时:373ms
  • 内存:58548kb
  • [2022-01-16 11:05:35]
  • 提交

answer

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
typedef long long ll;
const int N = 400005;
const ll inf = 0x3f3f3f3f3f3f3f3f;
int n, m, nn;
struct Edge
{
    int to, nxt, col, wei;
} E[N];
int head[N], tot = 1;
inline void add(int f, int t, int c, int w)
{
    E[++tot] = {t, head[f], c, w}, head[f] = tot;
    return;
}
std::vector<std::pair<int, ll>> G[N];
int stt[N], len[N];
ll dis[N];
ll dijkstra(void)
{
    std::priority_queue<std::pair<ll, int>, std::vector<std::pair<ll, int>>, std::greater<std::pair<ll, int>>> que;
    memset(dis, 0x3f, sizeof(dis)), dis[1] = 0;
    que.push({0, 1});
    while(!que.empty())
    {
        auto tmp = que.top();
        que.pop();
        int x = tmp.second;
        ll d = tmp.first;
        if(d != dis[x])
            continue;
        for (auto pr : G[x])
        {
            int y = pr.first;
            ll w = pr.second;
            if(dis[y] > dis[x] + w)
                que.push({dis[y] = dis[x] + w, y});
        }
    }
    if(dis[stt[n]] == inf)
        return -1;
    return dis[stt[n]];
}
int main(void)
{
    scanf("%d%d", &n, &m);
    for (int i = 1, u, v, c, w; i <= m; ++i)
        scanf("%d%d%d%d", &u, &v, &c, &w), add(u, v, c, w), add(v, u, c, w);
    nn = 0;
    for (int x = 1; x <= n; ++x)
    {
        static int bac[N];
        int top = 0;
        for (int i = head[x]; i; i = E[i].nxt)
        {
            int c = E[i].col;
            bac[++top] = c;
        }
        std::sort(bac + 1, bac + 1 + top), top = std::unique(bac + 1, bac + 1 + top) - bac - 1;
        stt[x] = ++nn, nn += (len[x] = top);
    }
    for (int x = 1; x <= n; ++x)
    {
        static int bac[N], id[N];
        int top = 0;
        static ll tmp[N];
        for (int i = head[x]; i; i = E[i].nxt)
        {
            int w = E[i].wei, c = E[i].col;
            tmp[c] += w;
            bac[++top] = c;
        }
        std::sort(bac + 1, bac + 1 + top), top = std::unique(bac + 1, bac + 1 + top) - bac - 1;
        for (int i = 1; i <= top; ++i)
            id[bac[i]] = i;
        for (int i = head[x]; i; i = E[i].nxt)
        {
            int y = E[i].to, w = E[i].wei, c = E[i].col;
            G[stt[x]].push_back({stt[y], std::min((ll)w, tmp[c] - w)});
            G[stt[x] + id[c]].push_back({stt[y], tmp[c] - w});
            G[stt[y]].push_back({stt[x] + id[c], 0});
        }
        for (int i = 1; i <= top; ++i)
            id[bac[i]] = 0;
        for (int i = head[x]; i; i = E[i].nxt)
        {
            int w = E[i].wei, c = E[i].col;
            tmp[c] -= w;
        }
    }
    printf("%lld\n", dijkstra());
    return 0;
}

詳細信息

Subtask #1:

score: 34
Accepted

Test #1:

score: 34
Accepted
time: 6ms
memory: 24700kb

input:

2 1
1 2 1 10

output:

0

result:

ok single line: '0'

Test #2:

score: 0
Accepted
time: 4ms
memory: 23428kb

input:

8 1
5 6 1 7

output:

-1

result:

ok single line: '-1'

Test #3:

score: 0
Accepted
time: 5ms
memory: 24704kb

input:

8 19
4 8 15 5
7 8 15 6
1 4 15 6
3 4 2 10
2 7 15 10
5 6 2 10
1 7 2 3
4 5 15 7
1 6 15 6
2 5 2 6
1 8 15 2
1 2 15 9
5 7 2 5
3 8 2 5
4 7 2 6
6 7 15 8
3 7 15 6
2 8 2 1
5 8 15 6

output:

2

result:

ok single line: '2'

Test #4:

score: 0
Accepted
time: 2ms
memory: 24756kb

input:

4 6
1 2 1 7
3 4 1 10
2 3 2 5
2 4 1 4
1 4 6 2
1 3 1 2

output:

0

result:

ok single line: '0'

Test #5:

score: 0
Accepted
time: 2ms
memory: 24696kb

input:

64 106
7 46 100 641441921
4 22 92 909042053
27 46 100 185644091
52 54 100 333473988
21 41 69 747879553
23 45 24 121784836
16 23 69 538978180
15 42 92 403583091
49 60 69 112127397
44 48 21 733685727
18 40 92 287239281
3 30 48 498139743
21 25 24 281665265
13 24 69 315527284
12 35 21 100990101
33 56 10...

output:

-1

result:

ok single line: '-1'

Test #6:

score: 0
Accepted
time: 2ms
memory: 24584kb

input:

10 45
6 7 29 19322896
6 8 29 826842878
5 9 29 229755065
1 6 29 49301462
4 10 29 356862039
3 7 29 377906409
8 10 29 877820670
4 8 29 150486169
1 10 29 291057766
1 5 29 982043864
1 3 29 126557279
5 6 29 721959799
3 10 29 636909401
1 7 29 772752473
5 8 29 523364181
7 9 29 250673970
2 6 29 417264209
2 4...

output:

255671682

result:

ok single line: '255671682'

Test #7:

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

input:

71 788
5 24 146 614916874
56 61 567 467226384
16 44 275 490241032
14 25 567 779488700
19 42 262 524833651
6 19 567 912315689
8 21 774 326632848
46 62 675 296672130
27 32 715 104878301
13 47 675 546642528
18 68 675 349712771
8 43 146 305351688
13 58 567 776051722
49 63 601 454628166
30 43 715 7695855...

output:

46083838

result:

ok single line: '46083838'

Test #8:

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

input:

55 443
11 21 307 732223755
32 42 307 182136903
47 48 346 925071240
45 53 307 225221704
1 45 307 807617287
28 46 307 644657251
2 42 346 807672874
39 42 346 173126332
11 50 346 105073586
48 53 346 363756204
19 27 346 749462761
8 20 346 838034581
28 31 307 183749842
28 53 346 909041858
33 50 346 364806...

output:

342534314

result:

ok single line: '342534314'

Test #9:

score: 0
Accepted
time: 2ms
memory: 25176kb

input:

999 1988
153 528 1690 1
1 867 1158 1
481 785 1741 1
226 528 203 1
356 481 1957 1
278 481 716 1
168 528 612 1
1 140 489 1
528 533 446 1
4 528 1715 1
481 698 1350 1
35 528 1658 1
528 601 1345 1
24 481 559 1
524 528 88 1
1 606 1547 1
481 493 1017 1
165 528 1685 1
481 849 1847 1
528 711 1464 1
1 663 222...

output:

3

result:

ok single line: '3'

Test #10:

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

input:

999 1988
328 983 1573 1
130 468 1140 1
44 983 210 1
15 983 1848 1
517 983 1451 1
1 131 563 1
1 209 182 1
130 793 1295 1
130 947 1295 1
130 680 1295 1
130 214 1295 1
584 983 567 1
726 983 1019 1
130 456 1295 1
198 575 1295 1
1 6 283 1
200 575 1295 1
205 575 1295 1
1 399 1128 1
130 589 1510 1
923 983 ...

output:

3

result:

ok single line: '3'

Test #11:

score: 0
Accepted
time: 5ms
memory: 25104kb

input:

1000 1990
528 730 1843 1
523 730 1843 1
124 894 1843 1
224 730 1843 1
124 617 1843 1
679 730 1843 1
124 913 1843 1
488 730 1843 1
493 730 1843 1
730 748 1843 1
730 959 1843 1
124 437 1843 1
124 187 1843 1
124 332 1843 1
124 279 1843 1
124 961 1843 1
124 744 1843 1
203 730 1843 1
723 730 1843 1
730 9...

output:

3

result:

ok single line: '3'

Test #12:

score: 0
Accepted
time: 4ms
memory: 24940kb

input:

998 1658
296 805 151 1
141 805 151 1
218 983 151 2
1 608 151 2
1 49 151 2
740 805 151 1
225 805 151 1
218 420 151 2
87 266 151 1
218 527 151 2
1 374 151 2
218 905 151 2
699 744 151 1
660 805 151 1
836 889 151 1
62 805 151 1
184 218 151 2
95 457 151 1
218 985 151 2
218 621 151 2
1 577 151 2
587 981 1...

output:

666

result:

ok single line: '666'

Test #13:

score: 0
Accepted
time: 4ms
memory: 25060kb

input:

1000 1983
752 787 507 1
752 832 507 1
752 927 507 1
556 581 507 1
581 891 507 1
451 581 507 1
107 581 507 1
752 765 507 1
81 752 507 2
251 581 507 1
581 859 507 1
321 581 507 1
55 581 507 1
752 814 507 1
581 780 507 1
581 790 507 1
387 581 507 1
356 752 507 1
581 932 507 1
1 889 507 2
581 893 507 1
...

output:

989

result:

ok single line: '989'

Test #14:

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

input:

1000 1983
415 567 756 1
62 709 756 1
89 709 756 1
417 709 756 1
457 709 756 1
149 415 756 1
709 964 756 1
275 709 756 1
709 928 756 1
299 709 756 1
487 709 756 1
709 791 756 1
415 967 756 1
415 941 756 1
217 709 756 1
709 984 756 1
415 604 756 1
212 415 756 1
399 415 756 1
438 709 756 1
294 709 756 ...

output:

26

result:

ok single line: '26'

Test #15:

score: 0
Accepted
time: 4ms
memory: 25008kb

input:

1000 999
656 793 229 300116971
200 526 229 848062849
57 209 229 748009426
608 970 229 962221417
161 721 229 384089949
260 595 229 428874737
156 233 229 577150696
158 385 229 738154446
136 709 229 67894231
25 903 229 397142287
732 767 229 957266971
550 781 229 823510106
384 752 229 406598247
5 271 22...

output:

201664848082

result:

ok single line: '201664848082'

Test #16:

score: 0
Accepted
time: 1ms
memory: 24984kb

input:

1000 1998
216 873 802 148650296
85 606 802 89598343
113 720 802 287659390
468 531 802 204322693
331 564 802 373686511
583 642 802 115887999
602 719 802 233321776
642 944 802 57082002
916 950 802 92555430
143 352 802 461653014
434 687 802 72505880
238 659 802 31377094
187 375 802 140765767
250 272 80...

output:

18092395296

result:

ok single line: '18092395296'

Test #17:

score: 0
Accepted
time: 4ms
memory: 24968kb

input:

800 1478
477 620 933 5658029
288 630 933 374079479
93 181 1082 151764046
469 690 1082 161114493
100 381 933 708106586
266 327 1082 738393737
17 495 933 368385363
312 496 933 399240908
165 548 1082 436276578
389 677 933 31330966
310 493 933 121847365
361 459 933 576299908
396 796 933 981781202
60 303...

output:

-1

result:

ok single line: '-1'

Test #18:

score: 0
Accepted
time: 2ms
memory: 24696kb

input:

915 572
332 504 416 228776811
435 728 445 412258532
93 182 506 914985113
10 162 416 307159431
339 583 416 622601819
738 814 445 464379203
787 795 560 265814135
806 820 445 529333835
774 798 506 119778570
435 583 506 6220730
374 789 560 753701380
441 693 560 808760860
81 102 506 803896086
383 507 506...

output:

-1

result:

ok single line: '-1'

Test #19:

score: 0
Accepted
time: 6ms
memory: 25052kb

input:

100 2000
35 48 1983 65612927
31 53 60 76830022
30 56 1764 65879682
32 35 60 20526498
38 83 60 28781478
31 99 60 2620538
32 51 1983 32927409
5 73 1764 2812104
7 41 1983 10191012
13 90 60 71582220
10 50 1262 38366351
45 80 1262 15238959
23 82 1983 12778753
39 48 1675 27393975
82 87 1764 48078651
28 96...

output:

153828372

result:

ok single line: '153828372'

Test #20:

score: 0
Accepted
time: 4ms
memory: 24900kb

input:

1000 1332
60 826 1091 1000000000
603 878 1091 1000000000
511 904 1091 999999999
111 952 1091 999999999
10 634 1091 1000000000
582 840 1091 999999999
87 486 1091 999999999
156 748 1091 999999999
45 232 1091 1000000000
625 940 1091 999999999
84 380 1091 1000000000
49 490 1091 999999999
184 909 1091 10...

output:

665999999497

result:

ok single line: '665999999497'

Subtask #2:

score: 24
Accepted

Test #21:

score: 24
Accepted
time: 116ms
memory: 36264kb

input:

25437 78923
921 9998 30945 1
5452 13736 24464 1
11746 24238 24464 1
10875 12958 24464 1
12267 20617 30945 1
3738 16549 35589 1
16223 16940 35589 1
1303 23059 24464 1
12424 21853 24464 1
11198 20674 35589 1
15645 19099 30945 1
8860 9441 24464 1
3609 15160 35589 1
22638 23472 24464 1
766 8991 35589 1
...

output:

5

result:

ok single line: '5'

Test #22:

score: 0
Accepted
time: 42ms
memory: 29348kb

input:

15761 34565
6553 7857 4268 1
1139 8149 4268 1
4136 9004 4268 1
3810 8194 27009 1
3005 10547 9061 1
3025 15018 27009 1
5735 6627 9061 1
2337 12263 9061 1
4260 8046 9061 1
12549 14043 4268 1
6992 11456 4268 1
833 4225 4268 1
1609 9603 4268 1
2588 9564 9061 1
2361 8162 27009 1
10250 10706 4268 1
6878 1...

output:

6

result:

ok single line: '6'

Test #23:

score: 0
Accepted
time: 154ms
memory: 44124kb

input:

16917 133722
10190 12792 75746 1
4125 15443 75746 1
163 5884 29061 1
2756 10488 29061 1
7080 9199 75746 1
1463 4211 75746 1
5115 7366 29061 1
10308 11662 75746 1
1196 14025 29061 1
2863 14178 75746 1
9795 13347 75746 1
13003 13888 75746 1
5035 16673 75746 1
1356 15130 75746 1
13068 16408 29061 1
349...

output:

3

result:

ok single line: '3'

Test #24:

score: 0
Accepted
time: 61ms
memory: 32220kb

input:

25063 52020
145 18915 3816 1
5378 20731 3816 1
17344 23239 21514 1
2212 6628 3816 1
3462 15824 3816 1
1660 15356 21514 1
7250 18036 21514 1
8600 17595 21514 1
1446 12372 3816 1
10292 22860 3816 1
6562 18473 21514 1
10903 20797 21514 1
5932 8895 21514 1
5310 8230 3816 1
15875 24245 21514 1
3521 3908 ...

output:

5

result:

ok single line: '5'

Test #25:

score: 0
Accepted
time: 350ms
memory: 56024kb

input:

99999 199988
4731 83366 89897 1
80907 83366 155057 1
1 15876 82022 1
83366 86520 193680 1
15678 83366 180045 1
31911 59651 263 1
1 61854 122596 1
83366 99983 63626 1
67027 83366 28130 1
19313 83366 74260 1
59651 87942 97680 1
1 98039 115849 1
53600 83366 150525 1
26771 83366 120178 1
80859 83366 537...

output:

3

result:

ok single line: '3'

Test #26:

score: 0
Accepted
time: 294ms
memory: 56952kb

input:

99999 199988
11815 64227 56577 1
11815 60572 63128 1
1 78695 24435 1
12018 22361 50088 1
11815 67504 38323 1
12018 19012 107473 1
11815 63558 63128 1
71961 74024 63128 1
11815 63837 63128 1
11815 35595 63128 1
12018 57914 87572 1
12018 54264 88988 1
12018 66879 117942 1
1 49113 107309 1
12018 81198 ...

output:

3

result:

ok single line: '3'

Test #27:

score: 0
Accepted
time: 203ms
memory: 56120kb

input:

100000 199990
37990 50087 155359 1
22611 37990 155359 1
4362 89790 155359 1
4362 96346 155359 1
4362 54455 155359 1
37990 93050 155359 1
31313 37990 155359 1
36462 37990 155359 1
4362 14580 155359 1
1140 4362 155359 1
4362 70772 155359 1
4362 53585 155359 1
37990 49713 155359 1
4362 47065 155359 1
3...

output:

3

result:

ok single line: '3'

Test #28:

score: 0
Accepted
time: 295ms
memory: 54780kb

input:

100000 199839
11865 45830 161515 1
46988 77944 161515 1
37628 62851 161515 1
21213 29495 161515 1
79467 91266 161515 1
42910 57123 161515 1
83278 89082 161515 1
17867 67021 161515 1
29361 92753 161515 1
32817 45699 161515 1
90648 93260 161515 1
14450 54441 161515 1
27147 85147 161515 1
11506 24762 1...

output:

12347

result:

ok single line: '12347'

Test #29:

score: 0
Accepted
time: 319ms
memory: 54752kb

input:

100000 200000
19447 99453 101188 1
4820 52736 101188 1
51887 94783 101188 1
20762 99520 101188 1
4745 89605 101188 1
49080 66338 101188 1
24656 26963 101188 1
64986 82044 101188 1
22890 89840 101188 1
483 35061 101188 1
72709 85911 101188 1
7597 76399 101188 1
17356 66290 101188 1
73758 94642 101188...

output:

1250

result:

ok single line: '1250'

Test #30:

score: 0
Accepted
time: 192ms
memory: 42244kb

input:

53901 119501
10291 14784 53288 1
4583 13856 53288 1
23363 33647 101468 1
3518 53845 101468 1
36419 38250 112685 1
3198 19748 112685 1
26033 32687 112685 1
14393 44922 112685 1
25180 38428 53288 1
23010 26128 112685 1
2403 51848 101468 1
12179 20699 101468 1
1420 27014 53288 1
35027 39700 112685 1
20...

output:

-1

result:

ok single line: '-1'

Test #31:

score: 0
Accepted
time: 115ms
memory: 38216kb

input:

83934 95347
43947 77849 83564 1
50335 74178 83564 1
5042 27838 83564 1
63088 79495 83564 1
3599 48287 83564 1
35299 75948 83564 1
40480 56081 83564 1
19327 53910 83564 1
9451 26020 83564 1
23126 64107 83564 1
26565 67741 83564 1
13340 22355 83564 1
1642 40258 83564 1
47323 69242 83564 1
41578 61309 ...

output:

-1

result:

ok single line: '-1'

Subtask #3:

score: 42
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #32:

score: 42
Accepted
time: 121ms
memory: 45068kb

input:

2445 146282
830 1909 64270 421480771
1396 1540 28807 270090950
66 1185 64270 71524096
1059 1734 64270 830550756
720 2157 64270 790559959
1257 2234 64270 713576326
1421 2016 28807 889234780
354 434 129594 367593234
1274 2038 129594 468554371
397 1241 117974 870021820
1735 2037 129594 615894836
51 183...

output:

97087531

result:

ok single line: '97087531'

Test #33:

score: 0
Accepted
time: 137ms
memory: 42232kb

input:

21290 112378
8518 19053 87182 21512652
12034 17609 87182 136256538
1411 1837 87182 193941665
5128 13961 87182 797586198
11725 17477 87182 693800893
6004 14707 87182 12385241
376 20871 87182 121739672
9528 12750 87182 512502774
8817 17436 87182 973179222
15091 16423 87182 347469895
689 1304 87182 670...

output:

939985629

result:

ok single line: '939985629'

Test #34:

score: 0
Accepted
time: 233ms
memory: 45764kb

input:

42209 137983
3814 35294 68766 269672127
28034 40599 10585 800541570
1062 20498 10585 272506273
401 11852 68766 2461831
16050 34594 68766 788919268
11586 17475 68766 127588493
16752 22622 10585 879001889
1621 26500 68766 909184350
19415 23456 10585 606979956
839 16752 110736 47062753
178 25969 10585 ...

output:

883432615

result:

ok single line: '883432615'

Test #35:

score: 0
Accepted
time: 185ms
memory: 42292kb

input:

42678 113868
24921 38259 22442 617493696
34389 38435 22442 219497925
19558 38852 85652 894248305
17401 24708 22442 376754564
6922 25299 22442 152377494
11884 26431 85652 411567778
27065 34239 85652 75294740
31533 37114 22442 118862387
121 21714 85652 515207607
5627 21694 85652 616507447
23103 39121 ...

output:

1192756507

result:

ok single line: '1192756507'

Test #36:

score: 0
Accepted
time: 208ms
memory: 42128kb

input:

99999 124996
44274 45445 36601 1000000000
1 92221 36601 1
75502 86284 36601 1
43077 47661 36601 1000000000
15314 75502 36601 1
10278 75502 36601 1
54861 92979 36601 1000000000
69623 92139 36601 1000000000
9434 93701 36601 1000000000
19905 93537 36601 1000000000
19340 61499 36601 2
59584 68006 36601 ...

output:

25003

result:

ok single line: '25003'

Test #37:

score: 0
Accepted
time: 220ms
memory: 49632kb

input:

99998 166658
35151 88805 158166 1
35151 95140 158166 1
61911 76731 158166 1
4094 35151 158166 1
35151 90830 158166 1
3027 29989 158166 2
3027 18760 158166 2
35151 51868 158166 1
35151 89653 158166 1
1 81022 158166 2
29241 66584 158166 1
20522 35151 158166 1
3027 92397 158166 2
35151 36911 158166 1
3...

output:

66666

result:

ok single line: '66666'

Test #38:

score: 0
Accepted
time: 230ms
memory: 58548kb

input:

100000 199893
20984 40160 4615 1
20984 30244 4615 1
49904 65610 4615 1
20984 38390 4615 1
49904 60240 4615 1
49904 92349 4615 1
10041 20984 4615 1
19679 20984 4615 1
6739 20984 4615 1
20984 99844 4615 1
20984 50725 4615 1
49904 74450 4615 1
20984 34899 4615 1
15005 49904 4615 1
37939 49904 4615 1
20...

output:

99899

result:

ok single line: '99899'

Test #39:

score: 0
Accepted
time: 158ms
memory: 53408kb

input:

10000 180708
5257 6607 178772 652286924
5210 9300 178772 33899993
839 2425 178772 39111391
5114 8128 178772 202522821
91 7147 178772 532814165
174 2849 178772 205074073
1805 4324 178772 67300195
3478 4259 178772 126009258
6177 9388 178772 69075949
6048 8754 178772 578982464
4643 7832 178772 23383438...

output:

6168681143

result:

ok single line: '6168681143'

Test #40:

score: 0
Accepted
time: 318ms
memory: 55044kb

input:

100000 199849
48193 64479 11440 858355804
1250 52559 11440 23835959
37657 89906 11440 788817720
52418 69256 11440 70175975
75558 97173 11440 52508165
23477 23929 11440 42976351
86446 94823 11440 70842206
32967 93386 11440 70180344
73634 87529 11440 6118715
14281 75126 11440 601986829
13557 74052 114...

output:

1835932335146

result:

ok single line: '1835932335146'

Test #41:

score: 0
Accepted
time: 311ms
memory: 54828kb

input:

100000 200000
1409 57022 121725 501462440
49906 90229 121725 754900923
41935 72132 121725 108049674
48200 86973 121725 124832554
61241 90620 121725 2857551
949 64322 121725 95681909
31350 72219 121725 650260391
64239 91282 121725 166102661
6274 44459 121725 25689710
50259 70748 121725 259556925
3526...

output:

130974831841

result:

ok single line: '130974831841'

Test #42:

score: 0
Accepted
time: 307ms
memory: 51088kb

input:

93286 175743
33439 72531 67480 178241647
43340 63258 72246 687946425
34375 79409 67480 545522255
55495 89509 67480 939773932
65983 88348 72246 557599078
43488 51722 67480 49425614
17850 32705 72246 546283328
1258 5505 72246 353716363
7886 32598 72246 561569748
10673 82252 67480 835283188
773 88353 7...

output:

-1

result:

ok single line: '-1'

Test #43:

score: 0
Accepted
time: 117ms
memory: 38224kb

input:

22940 94635
7252 13606 4375 205355730
12298 18298 4375 371216249
13666 22430 13893 694022291
8264 13107 13893 663324646
8512 11868 35703 935903901
17629 21464 75180 706766234
5891 12326 75180 911289921
2416 14871 35703 73832982
9841 16792 13893 86526194
4657 18843 35703 151828228
7761 17360 4375 410...

output:

-1

result:

ok single line: '-1'

Test #44:

score: 0
Accepted
time: 221ms
memory: 56424kb

input:

10000 200000
1518 2946 87539 39950219
2007 5041 192891 66581539
5247 6607 33553 47326555
6705 8314 87539 118470302
3431 9470 192891 22030753
948 4693 33553 129398913
7792 8587 192891 30423065
3569 8935 35086 44685918
167 1995 33553 116189849
98 3632 151757 78951977
8114 9168 21119 17799398
6884 9241...

output:

149848501

result:

ok single line: '149848501'

Test #45:

score: 0
Accepted
time: 254ms
memory: 46276kb

input:

100000 150000
1292 94111 96893 217736971
4940 87684 96893 489510072
48920 64120 96893 112077762
47763 56187 96893 101373493
21871 69964 96893 281564796
63921 90656 96893 128095948
45138 84880 96893 378245545
47510 99012 96893 233158521
17034 35059 96893 50315149
62002 78326 96893 37996250
29533 7656...

output:

201843889367

result:

ok single line: '201843889367'

Test #46:

score: 0
Accepted
time: 208ms
memory: 44912kb

input:

100000 133332
5308 80893 82558 1000000000
55429 91545 82558 1000000000
2286 96670 82558 999999999
6283 21652 82558 999999999
39741 85659 82558 1000000000
14898 51728 82558 1000000000
74997 79385 82558 1000000000
9827 22942 82558 999999999
41101 98528 82558 999999999
56355 97898 82558 1000000000
2454...

output:

66665999951917

result:

ok single line: '66665999951917'

Test #47:

score: 0
Accepted
time: 198ms
memory: 46144kb

input:

99999 149994
15841 55040 116947 40855
1021 55040 116947 64317
13722 55040 116947 87277
14055 55236 116947 21397
1 88207 116947 28492
1 39111 116947 34195
56348 59837 116947 41405
23845 91066 116947 9009
46444 48539 116947 76709
12187 47519 116947 32407
26870 76678 116947 60527
4668 55040 116947 5237...

output:

2000049998

result:

ok single line: '2000049998'

Test #48:

score: 0
Accepted
time: 373ms
memory: 57332kb

input:

100000 199993
55301 67577 18304 74208907
1 27543 173704 59423095
1 74439 144460 39981026
67577 94683 159687 47177485
1 83304 24483 59245219
1 44538 187159 72099419
67600 99809 95556 904079281
1 89151 171126 10510401
15002 67577 159063 66116720
67577 75933 177455 10785473
1 38751 167688 3051888
33957...

output:

964627556

result:

ok single line: '964627556'

Extra Test:

score: 0
Extra Test Passed