QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#302115#4272. Phone PlansOccDreamer5 224ms93864kbC++143.3kb2024-01-10 16:34:592024-01-10 16:35:00

Judging History

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

  • [2024-01-10 16:35:00]
  • 评测
  • 测评结果:5
  • 用时:224ms
  • 内存:93864kb
  • [2024-01-10 16:34:59]
  • 提交

answer

//code by Emissary
#include<bits/stdc++.h>

#define fi first
#define se second
#define vc vector
#define db double
#define ll long long
#define mk make_pair
#define pb push_back
#define PI pair<int,int>
#define ull unsigned long long
#define err cerr << "   -_-   " << endl
#define debug cerr << " ------------------- " << endl

#define input(x) freopen(#x".in","r",stdin)
#define output(x) freopen(#x".out","w",stdout)

#define NO puts("No")
#define YES puts("Yes")

//#define int long long

using namespace std;

namespace IO{
	inline ll read(){
		ll X=0, W=0; char ch=getchar();
		while(!isdigit(ch)) W|=ch=='-', ch=getchar();
		while(isdigit(ch)) X=(X<<1)+(X<<3)+(ch^48), ch=getchar();
		return W?-X:X;
	}
	inline void write(int x){
		if(x<0) x=-x, putchar('-');
		if(x>9) write(x/10);
		putchar(x%10+'0');
	}
	inline void sprint(int x){write(x), putchar(32);}
	inline void eprint(int x){write(x), putchar(10);}
}using namespace IO;

const int inf = 2e9;
const int MAXN = 4e5+5;
const int mod = 998244353;
//const int mod = 1e9+7;

int tot, ans=2e9+2;
int n, A, B, lc[MAXN], rc[MAXN], id[MAXN];
int fa[MAXN], siz[MAXN], val[MAXN], bel[MAXN], minid[MAXN];

ll now, K;

unordered_map<int,int> s[MAXN];

vc<int> node[MAXN];

struct edge{
	int u, v, w;
	inline bool friend operator < (const edge &x, const edge &y){return x.w<y.w;}
}p[MAXN], q[MAXN];

inline ll C(int x){return 1ll*x*(x-1)/2;}

inline int find(int x){return x==fa[x]?x:fa[x]=find(fa[x]);}

inline void add(int i){
	int x=q[i].u, y=q[i].v;
	x=find(x), y=find(y);
	if(x==y) return ;
	now-=C(node[x].size()); now-=C(node[y].size());
	if(node[x].size()>node[y].size()) swap(x,y);
	for(auto i:node[x]) node[y].pb(i), bel[i]=y; now+=C(node[y].size());
	for(auto i:s[x]) if(i.se) now+=C(i.se), now+=C(s[y][i.fi]), s[y][i.fi]+=i.se, now-=C(s[y][i.fi]); fa[x]=y;
	s[x].clear(); node[x].clear(); node[x].shrink_to_fit();
	return ;
}

inline void dfs(int x, int v, int k){
	if(x<=n){
		int t=bel[x];
		now+=C(s[t][k]);
		s[t][k]--; now-=C(s[t][k]);
		now+=C(s[t][v]);
		s[t][v]++; now-=C(s[t][v]);
		return ;
	}
	else dfs(lc[x],v,k), dfs(rc[x],v,k);
}

signed main(){
	n=read(), A=read(), B=read(), K=read(); tot=n;
	for(int i=1;i<=n;++i) fa[i]=i, siz[i]=1, node[i].pb(i), bel[i]=i;
	for(int i=1;i<=A;++i) p[i].u=read(), p[i].v=read(), p[i].w=read();
	for(int i=1;i<=B;++i) q[i].u=read(), q[i].v=read(), q[i].w=read();
	sort(p+1,p+1+A); sort(q+1,q+1+B);
	for(int i=1;i<=A;++i){
		int x=p[i].u, y=p[i].v;
		x=find(x), y=find(y);
		if(x==y) continue;
		++tot; val[tot]=p[i].w;
		if(siz[x]<siz[y]) swap(x,y);
		lc[tot]=x, rc[tot]=y, minid[tot]=id[y]; 
		id[tot]=id[x], siz[tot]=siz[x]+siz[y], fa[x]=fa[y]=fa[tot]=tot;
		now-=C(siz[x]); now-=C(siz[y]); now+=C(siz[tot]);
	}
	int r=1;
	for(int i=1;i<=n;++i) s[i][find(i)]=1;
	for(int i=1;i<=n;++i) fa[i]=i;
	for(int i=tot;i>=n;--i){
		while(r<=B && now<K) add(r), r++;
		if(now<K) break; ans=min(ans,val[i]+q[r-1].w);
		//cout << i << ' ' << q[r-1].w << ' ' << now << endl;
		if(i==n) break; 
		now-=C(siz[i]); 
		now+=C(siz[lc[i]]); now+=C(siz[rc[i]]);
		//cerr << "now=" << now << endl;
		dfs(rc[i],minid[i],id[i]);
	}
	eprint(ans>inf?-1:ans);
	return 0;
}





































































详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

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

output:

33

result:

ok single line: '33'

Test #2:

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

input:

1 0 0 0

output:

0

result:

ok single line: '0'

Test #3:

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

input:

2 0 0 1

output:

-1

result:

ok single line: '-1'

Test #4:

score: 0
Accepted
time: 8ms
memory: 44528kb

input:

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

output:

51122687

result:

ok single line: '51122687'

Test #5:

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

input:

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

output:

1000000000

result:

ok single line: '1000000000'

Test #6:

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

input:

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

output:

9768257

result:

ok single line: '9768257'

Test #7:

score: 0
Accepted
time: 28ms
memory: 41028kb

input:

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

output:

20263921

result:

ok single line: '20263921'

Test #8:

score: 0
Accepted
time: 47ms
memory: 45464kb

input:

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

output:

1999

result:

ok single line: '1999'

Test #9:

score: 0
Accepted
time: 56ms
memory: 52312kb

input:

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

output:

1999

result:

ok single line: '1999'

Test #10:

score: -6
Wrong Answer
time: 45ms
memory: 51416kb

input:

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

output:

2000

result:

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

Subtask #2:

score: 5
Accepted

Test #53:

score: 5
Accepted
time: 158ms
memory: 87572kb

input:

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

output:

502149991

result:

ok single line: '502149991'

Test #54:

score: 0
Accepted
time: 116ms
memory: 87088kb

input:

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

output:

11965880

result:

ok single line: '11965880'

Test #55:

score: 0
Accepted
time: 51ms
memory: 86908kb

input:

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

output:

7037526

result:

ok single line: '7037526'

Test #56:

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

input:

1 0 0 0

output:

0

result:

ok single line: '0'

Test #57:

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

input:

1 1 0 0
1 1 1

output:

0

result:

ok single line: '0'

Test #58:

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

input:

2 0 0 1

output:

-1

result:

ok single line: '-1'

Test #59:

score: 0
Accepted
time: 48ms
memory: 45056kb

input:

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

output:

-1

result:

ok single line: '-1'

Test #60:

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

input:

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

output:

-1

result:

ok single line: '-1'

Test #61:

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

input:

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

output:

216679869

result:

ok single line: '216679869'

Test #62:

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

input:

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

output:

245598855

result:

ok single line: '245598855'

Test #63:

score: 0
Accepted
time: 172ms
memory: 86004kb

input:

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

output:

-1

result:

ok single line: '-1'

Test #64:

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

input:

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

output:

-1

result:

ok single line: '-1'

Test #65:

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

input:

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

output:

-1

result:

ok single line: '-1'

Test #66:

score: 0
Accepted
time: 168ms
memory: 86092kb

input:

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

output:

-1

result:

ok single line: '-1'

Test #67:

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

input:

200000 0 0 0

output:

0

result:

ok single line: '0'

Test #68:

score: 0
Accepted
time: 34ms
memory: 76724kb

input:

200000 0 0 1

output:

-1

result:

ok single line: '-1'

Test #69:

score: 0
Accepted
time: 28ms
memory: 76780kb

input:

200000 0 0 19999900000

output:

-1

result:

ok single line: '-1'

Test #70:

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

input:

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

output:

0

result:

ok single line: '0'

Test #71:

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

input:

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

output:

2038

result:

ok single line: '2038'

Test #72:

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

input:

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

output:

15612

result:

ok single line: '15612'

Test #73:

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

input:

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

output:

171465

result:

ok single line: '171465'

Test #74:

score: 0
Accepted
time: 136ms
memory: 89536kb

input:

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

output:

3160928

result:

ok single line: '3160928'

Test #75:

score: 0
Accepted
time: 169ms
memory: 91748kb

input:

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

output:

39338620

result:

ok single line: '39338620'

Test #76:

score: 0
Accepted
time: 178ms
memory: 92012kb

input:

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

output:

202638987

result:

ok single line: '202638987'

Test #77:

score: 0
Accepted
time: 224ms
memory: 92428kb

input:

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

output:

267941690

result:

ok single line: '267941690'

Test #78:

score: 0
Accepted
time: 194ms
memory: 90428kb

input:

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

output:

369129717

result:

ok single line: '369129717'

Test #79:

score: 0
Accepted
time: 182ms
memory: 90880kb

input:

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

output:

-1

result:

ok single line: '-1'

Test #80:

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

input:

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

output:

0

result:

ok single line: '0'

Test #81:

score: 0
Accepted
time: 149ms
memory: 92000kb

input:

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

output:

6

result:

ok single line: '6'

Test #82:

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

input:

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

output:

30

result:

ok single line: '30'

Test #83:

score: 0
Accepted
time: 141ms
memory: 93864kb

input:

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

output:

70

result:

ok single line: '70'

Test #84:

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

input:

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

output:

11

result:

ok single line: '11'

Test #85:

score: 0
Accepted
time: 141ms
memory: 92004kb

input:

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

output:

39

result:

ok single line: '39'

Test #86:

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

input:

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

output:

48

result:

ok single line: '48'

Test #87:

score: 0
Accepted
time: 200ms
memory: 92256kb

input:

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

output:

53

result:

ok single line: '53'

Test #88:

score: 0
Accepted
time: 218ms
memory: 92696kb

input:

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

output:

71

result:

ok single line: '71'

Test #89:

score: 0
Accepted
time: 184ms
memory: 90712kb

input:

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

output:

-1

result:

ok single line: '-1'

Test #90:

score: 0
Accepted
time: 91ms
memory: 72628kb

input:

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

output:

408744771

result:

ok single line: '408744771'

Test #91:

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

input:

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

output:

69748190

result:

ok single line: '69748190'

Test #92:

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

input:

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

output:

10055771

result:

ok single line: '10055771'

Test #93:

score: 0
Accepted
time: 107ms
memory: 74016kb

input:

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

output:

929135

result:

ok single line: '929135'

Test #94:

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

input:

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

output:

645

result:

ok single line: '645'

Test #95:

score: 0
Accepted
time: 40ms
memory: 52780kb

input:

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

output:

-1

result:

ok single line: '-1'

Test #96:

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

input:

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

output:

127339

result:

ok single line: '127339'

Test #97:

score: 0
Accepted
time: 55ms
memory: 47200kb

input:

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

output:

963592

result:

ok single line: '963592'

Test #98:

score: 0
Accepted
time: 145ms
memory: 87816kb

input:

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

output:

77980650

result:

ok single line: '77980650'

Test #99:

score: 0
Accepted
time: 198ms
memory: 88228kb

input:

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

output:

259424947

result:

ok single line: '259424947'

Test #100:

score: 0
Accepted
time: 203ms
memory: 87028kb

input:

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

output:

-1

result:

ok single line: '-1'

Test #101:

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

input:

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

output:

20

result:

ok single line: '20'

Test #102:

score: 0
Accepted
time: 197ms
memory: 87468kb

input:

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

output:

90

result:

ok single line: '90'

Subtask #3:

score: 0
Wrong Answer

Test #103:

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

input:

1 0 0 0

output:

0

result:

ok single line: '0'

Test #104:

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

input:

2 0 0 1

output:

-1

result:

ok single line: '-1'

Test #105:

score: -6
Wrong Answer
time: 26ms
memory: 38580kb

input:

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

output:

319832429

result:

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

Subtask #4:

score: 0
Skipped

Dependency #1:

0%