QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#460920#5036. 卑鄙的下毒人Doqe100 ✓740ms69924kbC++172.2kb2024-07-02 13:30:312024-07-02 13:30:32

Judging History

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

  • [2024-07-02 13:30:32]
  • 评测
  • 测评结果:100
  • 用时:740ms
  • 内存:69924kb
  • [2024-07-02 13:30:31]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
namespace Flow
{
    const int N=5e5+10,M=2e6+10;
    int hd[N],to[M],nx[M],W[M],F[M],tt=1,po;
    long long h[N],d[N];
    int pre[N],v[N];
    void link(int u,int v,int f,int w)
    {
        to[++tt]=v,nx[tt]=hd[u],hd[u]=tt,F[tt]=f,W[tt]=w;
        to[++tt]=u,nx[tt]=hd[v],hd[v]=tt,F[tt]=0,W[tt]=-w;
        po=max({po,u,v});
    }
    const long long inf=1e18;
    void ini()
    {
        for(int i=2;i<=po;++i)d[i]=inf;
        for(int u=1;u<=po;++u)
            for(int i=hd[u];i;i=nx[i])if(F[i])
            {
                int v=to[i];
                d[v]=min(d[v],d[u]+W[i]);
            }
        for(int i=1;i<=po;++i)h[i]=d[i];
    }
    void Dij()
    {
        priority_queue<pair<long long,int>>Q;
        for(int i=1;i<=po;++i)d[i]=inf,v[i]=0;
        Q.push({0,1});d[1]=0;
        while(!Q.empty())
        {
            int u=Q.top().second;Q.pop();
            if(v[u])continue;v[u]=1;
            for(int i=hd[u];i;i=nx[i])if(F[i])
            {
                int v=to[i];
                if(d[v]>d[u]+W[i]+h[u]-h[v])
                {
                    d[v]=d[u]+W[i]+h[u]-h[v];
                    Q.push({-d[v],v});pre[v]=i;
                }
            }
        }
        for(int i=1;i<=po;++i)h[i]+=d[i];
    }
    long long ans;
    void EK(int flow)
    {
        ini();
        while(flow--)
        {
            Dij();
            int u=po;
            while(u!=1)
            {
                int I=pre[u];
                --F[I],++F[I^1];
                ans+=W[I];u=to[I^1];
            }
        }
    }
}
char buf[1<<23],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<22,stdin),p1==p2)?EOF:*p1++)
inline int rd() {
	int x=0;char ch=getchar();
	while(!isdigit(ch)){ch=getchar();}
	while(isdigit(ch)) x=x*10+(ch^48),ch=getchar();
	return x;
}

int main()
{
    cin.tie(0)->sync_with_stdio(0);
    int n=rd(),m=rd(),k=rd();
    for(int i=1;i<=n;++i)Flow::link(i,i+1,k,0);
    for(int i=1;i<=m;++i)
    {
        int l=rd(),r=rd(),v=rd();
        Flow::link(l,r+1,1,-v);
    }
    Flow::EK(k);
    cout<<-Flow::ans<<endl;
}

详细

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 0ms
memory: 22272kb

input:

7 20 5
3 4 1
1 1 1
2 7 1
3 7 1
2 2 1
3 7 1
4 6 1
7 7 1
5 5 1
1 6 1
3 4 1
1 4 1
3 6 1
3 3 1
2 5 1
1 1 1
5 5 1
1 1 1
6 7 1
2 2 1

output:

15

result:

ok "15"

Test #2:

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

input:

12 20 5
5 5 1
8 12 1
4 10 1
10 12 1
2 11 1
3 6 1
6 12 1
1 10 1
4 9 1
7 10 1
4 12 1
2 10 1
1 12 1
4 5 1
4 9 1
7 9 1
3 9 1
10 11 1
6 12 1
4 10 1

output:

10

result:

ok "10"

Test #3:

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

input:

7 20 5
2 7 1
6 6 1
3 6 1
3 3 1
2 5 1
6 6 1
2 6 1
2 7 1
4 6 1
3 3 1
2 2 1
5 5 1
1 4 1
1 5 1
2 5 1
4 4 1
2 7 1
3 4 1
2 4 1
1 2 1

output:

12

result:

ok "12"

Test #4:

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

input:

11 20 5
1 8 1
1 10 1
10 11 1
7 11 1
3 10 1
3 8 1
1 8 1
4 5 1
4 5 1
1 7 1
3 4 1
3 7 1
5 6 1
2 6 1
4 9 1
4 10 1
4 4 1
1 11 1
7 10 1
4 8 1

output:

9

result:

ok "9"

Test #5:

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

input:

8 20 5
6 7 1
4 5 1
1 7 1
3 7 1
1 6 1
3 8 1
1 1 1
2 2 1
1 7 1
3 4 1
6 6 1
1 7 1
1 1 1
1 3 1
4 4 1
8 8 1
3 4 1
1 6 1
6 6 1
2 8 1

output:

13

result:

ok "13"

Test #6:

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

input:

20 20 1
3 14 1
1 17 1
3 18 1
14 20 1
15 17 1
9 17 1
10 12 1
6 20 1
11 16 1
3 17 1
1 2 1
6 19 1
17 18 1
4 18 1
4 9 1
3 7 1
4 13 1
17 19 1
7 12 1
10 14 1

output:

4

result:

ok "4"

Test #7:

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

input:

20 20 2
10 20 1
8 9 1
1 8 1
12 17 1
3 20 1
7 18 1
6 10 1
3 5 1
5 9 1
3 6 1
1 3 1
2 6 1
9 11 1
2 11 1
3 15 1
1 7 1
5 7 1
6 11 1
15 18 1
8 10 1

output:

7

result:

ok "7"

Test #8:

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

input:

20 20 3
3 16 1
6 17 1
8 17 1
11 19 1
5 7 1
3 13 1
16 19 1
6 8 1
3 14 1
7 10 1
6 13 1
1 5 1
4 20 1
16 16 1
8 17 1
7 19 1
12 16 1
5 14 1
10 18 1
10 16 1

output:

7

result:

ok "7"

Test #9:

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

input:

20 20 4
8 19 1
15 19 1
10 20 1
5 11 1
1 2 1
12 15 1
5 7 1
10 14 1
3 6 1
13 19 1
5 10 1
6 7 1
7 7 1
1 19 1
9 16 1
3 16 1
1 2 1
4 20 1
15 16 1
7 11 1

output:

12

result:

ok "12"

Test #10:

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

input:

20 20 5
10 18 1
5 9 1
1 17 1
12 19 1
12 13 1
11 17 1
7 10 1
2 10 1
8 13 1
4 6 1
12 13 1
13 13 1
14 20 1
1 9 1
19 19 1
5 8 1
16 16 1
1 6 1
5 16 1
2 4 1

output:

15

result:

ok "15"

Subtask #2:

score: 20
Accepted

Test #11:

score: 20
Accepted
time: 2ms
memory: 20404kb

input:

1794 5000 5
419 430 46802829
1071 1140 167141363
1154 1554 366136993
735 1265 152210166
387 1104 646459531
1073 1637 525871859
1340 1729 44303243
1221 1574 588158235
91 478 922877048
1117 1268 460323230
315 1103 378106915
272 1071 784282054
1147 1469 220209516
281 375 514585737
677 1031 231082599
55...

output:

136716114929

result:

ok "136716114929"

Test #12:

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

input:

2230 5000 5
953 1373 769239749
1047 1661 462345610
303 2066 576160818
120 397 923490418
534 2140 430136299
1643 1673 257239112
161 881 468971965
500 1294 252402949
832 920 980969457
441 836 27310687
975 1362 566048899
1490 2033 444708762
14 1801 675115178
1054 2171 58928071
1372 1372 276209072
743 1...

output:

135024690658

result:

ok "135024690658"

Test #13:

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

input:

2491 4792 5
1244 1262 126130420
502 503 181548261
1087 1095 228548479
704 705 954511272
476 489 702154010
235 237 326120418
1281 1285 234352273
731 743 265589174
14 16 560099243
371 374 933553321
1760 1808 742608005
232 242 538815461
371 372 460405162
492 525 233200462
317 338 464746636
1810 1852 43...

output:

1017220528897

result:

ok "1017220528897"

Test #14:

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

input:

2499 4371 5
893 917 592732340
1752 1754 882828848
1549 1551 740947884
2338 2350 91426286
427 439 189133007
2166 2167 379789806
2247 2349 691763246
1584 1584 838300744
1664 1664 798939343
1701 1701 536171532
1284 1306 672406760
1903 1908 305480185
2428 2488 710578258
815 815 587350817
2196 2215 48525...

output:

1378597403736

result:

ok "1378597403736"

Test #15:

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

input:

2491 4792 5
2363 2365 462329955
724 846 358380916
2139 2177 784807072
1863 1867 7498275
2424 2427 260845642
2400 2404 76208421
1076 1115 489417670
1932 2003 183144091
336 342 693831668
639 671 325948926
571 573 215228365
558 587 842203082
2235 2241 720770164
1950 1977 184886521
566 645 580352976
212...

output:

1035330458129

result:

ok "1035330458129"

Test #16:

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

input:

2498 4162 5
1803 1916 257427142
1501 1501 279416289
1556 1559 249091733
2072 2072 159226156
1750 1757 499029842
461 462 801581319
355 360 308840186
2064 2073 875625340
1417 1417 174954462
2235 2382 103769364
1315 1344 34735682
264 264 445922659
2194 2197 335668538
1269 1270 259126342
660 660 3314207...

output:

1430601233900

result:

ok "1430601233900"

Test #17:

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

input:

2495 4787 5
2178 2179 635024727
698 699 897733963
1019 1019 292677389
591 624 655927180
1876 1880 434643653
1871 1871 995668224
1949 1960 10942328
1273 1285 433038661
704 931 18394432
558 567 85632358
2265 2274 882709007
1254 1257 7918753
955 1144 833586192
1331 1338 346476172
159 161 40693633
240 2...

output:

1032157982124

result:

ok "1032157982124"

Test #18:

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

input:

2285 5000 5
1 1 703673326
2 2 984399976
3 3 12955016
3 4 268283262
5 5 134408888
3 6 209459795
4 7 470635522
7 8 249169348
6 9 162916912
9 10 602537912
9 11 382389875
8 12 68732721
13 13 340548655
14 14 4974719
11 15 298533628
13 16 163122701
15 17 539051648
16 18 915285907
15 19 37353621
20 20 1686...

output:

1089824521179

result:

ok "1089824521179"

Test #19:

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

input:

1665 5000 5
1 1 391336295
2 2 818596937
2 3 36303460
3 4 692193603
3 5 167188334
5 6 42906417
7 7 209562094
8 8 432700460
5 9 277544758
9 10 368305190
7 11 123312993
10 12 257671641
11 13 325198974
12 14 314998086
11 15 524912574
14 16 7937721
15 17 595017521
15 18 152195724
16 19 220779532
20 20 66...

output:

802344415194

result:

ok "802344415194"

Test #20:

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

input:

1931 5000 5
1 1 426904002
2 2 254376243
3 3 135246289
3 4 976165593
3 5 275679478
2 6 362978352
4 7 241220838
4 8 449379797
9 9 640370206
7 10 573859128
7 11 449999338
9 12 551763746
11 13 13322541
14 14 581909052
11 15 821318917
16 16 77513741
14 17 236108255
14 18 698955546
19 19 785007040
16 20 5...

output:

907944994105

result:

ok "907944994105"

Test #21:

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

input:

2418 5000 5
1 1 929825278
1 2 962009514
3 3 743102519
3 4 464132861
1 5 7252315
6 6 636752676
5 7 724833328
6 8 99879879
8 9 609826241
9 10 845625766
9 11 925193241
12 12 426158918
9 13 377831123
13 14 906364820
12 15 785082373
16 16 368089175
13 17 652030701
17 18 313705349
17 19 367594932
20 20 74...

output:

1151584874159

result:

ok "1151584874159"

Test #22:

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

input:

2358 5000 5
1 1 791154556
2 2 484512933
1 3 518651087
4 4 926400
2 5 618444796
2 6 66449752
6 7 934785439
4 8 667556782
5 9 951515228
7 10 593580625
7 11 419572648
12 12 255412422
13 13 737068570
13 14 763078674
14 15 475480198
15 16 62348626
14 17 905538977
16 18 456813291
16 19 55692591
18 20 9743...

output:

1114690674370

result:

ok "1114690674370"

Test #23:

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

input:

2107 5000 5
607 870 514537120
606 1610 79052946
393 2007 90029679
688 1723 862198624
1382 1777 291331890
117 1287 738984259
112 1788 509811648
422 1005 922431102
1512 1580 802712536
103 1741 961665718
772 1207 539884988
574 1440 301778755
1099 1219 57806451
159 1198 136772460
2012 2099 157744717
165...

output:

142399749804

result:

ok "142399749804"

Test #24:

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

input:

2348 5000 5
80 2228 43351731
145 1450 656344008
63 248 727009680
320 668 147470842
699 1845 983020360
315 740 359250811
160 603 686757397
256 743 956274049
1745 2013 450809364
584 1343 222949110
34 1985 36564694
593 1243 643437646
2062 2160 650239880
403 1785 264806997
892 2282 84037625
1294 2252 67...

output:

144630193215

result:

ok "144630193215"

Test #25:

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

input:

3293 5000 5
106 223 629714784
1289 1772 324328176
1971 2160 503550458
327 2634 291970332
1488 2540 956391187
2955 3286 111461971
858 2924 373002734
825 3094 892207928
1752 2935 309749725
1691 2444 251270564
2309 2834 765733598
1367 2204 941261524
1214 1646 657176508
462 2503 127840382
382 1688 80437...

output:

145170473648

result:

ok "145170473648"

Test #26:

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

input:

5000 5000 1
1124 1146 14426411
1845 1863 95184853
2278 2288 587463824
508 523 121238323
4867 4875 873217210
740 780 991611483
2719 2723 179340482
4406 4445 903215313
1631 1674 894332853
7 49 462229092
4519 4563 115823970
4033 4053 318818798
1086 1125 240016939
3859 3883 747714046
1730 1738 241717867...

output:

351702474610

result:

ok "351702474610"

Test #27:

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

input:

5000 5000 2
2534 2580 675379620
2268 2316 105390519
2928 2931 657918945
963 1011 760333780
3193 3197 572128181
2067 2079 299073011
3855 3865 670491947
3182 3187 244383868
2803 2828 449754901
2922 2928 727397637
3261 3278 584944077
3284 3295 75312767
1958 2007 128181914
4744 4787 796542127
2911 2942 ...

output:

548379479880

result:

ok "548379479880"

Test #28:

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

input:

5000 5000 3
2926 2969 763822231
1141 1157 175044195
4456 4503 827149036
3383 3415 141289320
1980 2026 706255471
3399 3420 163170828
4287 4289 218968272
4769 4806 427095673
3777 3801 80340605
4042 4076 38128680
363 367 475394704
4317 4345 542132839
4253 4274 667902780
506 508 113297522
1791 1829 9793...

output:

739102015900

result:

ok "739102015900"

Test #29:

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

input:

5000 5000 4
4779 4795 628589840
676 707 675377893
4301 4348 430530606
2054 2099 144784746
2011 2053 572681525
2994 3023 335736873
2124 2158 295682015
225 241 893921331
4726 4759 409723785
3848 3858 296511889
4716 4736 67422050
4372 4417 836682811
1281 1321 108521706
4410 4443 622997921
4882 4892 225...

output:

889929637718

result:

ok "889929637718"

Test #30:

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

input:

5000 5000 5
606 606 847651838
3591 3609 782763818
4367 4370 411028363
1508 1553 317157945
4857 4883 347998076
4660 4669 211312717
256 263 42663879
3047 3073 121965879
4169 4191 322855822
4077 4101 370460858
4689 4700 488148920
15 51 374101361
430 452 434341510
4164 4192 79880936
4785 4828 988355619
...

output:

1023199538977

result:

ok "1023199538977"

Subtask #3:

score: 20
Accepted

Test #31:

score: 20
Accepted
time: 134ms
memory: 59328kb

input:

322675 500000 1
162058 177924 125740423
72321 188693 51206015
73706 159883 238256306
223634 241332 292316893
8164 94217 879196279
232892 319246 624760769
67688 195525 319652781
70831 92026 394982900
68675 156743 598333126
107804 308096 843245966
57077 248406 291662171
12794 193657 560389007
105560 2...

output:

480886198651

result:

ok "480886198651"

Test #32:

score: 0
Accepted
time: 127ms
memory: 57612kb

input:

252531 500000 1
73336 89104 198033994
117801 178724 312536059
83164 115804 819989513
1359 145774 511306394
47527 143191 383786500
1003 48236 76011634
125645 183182 48474946
106010 149967 927727206
103952 112384 125439208
104139 173611 971831922
92285 136188 923537157
1086 180210 427446035
23210 2210...

output:

475010855091

result:

ok "475010855091"

Test #33:

score: 0
Accepted
time: 125ms
memory: 62220kb

input:

249992 490700 1
214479 214496 515365625
14206 14382 334019307
217230 217309 735689827
63924 63925 258401277
12070 12079 934649204
207338 207371 758583044
37166 37413 417324175
126526 126539 124700076
55914 56166 936572436
216053 216093 893982405
45801 46192 131912638
241657 241696 730127825
116589 1...

output:

24050495775217

result:

ok "24050495775217"

Test #34:

score: 0
Accepted
time: 118ms
memory: 62328kb

input:

249997 494845 1
85695 85706 947011452
173987 175115 969606646
50884 50893 735552086
44292 44297 627665457
215893 215931 539749179
110666 111348 593653974
37171 38363 554044675
152491 152726 857012755
128775 129900 279287672
171922 172278 447261487
123925 123930 105674353
54822 54901 583760389
133139...

output:

18391590923314

result:

ok "18391590923314"

Test #35:

score: 0
Accepted
time: 118ms
memory: 62256kb

input:

249935 497717 1
48307 48437 56342637
151763 152298 861912241
19415 19415 927311192
59828 60101 204305982
147582 147862 395948999
186343 186386 10643541
44713 44853 524618914
192169 192211 648592572
188253 188338 998141500
34052 34721 466660212
156785 156916 59576841
202401 202629 971241453
139207 13...

output:

12964165809186

result:

ok "12964165809186"

Test #36:

score: 0
Accepted
time: 108ms
memory: 63260kb

input:

249950 496942 1
62391 62983 157267127
207325 208422 715495951
29165 29192 834359395
91599 91615 332629666
84504 85813 5574214
55544 55732 893133907
68164 68179 848654383
229512 230081 808984107
165586 165713 454872244
200207 201999 968200081
65750 65806 299499692
202042 202614 558169368
140195 14188...

output:

14606631340114

result:

ok "14606631340114"

Test #37:

score: 0
Accepted
time: 119ms
memory: 62924kb

input:

249982 495670 1
86390 86526 783248482
9407 9411 540434263
238452 238534 830682740
91200 91302 364033820
145244 147442 35874704
21309 21354 781112886
220232 221381 997542261
99464 99511 240733162
20848 21196 714567934
164306 164325 993562838
151641 151665 555186611
95172 95199 763915769
189851 189962...

output:

16988476067185

result:

ok "16988476067185"

Test #38:

score: 0
Accepted
time: 124ms
memory: 62208kb

input:

237809 500000 1
1 1 725340623
2 2 556538685
2 3 750113351
2 4 89997667
1 5 176278822
6 6 628044473
4 7 376781143
4 8 691054257
8 9 681694326
8 10 107877180
10 11 895699579
8 12 309610008
9 13 583966770
11 14 91473484
15 15 795666681
14 16 199439006
17 17 235804033
18 18 459166246
15 19 261822162
19 ...

output:

54827431453285

result:

ok "54827431453285"

Test #39:

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

input:

193004 500000 1
1 1 418968490
1 2 696290526
1 3 35413858
2 4 468838187
1 5 249430274
3 6 574413613
4 7 399467033
6 8 75065642
6 9 340727930
6 10 862056055
7 11 902270161
11 12 246578995
12 13 245100768
14 14 911540131
13 15 88554299
13 16 454499535
13 17 232059626
16 18 908692431
15 19 139531524
20 ...

output:

44183387167347

result:

ok "44183387167347"

Test #40:

score: 0
Accepted
time: 99ms
memory: 59596kb

input:

168037 500000 1
1 1 571104806
2 2 127213141
2 3 975939427
3 4 132217350
5 5 894810748
3 6 490775217
4 7 25203836
6 8 458117768
6 9 426044363
8 10 745181289
9 11 432989435
10 12 578165354
9 13 68938921
12 14 793934534
11 15 74005157
16 16 311972043
14 17 625329955
18 18 168234200
15 19 465554170
18 2...

output:

38680733724403

result:

ok "38680733724403"

Test #41:

score: 0
Accepted
time: 111ms
memory: 58508kb

input:

177842 500000 1
1 1 421267539
2 2 773838708
3 3 174145748
2 4 345791748
4 5 178857721
6 6 63445539
5 7 785501019
6 8 293135367
7 9 107408904
6 10 781833072
7 11 380579169
11 12 149601052
13 13 941321725
13 14 68117336
14 15 878597414
14 16 501204638
15 17 856015182
14 18 474203866
18 19 851148153
16...

output:

40928382637201

result:

ok "40928382637201"

Test #42:

score: 0
Accepted
time: 113ms
memory: 60420kb

input:

177915 500000 1
1 1 271292280
2 2 625813925
1 3 939340374
2 4 84776571
5 5 456945542
3 6 191363078
7 7 78237995
4 8 723718315
6 9 199913337
7 10 276964318
11 11 475214330
11 12 956526724
9 13 234753935
11 14 850526973
13 15 377635279
12 16 866464127
16 17 72950802
17 18 54563404
15 19 532673622
20 2...

output:

40869789096961

result:

ok "40869789096961"

Test #43:

score: 0
Accepted
time: 128ms
memory: 59600kb

input:

278352 500000 1
170913 214543 168974049
78160 236308 127212570
22624 192783 758327554
33353 119675 112500515
123238 138960 773944493
102641 104678 525298818
39746 265269 231933608
101566 199878 496386445
160697 214573 875085547
138890 189675 304621779
72230 233413 82446355
93697 111582 716259833
248...

output:

470663510567

result:

ok "470663510567"

Test #44:

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

input:

313114 500000 1
192852 245567 319309601
97135 304118 787617405
76891 190936 17692495
9880 226269 747702459
117760 188046 398275162
61120 289318 158491038
41844 216947 23254041
48629 302643 629285602
262794 301320 933483522
23187 211531 218319925
31448 106981 97268677
32372 191357 161506602
87160 272...

output:

469269376470

result:

ok "469269376470"

Test #45:

score: 0
Accepted
time: 127ms
memory: 62868kb

input:

205945 500000 1
146039 176990 894969853
61417 89219 764910645
37405 123868 427213499
64826 75839 220017382
85594 128873 116882220
186391 190027 882212569
5498 54259 155371726
21164 123514 490637163
96788 187848 376113236
35647 185488 993192042
36184 39246 792947747
108807 165538 393657269
83958 1120...

output:

483741106377

result:

ok "483741106377"

Test #46:

score: 0
Accepted
time: 181ms
memory: 61848kb

input:

500000 500000 1
496837 496870 923496382
278362 278392 357421464
274060 274061 345429203
65297 65317 503103187
236352 236398 120593170
181125 181172 197502113
123694 123736 224553449
130956 130974 786534231
134569 134606 55741322
12360 12365 286706634
300281 300328 410270588
236167 236193 832854993
4...

output:

33887394129829

result:

ok "33887394129829"

Test #47:

score: 0
Accepted
time: 177ms
memory: 59448kb

input:

500000 500000 1
51275 51298 906550332
91442 91490 890797911
483126 483169 880126619
438390 438400 604056812
23577 23608 201153018
112465 112503 146011563
84539 84565 351378223
60262 60277 458827584
305983 306004 140042073
312033 312044 18883706
238027 238047 356335074
163624 163668 134261442
272969 ...

output:

33962870370969

result:

ok "33962870370969"

Test #48:

score: 0
Accepted
time: 170ms
memory: 63476kb

input:

500000 500000 1
57535 57553 874794489
443359 443368 328379248
73189 73203 567826431
200304 200308 552526649
271876 271909 231476665
378433 378453 495669857
108553 108584 431003982
42176 42197 773752461
93371 93401 797605414
404017 404032 25578235
361930 361979 209265
247150 247182 620036262
18378 18...

output:

33917735271253

result:

ok "33917735271253"

Test #49:

score: 0
Accepted
time: 166ms
memory: 58696kb

input:

500000 500000 1
330583 330583 819334510
342192 342225 251008140
23558 23562 693668995
7713 7745 20457747
358117 358150 397036939
484167 484203 505239528
314640 314645 449883400
40462 40503 485953240
77808 77832 572898847
147529 147564 337988142
189570 189614 949484749
453228 453254 752514208
364749 ...

output:

33900595789167

result:

ok "33900595789167"

Test #50:

score: 0
Accepted
time: 163ms
memory: 60264kb

input:

500000 500000 1
167444 167450 930275075
359867 359876 53239020
441544 441576 585496181
439743 439786 17684411
36167 36203 217051650
29078 29096 949040506
124064 124110 880111173
59505 59551 825248135
177726 177746 769432518
17759 17804 604866783
265114 265151 657157449
356894 356929 496106508
82971 ...

output:

33861714821089

result:

ok "33861714821089"

Subtask #4:

score: 20
Accepted

Test #51:

score: 20
Accepted
time: 662ms
memory: 66912kb

input:

194181 500000 5
22921 38709 1
103611 130117 1
33044 135246 1
25161 106036 1
13484 183424 1
129622 133239 1
103905 105727 1
8418 141108 1
5951 145648 1
61392 105830 1
139975 149309 1
47361 59947 1
91598 172246 1
32303 43094 1
72490 170121 1
68502 168603 1
56051 91019 1
106112 129606 1
70776 177996 1
...

output:

2485

result:

ok "2485"

Test #52:

score: 0
Accepted
time: 734ms
memory: 69584kb

input:

304003 500000 5
101915 187818 1
96905 285932 1
39472 217335 1
223783 231789 1
201166 211239 1
22769 134905 1
19436 89499 1
78054 117024 1
6577 94503 1
16701 62281 1
59789 95662 1
68941 96708 1
17347 224646 1
1970 50789 1
197428 215792 1
79626 243334 1
70524 218601 1
17518 113996 1
199398 247243 1
63...

output:

2493

result:

ok "2493"

Test #53:

score: 0
Accepted
time: 424ms
memory: 58644kb

input:

249974 496542 5
87672 88771 1
52366 53940 1
25887 25963 1
184719 186260 1
104443 104706 1
95989 96053 1
134358 135382 1
55635 55647 1
134371 134382 1
148206 149011 1
95965 96135 1
140844 140891 1
78797 78798 1
15619 15943 1
31258 31343 1
47248 47358 1
157920 157998 1
135597 135708 1
98966 99089 1
20...

output:

78661

result:

ok "78661"

Test #54:

score: 0
Accepted
time: 435ms
memory: 56408kb

input:

249974 494350 5
161514 163184 1
87911 87959 1
105204 106421 1
178980 181538 1
19665 19715 1
58148 58167 1
67664 67964 1
5582 6048 1
242900 242913 1
218881 218915 1
84444 84678 1
99763 100602 1
208276 208335 1
35121 35190 1
115890 115966 1
122960 123877 1
22163 22657 1
100321 100645 1
99196 99575 1
1...

output:

97350

result:

ok "97350"

Test #55:

score: 0
Accepted
time: 419ms
memory: 58320kb

input:

249983 486062 5
178515 178556 1
46509 46657 1
623 630 1
223892 223897 1
227434 227448 1
127239 127242 1
175036 175061 1
144855 144868 1
107886 107891 1
118310 118312 1
165907 165919 1
174395 174413 1
196413 196457 1
137455 139090 1
59658 59673 1
196868 196878 1
53952 54025 1
49268 49480 1
38355 3885...

output:

144650

result:

ok "144650"

Test #56:

score: 0
Accepted
time: 432ms
memory: 57556kb

input:

249983 495448 5
123223 124925 1
161437 161839 1
204523 204907 1
123417 124631 1
169136 169205 1
109580 109591 1
202411 202609 1
237547 237552 1
43171 43533 1
19726 20052 1
191894 192321 1
140366 140369 1
24388 24490 1
1393 1417 1
155640 155653 1
204676 205389 1
232668 235247 1
45859 47006 1
77633 77...

output:

87916

result:

ok "87916"

Test #57:

score: 0
Accepted
time: 437ms
memory: 58404kb

input:

249992 494620 5
84373 84412 1
125864 125902 1
203420 203427 1
64431 64437 1
56552 56567 1
71532 71611 1
71190 71248 1
107213 108211 1
115775 116553 1
181151 181244 1
37673 37714 1
44770 44800 1
227519 227561 1
245293 245343 1
11949 12034 1
51161 51192 1
242357 242401 1
142142 142144 1
203117 203611 ...

output:

94967

result:

ok "94967"

Test #58:

score: 0
Accepted
time: 647ms
memory: 68220kb

input:

208426 500000 5
28645 101916 1
7440 127239 1
137321 138796 1
155729 158144 1
167838 203986 1
127568 151506 1
49515 81900 1
37962 167268 1
141888 144316 1
48742 192792 1
8191 124087 1
113172 141152 1
92571 105888 1
23469 75518 1
25800 127940 1
94900 157340 1
11438 114334 1
1826 37080 1
5738 122480 1
...

output:

2398

result:

ok "2398"

Test #59:

score: 0
Accepted
time: 717ms
memory: 69136kb

input:

270310 500000 5
151314 259090 1
80695 183506 1
20699 196732 1
142374 248474 1
77831 129977 1
31693 170486 1
42481 50638 1
237296 244555 1
117532 206885 1
154573 230747 1
17424 38046 1
95181 228843 1
123250 217068 1
194563 252222 1
93291 206436 1
4217 7976 1
89143 239119 1
222217 248624 1
9680 246195...

output:

2422

result:

ok "2422"

Test #60:

score: 0
Accepted
time: 661ms
memory: 69132kb

input:

255424 500000 5
59606 133843 1
186905 209051 1
67305 243269 1
27933 65974 1
78338 171108 1
3704 177437 1
62314 217400 1
65683 216660 1
10999 51811 1
203698 245062 1
200238 227732 1
95702 203308 1
108957 224327 1
7616 111101 1
188051 237741 1
54576 209144 1
98897 230281 1
154770 233686 1
106761 20723...

output:

2448

result:

ok "2448"

Test #61:

score: 0
Accepted
time: 156ms
memory: 60548kb

input:

500000 500000 1
435056 435101 1
96682 96726 1
366447 366479 1
409321 409329 1
319459 319478 1
386826 386851 1
477209 477243 1
405392 405424 1
366564 366584 1
313831 313852 1
126671 126705 1
402868 402877 1
126969 127001 1
433546 433559 1
103408 103446 1
203 220 1
499640 499669 1
86463 86509 1
222795...

output:

56551

result:

ok "56551"

Test #62:

score: 0
Accepted
time: 235ms
memory: 59948kb

input:

500000 500000 2
398851 398882 1
269476 269518 1
239296 239337 1
16069 16079 1
442104 442126 1
209852 209891 1
327424 327439 1
297952 297955 1
21272 21303 1
220730 220772 1
79140 79174 1
405354 405360 1
313185 313228 1
171020 171069 1
316725 316764 1
325712 325733 1
477774 477781 1
204985 205014 1
16...

output:

94306

result:

ok "94306"

Test #63:

score: 0
Accepted
time: 302ms
memory: 60816kb

input:

500000 500000 3
81122 81131 1
307742 307754 1
421008 421037 1
126583 126613 1
349371 349376 1
108214 108231 1
234333 234335 1
51679 51691 1
176180 176215 1
457610 457643 1
429415 429416 1
143493 143498 1
455898 455937 1
225199 225227 1
38247 38264 1
115825 115851 1
433824 433827 1
2395 2399 1
156156...

output:

124594

result:

ok "124594"

Test #64:

score: 0
Accepted
time: 389ms
memory: 60896kb

input:

500000 500000 4
50207 50249 1
466545 466586 1
409439 409451 1
3041 3073 1
261821 261845 1
303963 303989 1
74383 74417 1
256880 256917 1
393046 393056 1
56497 56534 1
255489 255533 1
283323 283329 1
151024 151051 1
110312 110338 1
229377 229384 1
252166 252196 1
387865 387886 1
398932 398966 1
287693...

output:

150753

result:

ok "150753"

Test #65:

score: 0
Accepted
time: 455ms
memory: 58784kb

input:

500000 500000 5
498982 499017 1
489602 489619 1
184352 184383 1
272166 272181 1
165728 165760 1
195337 195354 1
119007 119010 1
195484 195507 1
151529 151550 1
263467 263503 1
102050 102056 1
295825 295850 1
337212 337242 1
217581 217620 1
74890 74894 1
286633 286645 1
149257 149275 1
369127 369159 ...

output:

174194

result:

ok "174194"

Subtask #5:

score: 30
Accepted

Test #66:

score: 30
Accepted
time: 708ms
memory: 69408kb

input:

265199 500000 5
51732 151507 196279569
1147 251097 325871693
79410 120618 539045634
209514 221950 912376813
44813 147573 616444800
53619 134328 533306546
94940 108466 186490362
42483 236958 489649490
127349 167018 943263893
103970 193784 202963780
197001 221033 210521750
5815 113674 152090319
129972...

output:

1456927835184

result:

ok "1456927835184"

Test #67:

score: 0
Accepted
time: 712ms
memory: 68720kb

input:

268177 500000 5
55093 254918 329190467
191694 259222 605450222
201740 241267 889016683
8074 165848 966993207
30981 135466 865555732
1105 128353 16812688
61627 177774 206698174
80805 112708 726871173
172596 193653 490040425
68354 99896 511841431
39437 128591 466007838
143231 174591 141617857
38932 14...

output:

1459476434349

result:

ok "1459476434349"

Test #68:

score: 0
Accepted
time: 434ms
memory: 63072kb

input:

249955 497587 5
79492 80565 749378173
120773 120883 356880087
2663 2761 791554216
205008 205187 669029955
113957 114759 4070107
28900 28903 147024866
120950 121225 580701890
182312 182470 292393101
7516 7570 789015911
88848 88880 920036673
36642 36682 483037941
224928 225459 709435789
21548 21618 43...

output:

38988179261266

result:

ok "38988179261266"

Test #69:

score: 0
Accepted
time: 418ms
memory: 61952kb

input:

249989 490339 5
5309 5548 994345029
112028 112108 952030818
131043 131698 731416800
33402 33670 361343436
57764 57782 309582485
173239 173243 233816750
198963 199440 658785007
16120 16635 697590016
67074 67402 289847842
121562 121579 852348470
29480 29861 557733767
239049 239084 791445093
59760 6102...

output:

67774458466594

result:

ok "67774458466594"

Test #70:

score: 0
Accepted
time: 434ms
memory: 63164kb

input:

249935 497777 5
240946 241164 730588769
118578 118947 697929601
164669 164787 42373467
189285 189409 871962020
226457 226631 352297146
104589 104590 23202200
101341 101467 797379951
19923 20034 171294543
31924 32015 806110160
203499 204544 791479006
59997 60005 347798419
165755 165990 11341216
18295...

output:

37725653000458

result:

ok "37725653000458"

Test #71:

score: 0
Accepted
time: 419ms
memory: 62476kb

input:

249872 497680 5
245509 245660 8678421
110342 113762 300076911
4772 5529 108803245
38532 38852 963920126
6125 6181 100094023
21053 21064 792302324
38947 39099 694749390
248455 248519 437095869
212863 212976 371623643
80470 80789 177048228
82948 84686 544144120
20585 20757 837588835
99080 99146 235437...

output:

37480826313618

result:

ok "37480826313618"

Test #72:

score: 0
Accepted
time: 292ms
memory: 55124kb

input:

249998 416662 5
57590 57591 160261632
108756 108758 222296380
198532 198534 515546348
170746 170746 721669462
122524 122526 137693297
133466 133466 763777099
83224 83456 345760831
75804 75812 605472121
246366 246369 242149472
159049 159591 495008453
245186 245579 79312727
148576 148583 590436657
395...

output:

122877456309510

result:

ok "122877456309510"

Test #73:

score: 0
Accepted
time: 459ms
memory: 66624kb

input:

198451 500000 5
1 1 28763497
2 2 197977350
2 3 292040664
4 4 389958318
5 5 628044778
6 6 408050707
6 7 90473747
7 8 430964063
6 9 202042293
7 10 644729711
10 11 836961674
11 12 915937222
9 13 120414295
11 14 977942024
13 15 690255393
12 16 613778375
15 17 754434106
15 18 447072418
17 19 76327937
17 ...

output:

94182589783372

result:

ok "94182589783372"

Test #74:

score: 0
Accepted
time: 473ms
memory: 64580kb

input:

205950 500000 5
1 1 881748741
2 2 696783672
2 3 15870551
2 4 984614334
4 5 214354765
2 6 644693586
5 7 189173620
5 8 301008538
8 9 388595566
6 10 273527243
7 11 957458851
12 12 292026286
11 13 366992762
14 14 533514501
14 15 934486353
14 16 14640149
14 17 648710153
14 18 999486043
16 19 451768762
19...

output:

98059351282275

result:

ok "98059351282275"

Test #75:

score: 0
Accepted
time: 476ms
memory: 63984kb

input:

178836 500000 5
1 1 808910476
2 2 543884389
3 3 420435176
2 4 164604979
5 5 554331633
5 6 936684291
6 7 849991767
8 8 482530282
5 9 983778311
9 10 107198595
11 11 283589455
9 12 53604157
12 13 215665207
11 14 143148899
15 15 665554907
16 16 626032595
16 17 497216525
15 18 734783653
17 19 827918419
1...

output:

85110173072073

result:

ok "85110173072073"

Test #76:

score: 0
Accepted
time: 443ms
memory: 63392kb

input:

238349 500000 5
1 1 771627245
2 2 866613692
1 3 422569254
1 4 983838110
3 5 895648179
4 6 717564429
7 7 267590314
8 8 34022279
7 9 720316697
9 10 143835051
10 11 802637311
9 12 454427067
9 13 150807031
13 14 911671730
13 15 681201049
15 16 134190351
17 17 77204424
17 18 83579206
19 19 671536095
20 2...

output:

113566449004929

result:

ok "113566449004929"

Test #77:

score: 0
Accepted
time: 473ms
memory: 64568kb

input:

199811 500000 5
1 1 93059985
2 2 821154569
3 3 36605293
2 4 238004259
5 5 560107113
4 6 194286275
7 7 748200171
8 8 808073072
9 9 216914815
6 10 200254802
11 11 224547189
11 12 500654919
12 13 587849985
12 14 802523362
11 15 568329848
16 16 839442347
16 17 997344816
14 18 489626339
16 19 21083803
19...

output:

95205125344504

result:

ok "95205125344504"

Test #78:

score: 0
Accepted
time: 740ms
memory: 69924kb

input:

316126 500000 5
115522 122928 16696246
81051 219247 681015407
38939 51922 953614332
170255 230069 745834245
20703 37772 364546949
16197 79511 44432416
163696 220599 54163173
157955 296506 69317961
208409 221706 706413696
143301 249494 271624493
50307 129226 61226302
99845 207923 225914499
58237 1168...

output:

1427651556890

result:

ok "1427651556890"

Test #79:

score: 0
Accepted
time: 667ms
memory: 68144kb

input:

215977 500000 5
90221 179443 788919094
47595 215749 182602815
188030 194810 392874155
8906 24131 894466124
29561 164438 131128342
15462 126596 691323637
15094 204668 614382776
2427 142766 257070806
23477 51840 571151633
33420 138870 92354805
13628 65948 806232630
31670 56959 839454585
63744 148765 2...

output:

1461280416914

result:

ok "1461280416914"

Test #80:

score: 0
Accepted
time: 658ms
memory: 66600kb

input:

188029 500000 5
107772 167939 272574240
118116 148255 923282090
3987 59741 839094886
17119 87551 808214681
30755 32612 844416092
65782 175453 60630725
97715 160586 25490272
114409 141467 910526990
69842 114244 475768969
138717 151622 2053422
65062 153492 972084953
101473 143833 411954141
87744 97535...

output:

1467580707811

result:

ok "1467580707811"

Test #81:

score: 0
Accepted
time: 165ms
memory: 60284kb

input:

500000 500000 1
157320 157356 408761389
382696 382735 77799493
87710 87749 408558677
372335 372379 694379536
456409 456423 657960069
334728 334759 561375007
352101 352142 815584894
220463 220494 151598561
397873 397882 777497459
172771 172803 683035335
62985 63012 396530783
65459 65487 47442083
8235...

output:

33888025017477

result:

ok "33888025017477"

Test #82:

score: 0
Accepted
time: 246ms
memory: 65904kb

input:

500000 500000 2
403866 403887 422189814
442721 442762 794965807
63282 63312 525294358
183059 183074 176702426
487096 487100 126170816
142017 142063 725361513
46728 46744 241919631
208582 208631 952018086
214739 214780 415839911
183377 183389 27626225
497040 497055 744322004
346728 346759 232647936
3...

output:

56430098679032

result:

ok "56430098679032"

Test #83:

score: 0
Accepted
time: 322ms
memory: 59552kb

input:

500000 500000 3
444688 444691 97601263
164062 164110 69854488
427122 427161 92270322
340768 340811 833188998
302603 302621 186670639
239744 239744 325086028
20206 20239 257914571
183710 183730 637387065
411476 411483 145629089
208338 208338 626426575
170529 170549 206530861
161652 161654 791574048
1...

output:

73931818434575

result:

ok "73931818434575"

Test #84:

score: 0
Accepted
time: 395ms
memory: 61072kb

input:

500000 500000 4
380901 380916 250917175
365734 365772 495253735
145706 145749 286164777
116515 116532 294505364
49221 49252 214484527
303177 303190 987250227
315311 315319 2113476
369743 369762 836292930
155874 155892 549336650
358002 358050 729245905
171871 171915 759666396
203948 203970 435279472
...

output:

89285370204936

result:

ok "89285370204936"

Test #85:

score: 0
Accepted
time: 477ms
memory: 59740kb

input:

500000 500000 5
245128 245170 601185985
114624 114648 860272613
314240 314262 93933014
486321 486352 503291681
430343 430379 970208543
71808 71826 166969325
361895 361897 69769039
342061 342077 965897484
308704 308721 516419795
385897 385939 753576916
215884 215919 777099889
363695 363722 616776620
...

output:

102480523569514

result:

ok "102480523569514"