QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#532786#4272. Phone Planssonson6 810ms87052kbC++143.7kb2024-08-25 11:49:312024-08-25 11:49:32

Judging History

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

  • [2024-08-25 11:49:32]
  • 评测
  • 测评结果:6
  • 用时:810ms
  • 内存:87052kb
  • [2024-08-25 11:49:31]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
const int maxN=2e5+5;
const ll inf=2e18;
int n,A,B,k,pa[maxN+1],par[maxN+1];
ll ca[maxN+1],cb[maxN+1];
map<pii,int> mp;
struct canh
{
    int u,v;
    ll w;
};
struct node
{
    int u,pre,cur;
};
vector<node> vec_a[maxN+1],vec_b[maxN+1];
canh a[maxN+1],b[maxN+1];
struct dsu
{
    int parent[maxN+1];
    ll cnt;
    vector<int> vec[maxN+1];
    dsu()
    {
        memset(parent,-1,sizeof(parent));
        for(int i=1;i<=n;i++)
        {
            vec[i].clear();
            vec[i].push_back(i);
        }
        cnt=0;
    }
    void clr()
    {
        memset(parent,-1,sizeof(parent));
        for(int i=1;i<=n;i++)
        {
            vec[i].clear();
            vec[i].push_back(i);
        }
        cnt=0;
    }
    int Find(int v)
    {
        if(parent[v]<0)
        {
            return v;
        }
        return parent[v]=Find(parent[v]);
    }
    vector<node> Union(int a,int b)
    {
        a=Find(a);
        b=Find(b);
        vector<node> vt;
        if(a==b)
        {
            return vt;
        }
        if(-parent[a]<-parent[b])
        {
            swap(a,b);
        }
        cnt+=(parent[a]*parent[b]);
        parent[a]+=parent[b];
        parent[b]=a;
        //cout<<vec[a].size()<<" "<<vec[b].size()<<" ";
        for(auto i:vec[b])
        {
            vec[a].push_back(i);
            vt.push_back({i,b,a});
        }
        return vt;
    }
}ds;
int main()
{
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>A>>B>>k;
    for(int i=1;i<=A;i++)
    {
        cin>>a[i].u>>a[i].v>>a[i].w;
    }
    sort(a+1,a+A+1,[&](canh x,canh y)
    {
        return x.w<y.w;
    });
    for(int i=1;i<=B;i++)
    {
        cin>>b[i].u>>b[i].v>>b[i].w;
    }
    sort(b+1,b+B+1,[&](canh x,canh y)
    {
        return x.w<y.w;
    });
    if(k==0)
    {
        cout<<0;
        return 0;
    }
    ll ans=inf;
    for(int i=1;i<=n;i++)
    {
        ds.vec[i].push_back(i);
    }
    for(int i=1;i<=A;i++)
    {
        //cout<<a[i].u<<" "<<a[i].v<<" "<<a[i].w<<'\n';
        vec_a[i]=ds.Union(a[i].u,a[i].v);
        ca[i]=ds.cnt;
        if(ca[i]>=k)
        {
            ans=min(ans,a[i].w);
        }
    }
    ds.clr();
    for(int i=1;i<=n;i++)
    {
        ds.vec[i].push_back(i);
    }
    for(int i=1;i<=B;i++)
    {
        vec_b[i]=ds.Union(b[i].u,b[i].v);
        cb[i]=ds.cnt;
        if(cb[i]>=k)
        {
            ans=min(ans,b[i].w);
        }
    }
    for(int i=1;i<=n;i++)
    {
        pa[i]=i;
        par[i]=ds.Find(i);
        mp[{pa[i],par[i]}]++;
    }
    ll ch=0;
    for(int i=1,j=B;i<=A;i++)
    {
        for(auto [u,pre,cur]:vec_a[i])
        {
            mp[{pa[u],par[u]}]--;
            ch-=mp[{pa[u],par[u]}];
            pa[u]=cur;
            ch+=mp[{pa[u],par[u]}];
            mp[{pa[u],par[u]}]++;
        }
        while(j>=1&&ca[i]+cb[j]-ch>=k)
        {
            for(auto [u,pre,cur]:vec_b[j])
            {
                mp[{pa[u],par[u]}]--;
                ch-=mp[{pa[u],par[u]}];
                par[u]=pre;
                ch+=mp[{pa[u],par[u]}];
                mp[{pa[u],par[u]}]++;
            }
            j--;
        }
        if(j!=B)
        {
            //cout<<i<<" "<<j<<" "<<ch<<'\n';
            ans=min(ans,a[i].w+b[j+1].w);
        }
    }
    if(ans==inf)
    {
        cout<<-1;
    }
    else cout<<ans;
}

详细

Subtask #1:

score: 6
Accepted

Test #1:

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

input:

6 4 4 9
1 2 1
2 3 2
1 4 3
3 4 4
5 6 40
1 5 30
2 6 20
3 6 10

output:

33

result:

ok single line: '33'

Test #2:

score: 6
Accepted
time: 2ms
memory: 20952kb

input:

1 0 0 0

output:

0

result:

ok single line: '0'

Test #3:

score: 6
Accepted
time: 5ms
memory: 21536kb

input:

2 0 0 1

output:

-1

result:

ok single line: '-1'

Test #4:

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

input:

2 10 10 1
1 1 915886339
2 2 430624192
1 1 879808770
1 2 577221915
1 1 439429731
1 2 304911826
1 1 148009333
1 2 51122687
1 1 558282772
1 2 421196385
2 1 436692145
1 2 654020563
2 2 162573477
2 2 989531779
1 1 646687051
2 2 549037477
2 2 699532275
1 1 679375858
2 1 83352965
2 1 415698228

output:

51122687

result:

ok single line: '51122687'

Test #5:

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

input:

2 10 10 1
1 1 1000000000
1 2 1000000000
2 2 1000000000
2 1 1000000000
1 2 1000000000
1 1 1000000000
1 2 1000000000
2 2 1000000000
1 2 1000000000
1 2 1000000000
2 1 1000000000
1 2 1000000000
2 1 1000000000
2 2 1000000000
1 2 1000000000
2 2 1000000000
1 1 1000000000
1 1 1000000000
2 2 1000000000
1 2 1...

output:

1000000000

result:

ok single line: '1000000000'

Test #6:

score: 6
Accepted
time: 40ms
memory: 28880kb

input:

2000 0 200000 1199833
636 1231 120395621
689 1640 497332138
1861 1980 798839749
560 1283 560726905
1332 328 431171189
1203 1764 466367210
1102 347 317109768
1462 789 761470540
350 1093 551905741
1718 1047 548650524
51 546 56733461
58 1519 744207013
826 956 943929583
1969 207 238061756
99 47 99683567...

output:

9768257

result:

ok single line: '9768257'

Test #7:

score: 6
Accepted
time: 50ms
memory: 26748kb

input:

2000 200000 0 1937051
1325 1770 628367155
105 1670 728177982
358 778 959944062
826 1691 651665248
1119 1906 382208628
1684 1232 677646622
807 265 902880211
1685 1660 405567549
1853 1982 988679307
1241 1054 385406922
862 1049 356441384
1837 673 443580113
1082 1795 738355567
1703 663 221254144
1792 84...

output:

20263921

result:

ok single line: '20263921'

Test #8:

score: 6
Accepted
time: 86ms
memory: 28948kb

input:

2000 200000 200000 1999000
1303 1065 135024256
1400 1409 157921645
1208 515 422761224
466 1398 267944161
40 1202 560552418
722 1817 773826339
1022 1534 720452215
1512 200 145291518
538 230 98848391
434 529 911575234
470 1050 103133355
1800 351 180303134
1527 1871 779519820
258 1872 279904732
1 512 4...

output:

1999

result:

ok single line: '1999'

Test #9:

score: 6
Accepted
time: 86ms
memory: 28332kb

input:

2000 200000 200000 1999000
1566 1720 828051227
411 209 634755980
293 258 80524979
1149 1694 253684780
71 597 899974207
1934 440 11614281
1846 870 794303074
800 1090 576722282
1022 1619 486756658
1135 1004 589873220
1300 326 565865513
114 341 308227260
310 134 735603010
437 291 714079414
930 1131 136...

output:

1999

result:

ok single line: '1999'

Test #10:

score: 6
Accepted
time: 90ms
memory: 29676kb

input:

2000 200000 200000 1999000
1505 1008 194848918
955 1466 251380587
306 119 329528655
1072 1067 684468438
1798 755 822161204
1475 1987 886864916
609 790 525637795
1937 1639 534864650
63 792 948290690
1282 553 998185081
1995 243 367638087
1517 982 238895274
1891 358 612397768
229 1599 453255817
200 115...

output:

1999

result:

ok single line: '1999'

Test #11:

score: 6
Accepted
time: 90ms
memory: 29404kb

input:

2000 200000 200000 1999000
888 998 519088944
896 217 366603047
963 1703 281897731
1419 1583 296352197
318 1644 449932680
1252 683 299241251
1763 1736 16908823
400 673 940814267
1864 1654 16539370
21 1360 526031095
320 1052 879613936
383 555 433309121
243 869 603865861
567 236 829646077
1057 1138 545...

output:

2000

result:

ok single line: '2000'

Test #12:

score: 6
Accepted
time: 4ms
memory: 20652kb

input:

2000 0 0 0

output:

0

result:

ok single line: '0'

Test #13:

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

input:

2000 0 0 1

output:

-1

result:

ok single line: '-1'

Test #14:

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

input:

2000 0 0 1999000

output:

-1

result:

ok single line: '-1'

Test #15:

score: 6
Accepted
time: 84ms
memory: 24944kb

input:

2000 200000 200000 0
584 721 144517612
1593 1184 19655376
572 91 267489352
441 830 206284803
326 901 399207297
1220 164 270714861
1760 1765 242123575
1341 1187 778391819
247 104 618482901
1650 876 469853007
1338 660 237312298
593 1856 254405769
477 1212 387844191
603 1896 336160240
1397 444 77343103...

output:

0

result:

ok single line: '0'

Test #16:

score: 6
Accepted
time: 104ms
memory: 29340kb

input:

2000 200000 200000 1
1961 656 558726882
677 479 191436128
1411 291 100142168
932 1506 28223846
1264 1394 780504516
1276 1479 56569386
1363 65 480245792
1598 78 760054359
78 36 593906829
1112 535 999996793
1792 953 155333434
149 239 901391869
791 1800 803139774
1856 629 626568419
1931 779 330675974
8...

output:

2823

result:

ok single line: '2823'

Test #17:

score: 6
Accepted
time: 93ms
memory: 29008kb

input:

2000 200000 200000 4
1165 1872 797718594
1169 1055 624587802
866 899 658187098
1376 1679 853872729
635 1186 401602136
1058 241 170579264
1988 1953 539060919
1695 772 816154776
1551 1453 798051114
1678 810 856500252
637 1519 373040351
1663 1237 499974912
1222 174 950339946
952 1956 666630512
1053 17 ...

output:

13422

result:

ok single line: '13422'

Test #18:

score: 6
Accepted
time: 94ms
memory: 29980kb

input:

2000 200000 200000 51
825 28 972433150
472 1380 981558124
178 1129 462887818
496 1916 874585551
1806 1093 459363528
853 1063 835229701
1473 1816 509538236
1762 139 445678501
600 826 116492230
1924 1426 768569961
1093 802 138198370
1285 101 612512942
1696 527 863059072
1729 1091 238488099
1799 1725 9...

output:

207785

result:

ok single line: '207785'

Test #19:

score: 6
Accepted
time: 84ms
memory: 29948kb

input:

2000 200000 200000 346
479 1073 12925746
1739 528 708374552
1669 1597 187841053
420 1886 665883774
264 1753 39508213
1618 1695 153537785
734 950 163927318
946 639 332538805
1151 821 988862824
981 1265 633217016
1627 199 830812032
116 579 44204899
511 403 764449881
1828 538 469036862
953 1145 6928974...

output:

1325200

result:

ok single line: '1325200'

Test #20:

score: 6
Accepted
time: 92ms
memory: 29804kb

input:

2000 200000 200000 7700
1618 867 271795108
1951 151 702948614
463 231 446592273
882 479 999691562
1160 1496 458774157
862 177 365391789
1483 1529 152692222
1086 1926 981642023
650 1846 36577190
1541 1521 287755177
1549 145 326097587
1355 1965 846861888
968 1069 919410456
557 6 666217744
499 1453 429...

output:

4833174

result:

ok single line: '4833174'

Test #21:

score: 6
Accepted
time: 93ms
memory: 29064kb

input:

2000 200000 200000 10274
427 1831 50634939
924 761 973624360
1716 77 896823723
1770 286 368244715
281 1652 693233017
782 982 856834549
1990 872 586803005
1104 545 550493462
438 75 19630828
1939 95 811185364
1691 325 517180701
1832 1560 781228281
687 1611 15723447
651 73 423147727
1750 768 923943157
...

output:

4715135

result:

ok single line: '4715135'

Test #22:

score: 6
Accepted
time: 93ms
memory: 30020kb

input:

2000 200000 200000 353724
828 1686 612966370
1332 36 325102273
50 1233 839762664
1389 740 256158152
640 18 76640380
1324 508 966364428
1791 314 236880043
1092 1586 81535148
602 1178 352534909
640 1224 733613612
970 297 526950089
1654 1677 277859934
1583 1933 511147393
56 1854 778804499
1051 17 52473...

output:

6546895

result:

ok single line: '6546895'

Test #23:

score: 6
Accepted
time: 91ms
memory: 28440kb

input:

2000 200000 200000 1999000
1499 1526 627651931
378 1689 609556194
1326 237 371224081
98 527 251964139
1280 1750 293612965
905 1848 881495354
1870 900 902279678
1496 267 634703468
59 800 164035702
109 1934 882309468
1966 702 519776748
1020 666 951531959
385 850 241053535
1211 255 903671592
66 1285 65...

output:

34222040

result:

ok single line: '34222040'

Test #24:

score: 6
Accepted
time: 79ms
memory: 26220kb

input:

2000 200000 200000 0
1820 354 521259580
1799 1723 883151663
1892 479 590713896
748 499 454440477
1752 334 983007379
56 69 157027005
554 112 225804047
1680 600 279675368
36 1372 868160579
1988 1586 523730820
35 1704 39797544
117 1627 846004390
354 1056 280474791
1736 1676 249305541
1269 111 692287711...

output:

0

result:

ok single line: '0'

Test #25:

score: 6
Accepted
time: 96ms
memory: 29800kb

input:

2000 200000 200000 1
1787 1732 413014305
1909 217 339214620
519 1338 435678958
883 831 44937921
1912 970 736120426
1190 1219 718941669
1216 1909 109658172
1849 1869 686616094
301 965 677802187
445 724 195098678
1306 1951 299168831
1970 262 204353384
1220 1409 504375659
1713 623 754436498
1452 1620 5...

output:

2

result:

ok single line: '2'

Test #26:

score: 6
Accepted
time: 93ms
memory: 28968kb

input:

2000 200000 200000 4
402 1914 269682654
675 1436 291439604
193 370 988082031
1849 1502 691456540
883 665 492038489
28 1266 573600132
1656 352 680334585
1668 1039 911608739
157 1752 964298632
979 19 526980
1113 504 262870788
126 541 220684410
269 1031 721802318
1900 1999 328920840
1770 641 692254361
...

output:

37

result:

ok single line: '37'

Test #27:

score: 6
Accepted
time: 93ms
memory: 29992kb

input:

2000 200000 200000 26
526 1621 483988447
1703 1932 686404766
1111 1245 624032004
1457 1671 886702864
409 957 385143382
1928 1503 977317507
1319 349 983715228
401 30 251459110
245 1355 563161269
459 1436 965861604
679 949 983070365
1692 1261 456157217
698 99 409820975
1528 1362 963977301
1295 1852 79...

output:

25

result:

ok single line: '25'

Test #28:

score: 6
Accepted
time: 93ms
memory: 29052kb

input:

2000 200000 200000 625
728 133 344090289
1062 1880 597135161
844 1495 874100306
1930 389 490213163
1783 724 571192863
1499 1894 866097805
325 687 79859122
1674 1747 563976487
1940 60 855240336
1516 1087 431861062
1314 1217 250576340
646 311 63874546
647 1552 870943884
1535 1190 223697
345 1186 65344...

output:

39

result:

ok single line: '39'

Test #29:

score: 6
Accepted
time: 86ms
memory: 30020kb

input:

2000 200000 200000 4700
1725 821 429457120
1764 490 903325799
660 1294 347283520
325 16 253789876
464 1258 168173237
80 660 57504741
1136 1316 769617858
1767 1394 287008686
1824 1206 820352296
114 330 965781020
140 223 885989447
1458 742 932496684
762 1574 655017664
1598 596 723299463
1213 1898 5236...

output:

84

result:

ok single line: '84'

Test #30:

score: 6
Accepted
time: 90ms
memory: 29956kb

input:

2000 200000 200000 88061
668 1817 402362288
1250 696 637044070
1793 1147 890609254
1839 671 427058014
1636 51 777111988
567 359 308999615
1552 1510 40834395
1566 1311 738132782
271 1975 807983143
998 82 633239353
1096 843 454384442
102 1427 218117173
329 227 915637054
685 1727 911188324
1330 1175 94...

output:

652572

result:

ok single line: '652572'

Test #31:

score: 6
Accepted
time: 92ms
memory: 29120kb

input:

2000 200000 200000 533113
1338 1754 782883635
1349 1488 592703188
1645 1448 477986692
733 1042 47
981 1720 461041447
263 452 26372078
1812 765 384744847
205 372 507702235
12 1369 191909928
288 1600 812952698
1238 762 715972252
912 1876 653427552
974 1617 941376898
43 1554 514299614
220 1772 58179883...

output:

1962115

result:

ok single line: '1962115'

Test #32:

score: 6
Accepted
time: 90ms
memory: 29260kb

input:

2000 200000 200000 1999000
713 984 491810215
23 1495 711013830
1680 304 483176300
121 1907 948073782
176 89 573161170
1928 609 583837234
736 990 511532333
1734 1850 807407784
821 1402 566288558
1818 835 317847108
1824 126 439452972
1585 467 46541223
775 1709 549038510
1487 205 239467439
1096 1794 38...

output:

31758367

result:

ok single line: '31758367'

Test #33:

score: 6
Accepted
time: 64ms
memory: 29472kb

input:

995 199991 199994 128256
177 82 677669502
416 854 677166289
543 794 364534270
680 242 8
760 186 900225249
875 563 337492994
732 766 894982532
114 483 4
259 885 8
954 157 590392390
308 566 1
37 871 633804510
606 410 916672224
125 450 6
190 582 536149589
453 3 4
116 891 3
585 875 495228925
191 718 6
4...

output:

-1

result:

ok single line: '-1'

Test #34:

score: 6
Accepted
time: 77ms
memory: 28224kb

input:

996 199992 199993 124753
205 430 710291462
748 756 293873327
59 894 536099901
632 890 9
452 316 3
652 215 10
273 487 8
469 308 301806104
620 183 4
401 401 946696222
305 647 1
925 765 518528395
980 190 3
289 597 815252846
509 691 262814273
279 155 3
708 808 4
878 326 296665089
993 513 3
883 903 1
317...

output:

4319483

result:

ok single line: '4319483'

Test #35:

score: 6
Accepted
time: 73ms
memory: 28856kb

input:

997 199993 199992 124253
469 654 830723036
65 266 47739481
202 516 43614641
450 876 737667977
641 801 147893631
866 193 8
994 801 774993226
195 398 2
383 177 6
146 782 9
379 379 192058079
320 539 4
303 86 934535571
939 262 8
704 536 762562635
700 419 1
455 92 627464094
408 731 1
671 514 160757934
40...

output:

2465177

result:

ok single line: '2465177'

Test #36:

score: 6
Accepted
time: 64ms
memory: 28396kb

input:

998 199994 199991 124351
415 390 904570266
833 971 232183018
379 44 4
48 884 626169357
276 73 610900123
796 900 508923131
470 553 829096662
577 319 8
869 52 2
120 684 9
38 486 722467116
131 55 967841018
294 256 73055903
958 350 580089254
86 86 228617822
318 469 842579267
368 387 3
271 958 906176840
...

output:

659354

result:

ok single line: '659354'

Test #37:

score: 6
Accepted
time: 3ms
memory: 26984kb

input:

991 1990 1994 478740
207 85 448218904
597 457 171948410
694 916 64279329
887 773 546537318
823 474 274118886
537 337 29463181
774 790 740341746
519 263 854029433
672 88 541727414
511 529 850564468
739 665 797508491
40 659 122614430
337 219 353063113
811 126 478325496
348 587 746769857
800 169 303996...

output:

1767887856

result:

ok single line: '1767887856'

Test #38:

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

input:

997 1991 1993 484173
852 732 126678270
135 936 229775881
570 641 437402237
371 549 696980033
822 184 101268287
437 537 354404827
134 78 711324352
688 325 693925447
686 684 913713164
517 539 56813322
894 901 208395516
29 775 257694171
335 484 764720970
940 183 85080357
175 633 769278190
568 320 79030...

output:

1833053865

result:

ok single line: '1833053865'

Test #39:

score: 6
Accepted
time: 7ms
memory: 26104kb

input:

993 1992 1992 480707
63 659 677224503
750 57 329741935
563 292 492017497
213 264 204565684
750 326 474751877
714 180 100924568
579 617 316599370
350 84 321786007
926 308 142010183
163 211 962351042
250 54 172653606
477 534 22944969
603 653 926301029
928 449 283289417
774 760 584645421
232 563 569605...

output:

1949479093

result:

ok single line: '1949479093'

Test #40:

score: 6
Accepted
time: 2ms
memory: 27152kb

input:

999 1993 1991 487053
845 849 847102702
858 888 48454285
952 568 163696556
614 873 871362801
324 419 496504727
715 418 594630937
840 185 73686216
114 841 40600395
999 995 263506041
97 309 290200784
287 7 109411009
79 236 351218008
356 196 983091766
156 427 467315914
295 62 225676544
457 968 40660581
...

output:

1949517923

result:

ok single line: '1949517923'

Test #41:

score: 6
Accepted
time: 77ms
memory: 29360kb

input:

10 200000 200000 6
9 8 986848285
8 3 931517081
1 10 990030276
6 8 22174654
3 9 741608620
7 10 996595127
3 4 405443883
2 9 448297485
10 7 280036332
4 2 638708919
1 8 846101420
1 9 383098176
2 2 4438084
4 7 915119923
5 6 471311946
9 5 750933612
8 7 15209562
4 2 486285449
5 10 344117831
7 4 497234139
6...

output:

23502

result:

ok single line: '23502'

Test #42:

score: 6
Accepted
time: 76ms
memory: 27852kb

input:

10 200000 200000 23
3 7 658934308
9 10 81386292
5 4 285652873
2 5 772523383
1 1 795730594
5 8 50741312
9 2 971246865
2 7 567991455
4 8 689065221
6 6 344345044
9 10 70929696
6 8 650959161
10 6 295074773
3 1 808325119
5 4 22435862
2 2 731323941
6 9 146620290
4 2 917959872
1 9 886553133
9 4 727689938
4...

output:

26277

result:

ok single line: '26277'

Test #43:

score: 6
Accepted
time: 85ms
memory: 28232kb

input:

300 200000 200000 139
236 121 474662147
167 124 651551538
217 250 689739994
250 69 700658272
186 222 499487702
7 212 257241553
64 42 975321190
83 92 880594246
205 261 169920659
278 107 531192669
170 58 699055139
170 204 693987112
50 296 877792979
222 182 151537649
269 6 253701023
209 98 597012262
9 ...

output:

294541

result:

ok single line: '294541'

Test #44:

score: 6
Accepted
time: 80ms
memory: 28208kb

input:

300 200000 200000 20412
210 264 216203670
214 250 974296634
279 32 929952113
38 18 249913810
108 167 260470215
86 66 910068208
249 5 827240466
9 116 953392349
225 40 102480156
239 94 279596519
30 279 818189190
80 184 477648217
60 5 610659451
192 152 679644035
147 35 926830323
249 59 548262871
244 13...

output:

1102575

result:

ok single line: '1102575'

Test #45:

score: 6
Accepted
time: 94ms
memory: 30156kb

input:

1999 199999 199999 1002
604 1732 501973414
1124 1158 896848515
943 536 728730188
381 40 495131150
1204 1018 574946791
246 1677 57734808
1501 969 120747416
1432 994 962365222
1057 256 504254448
1902 886 686620566
1620 1954 520319198
1163 1599 6285366
1986 927 383847231
1893 272 421070825
1576 1519 57...

output:

2306516

result:

ok single line: '2306516'

Test #46:

score: 6
Accepted
time: 91ms
memory: 29392kb

input:

1999 199999 199999 934932
710 356 986359567
163 502 931269266
45 1640 894661892
248 1884 439841951
964 985 923332517
578 527 651980920
1954 1659 377309921
1658 485 565876604
1800 1410 431357741
1752 1368 666306267
136 765 157434202
244 1692 967595289
628 164 183326670
1101 1403 888498455
1065 1177 8...

output:

8279303

result:

ok single line: '8279303'

Test #47:

score: 6
Accepted
time: 88ms
memory: 29900kb

input:

1999 199999 199999 1997001
658 1076 283443107
638 281 264713525
1384 492 753401774
9 519 536302760
648 1497 978398389
119 1531 438321711
853 320 112394960
1717 1811 871346582
1862 781 39868053
1098 1506 489357373
1349 1606 524593749
418 422 382334468
403 905 91375635
966 246 105604949
1184 1932 5685...

output:

34065884

result:

ok single line: '34065884'

Test #48:

score: 6
Accepted
time: 66ms
memory: 28704kb

input:

1999 199999 199999 903
1947 1930 7
1852 1509 38
1542 1490 12
1397 1155 20
1145 9 15
1771 626 5
1853 735 28
1457 149 24
103 1036 95
970 598 26
857 618 3
1367 1495 3
215 526 88
419 1906 54
1348 1504 38
178 775 27
388 1216 52
1648 874 83
1063 1611 67
286 995 33
680 1662 37
449 1211 37
1334 1894 64
724 ...

output:

1

result:

ok single line: '1'

Test #49:

score: 6
Accepted
time: 70ms
memory: 28744kb

input:

1999 199999 199999 54468
738 1355 12
266 279 26
1029 1930 77
438 693 70
260 1050 34
1800 1035 27
1099 589 60
1934 1559 62
237 1214 29
1443 1136 33
571 808 24
1374 1209 6
398 1431 66
910 157 39
454 414 60
196 648 94
1520 647 23
1634 1824 22
1362 100 23
1612 1213 11
1896 1831 51
907 1056 90
1012 790 9...

output:

1

result:

ok single line: '1'

Test #50:

score: 6
Accepted
time: 6ms
memory: 27784kb

input:

2000 1000 1000 6879
1682 164 667209728
807 1245 46633516
1746 783 466227603
1066 1001 348097974
1044 271 759817769
97 936 51212234
75 1831 17340243
824 662 67837847
1498 120 160058344
1027 1184 941941144
1775 1269 22603192
1185 198 411282331
1065 65 105993975
77 626 353162560
1373 297 157133433
367 ...

output:

856920573

result:

ok single line: '856920573'

Test #51:

score: 6
Accepted
time: 39ms
memory: 26920kb

input:

2000 200000 87 5103
174 220 879476599
558 1943 13889882
530 839 757645356
614 1677 343073496
300 1480 734125448
592 555 336534868
785 1638 558198904
637 534 430996677
427 1519 215449815
1085 622 92229729
1452 880 993560457
1079 662 487134334
715 1566 285881213
366 737 554460906
14 556 609656702
430 ...

output:

4499824

result:

ok single line: '4499824'

Test #52:

score: 6
Accepted
time: 43ms
memory: 27016kb

input:

2000 103 199999 7540
452 1208 96
408 462 32
1461 428 100
997 678 21
1789 668 11
853 1617 38
1095 738 1
487 932 39
425 548 71
1573 1566 96
517 403 58
1050 1161 12
1815 1135 67
420 990 1
473 531 62
1120 1063 5
1049 1281 75
1146 598 45
1373 536 62
844 533 26
1514 1368 68
318 1447 65
202 1123 83
54 1227...

output:

4782088

result:

ok single line: '4782088'

Subtask #2:

score: 0
Wrong Answer

Test #53:

score: 5
Accepted
time: 701ms
memory: 82312kb

input:

200000 100000 100000 7628995
23677 113459 839167193
165893 15365 669621527
26287 109671 214795757
156871 136723 522277985
9957 100463 806718116
104783 161385 156110975
184577 92225 545172629
57373 130083 980035338
167231 49597 919886451
115601 24325 717233004
99413 141311 737488449
83437 62759 76873...

output:

502149991

result:

ok single line: '502149991'

Test #54:

score: 5
Accepted
time: 376ms
memory: 65588kb

input:

200000 200000 87 2694
197233 86229 181875035
85167 196363 328068482
177795 65479 693403443
119609 181977 588691030
115815 139981 486110961
92473 20483 199129328
166989 95385 210368646
98095 54673 357307451
122543 94377 907487846
46611 80735 71787832
158893 117071 521262491
92051 104395 365725125
142...

output:

11965880

result:

ok single line: '11965880'

Test #55:

score: 5
Accepted
time: 471ms
memory: 68584kb

input:

200000 103 199999 1593
75203 150269 64
68675 175215 100
176335 11837 94
33623 63279 56
16617 86741 63
167219 52783 58
6575 134399 1
144065 114171 2
32625 99459 50
35311 152509 36
132975 12211 8
175275 107903 23
17477 21319 95
157759 66683 71
34577 78339 26
154003 26703 18
187863 90945 74
116071 1089...

output:

7037526

result:

ok single line: '7037526'

Test #56:

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

input:

1 0 0 0

output:

0

result:

ok single line: '0'

Test #57:

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

input:

1 1 0 0
1 1 1

output:

0

result:

ok single line: '0'

Test #58:

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

input:

2 0 0 1

output:

-1

result:

ok single line: '-1'

Test #59:

score: 5
Accepted
time: 75ms
memory: 28748kb

input:

2 200000 200000 1
1 1 540311820
1 1 825820034
1 1 555157427
1 1 288420080
1 1 672135630
1 1 726777321
1 1 526670467
1 1 959728057
1 1 146842949
1 1 122695951
1 1 432194433
1 1 381185144
1 1 686598677
1 1 215624542
1 1 458312135
1 1 986262083
1 1 947920916
1 1 934427659
1 1 782364899
1 1 715992893
1 ...

output:

-1

result:

ok single line: '-1'

Test #60:

score: 5
Accepted
time: 51ms
memory: 28488kb

input:

2 200000 200000 1
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 10000000...

output:

-1

result:

ok single line: '-1'

Test #61:

score: 5
Accepted
time: 115ms
memory: 53996kb

input:

200000 0 200000 352487
135712 118584 670867088
72546 31680 1279343
123412 184392 678367510
125022 192330 57001931
134050 61434 212353526
6066 95972 717546833
47726 9232 949490922
166856 33998 986508808
166254 92344 143252836
82392 100980 919436840
84316 12292 753153826
192154 134452 832321404
144418...

output:

216679869

result:

ok single line: '216679869'

Test #62:

score: 5
Accepted
time: 344ms
memory: 63668kb

input:

200000 200000 0 1089706
197033 84309 947754387
112807 60173 477333202
102607 132751 957665006
143619 102001 642146230
32419 155751 770317403
53835 4703 414754921
9463 17929 312775978
172373 41459 29632969
48451 142975 596586913
36019 180115 791609008
145487 162325 699635731
177243 94157 221311090
18...

output:

245598855

result:

ok single line: '245598855'

Test #63:

score: 5
Accepted
time: 56ms
memory: 48036kb

input:

200000 200000 200000 19999900000
86215 110793 27420223
115281 150421 94498
135039 177319 663933319
36159 42207 779673045
183713 40779 749203477
19775 65311 4733
107303 126899 734749608
156297 176907 75566437
125743 186407 98466
140359 177109 654885923
71583 37783 772116721
159971 195153 554369442
98...

output:

-1

result:

ok single line: '-1'

Test #64:

score: 5
Accepted
time: 60ms
memory: 48156kb

input:

200000 200000 200000 19999900000
85515 12697 64028
96111 81277 723665166
2725 17313 680441413
93491 175625 540828929
67585 1395 36003
67231 61263 36674
38071 156361 828146734
28859 160423 12411
145939 126471 712935428
94263 91967 539663194
63247 197497 523841579
78633 56647 13319
167061 116147 69378...

output:

-1

result:

ok single line: '-1'

Test #65:

score: 5
Accepted
time: 60ms
memory: 48388kb

input:

200000 200000 200000 19999900000
148005 59733 752041265
123653 133439 52211
145097 100735 849514916
81383 172715 82449
73561 151351 5461
89063 14693 344507089
21037 114603 83348
58421 27517 990178176
92093 52843 44132
47187 108097 654752253
125675 121519 379610893
180175 114853 432259513
101563 1539...

output:

-1

result:

ok single line: '-1'

Test #66:

score: 5
Accepted
time: 61ms
memory: 48092kb

input:

200000 200000 200000 19999900000
84373 49303 809503019
121957 178579 27747
17401 130691 81723
167037 65841 156510963
150147 91835 955602352
38921 199303 799434899
148503 143389 545115194
167915 178111 32040
157739 135137 406444987
151557 114653 959815310
183647 73983 60436
22453 173189 907941124
942...

output:

-1

result:

ok single line: '-1'

Test #67:

score: 5
Accepted
time: 2ms
memory: 21488kb

input:

200000 0 0 0

output:

0

result:

ok single line: '0'

Test #68:

score: 5
Accepted
time: 32ms
memory: 42044kb

input:

200000 0 0 1

output:

-1

result:

ok single line: '-1'

Test #69:

score: 5
Accepted
time: 45ms
memory: 42064kb

input:

200000 0 0 19999900000

output:

-1

result:

ok single line: '-1'

Test #70:

score: 5
Accepted
time: 90ms
memory: 25608kb

input:

200000 200000 200000 0
87819 103509 211262
70831 128635 830521513
113429 141129 784161896
129435 11587 889301002
44001 115103 595627949
47949 142581 707781370
131047 3629 922790958
23679 66389 332015888
129675 123163 971290575
179611 66043 669206978
97337 71783 492187074
7571 2423 622850189
38605 78...

output:

0

result:

ok single line: '0'

Test #71:

score: 5
Accepted
time: 795ms
memory: 86504kb

input:

200000 200000 200000 1
156245 167853 177174928
188863 72787 774437619
4585 19395 257360617
128879 170657 682214518
161355 176611 304747786
43047 106383 127598967
24279 82135 957118009
196215 59199 751930028
170851 67831 778264730
137919 197693 331012429
11523 16765 713111895
97017 106453 758909521
1...

output:

2038

result:

ok single line: '2038'

Test #72:

score: 5
Accepted
time: 802ms
memory: 86432kb

input:

200000 200000 200000 7
57525 173001 851535810
90143 40469 390254518
47345 90621 810622886
30795 49971 298834588
189903 46443 134186592
137675 28429 339466374
69059 184047 584089294
147913 80315 8146656
179297 104151 362297351
70649 53131 388526766
107483 143767 505780466
148763 182199 408802373
1033...

output:

15612

result:

ok single line: '15612'

Test #73:

score: 5
Accepted
time: 775ms
memory: 86172kb

input:

200000 200000 200000 46
111931 134159 889741544
149639 128081 372249571
23933 64913 441243094
110657 34439 947713738
181857 11825 495039256
180791 95409 524765235
163423 157431 391773005
97399 19671 904565768
187819 122831 911398340
57913 31101 694661062
101755 67855 888773520
130677 22999 216816765...

output:

171465

result:

ok single line: '171465'

Test #74:

score: 5
Accepted
time: 788ms
memory: 86932kb

input:

200000 200000 200000 644
117565 176843 664885033
56817 162365 734743320
54117 113661 518155584
42661 109889 910590800
184271 71485 832406650
134697 122943 821929672
165513 26247 148140143
8219 181481 86904456
123701 150771 215687547
162763 49093 804995017
68581 130605 871496281
129291 12421 81737374...

output:

3160928

result:

ok single line: '3160928'

Test #75:

score: 5
Accepted
time: 743ms
memory: 86552kb

input:

200000 200000 200000 9470
171111 2867 135877098
129249 152799 427879861
44787 147563 166499191
4049 96289 733086628
121413 161723 119790707
53823 26279 736094176
53209 21459 928020229
51875 164485 617069767
34989 162955 337423730
108607 67767 141743345
117349 49929 922096240
134763 159225 820844700
...

output:

39338620

result:

ok single line: '39338620'

Test #76:

score: 5
Accepted
time: 780ms
memory: 86860kb

input:

200000 200000 200000 207102
29097 162609 472583329
136721 82267 502393608
178201 7889 162637370
43571 135237 698283102
168337 172757 347459265
126915 60005 552335616
103453 54641 14743234
59795 129775 702064533
171131 21901 921708772
124561 16561 807682192
33863 11007 13951811
172639 105263 96633136...

output:

202638987

result:

ok single line: '202638987'

Test #77:

score: 5
Accepted
time: 737ms
memory: 86440kb

input:

200000 200000 200000 66872916
27507 50665 155273602
63343 156069 75020472
181663 50753 520878795
77509 28129 705673982
33245 174951 976831676
153713 85163 721085033
127259 6161 716492030
148789 134331 750274596
8561 57175 17590758
63299 66635 763607824
81369 4431 34802407
169897 47365 6726815
184919...

output:

267941690

result:

ok single line: '267941690'

Test #78:

score: 5
Accepted
time: 749ms
memory: 86132kb

input:

200000 200000 200000 1615967186
28597 192271 748036920
8605 23351 686852552
23287 29959 390000705
172725 134059 250213783
20357 83315 37310191
148995 71921 674659550
147185 167215 907355289
77011 197963 567378302
147807 91251 465576335
190569 66209 499989959
18711 151301 478858869
96941 134849 73221...

output:

369129717

result:

ok single line: '369129717'

Test #79:

score: 5
Accepted
time: 60ms
memory: 48400kb

input:

200000 200000 200000 19999900000
112503 57253 66896775
142933 121865 459414667
99371 122355 841207482
18691 173709 976104678
29297 122363 79369742
39535 103593 852787869
92907 33993 541571419
194967 10385 694194246
103103 134627 189235736
150783 145017 527545307
187573 119507 626973719
181775 111443...

output:

-1

result:

ok single line: '-1'

Test #80:

score: 5
Accepted
time: 89ms
memory: 25804kb

input:

200000 200000 200000 0
82843 119905 2583524
10507 18913 991293003
171809 64495 881500988
23257 66045 14535911
95047 90719 840253158
130695 69835 336717057
80583 11407 15024676
131497 26551 424800825
127311 6023 84888655
66333 68761 650490282
27757 100653 788929702
164597 174717 3551432
108259 91059 ...

output:

0

result:

ok single line: '0'

Test #81:

score: 5
Accepted
time: 769ms
memory: 86620kb

input:

200000 200000 200000 1
100811 121599 138028622
83761 143579 613818666
188697 90929 978369338
172647 61673 721538906
98327 128307 855590378
18281 152243 624679278
4781 196535 633678011
153681 8687 362612591
61427 68167 597252991
152747 46175 996937075
146283 146607 947213497
87217 193847 572910775
88...

output:

6

result:

ok single line: '6'

Test #82:

score: 5
Accepted
time: 768ms
memory: 86784kb

input:

200000 200000 200000 4
70805 100727 915972585
9871 423 20063341
95861 1189 166742797
44987 48891 364010233
110397 92427 89481016
112049 41599 351108130
124495 182231 304774083
459 98879 654767300
81797 131237 492054186
144729 75043 416998693
39807 50047 296330701
9309 153391 574952294
115185 28801 5...

output:

30

result:

ok single line: '30'

Test #83:

score: 5
Accepted
time: 768ms
memory: 86572kb

input:

200000 200000 200000 86
153383 11103 403918135
99409 144239 164593728
182949 10301 753173665
151897 192119 702947277
187711 131925 881466743
154587 24647 295938676
30497 84419 649572217
176585 66335 997147073
5753 1873 228093143
87479 65437 754608340
179955 78555 900370553
75275 142099 754833229
701...

output:

70

result:

ok single line: '70'

Test #84:

score: 5
Accepted
time: 784ms
memory: 86708kb

input:

200000 200000 200000 126
58325 112789 991133947
26987 137775 672190970
80473 167605 172720704
79117 182819 156150287
131239 82801 918367499
120195 105443 593878101
194587 11451 109101989
73607 40151 20162560
32309 151297 110017594
69237 36435 593075481
57789 64297 154442585
134043 100663 656524375
3...

output:

11

result:

ok single line: '11'

Test #85:

score: 5
Accepted
time: 810ms
memory: 86128kb

input:

200000 200000 200000 4168
142043 107975 814664551
124739 85295 511693466
76677 81869 567575769
46869 35815 340726821
79235 2583 766743732
76081 81839 640096127
191953 42843 747019292
137509 7219 90
12773 113211 755306384
42985 67677 564510301
34323 104351 401667666
172125 173955 67979333
93503 6989 ...

output:

39

result:

ok single line: '39'

Test #86:

score: 5
Accepted
time: 810ms
memory: 86616kb

input:

200000 200000 200000 736121
198763 72285 163834706
128665 178573 19
86459 147699 923501303
74591 2757 790745419
155137 23345 9
141451 67849 54
168899 31301 52
181411 71269 600237233
32203 143045 213145787
168661 160363 83121315
165259 31537 80
47199 43249 92
112143 33477 980402833
47707 62035 593882...

output:

48

result:

ok single line: '48'

Test #87:

score: 5
Accepted
time: 796ms
memory: 87052kb

input:

200000 200000 200000 47010116
197353 153635 432621012
182969 15291 19
26115 68265 5
161387 84017 440653544
22667 18401 921402945
23603 110533 52804844
71083 34611 28
63401 47113 652057634
18363 62213 719650067
80071 123547 715385190
57023 35361 44
84037 64051 542266879
155871 131941 9
46449 195331 7...

output:

53

result:

ok single line: '53'

Test #88:

score: 5
Accepted
time: 775ms
memory: 86420kb

input:

200000 200000 200000 1348160454
65481 175369 60
116069 29613 36480437
25465 197007 5
166653 121999 4
93545 130519 241445605
65073 159281 73
92419 157433 61
137743 144567 528229725
20099 62855 57
104317 198329 27
186745 25903 954572672
90133 135343 693873674
41013 121387 13273762
46705 14257 59
10911...

output:

71

result:

ok single line: '71'

Test #89:

score: 5
Accepted
time: 49ms
memory: 48160kb

input:

200000 200000 200000 19999900000
103853 52629 160834957
116877 159979 51
181147 16769 41821995
151625 128229 65
195005 154095 1
167795 44515 71
197149 161495 530415114
111515 33907 950395437
167317 65991 8
68889 134661 79
78277 51137 12
199689 158023 56
92327 59039 388003009
157535 194629 788091982
...

output:

-1

result:

ok single line: '-1'

Test #90:

score: 5
Accepted
time: 220ms
memory: 50128kb

input:

99995 199991 199994 624425183
98859 78485 3
29499 92661 2
58487 95743 357500000
4813 16791 10
79743 59561 448767140
7423 69929 7
91095 51699 39233009
95311 72737 7
51975 51975 195560988
57955 22455 528064101
39661 42333 5
29453 11119 4
19647 69017 6
15045 46757 3
4017 66461 986429815
68073 48361 101...

output:

408744771

result:

ok single line: '408744771'

Test #91:

score: 5
Accepted
time: 235ms
memory: 50620kb

input:

99993 199992 199993 624410150
81229 64621 770206314
75751 74927 2
89433 645 736361003
95153 6099 710821792
41375 86187 96941540
38945 75663 547715721
19489 36311 88954176
65209 58289 5
41837 42775 782171403
53377 40181 37311742
5917 71903 7
84629 50895 954520344
93321 86611 88152955
76365 76365 7621...

output:

69748190

result:

ok single line: '69748190'

Test #92:

score: 5
Accepted
time: 231ms
memory: 50224kb

input:

99997 199993 199992 624401156
4757 48453 9
67283 21061 185605478
61665 2097 10
38771 38771 452914182
18651 2663 3
18329 18329 549230371
61835 54501 86613396
33885 96127 8
19789 57679 474571521
88129 79477 286313725
69257 91557 10
5067 96465 6
81633 47587 4
21679 45997 391891940
8489 47771 41707479
8...

output:

10055771

result:

ok single line: '10055771'

Test #93:

score: 5
Accepted
time: 229ms
memory: 50144kb

input:

99998 199994 199991 624550181
58551 18371 2
89757 2569 5
83295 60611 830711659
82083 86353 6
63511 32679 495278250
75525 74309 581507821
17561 13831 9
99025 79867 10
89727 35533 5
57967 69093 487847225
16197 91821 7
71837 16335 2
54495 91709 279381595
96515 65843 584314693
31229 59565 854536334
5741...

output:

929135

result:

ok single line: '929135'

Test #94:

score: 5
Accepted
time: 69ms
memory: 28556kb

input:

10 200000 200000 1
1 1 871886556
3 3 310062577
9 3 460488634
7 9 624913993
1 1 453682703
5 1 528633630
7 9 888263202
9 5 207212424
5 1 676247129
9 3 459479991
1 5 701109018
3 5 528022079
7 7 239662509
5 9 593102049
5 7 886839714
5 3 936381589
3 7 697071901
7 7 833204472
7 7 335128519
7 9 168519473
1...

output:

645

result:

ok single line: '645'

Test #95:

score: 5
Accepted
time: 72ms
memory: 29088kb

input:

10 200000 200000 45
7 3 172564753
9 9 33158789
3 7 141697842
5 9 821787431
3 9 784337536
9 1 637206863
5 7 418649261
3 1 15655083
3 9 535579995
5 5 239035786
7 5 515129415
3 1 116547607
9 9 254697597
7 5 227298431
9 9 237990112
9 9 562418632
7 9 476117158
3 9 658789408
9 1 677858614
3 1 690544905
5 ...

output:

-1

result:

ok single line: '-1'

Test #96:

score: 5
Accepted
time: 83ms
memory: 27904kb

input:

300 200000 200000 58
61 215 119098913
23 263 645656739
9 27 131605941
211 281 299607736
219 211 741794331
67 217 868045878
13 197 758598024
261 255 868199079
277 203 284970974
77 115 882652816
97 221 704828032
67 145 97237751
241 229 21146083
217 7 682103610
153 65 556790529
297 197 869135277
209 19...

output:

127339

result:

ok single line: '127339'

Test #97:

score: 5
Accepted
time: 80ms
memory: 28192kb

input:

300 200000 200000 8603
67 187 232816687
257 37 53701857
81 165 283912451
273 7 507923216
21 19 149845962
95 233 623165066
31 157 43303664
249 3 477341087
135 87 433355790
297 19 145552835
93 223 156244303
199 65 46338097
35 137 428773950
159 85 275342633
69 147 326833157
191 53 18868495
77 285 22625...

output:

963592

result:

ok single line: '963592'

Test #98:

score: 5
Accepted
time: 777ms
memory: 86448kb

input:

199999 199999 199999 22589
37075 144273 56995571
148973 112739 464743159
23807 26417 195516980
47065 13751 394432559
19693 713 510556844
98041 125805 622794862
162089 44365 531166968
114623 128079 544375809
176911 18673 927620957
88865 117193 938470719
75365 114241 80684631
4033 143217 371707337
186...

output:

77980650

result:

ok single line: '77980650'

Test #99:

score: 5
Accepted
time: 806ms
memory: 86380kb

input:

199999 199999 199999 25515937
127295 113885 322807916
179203 6251 909116728
2043 143279 38393641
33027 42715 65077951
117623 198985 944085981
186297 143451 503424450
118989 148601 812211230
113377 71291 505099088
54107 157159 90071716
20441 59911 1403830
157023 110009 608627420
60987 17221 339305281...

output:

259424947

result:

ok single line: '259424947'

Test #100:

score: 5
Accepted
time: 57ms
memory: 48160kb

input:

199999 199999 199999 19999700001
54549 62573 903472942
127703 177949 408945470
35365 88921 625226989
146599 23117 901759959
15797 145417 904924493
45687 43793 373169943
22041 104977 780538819
165249 60049 681622319
26371 169857 183728575
184025 22889 809424459
69439 41279 121348033
100897 61823 1745...

output:

-1

result:

ok single line: '-1'

Test #101:

score: 5
Accepted
time: 774ms
memory: 86732kb

input:

199999 199999 199999 187468
30955 199915 8
100047 92811 89
87267 70205 88
185401 92353 32
129415 153239 10
60239 113113 8
108613 146239 36
47721 113431 95
100457 65729 26
77745 33621 67
145739 60201 77
118109 114731 2
41159 55637 45
143483 155545 59
69549 79797 62
103925 177517 72
25699 152457 19
34...

output:

20

result:

ok single line: '20'

Test #102:

score: 0
Wrong Answer
time: 62ms
memory: 48168kb

input:

199999 199999 199999 5321422162
99023 149963 72
157091 7497 86
15951 198347 94
50001 71951 68
27791 136549 93
180369 176341 90
111471 42615 56
88355 40291 93
66039 102573 10
16031 61219 70
150811 66987 62
83357 129139 19
79959 81249 89
149559 173693 48
141015 140903 38
23491 167949 48
169681 73811 1...

output:

-1

result:

wrong answer 1st lines differ - expected: '90', found: '-1'

Subtask #3:

score: 0
Wrong Answer

Test #103:

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

input:

1 0 0 0

output:

0

result:

ok single line: '0'

Test #104:

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

input:

2 0 0 1

output:

-1

result:

ok single line: '-1'

Test #105:

score: 6
Accepted
time: 39ms
memory: 28288kb

input:

2 10 200000 1
2 1 319832429
1 1 412617159
2 1 337734185
1 2 674652880
1 2 454610992
2 2 688717944
1 1 189208056
2 2 951221780
1 2 594191431
2 2 87592160
1 2 833491749
2 2 732961971
2 1 575969648
2 2 268359887
2 1 436382098
1 2 514959278
1 2 305446083
1 2 365989813
1 2 296840111
1 1 541558213
1 1 497...

output:

10104

result:

ok single line: '10104'

Test #106:

score: 6
Accepted
time: 31ms
memory: 28220kb

input:

2 10 200000 1
1 1 1000000000
1 1 1000000000
1 2 1000000000
1 2 1000000000
1 2 1000000000
1 1 1000000000
2 1 1000000000
2 2 1000000000
2 2 1000000000
2 2 1000000000
1 1 1000000000
1 2 1000000000
1 1 1000000000
2 1 1000000000
1 1 1000000000
1 1 1000000000
2 1 1000000000
1 1 1000000000
2 2 1000000000
2...

output:

1000000000

result:

ok single line: '1000000000'

Test #107:

score: 6
Accepted
time: 721ms
memory: 84740kb

input:

200000 10 200000 17900
199675 76237 290240030
50211 6922 761990536
92097 120746 607490
192856 130409 616541101
50427 80049 330957286
129588 180294 466199684
8674 110653 155297749
91380 156344 798960399
102127 40858 801752583
94673 105892 152356242
185676 6183 263664373
169026 112948 812501808
93517 ...

output:

75425485

result:

ok single line: '75425485'

Test #108:

score: 0
Wrong Answer
time: 59ms
memory: 47008kb

input:

200000 10 200000 11791021341
90115 14234 985783971
123477 154651 628493605
123171 47179 220847663
8072 163826 30383173
174753 12792 15862638
172837 96919 880800330
92696 166466 443031361
85298 185851 999558577
23737 111350 809362300
24551 127050 920973896
121483 145215 67814677
78536 41919 475800490...

output:

-1

result:

wrong answer 1st lines differ - expected: '949367959', found: '-1'

Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%