QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#874540#9687. 仙人掌染色JohnAlfnov#59 1809ms64380kbC++142.8kb2025-01-28 10:44:092025-01-28 10:44:10

Judging History

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

  • [2025-01-28 10:44:10]
  • 评测
  • 测评结果:59
  • 用时:1809ms
  • 内存:64380kb
  • [2025-01-28 10:44:09]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,m,p,N;
vector<pair<int,int>>g[200005];
int dfn[200005],low[200005],tot=0;
stack<int>st;
vector<pair<int,int>>gg[400005];
map<long long,int>mp;
void jia(int u,int v,int w){
	if(u>v)swap(u,v);
	mp[1ll*u*(n+1)+v]=w;
}
int cha(int u,int v){
	if(u>v)swap(u,v);
	return mp[1ll*u*(n+1)+v];
}
void dfs0(int x,int la){
	dfn[x]=low[x]=++tot;
	st.emplace(x);
	for(auto pi:g[x]){
		int cu=pi.first,c2=pi.second;
		if(cu==la)continue;
		if(!dfn[cu]){
			dfs0(cu,x);
			low[x]=min(low[x],low[cu]);
			if(low[cu]>=dfn[x]){
				vector<int>vc;
				while(st.size()){
					int u=st.top();st.pop();
					vc.emplace_back(u);
					if(u==cu)break;
				}
				int sz=vc.size();
				if(sz==1){
					gg[x].emplace_back(cu,c2);
				}else{
					++N;gg[x].emplace_back(N,c2);
					for(int i=sz-1;i>=0;--i){
						int u=vc[i],v=(i>0?vc[i-1]:x);
						gg[N].emplace_back(u,cha(u,v));
					}
				}
			}
		}else{
			low[x]=min(low[x],dfn[cu]);
		}
	}
}
long long f0[400005],f1[400005],f2[400005];
__int128 f[200005][2][2];
inline long long get(int x,int y){
	return y==0?f0[x]:y==1?f1[x]:f2[x];
}
__int128 ff[400005],f3[400005];
int h;
void gai(long long x){
	for(int i=0;i<=h;++i)f3[i+1]=ff[i]+x;
	ff[h+1]=-1e25;
	for(int i=1;i<=h+1;++i)ff[i]=max(ff[i],f3[i]);
	++h;
}
void gai2(long long x,long long y){
	for(int i=0;i<=h;++i)f3[i+2]=ff[i]+y;
	f3[1]=ff[0]+x;
	for(int i=1;i<=h;++i)f3[i+1]=max(f3[i+1],ff[i]+x);
	ff[h+1]=ff[h+2]=-1e25;
	for(int i=1;i<=h+2;++i)ff[i]=max(ff[i],f3[i]);
	++h;++h;
}
void dfs1(int x,int la,int c2){
	for(auto pi:gg[x]){
		int cu=pi.first,cc=pi.second;
		dfs1(cu,x,cc);
	}
	if(x<=n){
		long long fh=0;
		h=0;ff[0]=0;
		for(auto pi:gg[x]){
			int cu=pi.first,cc=pi.second;
			fh+=f0[cu];
			if(cu<=n)gai(f1[cu]-f0[cu]-cc);
			else{
				gai2(f1[cu]-f0[cu],f2[cu]-f0[cu]);
			}
		}
		int d=g[x].size();
		f0[x]=fh;f1[x]=fh+1ll*d*(d-1)*p;f2[x]=fh+2ll*d*(d-2)*p;
		for(int i=0;i<h;++i){
			__int128 he=ff[i+1];
			f0[x]=max((__int128)f0[x],fh+he+1ll*(i+1)*(d-i-1)*d*p);
			f1[x]=max((__int128)f1[x],fh+he+1ll*(i+2)*(d-i-2)*d*p);
			f2[x]=max((__int128)f2[x],fh+he+1ll*(i+3)*(d-i-3)*d*p);
		}
	}else{
		int m=gg[x].size();
		for(int i=0;i<=m;++i)memset(f[i],-63,sizeof(f[i]));
		f[0][0][0]=0;f[0][1][1]=-c2;
		for(int i=0;i<m;++i){
			for(int j=0;j<2;++j)for(int k=0;k<2;++k){
				for(int s=0;s<2;++s){
					f[i+1][j][s]=max(f[i+1][j][s],f[i][j][k]+get(gg[x][i].first,k+s)-gg[x][i].second*s);
				}
			}
		}
		f0[x]=f[m][0][0];f2[x]=f[m][1][1];
		f1[x]=max(f[m][0][1],f[m][1][0]);
	}
}
int main(){
	scanf("%d%d%d",&n,&m,&p);
	for(int i=1;i<=m;++i){
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);w*=2;
		g[u].emplace_back(v,w);
		g[v].emplace_back(u,w);
		jia(u,v,w);
	}
	N=n;dfs0(1,0);
	dfs1(1,0,0);
	printf("%lld\n",f0[1]/2);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 7
Accepted

Test #1:

score: 7
Accepted
time: 1ms
memory: 29252kb

input:

20 19 444
1 2 932
2 3 9129
1 4 3180
4 5 502
4 6 3906
4 7 4020
4 8 2771
2 9 4132
6 10 3311
2 11 1547
3 12 7576
11 13 1254
6 14 1653
7 15 6855
6 16 8691
5 17 2048
3 18 8097
12 19 2113
10 20 2594
0 0
1 0
2 0
1 1
2 3
2 4
2 5
2 6
2 1
3 4
2 2
3 0
3 2
3 5
3 7
3 6
3 3
3 1
4 0
4 1

output:

7569

result:

ok answer is '7569'

Test #2:

score: 7
Accepted
time: 1ms
memory: 28072kb

input:

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

output:

27334

result:

ok answer is '27334'

Test #3:

score: 7
Accepted
time: 2ms
memory: 28156kb

input:

20 19 389
1 2 6358
2 3 6342
3 4 5165
4 5 3974
5 6 9030
1 7 7437
1 8 2856
1 9 8098
1 10 7327
1 11 9108
1 12 1742
1 13 1336
1 14 9080
1 15 501
1 16 5086
1 17 1331
1 18 3535
1 19 8930
1 20 4691
0 0
1 0
2 0
3 0
4 0
5 0
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14

output:

147388

result:

ok answer is '147388'

Test #4:

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

input:

20 19 996
1 2 6343
2 3 4327
3 4 7056
4 5 8316
5 6 6511
1 7 3194
1 8 9784
1 9 239
1 10 6493
1 11 7645
1 12 1188
1 13 3829
1 14 4949
1 15 4056
1 16 7516
1 17 2020
10 18 1299
1 19 2256
1 20 4835
0 0
1 0
2 0
3 0
4 0
5 0
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
2 1
1 12
1 13

output:

324846

result:

ok answer is '324846'

Subtask #2:

score: 9
Accepted

Dependency #1:

100%
Accepted

Test #5:

score: 9
Accepted
time: 1ms
memory: 30404kb

input:

15 20 265
13 15 0
5 14 4
15 10 8
3 12 9
14 7 0
7 11 2
5 9 1
5 13 0
6 5 5
13 2 8
2 3 7
2 12 2
14 9 2
14 1 1
1 8 5
13 10 0
6 2 9
14 4 10
11 4 2
14 8 9
4754354 3960467
4629204 2001500
6793471 6167134
2135231 397939
4054633 471608
8818077 1222890
4313744 8937757
3700257 7400078
9056146 3171567
1832451 2...

output:

16403

result:

ok answer is '16403'

Test #6:

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

input:

16 20 538
11 14 6256
16 7 2849
13 11 9877
13 5 2612
16 9 3079
11 8 9929
11 12 4614
8 3 5374
6 13 182
11 15 7469
15 10 3654
16 6 4759
11 4 85
10 14 6118
16 13 6098
2 1 7507
11 1 5743
12 2 9669
7 9 6709
13 3 8923
8407920 139886
8548719 3106021
9493665 2215187
8468961 8057751
6907841 9181328
6049364 99...

output:

21400

result:

ok answer is '21400'

Test #7:

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

input:

17 20 779
17 7 3882
17 8 5085
15 13 3362
17 1 108
17 9 6762
17 11 3624
17 5 4278
17 3 9267
17 2 1503
6 10 6884
17 4 8340
17 15 4421
5 16 5778
17 16 2567
17 6 9186
10 4 2523
9 12 3361
17 13 2117
17 12 8585
17 14 6808
5324296 4687212
9329914 5276184
3453993 5741483
5942309 676651
9885184 4115242
80338...

output:

311678

result:

ok answer is '311678'

Test #8:

score: 9
Accepted
time: 2ms
memory: 31180kb

input:

20 20 107
16 8 2948
2 8 1149
16 12 5285
16 14 1529
16 20 6642
16 19 6559
16 9 4
16 10 640
16 17 5364
16 1 9624
3 2 5810
16 11 581
16 6 1791
16 18 5463
17 15 3895
16 13 7428
16 4 9028
16 5 3162
15 3 3608
16 7 9857
6624862 2177366
6962081 357372
4026592 9527019
7985220 7909129
9673578 3778191
6091138 ...

output:

43974

result:

ok answer is '43974'

Test #9:

score: 9
Accepted
time: 1ms
memory: 30508kb

input:

15 20 291
11 9 767
15 5 2
15 8 4
15 11 6625
15 7 1
3 10 5522
15 4 1
15 12 10
7 8 8489
15 3 6
15 13 8
4 5 9074
15 14 5
15 6 0
15 1 2
15 10 6
6 13 3188
2 14 6283
1 12 803
15 2 2
6807455 8012526
3185535 9263149
6918697 5035690
744362 1122805
9752082 9859811
6226325 4162819
7917343 1342566
1704456 71987...

output:

81468

result:

ok answer is '81468'

Test #10:

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

input:

20 20 556
2 5 10
12 3 4885
15 8 5582
4 18 5917
5 11 5678
8 9 8684
3 16 9154
13 4 4831
2 11 7
20 1 8899
6 12 498
19 20 36
9 17 7374
18 6 7340
1 7 8417
7 15 5487
17 13 9951
2 10 6240
10 14 8081
14 19 6250
7543208 353954
1148217 3984687
9167367 1316955
5145203 7813284
5601985 9437718
1289475 91889
8867...

output:

4453

result:

ok answer is '4453'

Subtask #3:

score: 3
Accepted

Dependency #1:

100%
Accepted

Test #11:

score: 3
Accepted
time: 5ms
memory: 29520kb

input:

5000 4999 610
1 2 1965
2 3 4777
2 4 5957
2 5 8820
4 6 6213
5 7 109
7 8 6335
8 9 3
7 10 3715
10 11 474
7 12 4698
6 13 4799
8 14 2979
9 15 8005
9 16 6216
5 17 3682
4 18 4635
2 19 1259
5 20 962
1 21 401
14 22 4103
20 23 8509
11 24 6237
9 25 8202
8 26 8866
7 27 8539
20 28 2811
23 29 8060
1 30 8008
28 31...

output:

4272781564

result:

ok answer is '4272781564'

Test #12:

score: 3
Accepted
time: 39ms
memory: 32304kb

input:

8000 7999 105
1 2 1704
1 3 6950
1 4 1836
1 5 1002
1 6 7226
1 7 9243
1 8 7298
1 9 1999
1 10 680
1 11 6175
1 12 3669
1 13 1104
1 14 6543
1 15 8914
1 16 812
1 17 6525
1 18 4551
1 19 342
1 20 4837
1 21 8167
1 22 8301
12 23 5584
1 24 1174
1 25 7824
1 26 9762
1 27 5679
1 28 5521
1 29 8448
1 30 2357
1 31 6...

output:

3819876223392

result:

ok answer is '3819876223392'

Test #13:

score: 3
Accepted
time: 25ms
memory: 29864kb

input:

8000 7999 352
1 2 1793
2 3 2096
3 4 9372
4 5 9802
5 6 9226
6 7 1130
7 8 6785
8 9 9112
9 10 8026
10 11 783
11 12 5532
12 13 1630
13 14 5805
14 15 9619
15 16 8787
16 17 6733
17 18 2522
18 19 36
19 20 2066
20 21 6159
21 22 6721
22 23 8138
23 24 8130
24 25 4329
25 26 8347
26 27 4709
27 28 6817
28 29 558...

output:

4890413099933

result:

ok answer is '4890413099933'

Subtask #4:

score: 9
Accepted

Dependency #3:

100%
Accepted

Test #14:

score: 9
Accepted
time: 30ms
memory: 31636kb

input:

6560 6559 936
612 1661 141
1556 2672 9935
3186 5498 7334
1556 3791 1141
1556 5274 5148
1556 4382 9947
1556 5507 9448
5254 1814 3560
1556 1802 3957
4149 5350 6290
1556 1870 2470
1556 5725 2102
1556 5344 615
1556 1804 2131
1556 2139 9177
1556 878 556
1556 4769 4378
1556 6445 8551
1556 1353 7057
1556 3...

output:

19465870192297

result:

ok answer is '19465870192297'

Test #15:

score: 9
Accepted
time: 5ms
memory: 29812kb

input:

8000 7999 524
872 2240 7746
2571 290 1333
1495 4963 9262
1027 6592 7241
3333 1615 4056
2067 6621 636
2895 1816 6643
2320 2170 3902
4125 3674 9822
6357 5016 7934
3393 3151 2928
6632 6297 8223
6026 7454 7955
7849 2308 9893
4063 5453 7576
4092 1203 8485
2942 977 6593
5235 1397 8843
4686 5085 3267
7909 ...

output:

420867

result:

ok answer is '420867'

Test #16:

score: 9
Accepted
time: 8ms
memory: 30136kb

input:

8000 7999 712
462 2947 4370
4261 6499 8722
1231 7075 1931
750 2079 5922
2074 5286 2102
7594 5184 5703
2087 1857 5705
2009 1146 2521
7962 7555 7332
1261 1159 8774
7119 501 6059
7154 586 6065
1138 2437 4761
4934 7339 5023
2401 2384 7223
3296 6537 477
7270 6489 2176
3800 7210 3917
87 7248 1371
2957 653...

output:

726620

result:

ok answer is '726620'

Subtask #5:

score: 30
Accepted

Dependency #2:

100%
Accepted

Dependency #4:

100%
Accepted

Test #17:

score: 30
Accepted
time: 5ms
memory: 30716kb

input:

4567 5000 382
1161 1072 7488
2778 299 559
926 3556 7990
3520 2042 3554
449 1428 5362
4543 138 9002
3244 3400 3608
2241 2348 5221
2524 2593 4491
979 848 2911
4294 1209 1119
2239 4144 7584
3260 1406 7974
4084 4217 7600
195 883 5117
3662 2160 4191
1813 4496 4923
3439 4485 1554
1256 1870 1443
2527 1052 ...

output:

69960711

result:

ok answer is '69960711'

Test #18:

score: 30
Accepted
time: 5ms
memory: 32716kb

input:

5290 7779 916
2750 2577 5491
724 2506 8170
230 1750 4093
3234 597 3240
2909 4415 8786
2827 4994 52
96 3293 3035
1651 2728 8815
750 4535 6860
2226 2168 5971
2974 4788 7105
4180 3403 7251
2317 1522 8960
2755 1441 4478
3136 523 3130
288 2156 6172
3624 459 1943
2716 1801 1737
4265 1475 5336
2317 3749 52...

output:

1666184672

result:

ok answer is '1666184672'

Test #19:

score: 30
Accepted
time: 6ms
memory: 32772kb

input:

7369 7887 157
6093 6496 9832
7229 7192 7611
7298 3894 7485
4396 7003 6514
2149 4121 9465
7046 2484 4880
874 3458 3096
4471 3174 3967
2525 7308 6010
2284 4744 2973
1428 5315 7501
6652 2926 1283
5348 1404 9248
5508 3531 5293
2938 5814 292
4728 2582 546
4460 2416 5313
2626 2500 9176
7294 5082 6903
3986...

output:

7166174

result:

ok answer is '7166174'

Test #20:

score: 30
Accepted
time: 15ms
memory: 31880kb

input:

5630 7890 331
1858 99 3161
3193 4665 7597
1858 3559 9611
652 3848 4016
1858 2436 866
1653 4645 3623
1858 1911 4324
1858 3965 2780
2856 2665 9743
1858 676 6354
2700 5138 1365
1858 3734 2018
4732 910 4886
3084 1917 5101
1858 807 2728
4771 2419 6804
1858 4182 3115
1858 4470 1929
384 5099 7278
1858 1163...

output:

2268533846672

result:

ok answer is '2268533846672'

Test #21:

score: 30
Accepted
time: 11ms
memory: 34348kb

input:

6561 8000 58
2203 2941 424
1218 3635 6348
6037 92 8
3294 4292 8237
6037 4387 10
4991 2849 1910
6037 3269 9
6037 6322 3
3503 1902 1055
6037 153 8
5689 3347 7660
6037 2006 6
808 13 3000
6037 5565 3
6339 3116 7995
6037 4753 3
6037 3287 0
88 3508 2045
6037 419 7
4986 5233 5949
3141 4128 8618
5617 1770 6...

output:

127279357378

result:

ok answer is '127279357378'

Test #22:

score: 30
Accepted
time: 7ms
memory: 31900kb

input:

7231 8000 924
5730 4145 3
1667 2340 3199
3145 1845 2414
5730 2747 3
5730 2746 8
5730 4317 3
7213 5054 4967
5730 3371 9
5730 2808 1
6620 3001 4075
1121 6533 7333
7166 1150 6267
242 4283 2643
4003 694 9328
5730 4907 6
5972 3020 6939
4807 4761 9038
2499 3641 1848
6294 2513 7281
5776 232 9642
4605 341 7...

output:

286076834298

result:

ok answer is '286076834298'

Test #23:

score: 30
Accepted
time: 9ms
memory: 32780kb

input:

6938 8000 355
5690 100 1684
3297 6360 1055
5948 2606 4939
6788 4759 10
6199 5109 6416
5740 787 2139
5460 4767 7493
4519 4798 7246
6788 334 4
318 3498 9040
3339 4098 7346
5429 1029 4543
4786 1037 2022
3902 771 2069
1743 6890 7527
5190 6882 104
1160 2509 8439
1897 1452 1147
6788 1647 5
4333 4427 4336
...

output:

295328911424

result:

ok answer is '295328911424'

Test #24:

score: 30
Accepted
time: 5ms
memory: 32708kb

input:

7561 8000 995
3745 3758 2
5794 5436 2
4822 5580 1
4892 1843 0
181 4719 1
6653 1667 1
1345 5362 2
2920 5795 1
5510 2733 2
6610 7003 1
6209 2474 1
4896 7140 3
1145 6731 2
3929 5602 2
2713 711 3
3169 4575 3
2310 755 0
6324 5141 1
4529 1049 2
696 2136 2
2827 4489 0
5255 4540 0
2088 4157 2
6626 3875 2
44...

output:

59486328015

result:

ok answer is '59486328015'

Test #25:

score: 30
Accepted
time: 8ms
memory: 34528kb

input:

6608 8000 119
5491 6481 0
3715 5491 0
5835 5853 2
1729 1574 1
6314 1664 2
1402 3519 2
529 538 2
1402 1911 2
1402 4817 3
1402 2168 3
938 353 0
5814 3332 1
3102 8 1
1402 2780 1
1402 1450 0
4881 2039 0
3741 1865 3
3041 4795 0
136 927 0
3456 2091 2
4610 1137 2
1406 4682 2
1010 5417 3
6283 19 3
336 5979 ...

output:

236631815805

result:

ok answer is '236631815805'

Test #26:

score: 30
Accepted
time: 18ms
memory: 32104kb

input:

5598 8000 570
2970 595 2
2970 1733 2
2970 5443 0
4518 367 1
3598 3532 3
3075 3976 3
3106 2724 0
2970 5332 0
2876 4967 2
4351 4310 1
2970 3668 1
2970 3832 1
2636 728 1
2970 95 3
1688 2486 1
2970 4296 1
2970 1663 2
1735 2663 1
2970 1567 1
2970 3074 2
2970 2451 1
2970 693 3
2970 2114 1
2970 5543 0
3628...

output:

5668830861353

result:

ok answer is '5668830861353'

Test #27:

score: 30
Accepted
time: 39ms
memory: 33816kb

input:

8000 8000 943
6053 2153 2739
3005 3234 8723
6053 7730 5287
6053 3600 7602
6053 5313 4703
6053 6744 5565
6053 4610 1238
6053 328 7137
6053 5297 4736
6053 6834 8377
6053 6733 6614
6053 7461 7473
6495 5790 8567
6053 7278 3254
6053 4060 2108
6053 2546 8623
6053 2612 2992
6053 4847 8305
6053 726 4640
605...

output:

35373119996390

result:

ok answer is '35373119996390'

Test #28:

score: 30
Accepted
time: 7ms
memory: 32476kb

input:

8000 8000 162
2743 722 0
1859 1297 0
4338 2981 1
3728 1428 1
5626 47 3
1083 5644 0
2143 5323 3
7055 7887 1
7932 6786 1
2968 6848 0
7166 1956 0
18 5980 1
5395 2101 0
286 3334 2
5220 3097 1
5544 890 3
823 4371 3
7414 1522 3
4748 326 0
449 5121 0
1672 2649 2
4632 6113 1
2433 6300 2
1983 7208 1
6659 12 ...

output:

1290525

result:

ok answer is '1290525'

Test #29:

score: 30
Accepted
time: 9ms
memory: 34064kb

input:

7000 8000 444
3660 6404 7002
6877 1549 3536
4077 6519 6934
4362 234 633
4376 5208 9496
5758 5481 4906
6151 4505 491
6151 572 7043
6151 268 2132
2498 5250 9092
5234 6560 327
4677 6154 2827
3399 6483 438
2425 729 1253
6151 640 8699
6151 208 3882
5720 6021 6150
3910 6996 6334
6151 5744 1046
6151 2136 6...

output:

908406011625

result:

ok answer is '908406011625'

Test #30:

score: 30
Accepted
time: 13ms
memory: 31636kb

input:

5330 7993 1000
1 2 10000
2 3 4684
2 4 9296
3 4 9441
2 5 4303
2 6 8312
5 6 8998
2 7 6820
2 8 30
7 8 5470
2 9 5029
2 10 2695
9 10 3427
2 11 7986
2 12 3407
11 12 8987
2 13 7906
2 14 8499
13 14 1229
2 15 4556
2 16 1178
15 16 2159
2 17 6922
2 18 1680
17 18 2465
2 19 9084
2 20 3117
19 20 1599
2 21 6535
2 ...

output:

4731852534740

result:

ok answer is '4731852534740'

Subtask #6:

score: 0
Time Limit Exceeded

Dependency #4:

100%
Accepted

Test #31:

score: 11
Accepted
time: 182ms
memory: 55996kb

input:

200000 199999 591
1 2 712
1 3 3028
1 4 56
1 5 3878
4 6 9579
1 7 5054
4 8 303
6 9 4293
3 10 3097
9 11 3270
5 12 8292
4 13 5894
3 14 6645
11 15 7422
13 16 5419
1 17 7723
16 18 2775
13 19 7612
1 20 1965
14 21 6314
11 22 9871
3 23 3851
11 24 87
16 25 7976
11 26 9026
25 27 8732
8 28 4290
3 29 6025
8 30 5...

output:

54095245642

result:

ok answer is '54095245642'

Test #32:

score: 0
Time Limit Exceeded

input:

200000 199999 554
190009 179065 2540
190009 129514 3604
190009 184746 3212
73130 173024 3805
172448 165256 259
190009 139039 8045
190009 103385 4620
190009 82590 7279
190009 97738 2112
176322 176196 1307
190009 171773 1986
190009 150419 8155
127496 104121 5747
190009 155055 1704
190009 193935 6483
2...

output:


result:


Subtask #7:

score: 1
Accepted

Test #35:

score: 1
Accepted
time: 1306ms
memory: 63096kb

input:

175359 200000 988
88931 90388 0
153878 127005 0
51428 146698 0
47233 44294 0
165647 94047 0
166749 168430 0
72728 87056 0
166749 113491 0
53604 116732 0
124969 120242 0
149669 118248 0
132892 45646 0
159774 167127 0
166749 148203 0
166749 129635 0
144811 121866 0
79510 144556 0
12541 75600 0
166749 ...

output:

8835898341292464

result:

ok answer is '8835898341292464'

Subtask #8:

score: 0
Time Limit Exceeded

Test #36:

score: 12
Accepted
time: 252ms
memory: 62852kb

input:

169178 200000 1
108026 106006 1
130712 146166 1
103490 133909 1
168608 113741 1
113670 115210 1
41692 127482 1
88594 91086 1
73606 78011 1
47848 99392 1
138615 97485 1
133884 131888 1
126125 47540 1
42576 147882 1
105365 109903 1
71043 153403 1
104808 113745 1
63589 160217 1
52766 161917 1
112636 13...

output:

554978

result:

ok answer is '554978'

Test #37:

score: 12
Accepted
time: 1809ms
memory: 64380kb

input:

170165 200000 1
145590 111071 1
168740 120177 1
145054 155580 1
168740 137006 1
168740 126711 1
168740 126008 1
168740 125292 1
168740 112288 1
168740 156272 1
128847 168257 1
168740 145797 1
168740 135987 1
145695 148228 1
168740 85963 1
141298 116007 1
105576 79043 1
168740 83733 1
117135 151654 1...

output:

15360259547191

result:

ok answer is '15360259547191'

Test #38:

score: 0
Time Limit Exceeded

input:

165093 200000 1
74586 45972 1
69524 87420 1
154090 151474 1
143717 83577 1
143717 111549 1
133199 125146 1
143717 126153 1
143976 164934 1
3144 59817 1
143717 111289 1
40872 154773 1
71203 121341 1
137769 144165 1
121180 118664 1
130398 145830 1
67408 104603 1
143717 117477 1
127427 128184 1
143717 ...

output:


result:


Subtask #9:

score: 0
Skipped

Dependency #5:

100%
Accepted

Dependency #6:

0%