QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#31240#3871. Voting CitiesLFCode100 ✓70ms9452kbC++141.8kb2022-05-05 16:08:582022-05-05 16:08:59

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-05 16:08:59]
  • Judged
  • Verdict: 100
  • Time: 70ms
  • Memory: 9452kb
  • [2022-05-05 16:08:58]
  • Submitted

answer

//什么时候我才能有杜爷一半强呀/kk
#include<cstdio>
#include<queue>
#include<cstring>
using namespace std;
const int N=5050,M=10086,V=32;
const long long INF=1e18;
int n,m,K,tot,h[N];
long long dis[N][V],sum[V];
struct edge{int v,w,nxt;}e[M];//注意这题单向边
struct node{
	int p,f;long long w;node(){}
	node(int _p,int _f,long long _w){p=_p;f=_f;w=_w;}
	bool operator <(const node b)const{return w>b.w;}
};
priority_queue<node>q;
long long Max(long long a,long long b){return a>b?a:b;}
long long Min(long long a,long long b){return a<b?a:b;}
int read(){
	char ch=getchar();int nn=0,ssss=1;
	while(ch<'0'||ch>'9'){if(ch=='-')ssss*=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){nn=nn*10+(ch-'0');ch=getchar();}
	return nn*ssss;
}
bool add(int u,int v,int w){e[++tot].v=v;e[tot].w=w;e[tot].nxt=h[u];h[u]=tot;return true;}
int main(){
	n=read();m=read();K=read();
	memset(dis,0x3f,sizeof(dis));
	for(int i=1;i<=K;i++){int p=read()+1;q.push(node(p,0,dis[p][0]=0));}
	for(int i=1;i<=m;i++){int u=read()+1,v=read()+1,w=read();add(v,u,w);}
	while(!q.empty()){
		node np=q.top();q.pop();if(np.w!=dis[np.p][np.f])continue;
		for(int i=h[np.p];i;i=e[i].nxt){
			if(dis[e[i].v][np.f]>np.w+e[i].w)
				q.push(node(e[i].v,np.f,dis[e[i].v][np.f]=np.w+e[i].w));
			for(int j=0;j<5;j++){
				if((np.f>>j)&1)continue;
				int w=e[i].w/10*(9-j),f=np.f|(1<<j);
				if(dis[e[i].v][f]>np.w+w)
					q.push(node(e[i].v,f,dis[e[i].v][f]=np.w+w));
			}
		}
	}
	int Q=read();
	while(Q--){
		int s=read()+1,U=31;long long ans=INF;
		for(int i=0;i<5;i++){sum[1<<i]=read();if(sum[1<<i]<0)U^=1<<i;}
		for(int S=1;S<32;S++){
			if(__builtin_popcount(S)==1)continue;
			sum[S]=sum[S&(S-1)]+sum[S&(-S)];
		}
		for(int S=U;;S=(S-1)&U){ans=Min(ans,sum[S]+dis[s][S]);if(S==0)break;}
		if(ans==INF)puts("-1");
		else printf("%lld\n",ans);
	}
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

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

input:

5000 10000 1
4683
0 715 579327370
0 954 664830350
0 2453 244225980
0 2918 399241150
0 3929 982683290
1 4944 723915200
2 3725 390369490
3 1370 230814450
3 3348 750421430
3 3408 503334040
4 252 852709300
4 989 474431070
4 1013 466847840
4 4956 152207550
5 4162 271201150
6 3335 991911830
6 3596 4382854...

output:

7570531610

result:

ok single line: '7570531610'

Test #2:

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

input:

5000 4999 1
1299
0 64 377331280
1 3636 982700680
2 3915 477029460
3 4810 393196920
4 3199 772708750
5 974 807412160
6 172 514839640
7 4390 737960950
8 3007 115380210
9 164 180129040
10 3217 244250350
11 3305 624997990
12 2097 203276470
13 3419 805725540
14 2797 934906840
15 2266 782245770
16 3632 56...

output:

1267241546350

result:

ok single line: '1267241546350'

Test #3:

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

input:

5000 10000 1
4932
0 1 242102390
0 3260 760978600
1 2 943188730
2 3 921660880
2 4662 628221750
3 4 237866670
3 5 870214480
4 3429 906351860
5 6 806646100
6 7 225335570
6 968 45416840
7 8 629227600
7 10 39825340
7 3141 397131680
7 4247 675964610
7 4935 646589630
8 9 156003140
8 4388 583428630
9 3931 9...

output:

6287188870

result:

ok single line: '6287188870'

Test #4:

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

input:

5 6 1
1
1 2 621846600
1 3 336827160
3 0 525498650
3 1 126718720
3 4 768175340
4 1 153087190
1
1 -1 -1 -1 -1 -1

output:

0

result:

ok single line: '0'

Test #5:

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

input:

3 3 1
0
0 1 169244410
1 2 409500510
2 0 553080380
1
0 -1 -1 -1 -1 -1

output:

0

result:

ok single line: '0'

Subtask #2:

score: 5
Accepted

Test #6:

score: 5
Accepted
time: 42ms
memory: 5000kb

input:

5000 10000 1
939
0 1074 697931020
0 4334 347738890
1 2400 681303040
2 1685 896587820
2 2368 928896100
2 3133 12276450
2 3258 765661210
4 3606 993201320
5 1081 613705100
5 2339 700470170
5 2625 209307440
5 2832 129029550
7 1517 251821020
7 1751 713428320
7 2308 951691550
7 3980 498317440
7 4014 78197...

output:

5627552460
-1
4246029940
3761657420
4380835410
2491074640
3803606150
4373173360
-1
-1
2801457640
-1
4795371840
4240270840
-1
-1
-1
4178646650
1904132330
4723617640
-1
3681994990
4524064110
6370263130
2936159730
4375108180
6982682750
6477915010
4681205940
-1
3755439560
-1
6819403420
3673261770
-1
504...

result:

ok 100 lines

Test #7:

score: 0
Accepted
time: 14ms
memory: 4396kb

input:

5000 4999 1
1600
0 4814 896397660
1 4984 739406180
2 694 114517340
3 4309 218471300
4 920 590985330
5 2719 754542380
6 2504 137382510
7 1035 499505610
8 1496 125459930
9 2835 281015760
10 2884 593613550
11 4299 563512780
12 1641 78196580
13 4063 437582110
14 4531 161182440
15 1985 146282870
16 1542 ...

output:

2482347025410
2413549249250
1163267123140
193707105420
1303191463070
1150457808750
416481342360
958052897780
1627382495400
2213481766090
63918924520
1385980498700
1787190634400
385286330050
694780572660
536069307270
665015464460
2050578445880
2417231990400
696189478770
11411899680
296514744410
75144...

result:

ok 100 lines

Test #8:

score: 0
Accepted
time: 43ms
memory: 4896kb

input:

5000 10000 1
499
0 1 694980180
0 2433 28823070
1 2 728686200
1 86 619222880
2 3 26992400
2 4 839612680
2 1898 635010730
4 5 377517310
4 6 749940480
5 2667 791214220
6 7 745281280
6 8 400320590
7 1260 918251840
7 3221 257682180
8 9 628377120
9 10 13654560
10 11 855598110
10 3389 687839800
10 3848 208...

output:

6545145780
6320543620
5558635220
7832193970
6015073740
5715376930
4015418390
3535383550
-1
5146644790
-1
7948033760
-1
-1
6960357490
4380884330
-1
4853943790
5787118910
5175104430
5028667730
-1
-1
5076114990
6264416340
5073783270
3961639500
7416222680
6459744650
7017837430
5371935030
5542488450
7137...

result:

ok 100 lines

Test #9:

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

input:

5 6 1
1
0 3 578761210
1 2 507284400
2 3 249485200
3 2 652750640
4 0 112590950
4 1 438010780
2
0 -1 -1 -1 -1 -1
3 -1 -1 -1 -1 -1

output:

-1
-1

result:

ok 2 lines

Test #10:

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

input:

3 3 1
1
1 0 567487650
1 2 917405800
2 1 249016270
3
1 -1 -1 -1 -1 -1
0 -1 -1 -1 -1 -1
2 -1 -1 -1 -1 -1

output:

0
-1
249016270

result:

ok 3 lines

Subtask #3:

score: 5
Accepted

Test #11:

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

input:

5000 10000 2000
366 1016 3277 5 3742 3640 2511 1725 2168 2349 1037 4972 2930 4374 3504 1098 3439 3970 1952 3474 2664 2097 1751 3679 3155 3266 2070 2016 338 1273 2648 4398 3694 2045 3524 1027 839 1898 1795 1192 2975 1756 4707 1548 4984 1891 2364 123 3181 1096 2970 3264 1628 1295 4852 829 4940 2251 37...

output:

0
0
-1
524672860
0
0
0
206839450
707709240
0
738220490
0
590711250
638089240
0
0
0
0
2259893470
0
0
1425582250
417331380
1369108520
848243380
568654300
-1
31220760
101654610
0
68502140
0
1923846430
-1
1073048140
0
895045250
0
207461590
-1
562502090
867633840
0
44530950
-1
0
0
0
0
614867560
130393210...

result:

ok 100 lines

Test #12:

score: 0
Accepted
time: 22ms
memory: 4372kb

input:

5000 4999 5
612 531 1968 410 2782
0 2103 349281350
1 2480 594374500
2 2033 402172500
3 403 80637270
4 1816 160451980
5 639 846953920
6 2664 977129160
7 521 422049390
8 381 804390200
9 4823 279895120
10 4437 160159660
11 111 644269260
12 2918 579533860
13 3020 277966440
14 3067 626653710
15 3418 6878...

output:

88817191850
1183150862130
209485420890
313903092290
305571745150
192504729570
71621285160
929980930730
299152884440
147595181610
1189655433660
1023128543510
239735056920
136198489290
665815290630
124175311160
212188941690
158535471660
124411315210
189647282680
196753410780
137772024310
178918749330
...

result:

ok 100 lines

Test #13:

score: 0
Accepted
time: 64ms
memory: 4948kb

input:

5000 10000 10
1390 2211 1281 4355 4632 1243 4356 1010 2391 2700
0 1 133262380
1 2 727699550
1 705 534362220
1 4986 70479650
2 3 907226330
2 3460 709286650
3 4 175466540
3 6 948045550
3 7 487883480
4 5 943367740
4 3162 946618820
4 4917 187658450
7 8 790383730
7 15 357484820
7 1516 158800830
8 9 34017...

output:

3930294140
2759540890
2741810620
3922456530
2662043850
3036944090
3576962770
2751271190
2064675880
3217717780
3143225060
3445699300
-1
2473253080
2347081530
3377890460
3043574850
-1
3483450210
2387724730
4170287160
4990061730
2949093580
3991840440
1974073420
3260190340
-1
1737747670
0
3046500000
278...

result:

ok 100 lines

Test #14:

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

input:

5 6 2
1 0
1 3 764266000
2 1 660773340
2 4 128055370
3 0 591098210
3 2 555395050
4 3 788956120
4
0 -1 -1 -1 -1 -1
4 -1 -1 -1 -1 -1
1 -1 -1 -1 -1 -1
2 -1 -1 -1 -1 -1

output:

0
1380054330
0
660773340

result:

ok 4 lines

Test #15:

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

input:

3 3 3
0 1 2
0 2 232764240
2 0 150858370
2 1 132459350
3
1 -1 -1 -1 -1 -1
0 -1 -1 -1 -1 -1
2 -1 -1 -1 -1 -1

output:

0
0
0

result:

ok 3 lines

Subtask #4:

score: 5
Accepted

Test #16:

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

input:

5000 10000 1
4577
0 248 57534230
0 3020 827662530
0 3190 138424730
1 3154 752916230
4 1256 398736840
5 4116 833556610
5 4127 547494700
6 396 793865570
6 1661 388141660
7 4581 595148940
8 3768 724151300
9 1367 840320860
9 1656 391917460
10 3210 806346090
10 3356 767016610
10 3367 272248610
12 1145 72...

output:

-1

result:

ok single line: '-1'

Test #17:

score: 0
Accepted
time: 15ms
memory: 4324kb

input:

5000 4999 1
1212
0 3971 436288070
1 2759 815489840
2 810 158593560
3 2832 492373670
4 2209 368268770
5 2482 801981570
6 989 201812580
7 4202 350017710
8 2772 560704100
9 2017 156669510
10 4682 92934580
11 3450 514756530
12 3306 895638580
13 4257 871378280
14 1872 922166080
15 1805 346581840
16 1128 ...

output:

1612805668230

result:

ok single line: '1612805668230'

Test #18:

score: 0
Accepted
time: 38ms
memory: 5044kb

input:

5000 10000 1
3608
0 1 810121220
0 2 355065080
0 2896 301650880
0 4717 386184700
2 3 950388340
3 4 477643040
4 5 241940330
4 6 187063440
4 7 130985470
4 2163 577070050
5 1203 806247670
6 3440 245643890
7 8 782485830
7 893 889883080
7 3541 5217960
8 9 942491640
8 11 207075260
8 12 202843280
8 3629 921...

output:

5134464520

result:

ok single line: '5134464520'

Subtask #5:

score: 5
Accepted

Dependency #4:

100%
Accepted

Test #19:

score: 5
Accepted
time: 35ms
memory: 4892kb

input:

5000 10000 1
2732
0 2754 813230770
0 3355 792927570
1 1095 752876150
1 1702 60134960
1 3298 58308710
3 2532 545385230
3 3493 519815830
3 3831 87299670
3 4304 819918750
4 1296 129849950
6 171 381977660
6 605 447093590
6 3172 195396460
6 4522 972555440
8 2580 998199040
8 4488 981698540
9 617 151220820...

output:

-1
-1
6844725280
-1
-1
4970228790
6207082620
6256771157
7189097250
6555251950
-1
5707151643
6922669237
-1
4331382082
-1
7479176031
8382930113
5446187267
5259480093
6469144775
5077783348
5052081665
6878899618
-1
7147496482
7323901431
5429189672
7562818823
6145578908
7634473031
7213576761
7516983564
7...

result:

ok 100 lines

Test #20:

score: 0
Accepted
time: 9ms
memory: 4384kb

input:

5000 4999 1
3172
0 3425 212921950
1 358 862302700
2 422 11218920
3 1403 670932170
4 1412 169346020
5 2307 959992040
6 1991 511614800
7 391 889429880
8 68 78669920
9 4330 787980200
10 505 382958210
11 3935 137246400
12 4234 712583210
13 3342 401786600
14 4098 918653140
15 4077 57403210
16 4997 895126...

output:

1008027043311
1241172647829
91674265728
2196833504607
365975602990
202813027918
397347563788
2216999484851
1217726223566
2392686101830
2342477217889
1943064442790
1573935864904
353224827908
2343949923083
1327986959793
2104879782662
269312348190
2171886544166
2111949631340
123888365974
1941080673152
...

result:

ok 100 lines

Test #21:

score: 0
Accepted
time: 49ms
memory: 5052kb

input:

5000 10000 1
3241
0 1 446152100
1 2 963620770
1 3061 295980340
2 3 302935420
2 4 29749730
2 617 830667750
3 3881 919115000
4 5 793367310
4 3987 855122150
5 6 874572100
5 2262 57790570
6 7 229296020
7 8 597562450
7 410 614207350
8 9 96738950
8 787 119642250
8 1839 493563530
8 3835 172546230
9 10 1284...

output:

4654029880
4808237650
2835091570
2418568910
6398877830
-1
4960814937
3068551275
3984416279
4880732214
4679353170
4781864010
6642134664
4452533714
-1
4577503096
3943474383
3193480180
5076471477
-1
3124876870
3522308310
3251187240
4220214450
-1
4981827680
3857452030
4329397460
4111863508
4016220610
41...

result:

ok 99 lines

Subtask #6:

score: 10
Accepted

Test #22:

score: 10
Accepted
time: 57ms
memory: 5988kb

input:

5000 10000 200
1044 1225 1941 2497 4667 2566 3603 92 2261 1826 770 4780 127 4386 1948 2156 1504 4511 3119 4006 4473 389 3469 2670 3989 3092 55 670 4525 4965 1038 375 419 2599 4912 3665 4799 2997 4759 1660 1136 2308 1707 4249 3246 625 3378 52 734 4317 4958 3355 869 3361 2010 2300 2809 2635 2241 3441 ...

output:

-1
2711183020
697856260
1516782260
2354919910
-1
480464090
-1
2697573650
-1
1124944640
1861504690
-1
-1
741307190
-1
-1
976285550
2852046420
1719694410
2990735250
2873388140
1662807060
2174636268
1457722880
0
1784816420
-1
-1
1055305240
3876585820
3104699870
2543260280
953014320
-1
-1
-1
4031155510
...

result:

ok 100 lines

Test #23:

score: 0
Accepted
time: 59ms
memory: 9452kb

input:

5000 10000 1000
1724 797 4366 648 4874 4181 4906 1674 418 2374 1305 3729 713 4012 1292 1145 4213 2823 2946 593 846 4790 141 2242 2763 1706 4276 315 520 754 4454 3971 982 3262 4764 410 4128 0 2653 2125 3007 3223 3142 3078 2523 1932 2876 993 4924 1086 270 2400 2272 1936 84 1869 1187 2440 2095 4061 183...

output:

-1
504736580
533319930
0
1598336130
0
674852850
619682840
96661730
0
-1
0
-1
877923950
837181240
337188680
334032830
883133580
0
1753597640
282518400
-1
1003511900
835771200
0
-1
370947710
359011907
1667581460
-1
-1
897197910
-1
-1
0
-1
12595850
336908950
0
1850076420
1637857990
1238742070
410269360...

result:

ok 100 lines

Test #24:

score: 0
Accepted
time: 27ms
memory: 4472kb

input:

5000 4999 200
2401 2385 682 3001 4099 2293 1012 1484 2708 4374 3563 4153 3204 2598 4567 3403 4495 843 4154 2803 316 844 14 3557 597 319 619 4709 418 188 3797 1408 4939 2738 476 1126 1449 2236 274 686 3579 221 4839 4050 678 952 3232 932 166 1686 4315 737 664 1172 3624 4388 4697 4974 1256 3450 3210 86...

output:

19739260929
4470428810
3360164870
2695387200
2163014110
2365937840
21059321620
7305460630
28070668050
21590166910
31220463950
4867060350
1695748880
0
16554839450
12439922530
9989649050
8779275960
38969491520
20034888465
2000432470
20625369130
9158744090
30696903330
8665056303
14358198770
2136504540
...

result:

ok 100 lines

Test #25:

score: 0
Accepted
time: 41ms
memory: 4896kb

input:

5000 10000 5
4655 3633 4436 692 635
0 1 77960320
0 4 352635430
0 5 32432770
1 2 59642940
2 3 111969210
4 1424 369598780
5 6 135683440
5 11 14082840
6 7 951491240
6 8 775544380
6 9 493601950
6 1593 518195620
7 2061 781633510
8 1955 15556000
8 3316 662542360
8 3819 943133120
9 10 485335530
9 189 52352...

output:

3064371790
-1
3480875420
-1
3128850560
2677033182
4433222050
4211151510
4158633710
3560357430
3277633110
1631992100
1838682760
4651490930
4146944750
2094350100
2956951400
6574571560
3812440590
4823270970
3071280350
3661727360
2499551080
2345997260
2712955330
5637415350
4157892660
6607330290
-1
77749...

result:

ok 99 lines

Subtask #7:

score: 15
Accepted

Test #26:

score: 15
Accepted
time: 6ms
memory: 4320kb

input:

100 1000 10
98 30 76 47 68 72 37 62 38 78
0 40 955510110
0 58 380472040
0 67 471726660
0 75 21910230
0 76 203779460
0 79 619337400
0 92 789108960
0 95 850838250
1 7 708430
1 8 800979960
1 24 529606990
1 25 822365030
1 40 803087030
1 75 339182160
1 79 841073850
1 86 249876300
1 92 93708160
2 6 653731...

output:

410099610
386216320
0
233546015
399770707
276108460
524518580
278520060
521727310
450306330
461649420
464823212
386031210
153282630
127385060
0
131407620
178369240
481426810
403923330
311973790
259478290
167906470
345801959
310169200
240099870
56486000
123774050
263065700
433249160
203779460
2717947...

result:

ok 100 lines

Test #27:

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

input:

100 1000 5
56 95 36 60 62
0 3 192396910
0 22 805335870
0 35 399624690
0 47 499610620
0 56 510076020
0 61 324899250
0 74 732506440
0 76 680413950
1 2 235730090
1 3 515640540
1 5 661788560
1 8 443664920
1 16 84209830
1 27 882274860
1 50 504921340
1 56 452206250
1 69 680192960
1 76 67162500
1 80 594724...

output:

483543930
118596430
106636800
146240560
266101930
377031810
152249730
265604350
393673640
388292710
358911790
250019110
227832147
319580670
74227020
89700330
148624010
306053820
302071574
20982620
34191060
312317250
91892820
75343050
191446180
224783520
326265270
165805090
299111710
103355550
222858...

result:

ok 100 lines

Test #28:

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

input:

100 99 2
24 6
0 23 197416360
1 65 653204870
2 48 895802830
3 2 304965120
4 18 155013130
5 20 643250780
6 80 326094400
7 15 613530510
8 7 27830900
9 28 64986310
10 92 452569930
11 43 209666820
12 98 856446580
13 9 585386760
14 37 87758750
15 21 480701780
16 6 229947490
17 0 416482660
18 70 308710360
...

output:

11394907590
17577497190
1974662330
229947490
21560422139
557697820
13546331963
295764340
16859683496
7284957976
29218886720
5426111488
28267019816
36409480160
7352231543
6325708230
8817367960
1941473558
9648951040
17928324721
16741298696
7702342318
6549052910
31476226575
4680478720
3281744467
229938...

result:

ok 100 lines

Test #29:

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

input:

70 800 10
26 9 17 22 34 0 56 3 32 13
0 13 752543950
0 17 878514670
0 18 394546530
0 31 490617700
0 49 525844750
0 52 895409820
0 56 384845020
0 58 32932060
0 66 520113450
1 6 220247690
1 8 957994970
1 13 991853520
1 17 724453620
1 23 499439780
1 25 335146290
1 31 944771600
1 34 50258960
1 38 7836021...

output:

233262196
178175070
296835810
286834670
250389800
171237940
153094600
353036360
301944760
146352860
216988650
499109423
166244200
0
120796210
0
365822540
247380211
220114046
241220857
316470550
0
131866410
403222622
67497480
357344848
474031410
129889370
112039900
169133800
322748021
79135733
951325...

result:

ok 70 lines

Test #30:

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

input:

90 900 52
79 48 16 56 24 42 81 8 78 65 9 1 51 57 67 59 33 36 49 61 86 58 64 41 6 47 21 18 76 34 71 39 54 82 52 69 11 73 44 2 23 3 20 53 14 30 66 10 27 60 32 38
0 1 117890180
0 2 784309190
0 6 254401860
0 10 727085290
0 28 184275140
0 33 349545050
0 44 609882160
0 68 695751180
0 75 119032860
0 83 705...

output:

5973910
117890180
81511610
0
0
0
0
0
0
0
0
0
277113280
87279710
27070550
48104400
0
0
94235460
0
0
0
0
0
0
169058580
0
0
81644240
88717320
0
35125589
147379930
16869510
297635123
0
0
23828820
90068660
0
167598990
295131330
0
0
0
0
122828740
77348370
0
0
52799160
0
94053560
86120200
85195970
71759820...

result:

ok 90 lines

Test #31:

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

input:

100 99 20
41 94 46 4 64 59 81 42 68 36 69 63 18 96 11 56 74 1 77 93
0 45 107934930
1 84 32786000
2 96 728543090
3 18 933371690
4 72 614853570
5 12 817901020
6 85 239120310
7 69 638798320
8 20 778612350
9 4 641900670
10 70 60796980
11 91 177788090
12 47 162578330
13 58 444163380
14 50 381391910
15 8 ...

output:

4048559590
453672561
1981917660
2443168480
1299316985
0
792658650
1015303356
1492640275
2360280074
0
778272805
0
0
495394784
1785742500
413555570
2281247089
894949276
896647830
681033570
2959003779
5984779565
3922541217
3348458600
1337301613
3267707793
2927313924
0
1979177020
0
1771977066
3923183832...

result:

ok 100 lines

Test #32:

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

input:

100 1000 20
67 75 23 98 64 88 31 29 61 17 35 38 78 76 43 55 7 92 14 26
0 5 454346090
0 16 840201330
0 40 247707810
0 62 716233510
0 71 825289880
0 73 967959420
0 77 528301890
1 5 919109510
1 25 893055090
1 30 713280040
1 42 984094610
1 49 968876810
1 59 770138290
1 67 822562030
1 70 438760060
1 83 2...

output:

215477150
197609870
467721120
0
291323320
0
0
64785670
222821040
263344480
55819220
0
0
279457129
32832490
207385410
189944160
0
260532540
113849089
207141670
187385290
133566040
0
0
193137340
189471080
0
0
104031170
0
381115330
167572520
81182370
186898060
170874590
138753740
0
145215150
65176349
3...

result:

ok 99 lines

Test #33:

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

input:

100 1000 18
5 27 90 2 31 83 19 21 17 87 24 13 65 16 60 39 23 15
0 6 725253650
0 21 909741480
0 22 137866640
0 31 907614940
0 44 903058110
0 45 719823160
0 48 286033780
0 49 633535670
0 56 888583550
0 71 305844160
0 76 5886750
0 88 177417520
0 97 148595400
1 11 749832490
1 15 800257910
1 16 652415640...

output:

0
266648420
238222970
141413100
131847740
141778640
177424840
17211100
115642270
125996490
0
81259860
299761610
91540780
76978010
0
363898610
0
103853970
295318610
426787090
266878060
467169380
0
28422700
78414800
86429160
246151530
762983210
0
126708080
105969240
50516000
134315000
46604950
2682028...

result:

ok 100 lines

Subtask #8:

score: 50
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #6:

100%
Accepted

Dependency #7:

100%
Accepted

Test #34:

score: 50
Accepted
time: 59ms
memory: 9184kb

input:

5000 10000 1000
4591 2980 726 325 1299 2245 229 1124 2339 783 319 492 129 4478 2892 1371 3664 2819 2640 4643 3571 2090 207 3403 1699 744 2063 498 4639 2264 799 2489 580 212 2088 3613 508 3744 1618 1115 4553 4918 50 4555 4148 3048 2937 2718 124 1771 3097 2872 4448 859 3134 2922 815 3663 4605 4702 433...

output:

0
0
689802610
1711142341
1192294707
0
1041527420
532811952
-1
30565690
-1
-1
351367052
686766066
78477483
219667420
700369510
0
428630009
336790740
264513710
29986390
1840686733
0
-1
419391391
916624239
-1
224720020
1439547146
-1
-1
577821295
379024610
10372860
1236494850
0
0
243141000
0
0
148991622...

result:

ok 100 lines

Test #35:

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

input:

5000 10000 5000
318 3743 4444 822 375 3515 3098 3912 4271 1198 4100 613 3153 296 802 4343 459 1617 3445 1535 514 467 4675 2666 2946 3423 1056 1982 126 3347 3882 1362 1284 40 3885 327 2115 1772 860 855 2302 1090 2701 3485 3683 4946 2705 4608 4714 963 2577 1512 2394 1967 239 4130 1171 3813 1432 629 21...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 100 lines

Test #36:

score: 0
Accepted
time: 41ms
memory: 4972kb

input:

5000 10000 10
2891 4663 1274 4747 1586 3583 3529 3122 2394 1854
0 1638 526358240
0 2116 286811730
0 4789 254216210
1 225 382284020
1 260 325903900
1 4264 106028480
2 1976 714012470
2 2920 793323770
2 3751 988378160
2 4993 200145390
3 263 977322670
3 898 446438170
4 613 301361040
4 2331 530341500
4 2...

output:

2839889837
1898483326
-1
3423643117
3284721759
2554825510
3153852306
4058390440
2159585149
2319982076
4417297050
2863865370
4847760091
2745720866
2215913760
-1
2884576068
3089905194
2742409531
2627747751
3805474060
3227008150
3316450550
4242970717
-1
4010877983
2801406847
2153357184
1485559260
-1
-1...

result:

ok 100 lines

Test #37:

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

input:

5000 0 10
2926 4599 4037 2886 1292 4486 4244 2915 4975 1546
100
1540 978144017 578905073 174932767 611158835 440032215
3512 987784533 863508254 199358341 357407131 474830337
1310 957047801 427892992 820784469 585867045 281338866
3159 986391825 768389682 712389138 904012672 536977402
4348 58080131 79...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1

result:

ok 100 lines

Test #38:

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

input:

5000 0 5000
3579 786 4259 426 471 1424 3764 1836 1792 4104 2663 1117 1195 3692 4130 1283 1332 3085 215 4978 1126 3294 282 216 4177 1933 2120 4149 3858 2819 4590 3241 66 2905 1602 772 3363 3071 3526 4673 3565 1840 2344 4230 4907 3631 2396 288 3254 512 4032 2032 4432 4943 1728 3290 2113 4527 437 3212 ...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 100 lines

Test #39:

score: 0
Accepted
time: 70ms
memory: 8948kb

input:

5000 10000 1000
529 1794 4536 2950 1279 3261 3103 3284 975 3526 1897 519 1726 939 4626 1906 1218 3767 4346 3257 1136 2938 4203 1559 1244 931 2122 1721 4622 1446 4932 4984 3670 1803 1737 3924 4136 2511 3311 1729 1393 4320 4796 2289 1786 4314 2062 4181 73 479 622 781 2965 4655 2533 2979 2209 80 1296 1...

output:

0
223955176
0
455518027
-1
836259180
1250687110
0
632668226
42029680
2656897370
-1
1711755340
1271012273
0
905152310
972536530
683712856
0
-1
404204343
0
395607090
-1
0
1850973556
650404330
203899580
414874114
782983023
401399430
-1
672787290
636621140
623161200
611982362
-1
523782729
597595818
5900...

result:

ok 100 lines

Test #40:

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

input:

5000 10000 5000
552 2829 4852 4151 1081 1823 4009 4357 1616 4881 3284 3389 773 3568 3965 2484 3286 16 4346 4517 661 2816 2142 3942 4486 2700 1922 1741 2184 554 1749 3634 4497 3252 2554 2957 4908 4153 301 1961 49 2156 2687 1432 1404 2744 4173 3504 1131 4190 2727 81 810 4913 4804 294 1792 2440 4232 10...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 100 lines

Test #41:

score: 0
Accepted
time: 52ms
memory: 4900kb

input:

5000 10000 10
2593 3626 2770 701 1806 1690 3529 2801 2549 4951
0 1 233822000
0 13 735645370
0 555 852610610
1 2 650716290
1 3 471957670
2 1304 588752900
2 2825 648889910
3 4 490306550
3 5 860527980
3 11 665904400
3 12 350870360
3 2674 473963030
4 3512 424374600
5 6 561847420
5 7 314048610
5 8 263573...

output:

3293890796
3025532040
4181251020
2150757805
3006837274
3487624279
-1
2317674560
3127918438
3248165700
3171732065
2643393110
2483621198
-1
1529717014
1037693630
-1
1592155180
-1
2855341190
4378278960
2630822350
5345686280
3230886253
5115932190
3826600090
2060057300
-1
-1
-1
1689167120
2182491930
3278...

result:

ok 100 lines

Test #42:

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

input:

5000 4999 100
1791 1938 243 2391 2400 3437 1087 3279 2784 2040 2896 3488 872 397 565 2800 1037 1162 2264 944 4848 4284 4476 2983 4014 2155 1812 2858 4444 1464 69 1404 2410 2289 2525 2156 4788 3544 545 114 2272 3886 3588 557 4325 2221 4813 1723 3447 4303 487 15 2728 3151 1110 405 3421 81 4620 1743 33...

output:

3741665299
815223976
647507900
3117040451
22574292560
83664973820
20143532530
25434569290
95664064960
19989579490
20351861140
21971518130
519053600
9017107400
20831555404
9673662845
2362332980
35440399240
6861295160
5331166810
4851085426
32866417957
32552565152
35527758337
661520940
7854505737
84087...

result:

ok 99 lines

Extra Test:

score: 0
Extra Test Passed