QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#95589#68. Designated Citiestricyzhkx100 ✓171ms38164kbC++141.7kb2023-04-10 19:13:392023-04-10 19:13:42

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-10 19:13:42]
  • 评测
  • 测评结果:100
  • 用时:171ms
  • 内存:38164kb
  • [2023-04-10 19:13:39]
  • 提交

answer

# include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int> pli;
pli operator+(pli a,int b){return {a.first+b,a.second};}
int rt,head[200010],to[400010],edge[400010],nxt[400010],tot=1;
ll maxn,f[200010],g[200010],a[200010],len[200010];
pli h[200010];
void addedge(int u,int v,int w)
{
	to[++tot]=v;
	edge[tot]=w;
	nxt[tot]=head[u];
	head[u]=tot;
}
void dfs1(int u,int fa)
{
	h[u]={0,u};
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i],w1=edge[i],w2=edge[i^1];
		if(v==fa) continue;
		dfs1(v,u);f[u]+=f[v]+w2;
		if(maxn<h[u].first+h[v].first+w1) maxn=h[u].first+h[v].first+w1,rt=h[u].second;
		h[u]=max(h[u],h[v]+w1);
	}
}
void dfs2(int u,int fa)
{
	ll sum=0;
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i],w=edge[i^1];
		if(v!=fa) sum+=f[v]+w;
	}
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i],w1=edge[i],w2=edge[i^1];
		if(v==fa) continue;
		g[v]=g[u]+sum-f[v]-w2+w1;
		dfs2(v,u);
	}
}
void dfs3(int u,int fa)
{
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i],w=edge[i];
		if(v==fa) continue;
		dfs3(v,u);
		if(!len[u]) len[u]=len[v]+w;
		else if(len[v]+w>len[u]) a[++tot]=len[u],len[u]=len[v]+w;
		else a[++tot]=len[v]+w;
	}
}
int main()
{
	int n,q,x,u,v,w1,w2;
	ll sum=0;
	cin>>n;
	for(int i=1;i<n;i++)
	{
		scanf("%d%d%d%d",&u,&v,&w1,&w2);sum+=w1+w2;
		addedge(u,v,w1);addedge(v,u,w2);
	}
	tot=0;dfs1(1,0);dfs2(1,0);dfs3(rt,0);
	a[++tot]=len[rt];maxn=0;
	for(int i=1;i<=n;i++) maxn=max(maxn,f[i]+g[i]);
	sort(a+1,a+tot+1,greater<ll>());
	a[0]=f[rt]+g[rt];
	for(int i=1;i<=tot;i++) a[i]+=a[i-1];
	cin>>q;
	while(q--)
	{
		scanf("%d",&x);
		if(x==1) printf("%lld\n",sum-maxn);
		else printf("%lld\n",sum-a[min(x-1,tot)]);
	}
	return 0;
}

詳細信息

Subtask #1:

score: 6
Accepted

Test #1:

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

input:

2
1 2 781089648 283888890
2
1
2

output:

283888890
0

result:

ok 2 lines

Test #2:

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

input:

16
6 10 160848335 124052868
7 1 241203243 110601447
14 6 290972019 163072373
11 15 938517011 154373610
12 1 138651641 741445657
7 8 60218933 280830068
16 15 203079209 633547400
11 7 199606763 919756826
14 12 266702877 916493997
15 13 905937802 481991969
2 10 234605456 722866810
3 5 366455156 4966982...

output:

6311369523
2092762454
966156735
60218933
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 16 lines

Test #3:

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

input:

16
3 4 204022014 914663555
9 10 11007340 458844696
2 7 605164817 895349276
14 11 434326485 550918606
14 7 712866927 489761842
6 1 356406033 534499656
16 8 942553720 855217399
5 10 865707145 586883622
6 13 108330979 234031340
15 8 769531307 948036095
3 16 358448538 363203546
5 2 419315988 76297418
12...

output:

7413430560
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 16 lines

Test #4:

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

input:

16
4 5 1000000000 1000000000
10 5 1000000000 1000000000
8 5 1000000000 1000000000
11 13 999999646 999999646
15 16 999998089 999998089
7 5 929 929
14 7 898 898
16 9 159 159
6 12 603 603
9 2 999997930 999997930
3 6 999999242 999999242
5 12 155 155
16 14 84 84
14 1 999998173 999998173
12 13 199 199
16
...

output:

7999996107
5999996107
4999996107
3999996107
2999996107
1999996262
999998089
0
0
0
0
0
0
0
0
0

result:

ok 16 lines

Test #5:

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

input:

16
11 14 14368758 85219578
14 16 643747916 252121045
9 14 727413140 523990811
2 15 521253466 147320442
7 13 866289084 908489699
12 6 320730514 344516785
10 9 516379646 496493179
15 8 776569142 612383860
8 3 734861011 149748310
1 5 815040382 677607019
2 12 50609677 301797586
5 14 716517909 635543949
...

output:

7189308203
2211904770
1191420780
456559769
85219578
0
0
0
0
0
0
0
0
0
0
0

result:

ok 16 lines

Test #6:

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

input:

16
13 9 720744296 759388601
13 5 458441737 833011123
1 16 698474192 71086181
3 8 861918984 114516836
15 10 278084894 710666762
4 8 287405359 250250967
1 6 741642264 735381406
2 15 792787000 825787518
6 12 261754526 230466084
13 7 938274540 78969406
12 10 202958723 294264294
12 4 98252269 169605483
3...

output:

5844026168
2690903861
1848894892
1128150596
458441737
0
0
0
0
0
0
0
0
0
0
0

result:

ok 16 lines

Test #7:

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

input:

16
1 7 765638022 679756044
10 6 759069284 453967337
5 7 726239258 178402766
4 15 242761737 318885919
1 15 723511609 915383888
9 8 553064704 380886548
12 13 822971769 782770910
6 8 525975561 603298402
11 6 724594701 141189620
13 2 8408668 628943880
12 10 299406310 356329223
5 14 795305423 974800675
8...

output:

7154270560
522076168
141189620
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 16 lines

Test #8:

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

input:

16
6 2 396591 824425
14 1 121765 805092
9 10 386895 457376
3 15 20413 247942
8 3 426212 748706
12 11 318841 270569
2 16 925055746 604726712
12 1 359775 784231
14 5 516354 617685
2 9 970316 896797
2 7 943776860 978585272
14 9 712667 948012
8 9 566593 580631
4 12 761761 974298
13 2 136216 831818
16
1
...

output:

1556207783
7704211
3905589
2878333
2046515
1222090
705736
318841
0
0
0
0
0
0
0
0

result:

ok 16 lines

Test #9:

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

input:

16
2 8 119073534 555736925
5 2 866791517 685527555
11 14 180535517 448907590
2 16 393190702 164818863
6 9 298521139 301021930
2 1 808238767 844723287
4 1 221776781 268737189
10 2 551486708 14310879
2 15 363573262 106859347
2 9 622353716 714488454
13 2 908780203 288479297
13 7 897814090 253679879
2 3...

output:

6418370219
4638508078
3561532122
2638156476
1952628921
1339055967
890148377
496957675
133384413
14310879
0
0
0
0
0
0

result:

ok 16 lines

Test #10:

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

input:

16
3 12 901164666 987344195
7 11 777270351 297899178
6 14 441322434 685318792
3 4 894100390 768738682
6 10 308476613 227952988
12 2 398335684 800091780
15 9 683557377 818349714
2 8 55495903 851348261
5 10 842245631 650602672
11 16 169505872 655780963
9 8 978986177 766795908
5 13 17521706 829965580
1...

output:

8007192643
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 16 lines

Test #11:

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

input:

16
12 15 517822965 25354413
11 15 338190311 652436812
7 15 127729186 939448905
15 13 696913706 181993967
1 15 498822103 388824680
9 15 20787116 535387165
15 16 202795662 159091154
15 4 474628657 160994640
15 14 997130096 858493491
15 3 341451768 47792481
15 5 757815934 174503003
8 15 341732022 77854...

output:

7709225932
6581334361
5641885456
4863341388
4105525454
3408611748
2756174936
2220787771
1746159114
1337789248
948964568
569601843
228150075
25354413
0
0

result:

ok 16 lines

Subtask #2:

score: 7
Accepted

Test #12:

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

input:

2
1 2 683402985 526289818
1
1

output:

526289818

result:

ok single line: '526289818'

Test #13:

score: 0
Accepted
time: 109ms
memory: 17568kb

input:

200000
30498 170310 456566691 649436035
88553 73637 443596936 376869783
157116 8270 670934073 119072463
24742 48732 237943289 398782798
118620 71333 841086509 861755957
91523 118037 345609124 755508586
182978 92078 999023640 247489369
57480 73002 550952716 31090859
85037 151494 615937607 181113974
8...

output:

100090261531134

result:

ok single line: '100090261531134'

Test #14:

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

input:

200000
62380 190510 660465798 980286669
73494 59167 399860395 883378826
78917 156327 617261054 354160980
25845 163881 79154538 824380095
97426 144191 891448990 704743172
73271 43633 837335594 922276690
193758 169742 364918510 151494521
62996 52874 828453581 144363372
199529 178275 804482094 11831376...

output:

100066669866017

result:

ok single line: '100066669866017'

Test #15:

score: 0
Accepted
time: 102ms
memory: 17724kb

input:

200000
183258 143073 982 982
31786 177754 580 580
26332 6792 85 85
6390 70312 847 847
193105 75442 735 735
172433 196956 999926081 999926081
114861 33150 991 991
108634 161301 206 206
122529 105025 426 426
21388 86201 300 300
170711 87982 999923960 999923960
120595 43763 921 921
99462 120013 737 737...

output:

81103004367189

result:

ok single line: '81103004367189'

Test #16:

score: 0
Accepted
time: 123ms
memory: 17620kb

input:

200000
1539 92316 48323903 202410877
35890 69243 415172828 308900141
190963 50985 755719943 159735479
72146 159885 72946173 622268672
127505 64851 485107488 958218451
43378 89830 417162770 911217276
158176 69012 355971119 826228739
146386 106745 99361947 614603091
190012 95465 758111489 876554997
40...

output:

99944714663527

result:

ok single line: '99944714663527'

Test #17:

score: 0
Accepted
time: 112ms
memory: 19916kb

input:

200000
13693 159720 471504101 851110321
134244 80255 908560356 681906336
52579 127713 744119846 470734684
84038 32991 525544642 941494197
118155 105510 885724375 303139090
24258 176279 806826007 371683303
46557 54039 791816892 13705486
119090 160877 781290926 259135450
21899 55292 338745705 70209065...

output:

100142110488065

result:

ok single line: '100142110488065'

Test #18:

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

input:

200000
51485 158642 829759545 555246994
46408 182427 680884310 952048393
181386 51981 774364250 510078376
158642 137221 958595981 417456152
158642 13560 525026357 666355475
158642 119626 653370640 66503632
23721 100035 260540702 507629954
180546 101304 430322145 698388876
62412 158642 536391228 6818...

output:

100029161376725

result:

ok single line: '100029161376725'

Test #19:

score: 0
Accepted
time: 148ms
memory: 35160kb

input:

200000
172976 108672 288769649 485088836
159642 46318 971501113 486464598
120751 69878 169239703 173145059
44498 138117 820693607 695329677
158520 63527 366383754 437019528
19626 64856 939531671 635492288
21084 66469 694278429 909732840
30440 161053 573714265 203831805
160668 89739 513226897 3644949...

output:

99756547102864

result:

ok single line: '99756547102864'

Test #20:

score: 0
Accepted
time: 110ms
memory: 17456kb

input:

200000
154441 4651 747796649 453770199
137511 154441 46174763 669025918
154441 46408 501310306 365029626
154441 70897 637262505 711161748
149885 154441 906469650 910775313
56604 154441 120489234 529690198
154441 128437 857569560 602188933
154441 12895 528165172 22359068
177797 154441 947733025 70024...

output:

100044587345734

result:

ok single line: '100044587345734'

Subtask #3:

score: 9
Accepted

Test #21:

score: 9
Accepted
time: 3ms
memory: 7740kb

input:

2
2 1 92722556 873785501
1
2

output:

0

result:

ok single line: '0'

Test #22:

score: 0
Accepted
time: 106ms
memory: 17584kb

input:

200000
99982 83075 709942852 92942003
168325 12929 879930937 637190556
85628 123672 784369088 731448156
34917 117619 569166498 663184347
92257 112058 369526210 824568522
32464 109884 258245678 691717157
129594 115097 627894556 937225369
54700 187473 81636213 510866047
52020 197198 577461848 47343465...

output:

99980874607500

result:

ok single line: '99980874607500'

Test #23:

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

input:

200000
95719 149301 794275735 801652183
143736 125721 536375521 497451149
4070 82461 612985394 185791331
187444 177732 203761783 978534058
64389 115859 767852404 159121136
62787 153732 112099169 754249162
9791 45944 722996059 45421943
86166 76684 734259220 976172654
144257 171894 593459611 866106682...

output:

0

result:

ok single line: '0'

Test #24:

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

input:

200000
91072 122945 396 396
108944 92874 371 371
102962 134537 999957708 999957708
76444 112175 999974422 999974422
92013 18283 224 224
47655 149920 674 674
199293 47834 240 240
143059 145065 306 306
135615 109141 702 702
1701 49881 38 38
73750 69655 585 585
44570 126598 823 823
154521 29581 601 601...

output:

81260440461409

result:

ok single line: '81260440461409'

Test #25:

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

input:

200000
67335 151665 90056816 679694202
146132 193464 78979944 31693610
12681 195973 465813284 579615164
121902 196667 589074557 966872296
161123 6959 801681236 38291288
183137 2828 885145066 943464735
120574 8814 71857893 233909004
125797 191097 749557098 250997809
169492 36886 49204718 996198360
12...

output:

99809636135608

result:

ok single line: '99809636135608'

Test #26:

score: 0
Accepted
time: 104ms
memory: 20324kb

input:

200000
93451 53831 682115484 829322216
86322 162604 254622021 431488750
147239 61110 113915150 613534953
82511 156348 664035377 946257404
88519 17517 226289497 122021251
112417 43731 544607243 486486588
35770 121679 465952267 546169853
90586 30876 245521241 309759680
113666 65754 237364361 270831775...

output:

84393916618910

result:

ok single line: '84393916618910'

Test #27:

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

input:

200000
56712 10679 477548548 250987465
48768 10679 648414920 382252569
10679 138629 849839069 418932116
10679 196853 372927887 111589355
66660 10679 746411098 882637935
186062 10679 311457882 818901438
10679 60211 350285495 867834084
143533 10679 509730429 587741385
10679 87624 514054621 907539858
1...

output:

99896973077522

result:

ok single line: '99896973077522'

Test #28:

score: 0
Accepted
time: 122ms
memory: 28464kb

input:

200000
137614 48684 905625272 307783875
31464 61159 171680699 710988975
53283 142419 838631110 435432764
123798 38255 535935021 734147826
29584 149426 371764453 875958871
175282 48325 804482249 620893459
55526 102124 797947818 494644787
62800 128616 320838726 279002065
33102 171918 195788467 4014179...

output:

38157344174731

result:

ok single line: '38157344174731'

Test #29:

score: 0
Accepted
time: 100ms
memory: 17236kb

input:

200000
199712 1338 415002784 805964493
102372 1338 193298420 76290567
28728 1338 804225462 746940935
1338 98005 301699377 822393419
1338 162021 577703287 907659652
1338 57339 183927508 654074158
1338 168042 859700698 427766288
1338 87100 984454975 400556960
193867 1338 787582553 819174352
1338 18369...

output:

99976824303453

result:

ok single line: '99976824303453'

Subtask #4:

score: 17
Accepted

Dependency #1:

100%
Accepted

Test #30:

score: 17
Accepted
time: 3ms
memory: 9832kb

input:

2
1 2 781089648 283888890
2
1
2

output:

283888890
0

result:

ok 2 lines

Test #31:

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

input:

2000
668 1839 972599655 457068476
133 11 666838083 851019038
1194 1287 133765716 574032589
107 441 176385032 470971775
131 1040 243142030 758968684
377 1963 707275419 115749455
1599 1801 764665175 425876028
169 656 229430355 330349441
128 1885 47324906 989597389
1366 419 253887722 295321149
1520 605...

output:

1007815336129
968471364756
948794710183
931465538135
919379309781
908949503371
898863017460
889541245976
880407673956
871485748529
862948404232
854564677534
846315324929
838321505364
830946890393
824397294302
818173445062
811962023909
805811586483
799889608613
794074981118
788469743669
783290399664
...

result:

ok 2000 lines

Test #32:

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

input:

2000
1507 1054 442165448 671661615
1248 179 87718372 57803246
177 1811 573774719 208696657
1774 45 808902498 987598144
100 667 997239116 107950700
1114 1047 90988914 625746213
818 116 312860776 925130030
1986 811 196318668 361242571
1124 1820 798979369 753656023
435 638 63026816 169722034
496 1349 9...

output:

979634806036
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
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 2000 lines

Test #33:

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

input:

2000
1525 429 147 147
1216 1496 340 340
717 1473 999975270 999975270
1114 862 697 697
1723 216 974 974
1059 865 495 495
182 210 766 766
1745 1959 999981504 999981504
1052 1914 638 638
318 1144 288 288
1401 927 176 176
1555 496 318 318
565 304 116 116
1439 265 90 90
952 790 402 402
1795 677 127 127
1...

output:

816987603536
814987603536
813987604014
812987604504
811987605268
810987606227
809987607186
808987608484
807987609782
806987611080
805987612378
804987613751
803987615124
802987616617
801987618383
800987620192
799987622058
798987623924
797987625794
796987627815
795987630118
794987632435
793987634752
7...

result:

ok 2000 lines

Test #34:

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

input:

2000
373 1642 63657133 850914336
103 774 827627582 753286797
1704 813 857134718 516101827
886 354 134978226 145183107
132 1239 17657223 582173637
1806 1813 549768976 884335257
993 1205 145864886 175216094
110 1804 554037719 889640060
1240 760 622694407 818131870
335 1049 176463161 321592201
1985 982...

output:

993439578644
956445814624
939840118265
927190958260
916391337740
906274516515
897352078924
888518216208
879966749793
871626842858
863454140478
855567065753
847681257509
840122943214
832807138112
825772780035
818957114766
812382909807
805850688392
799689205484
793683039565
788190914731
782921891017
7...

result:

ok 2000 lines

Test #35:

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

input:

2000
838 616 964972 727856
767 1966 297293 961917
1528 1174 350309 809912
94 145 528172 786328
1519 25 474782 330748
150 84 987021 119895
792 1577 188984 806709
76 1836 801862 360250
9 148 577892 890736
991 955 613442 930810
135 1623 71117 754738
1618 61 754384 824814
1921 1150 9872 832902
1416 16 3...

output:

3151729932
1490745586
970501973
936634296
916387727
896432666
882364904
871595506
861275935
852160225
843667677
835335533
827285136
819530016
812028588
804721144
798490006
792337990
786258606
780232964
774529076
768857427
763423701
758219379
753037762
747913173
742881442
737906445
732937194
72800087...

result:

ok 2000 lines

Test #36:

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

input:

2000
267 1012 29026841 359918212
1553 1061 435867283 33144312
1670 1109 988917740 68160339
948 496 231906652 737226954
610 1641 972617450 818164551
1030 931 630927532 461579893
1209 970 625011983 682844528
63 1856 458314131 670604776
1746 1008 696454538 404229917
917 813 392046602 435463075
1468 102...

output:

998853819359
967120682374
953269672580
941849331387
931241683825
921276677110
911337819540
901986725243
893200309022
884558703799
875976456800
867522290743
859558632337
851608471803
843762237099
836142232132
828919740309
821971874595
815367534376
809019317904
802895133103
796998597941
791322345111
7...

result:

ok 2000 lines

Test #37:

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

input:

2000
278 314 642322 260619
1354 1355 778536 561972
1107 765 653443 859029
810 1596 342249 271261
17 188 909841 624772
784 1153 387898 928863
230 566 503491 92369
1902 17 333718 17338
974 1777 696073 718026
358 758 956259 611920
1996 211 73914 992273
851 376 143429 561006
476 1156 762866 927086
177 7...

output:

14886853906
13166663751
12197152661
11244345647
10325387509
9436897021
8629006527
7850290167
7147075931
6474998375
5890753359
5309769240
4735542024
4172519089
3616514278
3067013296
2536143195
2014862258
1494918615
993605672
969765636
953350461
940694413
928618413
917888172
908243771
899808403
891555...

result:

ok 2000 lines

Test #38:

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

input:

2000
374 138 224422639 38871324
274 25 614140855 294378456
960 482 771284019 389463551
673 1495 327509275 759582532
1670 425 494511063 516818198
1512 234 758587972 294061250
125 416 760945280 345853400
1003 405 84717299 354546151
1935 927 394014334 986087601
1945 286 237720954 958374134
1212 502 139...

output:

1020766846606
1007002784804
999346872165
992274505754
985589793611
979434926460
973485015062
967649305774
961825435056
956057364162
950459867350
944914649107
939463540924
934278992727
929115619904
924079006080
919101029671
914194699920
909382255333
904589503356
899958668369
895331464064
890705684752...

result:

ok 2000 lines

Test #39:

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

input:

2000
1143 1229 81340832 203783547
797 1383 973573951 938965060
688 802 32619795 803180557
1430 1438 330664534 241372464
643 706 61158209 115993048
1648 106 327252353 597706939
1779 1415 293303361 360351419
692 1828 915132451 368048738
16 1709 95899611 285365876
1351 458 166747820 509256128
1727 793 ...

output:

998301212759
880537928692
870457219325
861252294892
852396337323
843981634800
835667290515
828477413156
821655401311
814870686928
808222533521
802024821337
796150817317
790387213402
784736669906
779359674398
774039179523
768840175047
763750052574
758953098983
754172321967
749445382638
744756930608
7...

result:

ok 2000 lines

Test #40:

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

input:

2000
287 975 25233696 534621398
1113 396 104395603 704259239
944 968 167901712 996060127
1820 1963 59027230 940778339
517 421 142414910 668774876
1194 987 697044445 916940725
758 1996 840435736 296316325
859 1228 942003242 410430124
267 1863 69640147 572953353
1531 664 675846017 437317470
1896 1937 ...

output:

979865969015
938524253268
919252073876
908446325642
898652991327
889092497390
880176982256
871653554541
863190891606
854923191298
846796123803
838968661922
831239262473
823590794453
815982441829
808439653715
800918039984
793492711274
786193390091
779078065331
771979068036
765125487688
758277507704
7...

result:

ok 2000 lines

Test #41:

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

input:

2000
151 987 401112 51743
1571 1615 48174 742492
1382 1435 702779 104242
4 1937 536648583 582006045
407 1292 690047 209913
18 74 609460 921874
1713 615 837107 163945
595 1110 736540 874700
104 296 336025 925055
436 1478 268683 619735
1303 213 353888 717230
238 1973 859805 102668
379 1922 238240 8461...

output:

253674247639
252146222576
251150950748
250159056506
249169328747
248179917829
247192247572
246207031683
245222508185
244239965485
243258799509
242277744406
241297414827
240317798683
239339147347
238360849518
237384439214
236408299310
235432280907
234457447152
233485340091
232513737287
231545110505
2...

result:

ok 2000 lines

Test #42:

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

input:

2000
1182 1921 605080443 886655033
1708 1921 595798016 843919086
1680 1921 860566020 131317035
975 1921 418114074 512317024
226 587 473765902 67634029
776 1921 433855395 216901660
495 1921 409271624 79315361
1921 149 936810062 509308613
132 1921 150894436 98571823
1529 1921 430693927 259969407
764 1...

output:

1009089197282
1006610361108
1004752344991
1002897699917
1001044344246
999213639830
997395170490
995584737424
993790322164
991996888755
990214477773
988434882351
986697111591
984984989073
983283340517
981585399308
979893311639
978212055868
976564068551
974938526236
973323760294
971712816971
970105147...

result:

ok 2000 lines

Test #43:

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

input:

2000
1464 1864 547333628 669063562
1110 745 632608125 908067725
1684 428 8923157 938458876
1765 1430 986598839 576426299
1927 1280 377814925 800077297
1161 731 430521772 265852180
1638 1725 909244690 745425182
111 1733 251904285 714544194
743 1824 285789564 35311843
1856 1602 316442646 397926101
214...

output:

985726096226
120339232724
118500847924
116729781772
115033477360
113477145230
112001745571
110529934958
109314993504
108147080886
106995756702
105956093186
104937429871
103931619182
102932846661
101934984607
100952729677
99971614132
98995604204
98028346026
97077956501
96128655790
95190898491
9425401...

result:

ok 2000 lines

Test #44:

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

input:

2000
1594 99 114938634 955551953
1594 535 724720583 787940175
941 1594 632758297 743357149
1594 360 540763785 555917064
1594 304 748278274 799266695
1594 352 264038818 900446954
1594 1913 669527592 537488989
1657 1594 183798298 397102870
1594 1275 186397916 822447484
1594 1982 333936723 32520282
333...

output:

985192149621
984143039445
983144785233
982146796921
981149821551
980152942601
979156406727
978161102895
977166217002
976171652235
975177196106
974184023009
973191204385
972198955355
971206748663
970214979896
969223519746
968232067678
967241269126
966250730842
965261103232
964271731653
963282385779
9...

result:

ok 2000 lines

Subtask #5:

score: 17
Accepted

Test #45:

score: 17
Accepted
time: 4ms
memory: 11876kb

input:

2
1 2 543195986 144983073
1
1

output:

144983073

result:

ok single line: '144983073'

Test #46:

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

input:

200000
73974 46059 151001152 42729969
112523 175399 580450366 914798605
65645 46109 848220487 698683602
63048 106502 596698349 144038980
98888 11174 948423025 972032422
115490 95315 788936645 231068151
5185 187319 690370465 616111588
10331 161483 606127487 195799307
133831 170948 694137989 490575964...

output:

5449143475272

result:

ok single line: '5449143475272'

Test #47:

score: 0
Accepted
time: 134ms
memory: 38164kb

input:

200000
55956 185434 219535533 77244021
65295 10318 437281446 132103674
53900 4204 965744871 874409893
67035 24879 596850278 341918390
70240 26074 837750040 304745373
116294 182996 806065306 688634320
21494 104498 465710706 695396976
71934 165575 761917591 524436924
95534 186806 199405432 534812435
1...

output:

99875550841137

result:

ok single line: '99875550841137'

Test #48:

score: 0
Accepted
time: 95ms
memory: 17640kb

input:

200000
7483 177514 697 697
3231 129745 999845999 999845999
109949 87100 999891988 999891988
29413 172327 299 299
170523 87926 999952504 999952504
124853 61455 999934698 999934698
42350 132622 91 91
69970 50413 815 815
55204 183824 999939325 999939325
59484 71281 206 206
37791 170069 451 451
50058 17...

output:

1780721830674

result:

ok single line: '1780721830674'

Test #49:

score: 0
Accepted
time: 110ms
memory: 17524kb

input:

200000
105838 73186 128349778 353598318
63031 136227 114628484 285882597
191398 198457 37866162 634787861
171869 171043 573009985 810912546
37331 137239 646433925 996743109
49856 185509 134224603 278011602
160259 37541 150993603 746491914
59331 161858 652495320 165803995
117507 178303 933794623 4222...

output:

98851135600011

result:

ok single line: '98851135600011'

Test #50:

score: 0
Accepted
time: 110ms
memory: 17564kb

input:

200000
140663 129611 636279 260017
196385 122941 547533 592198
114132 160778 43364 613890
88859 39847 443789 512911
114404 161183 856155 49796
67299 83775 31748 559092
72303 74977 250332 609125
68306 161828 565819 826801
65357 98383 789137 755350
108533 38461 214064 982695
137910 8024 674613 855905
...

output:

121701643090

result:

ok single line: '121701643090'

Test #51:

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

input:

200000
194805 91167 96006427 746087633
19172 51672 703076613 703507534
129776 6959 147190461 210591357
107179 63438 934326702 717246383
80551 7862 340033856 42790691
174094 147100 93534123 588911952
16841 106289 330166235 144103001
127608 89570 526650289 259902042
83162 168481 830039469 619808700
97...

output:

98850979599881

result:

ok single line: '98850979599881'

Test #52:

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

input:

200000
104188 40173 518798 400873
74450 186185 454835 624317
34752 157183 496291 489884
53876 145380 544680 183688
8015 65233 387174 69062
34450 54750 507740 406375
131441 167028 859185 425529
160168 160307 565172 163779
51621 92179 414635 854124
192560 59890 67817 557177
20346 38814 909372 207112
1...

output:

2073045420823

result:

ok single line: '2073045420823'

Test #53:

score: 0
Accepted
time: 140ms
memory: 17612kb

input:

200000
36234 48499 497762619 268240611
61631 22160 249970846 76734461
96939 174559 273525596 277814042
33667 191684 350573347 320714717
66892 81318 492270419 242486005
9223 51478 302202500 1452383
110040 35016 129099352 359187439
17314 132066 183661699 778288251
110040 70931 750625996 484714051
4396...

output:

51135293866439

result:

ok single line: '51135293866439'

Test #54:

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

input:

200000
183062 61942 195495034 670262692
160284 94545 558986737 74870683
162714 101868 929690547 336544868
189299 19925 853155959 659182060
121123 106943 326206617 124808162
26384 54945 996860044 871381136
28523 100744 300454000 658917117
143026 153583 958105033 893037327
157880 138484 444666156 3319...

output:

3299654185147

result:

ok single line: '3299654185147'

Test #55:

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

input:

200000
159287 10497 134128546 375519540
54050 6880 652209391 685600434
64819 100589 468264811 669713633
21538 42057 208086343 266212316
144623 154696 891658106 589370999
187481 49088 462695361 664697185
172258 8653 138424940 735985051
42828 173282 910919433 804041217
187820 48021 69765115 86631456
1...

output:

90571973135125

result:

ok single line: '90571973135125'

Test #56:

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

input:

200000
1668 46162 335237 921785
113769 127901 853451705 934150953
1626 35497 533058 791354
111597 54552 186865 35999
126603 83723 570650 215845
130809 113769 533240830 792980919
109646 143446 640055 759014
81148 77400 102642 184563
170617 167437 530479 964975
13500 177003 968531 702011
116634 165372...

output:

11052402240814

result:

ok single line: '11052402240814'

Test #57:

score: 0
Accepted
time: 109ms
memory: 18012kb

input:

200000
169530 195889 230163362 439799818
119233 134720 559035500 953508831
8940 134720 884441063 243088533
134720 69148 680467824 593559555
134720 29050 577681718 589369589
35824 166656 841766082 244727568
134720 198916 67469622 39769615
193336 149614 866808245 894158218
192941 134720 258122702 9382...

output:

40626528262020

result:

ok single line: '40626528262020'

Test #58:

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

input:

200000
110455 115168 942917483 944057356
24250 174224 120443609 532352510
11171 74665 190086664 829576737
159411 147194 706659415 940447640
21273 60049 121436594 924345007
199052 198780 576499335 914436406
80048 25499 994151154 181108553
21097 69194 919349404 246872582
69845 47327 610809487 71576289...

output:

29337562026797

result:

ok single line: '29337562026797'

Test #59:

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

input:

200000
103057 108208 924190969 473823292
103057 183266 908503598 913830751
160109 103057 152232631 446122875
150542 103057 645333429 20388717
9111 103057 958697887 339808805
186911 103057 832784802 864166960
103057 107162 110079035 799843025
103057 41684 472282933 46971465
120852 103057 515888934 87...

output:

68177387813969

result:

ok single line: '68177387813969'

Subtask #6:

score: 44
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Test #60:

score: 44
Accepted
time: 3ms
memory: 7800kb

input:

2
1 2 781089648 283888890
2
1
2

output:

283888890
0

result:

ok 2 lines

Test #61:

score: 0
Accepted
time: 139ms
memory: 17520kb

input:

200000
44159 197131 891233343 986928673
108175 35372 198085304 271789370
53683 24668 495215545 450974548
89492 22897 81376180 225566918
179614 50294 694042950 467925728
138499 55918 279410537 411284019
73038 185532 724888513 746414782
55794 68935 669013578 866137236
24781 190216 824031578 574380614
...

output:

100115113662611
99900558725947
99800093356460
99721352294060
99650961400968
99581104259681
99516838769298
99457230356039
99398333443683
99340651810941
99285949441869
99233677205373
99185132050182
99136756554355
99090108811271
99044150304377
98999685202852
98958863736021
98919786702266
98881179267175...

result:

ok 200000 lines

Test #62:

score: 0
Accepted
time: 171ms
memory: 35060kb

input:

200000
175359 168254 5931790 258081728
37021 111569 954582420 389161703
329 5513 169962574 630413033
84610 162995 919900065 471408027
130766 117286 197051215 315737739
25220 196912 588903843 373994012
178755 136124 839873329 292286218
154141 156034 311661610 996614389
96783 41805 47053107 960108409
...

output:

99689152074699
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
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 200000 lines

Test #63:

score: 0
Accepted
time: 143ms
memory: 17632kb

input:

200000
6275 84873 459 459
84419 114902 999909322 999909322
162203 5885 510 510
14970 26320 526 526
91557 151031 614 614
11931 114770 999939970 999939970
67496 92287 999953031 999953031
162252 81104 999898937 999898937
59589 116312 999930064 999930064
74572 58923 924 924
59615 143971 314 314
92780 72...

output:

81098614130755
81096614130755
81095614130755
81094614130863
81093614131888
81092614133803
81091614135718
81090614137896
81089614140336
81088614142976
81087614145616
81086614148256
81085614151592
81084614154928
81083614158530
81082614162351
81081614166421
81080614170520
81079614174619
81078614178932
...

result:

ok 200000 lines

Test #64:

score: 0
Accepted
time: 153ms
memory: 17648kb

input:

200000
160977 17462 678276164 881765461
11805 157245 686233376 670626811
176887 175697 650067753 751938146
119454 68583 225034481 293453725
125377 18938 5975211 852081006
60833 78935 408152568 108532377
42822 56928 439404520 765987681
187121 6426 663723325 651618633
141165 86029 635208307 955777644
...

output:

99994866396556
99787311149239
99699510785397
99634275304509
99571493788746
99511257023245
99453038705758
99396236791850
99344957967465
99296492449687
99248153461804
99200432399944
99153351951549
99108556670752
99064044438973
99021576013095
98979290729931
98937277668964
98897952033484
98858767272483
...

result:

ok 200000 lines

Test #65:

score: 0
Accepted
time: 140ms
memory: 17572kb

input:

200000
88924 86654 733531 771673
141960 160100 802037 579654
71983 79080 543638 631282
45923 24562 934484 895784
144862 123024 651297 361225
110714 185138 284486 109722
86175 190161 743852 103208
155099 94388 300252 22586
55327 186560 216038 593098
155886 67271 266812 987528
86819 181093 419816 3507...

output:

313374674046
311865946570
310867992772
309872953464
308882045636
307898324388
306916635955
305935287635
304954194862
303978434921
303002728876
302030065715
301057726687
300088982311
299122619149
298156853793
297196301958
296237491214
295282976419
294332110721
293382901383
292434907544
291489611566
2...

result:

ok 200000 lines

Test #66:

score: 0
Accepted
time: 126ms
memory: 17576kb

input:

200000
196350 54507 77738573 962067321
34474 44767 855892331 555193005
32985 75231 231516004 405549503
91251 134218 160305236 912262892
39911 173155 888442455 86557534
192457 143178 630855651 182512591
46813 171897 200878617 307002757
65865 72486 702445421 136847970
133759 75057 835925723 853539417
...

output:

100015606995577
99673614491424
99572965538611
99473273254295
99377225608182
99281720114997
99186416021044
99091829318505
98997964511007
98905124043727
98812581243391
98720376428788
98628353081440
98536484273580
98445295645747
98355551099019
98265839391368
98176515337358
98089253625948
98003554855586...

result:

ok 200000 lines

Test #67:

score: 0
Accepted
time: 133ms
memory: 17632kb

input:

200000
33746 108534 972168 748690
81066 144204 515329 439784
168792 176925 569638 866120
169466 82636 408680 964236
23559 164839 3911 637859
3510 139199 142460 995179
179990 182846 183642 455753
23788 86291 504006 346529
75279 169660 309512 999230
127656 14719 393161 987180
87643 77178 976421 228652...

output:

1977997787540
1976478983619
1975479426330
1974480010545
1973480596399
1972481422387
1971482250926
1970483121254
1969484185725
1968485271867
1967486819127
1966488830936
1965490980498
1964493721308
1963496670580
1962499713632
1961503277769
1960507015573
1959511012922
1958515148392
1957519633179
195652...

result:

ok 200000 lines

Test #68:

score: 0
Accepted
time: 152ms
memory: 17680kb

input:

200000
16988 166144 110123679 170167529
113059 188862 494518328 262159447
6964 193846 821331019 825834910
77262 39605 637348267 335601010
158351 63078 147419087 463748048
42321 7360 834913593 220953771
71374 16019 261983461 160746812
95299 26299 385262538 373380596
74548 80753 890852973 277948162
19...

output:

100052435363023
100023999451422
100009195309040
99995254712109
99982248438388
99969527068423
99956911009197
99944501769306
99932129947446
99920026642913
99907947872890
99896129912455
99884525154306
99872926517424
99861436909700
99850100176480
99838768549407
99827622464782
99816531826667
998054432636...

result:

ok 200000 lines

Test #69:

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

input:

200000
149671 171876 306741618 782758924
52048 25726 72871358 318729100
111747 147371 804989847 905333520
168174 75321 229393389 752385337
76047 6475 302710715 224462330
7132 141833 137317548 77963635
57722 34042 784515193 168421253
66062 150118 670329059 398166149
181286 52819 995053932 509460416
1...

output:

99962954222748
87100127164041
87082131945093
87067612994623
87053616599472
87040256066278
87027548737868
87014974207965
87002705538513
86990881438971
86979167384193
86967649720568
86956404037901
86945165215309
86934022815003
86922886698426
86911801500106
86900747371152
86889713795123
86878750478396
...

result:

ok 200000 lines

Test #70:

score: 0
Accepted
time: 147ms
memory: 17756kb

input:

200000
173456 156538 707322519 492268960
169758 37680 498867479 683085761
170712 90356 49286607 149373376
66956 195913 766271491 757986438
122803 113106 82162901 412469981
184142 90707 871759517 19750224
114684 25723 790593883 313027752
36644 12701 786966850 896853325
105036 135832 559064106 3531277...

output:

99687115918801
97750442670126
96778206151060
95806120392048
94835619789797
93865271232403
92895172866358
91925092641872
90955209899417
89985881931641
89021633920665
88060048459425
87102725693688
86145503795291
85189728173393
84244276699307
83301667616689
82364402937083
81433282510910
80809273410680
...

result:

ok 200000 lines

Test #71:

score: 0
Accepted
time: 134ms
memory: 17740kb

input:

200000
122616 188874 224405 471310
27125 131453 138691 812503
107916 20134 253092 948098
53554 154062 889692 975216
6403 134365 718751 643805
186371 37794 387709 602032
553 27519 535334 98887
106465 29846 964848943 571004226
181314 142204 407162 229940
15623 173197 228878 272496
188165 184188 113218...

output:

28723918650729
28722417584475
28721417623279
28720417687972
28719417777877
28718417869160
28717417969127
28716418071793
28715418181377
28714418293691
28713418413364
28712418551057
28711418691379
28710418833346
28709418977613
28708419123626
28707419284245
28706419471842
28705419673947
28704419880260
...

result:

ok 200000 lines

Test #72:

score: 0
Accepted
time: 130ms
memory: 18424kb

input:

200000
48461 123277 241239443 106519096
83596 43577 225945948 884545412
123277 142081 613057371 239000469
55807 123277 381705386 46477131
7533 123277 208572829 17441867
189624 54347 487099620 165831821
123277 103545 662222288 700987676
174790 123277 548605503 583110325
93602 110191 343063581 1413752...

output:

99891046616041
99882517879767
99876988077292
99871663349834
99866554601708
99861520013079
99856491099153
99851470575939
99846484840016
99841525961652
99836591312780
99831710932251
99826832634218
99821956901059
99817158925892
99812361348698
99807604707769
99802879196446
99798185823760
99793540465857
...

result:

ok 200000 lines

Test #73:

score: 0
Accepted
time: 161ms
memory: 27748kb

input:

200000
119609 67416 691497916 297831253
80134 127685 41560838 118476118
164616 35512 982912619 931886609
30685 35847 544949786 355506043
15057 69768 392148856 169997817
22344 104975 703524354 647092332
169275 124154 649279330 133075386
99770 91069 380501252 281558941
72440 179967 883357594 361144072...

output:

99806755209267
35984759474900
35980359623204
35975997266680
35971876075059
35967768730750
35963673714372
35959618732688
35955609028773
35951599694612
35947613761661
35943671037739
35939806500561
35935991600885
35932186408974
35928389618856
35924625584792
35920908344490
35917242645953
35913598858305
...

result:

ok 200000 lines

Test #74:

score: 0
Accepted
time: 121ms
memory: 17496kb

input:

200000
194683 176210 368911574 689024599
128374 194683 919585303 9895564
126259 194683 444046314 191665947
194683 35789 80923156 731837905
194683 76498 436333118 314499714
194683 136355 896178730 958549098
155743 194683 431886734 25863316
165622 194683 749864622 618223134
194683 77129 921121196 3056...

output:

99844912648715
99843910194425
99842910200060
99841910216675
99840910237736
99839910263691
99838910294398
99837910328670
99836910364929
99835910405431
99834910447231
99833910494926
99832910545314
99831910598200
99830910668568
99829910740824
99828910830654
99827910922645
99826911017663
99825911119470
...

result:

ok 200000 lines

Extra Test:

score: 0
Extra Test Passed