QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#865917#1454. Um nik's Algorithmtuxuanming2024TL 3631ms258068kbC++141.9kb2025-01-22 08:45:012025-01-22 08:45:03

Judging History

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

  • [2025-01-22 08:45:03]
  • 评测
  • 测评结果:TL
  • 用时:3631ms
  • 内存:258068kb
  • [2025-01-22 08:45:01]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=4e6+5,INF=0x3f3f3f3f;
int n1,n2,m,h[N],hh[N],cnt=1,S,T,dep[N];
struct edge {int to,nxt,f,id;}e[N*4];
char buf[1<<20],*p1,*p2;
#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
void Addedge(int x,int y,int f,int id=0)
{
	e[++cnt]=(edge){y,h[x],f,id},h[x]=cnt;
	e[++cnt]=(edge){x,h[y],0,id},h[y]=cnt;
}
bool bfs()
{
	memset(dep,0,sizeof(dep));
	queue<int>q; dep[S]=1,q.push(S);
	while(!q.empty())
	{
		int x=q.front(); q.pop();
		for(int i=h[x];i;i=e[i].nxt) if(e[i].f)
		{
			int y=e[i].to;
			if(!dep[y]) dep[y]=dep[x]+1,q.push(y);
		}
	}
	return dep[T];
}
int dfs(int x,int f)
{
	if(x==T||!f) return f;
	int res=0;
	for(int &i=hh[x];i;i=e[i].nxt)
	{
		int y=e[i].to;
		if(dep[x]+1==dep[y])
		{
			int d=dfs(y,min(e[i].f,f-res));
			if(d) e[i].f-=d,e[i^1].f+=d,res+=d;
			if(res==f) return res;
		}
	}
	return res;
}
inline int read()
{
	int s=0; char c=gc();
	while(c<'0'||c>'9') c=gc();
	while(c>='0'&&c<='9') s=s*10+(c^48),c=gc();
	return s;
}
inline void write(int x)
{
	if(!x) {putchar('0'); return;}
	static int s[11],t=0;
	while(x) s[++t]=x%10,x/=10;
	while(t) putchar(s[t--]+'0');
}
int main()
{
#ifdef LOCAL
	freopen("1.in","r",stdin);
	freopen("1.out","w",stdout);
	freopen("1.err","w",stderr);
#endif
	ios::sync_with_stdio(0),cin.tie(0);
	n1=read(),n2=read(),m=read(),S=n1+n2+1,T=S+1;
	for(int i=1,x,y;i<=m;i++) x=read(),y=read(),Addedge(x,y+n1,1,i);
	for(int i=1;i<=n1;i++) Addedge(S,i,1);
	for(int i=1;i<=n2;i++) Addedge(i+n1,T,1);
	int t=20,res=0;
	while(t--&&bfs()) memcpy(hh,h,sizeof(h)),res+=dfs(S,INF);
	write(res),puts("");
	vector<int>ans;
	for(int x=1;x<=n1;x++)
		for(int i=h[x];i;i=e[i].nxt) if(e[i].id&&!e[i].f) ans.emplace_back(e[i].id);
	for(auto x:ans) write(x),puts("");
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 36848kb

input:

3 2 4
1 1
2 1
3 1
3 2

output:

2
2
4

result:

ok answer: 2, maximum: 2

Test #2:

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

input:

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

output:

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

result:

ok answer: 20, maximum: 20

Test #3:

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

input:

1000 1000 10000
988 405
844 805
40 354
416 591
520 704
697 24
315 386
122 390
991 213
506 14
309 298
26 829
329 63
787 91
971 703
805 699
624 645
121 181
841 741
473 84
258 116
490 753
725 603
265 302
869 71
611 507
59 292
11 532
117 61
192 600
650 342
204 580
687 675
670 407
637 622
569 236
728 476...

output:

1000
7650
8240
3037
2330
9523
1971
4134
3228
4607
233
7021
5673
1590
5174
2099
2942
9530
5621
6246
8427
3728
9353
4094
9557
7483
7052
9871
972
8608
9227
5936
2718
5572
7128
697
7073
5993
8419
1703
3
3722
2137
993
4682
2727
7898
4164
297
5103
9193
6897
2398
1759
8374
401
603
9714
7175
8210
4466
234
1...

result:

ok answer: 1000, maximum: 1000

Test #4:

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

input:

100 2 200
40 1
22 2
75 2
79 1
27 2
11 1
7 1
64 1
21 1
57 2
47 1
4 2
61 2
37 1
8 2
32 2
84 1
63 1
67 1
86 2
88 2
73 1
17 1
94 2
44 2
19 2
16 1
33 2
92 1
24 2
100 2
18 2
85 1
7 2
43 1
82 2
15 2
88 1
91 1
65 1
69 1
36 1
6 2
23 2
58 1
59 1
64 2
38 1
72 1
99 1
76 1
11 2
2 2
98 1
66 2
77 1
47 2
98 2
52 2
...

output:

2
150
116

result:

ok answer: 2, maximum: 2

Test #5:

score: 0
Accepted
time: 11ms
memory: 37884kb

input:

1000 1000 1000
411 789
753 186
495 203
417 324
490 424
195 480
314 23
663 218
12 747
124 390
134 38
218 536
291 840
174 908
474 767
313 167
575 9
857 427
313 27
959 935
258 70
472 957
747 228
205 939
293 303
626 802
712 283
658 346
208 383
889 204
99 640
801 966
828 742
534 11
259 734
226 129
843 35...

output:

540
384
154
274
96
490
97
806
995
694
464
848
443
199
610
738
669
342
597
701
393
774
42
269
446
408
122
685
959
842
628
771
624
474
258
965
841
555
374
49
307
846
212
847
898
31
66
911
50
113
861
952
683
787
930
884
950
729
905
837
486
796
473
778
52
571
558
570
629
11
103
364
714
805
206
676
210
7...

result:

ok answer: 540, maximum: 540

Test #6:

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

input:

1000 2000 3000
143 619
571 526
215 1074
6 1714
370 937
120 784
134 1671
722 1528
397 345
464 401
198 589
283 564
212 232
527 286
237 1649
413 1570
964 1731
194 645
639 735
182 656
641 1143
535 98
113 596
787 972
306 818
657 1202
321 1327
753 1088
122 1823
471 611
516 811
380 1548
872 973
509 1841
70...

output:

944
2279
2715
2066
2529
2481
820
620
770
1743
2377
1541
2663
1639
1826
1804
2485
2461
2866
2567
2274
91
2886
2421
2561
2639
1595
2248
1883
1677
2761
2067
2954
773
2539
2458
2762
1614
2259
2368
2677
1322
1933
1147
1907
1836
2158
2724
2623
1345
2392
2114
2739
1898
2776
2829
490
2098
1395
187
638
1728
...

result:

ok answer: 944, maximum: 944

Test #7:

score: 0
Accepted
time: 3622ms
memory: 255376kb

input:

2000000 2000000 2000000
1203137 1030076
215220 238101
293102 491863
1260446 165178
1683989 1718181
1641329 1179380
708733 403707
1918936 574923
525651 11571
1169951 422281
1086376 303530
1286459 1692862
31854 394688
916288 273853
709758 1176923
1730408 1766172
1890708 588004
344339 283448
1676753 13...

output:

1088264
574238
1553819
390185
675162
385807
713135
1274732
1100762
1499360
1345142
352654
131076
1679462
786983
1086102
1452164
1117195
1024223
1689509
1801919
1520861
447735
1438488
16840
1909887
685509
1515120
69361
1311674
1801640
1349150
1855694
229841
1477983
1613413
984695
120443
1593046
23341...

result:

ok answer: 1088264, maximum: 1088264

Test #8:

score: 0
Accepted
time: 3625ms
memory: 253792kb

input:

2000000 2000000 2000000
1286561 1611624
1028477 1867578
1642356 1162128
1032429 316462
618144 22363
1644873 1514932
508824 1230141
1889259 22840
30270 259129
1567969 462330
150124 1227115
393968 534541
1378415 770304
977805 1666010
1199878 1476793
1249634 243739
1232999 531436
1146447 1845344
478779...

output:

1088048
504383
885219
908277
1888666
166581
535493
44165
1515178
193880
1907290
1648404
1425814
1642331
20030
1371613
704734
510907
82104
1786792
377030
1381872
571460
248994
528203
295501
1525570
799606
1850255
569054
1620597
1466384
1556664
1396656
1777737
919814
454847
1168579
1121704
1273486
182...

result:

ok answer: 1088048, maximum: 1088048

Test #9:

score: 0
Accepted
time: 3312ms
memory: 253820kb

input:

2000000 2000000 2000000
402689 127765
1065927 1753952
991609 1640904
1061308 533154
1552300 326545
1905312 1074675
1084722 1799678
51070 1470757
310696 763584
1965988 759275
246577 1374893
277285 408924
1692272 1856320
72026 1123575
1881487 1519767
1993052 1562521
575291 1507572
205452 248456
134621...

output:

1087919
837953
1445500
770875
820425
731776
376606
904538
1994239
1720093
1518641
463705
1239453
1531316
1196425
905866
625664
24927
1795764
444677
1047395
572254
1695776
653004
332441
357998
870143
1233141
1566694
57488
1731577
362066
1847846
195858
1713440
1776165
975937
317582
997571
1589120
8072...

result:

ok answer: 1087919, maximum: 1087919

Test #10:

score: 0
Accepted
time: 3623ms
memory: 253840kb

input:

2000000 2000000 2000000
486113 452417
846481 1383429
1116671 119681
1800588 1717142
294967 630728
1198456 1601715
884812 626111
1054097 142866
782611 1978438
1396710 1832027
534517 555375
417499 1250604
6129 166529
1166247 772627
371607 1819638
1512279 1072791
884878 1451005
1974857 843056
213647 10...

output:

1088039
1328189
1724622
1548099
1468045
514002
1916395
914727
605099
1342629
1715388
1032428
855810
542412
1714327
1792257
1700433
1711390
934010
1043886
1485731
1655910
415341
258442
824470
769885
326828
325452
501797
565476
778767
1886353
866330
1067010
1507006
450493
1110781
546530
298772
734942
...

result:

ok answer: 1088039, maximum: 1088039

Test #11:

score: 0
Accepted
time: 3312ms
memory: 253084kb

input:

2000000 2000000 2000000
569537 968557
1851226 45611
465925 789946
605275 1868426
261827 934910
1458895 1161459
684902 1195648
1215908 623487
30333 482892
827432 1096268
1598266 1478961
1525008 349179
385394 476737
1227764 164784
85919 119508
255697 326166
1970273 1394437
1809670 1180760
1015672 2547...

output:

1088084
968620
1852251
1611625
457420
384561
1682882
1462004
261888
1096461
1385844
1366662
785234
1073713
1155785
1413421
142989
740394
904204
662826
1195670
1773563
1671916
235370
1508576
1859227
742806
1508744
1982740
1771356
1320551
1187731
896021
1832901
1378009
1868689
1546614
908050
498344
84...

result:

ok answer: 1088084, maximum: 1088084

Test #12:

score: 0
Accepted
time: 3631ms
memory: 252892kb

input:

2000000 2000000 2000000
1685665 517402
664484 1675089
782474 1268723
1601450 85118
1195982 1239092
752039 721202
484993 1054786
218935 71404
310760 730450
1225450 1393213
662014 594034
632517 223562
699251 595457
321985 846541
576040 1386674
1774923 1836436
1312564 1337869
868675 808065
1107298 1517...

output:

1087210
881214
1567679
208184
405113
1889230
500980
345928
1885809
285974
125651
1659446
1434211
1969714
153864
1880417
1436324
167454
287327
1522861
162659
949482
260650
699165
498965
984199
1112843
1837643
1645999
104406
1552913
1631510
1412073
1991100
656886
1257218
1785977
872777
410987
316004
9...

result:

ok answer: 1087210, maximum: 1087210

Test #13:

score: 0
Accepted
time: 2278ms
memory: 258068kb

input:

2000000 2000000 2000000
671367 438853
664485 1398539
742842 386640
982299 485454
546419 1461681
1152709 654964
1250048 1661588
622998 536507
189300 1149326
1931736 1799077
327683 1819025
1040667 1571337
868282 1226836
498815 773984
808618 988294
712394 173925
134058 436291
98285 443781
1609589 78910...

output:

1535209
1120556
1423199
384989
598957
523457
1714883
56865
1080774
743400
1755097
1993518
440113
1190137
744384
97424
572535
1441382
445740
1169531
228510
1154754
1561363
135009
845678
714245
1023547
1045159
1259514
676272
1867622
1793696
1010277
292729
731184
1087628
977833
517452
886367
1533024
13...

result:

ok answer: 1535209, maximum: 1535209

Test #14:

score: 0
Accepted
time: 1619ms
memory: 254464kb

input:

2000000 2000000 2000000
138574 1342064
1643595 562587
1113082 1866381
1046781 69854
1995906 718620
1878456 1065477
1148129 1000230
128358 393159
1893827 365760
1922621 1583574
868735 553414
1400420 471921
147059 404788
1439120 680482
225083 1540271
1016807 1950769
1635754 371279
967724 1695575
13292...

output:

1802113
6362
1339423
60115
1999121
820864
696167
709041
1396160
868571
1322619
940568
1529006
1549445
514474
1343837
1949865
1108408
835048
1840966
234042
13142
1750442
409270
772698
1547917
366449
1178431
1194409
936462
1105293
1977808
620731
1105901
1412166
91471
504162
386533
654067
110586
164378...

result:

ok answer: 1802113, maximum: 1802113

Test #15:

score: 0
Accepted
time: 1197ms
memory: 258000kb

input:

2000000 2000000 2000000
536222 1734576
23820 45248
833336 1030570
413414 1449610
1303634 31529
1081756 593258
988649 183711
216216 1083600
127109 1327665
1021151 187582
712397 68980
1201276 912972
579821 1496356
516811 165481
829561 433889
116397 1703535
41995 1565188
452103 1023063
124730 1958243
2...

output:

1900296
958576
1740016
1161117
644631
280340
827347
1807781
1203534
1147968
383576
1741395
1542944
446365
114091
1278666
1593112
635550
1142718
1589809
1172424
1632521
653844
1741658
1939044
490864
1775919
1340062
1457210
297170
880035
1397755
1060445
989419
1393719
247031
1426183
392411
1652066
145...

result:

ok answer: 1900296, maximum: 1900296

Test #16:

score: 0
Accepted
time: 581ms
memory: 257880kb

input:

2000000 2000000 2000000
722296 810199
1104653 1326072
1384593 1991732
1359998 1074298
1745667 1702626
1958690 1040248
741056 1119935
123334 480039
941370 1134989
1340612 1877995
1628998 735318
1713870 573904
179004 731624
244572 1375222
1938456 934124
429528 1129329
655320 133186
1680525 1039251
180...

output:

1999999
1285010
1756744
1643939
968675
69977
96998
497277
1152546
387546
1401359
1672824
381286
46277
634809
1963762
881477
1302540
1331047
634583
1512173
1276602
599004
1733509
478730
767881
220076
791736
797263
1954887
1728713
382149
62362
334218
948178
1615066
1479842
463419
427277
242773
1261507...

result:

ok answer: 1999999, maximum: 1999999

Test #17:

score: 0
Accepted
time: 689ms
memory: 250460kb

input:

2000000 2000000 2000000
1047606 1292677
12506 1323616
1342868 93241
104701 1762734
1092674 826296
832718 320225
1030367 1004288
1092277 1855541
1147594 1592403
344053 1265006
957034 1327349
1581922 1471180
1394689 1275806
347140 757111
1968638 1065864
1735165 801763
916090 1855541
1294013 117591
177...

output:

38
1999984
1999918
1999989
1999795
1999925
1999930
1999929
1999939
1999959
1999995
1999962
1999982
1999973
1999940
1999985
1999933
1999988
1999992
1999990
782456
1292643
1810122
1096601
133699
1103323
202799
1129875
915823
1506241
397617
1814857
1260088
1319191
1178857
130534
228363
1349480
584664

result:

ok answer: 38, maximum: 38

Test #18:

score: 0
Accepted
time: 360ms
memory: 247888kb

input:

2000000 2000000 2000000
1873411 1383547
592374 1383547
837927 228335
880140 1383547
117684 1383547
873521 1383547
1659145 1383547
837927 1940103
684954 1383547
837927 649822
837927 553974
837927 263980
837927 1851187
645118 1383547
837927 536305
1931765 1383547
960556 1383547
837927 741946
837927 18...

output:

2
1999999
1778614

result:

ok answer: 2, maximum: 2

Test #19:

score: 0
Accepted
time: 357ms
memory: 247844kb

input:

2000000 2000000 2000000
679516 1758922
654113 491405
679516 903481
679516 1931142
1695416 491405
1087335 491405
679516 209225
991588 491405
679516 1423758
679516 1731533
815888 491405
84804 491405
679516 614525
532920 491405
679516 1583057
852179 491405
679516 641320
679516 158707
679516 883286
6795...

output:

2
1999999
550532

result:

ok answer: 2, maximum: 2

Test #20:

score: 0
Accepted
time: 730ms
memory: 250528kb

input:

2000000 2000000 2000000
950672 1358549
1019276 293
1341818 453182
517288 976497
1157473 567426
1601935 896019
1434229 1234860
1822883 1319667
1174043 794189
815886 186003
1433841 238760
599172 90292
1139073 538283
1651444 1723218
1890294 90292
749958 1255878
1584651 934604
31690 1957346
582723 18920...

output:

444
1999583
1999972
1999706
1999621
1998801
1999830
1999704
1999728
1999983
1999894
1998413
1999748
1999992
1999287
1999751
1999474
1999897
1999814
1999885
1999096
1999377
1998886
1999871
1998728
1998305
1999354
1999353
1998836
1998426
1999846
1999632
1999500
1999313
1999231
1999673
1999769
1999246
...

result:

ok answer: 444, maximum: 444

Test #21:

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

input:

32 32 768
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
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
2 1
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2 10
2 11
2 12
2 13
2 14
2 15
2 16
2 17
2 18
2 19
2 20
2 21
2 22
2 23
2 24
2 25
2 26
2 27
2 28
2 29
2 3...

output:

32
17
50
83
116
149
182
215
248
281
314
347
380
413
446
479
512
513
530
547
564
581
598
615
632
649
666
683
700
717
734
751
768

result:

ok answer: 32, maximum: 32

Test #22:

score: 0
Accepted
time: 271ms
memory: 101568kb

input:

1632 1632 1997568
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
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1...

output:

1632
817
2450
4083
5716
7349
8982
10615
12248
13881
15514
17147
18780
20413
22046
23679
25312
26945
28578
30211
31844
33477
35110
36743
38376
40009
41642
43275
44908
46541
48174
49807
51440
53073
54706
56339
57972
59605
61238
62871
64504
66137
67770
69403
71036
72669
74302
75935
77568
79201
80834
82...

result:

ok answer: 1632, maximum: 1632

Test #23:

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

input:

189 189 19845
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
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
...

output:

189
64
191
318
445
572
699
826
953
1080
1207
1334
1461
1588
1715
1842
1969
2096
2223
2350
2477
2604
2731
2858
2985
3112
3239
3366
3493
3620
3747
3874
4001
4128
4255
4382
4509
4636
4763
4890
5017
5144
5271
5398
5525
5652
5779
5906
6033
6160
6287
6414
6541
6668
6795
6922
7049
7176
7303
7430
7557
7684
...

result:

ok answer: 189, maximum: 189

Test #24:

score: 0
Accepted
time: 212ms
memory: 99416kb

input:

1896 1896 1997120
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
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1...

output:

1896
633
1898
3163
4428
5693
6958
8223
9488
10753
12018
13283
14548
15813
17078
18343
19608
20873
22138
23403
24668
25933
27198
28463
29728
30993
32258
33523
34788
36053
37318
38583
39848
41113
42378
43643
44908
46173
47438
48703
49968
51233
52498
53763
55028
56293
57558
58823
60088
61353
62618
6388...

result:

ok answer: 1896, maximum: 1896

Test #25:

score: 0
Accepted
time: 283ms
memory: 250552kb

input:

2000000 2000000 1997120
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
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
...

output:

1896
633
1898
3163
4428
5693
6958
8223
9488
10753
12018
13283
14548
15813
17078
18343
19608
20873
22138
23403
24668
25933
27198
28463
29728
30993
32258
33523
34788
36053
37318
38583
39848
41113
42378
43643
44908
46173
47438
48703
49968
51233
52498
53763
55028
56293
57558
58823
60088
61353
62618
6388...

result:

ok answer: 1896, maximum: 1896

Test #26:

score: 0
Accepted
time: 660ms
memory: 247740kb

input:

2000000 2000000 2000000
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
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
...

output:

183937
601
1802
3003
4204
5405
6606
7807
9008
10209
11410
12611
13812
15013
16214
17415
18616
19817
21018
22219
23420
24621
25822
27023
28224
29425
30626
31827
33028
34229
35430
36631
37832
39033
40234
41435
42636
43837
45038
46239
47440
48641
49842
51043
52244
53445
54646
55847
57048
58249
59450
60...

result:

ok answer: 183937, maximum: 183937

Test #27:

score: 0
Accepted
time: 1718ms
memory: 248112kb

input:

2000000 2000000 2000000
513 1122
1458 523
325 794
1951215 1284660
33 326
361 381
967 990
554 329
1682 399
250 704
294 196
520 496
976 939
583 776
689 1048
163 262
884 889
1147 1673
1552 459
1097 1091
826436 1860
255 516
1640 446
1643 55
1028 1318
1307752 1431867
716 1405
264 671
1018 1511
1798 413
1...

output:

184175
1631575
1264497
986356
1856608
1653057
1672188
1159956
1872174
1767218
1805065
1991152
1762024
1924442
1803901
1938192
1825274
1884021
1951659
1965642
1880466
1952438
1826009
1988677
1923200
1898021
1841362
1936439
1909280
1969214
1950477
1870308
1780690
1995244
1997511
1807060
1963294
199685...

result:

ok answer: 184175, maximum: 184175

Test #28:

score: 0
Accepted
time: 812ms
memory: 249804kb

input:

2000000 2000000 2000000
318377 264230
318377 297294
318377 1168121
318377 1168378
318377 687841
318377 317579
318377 1045281
318377 193774
318377 1286449
318377 809491
318377 305478
318377 1431410
318377 173240
318377 1833841
318377 824344
318377 722522
318377 1887702
318377 1302344
318377 864333
31...

output:

183975
1913906
1985118
1828617
1896679
1880067
1987606
1833507
1929104
1941361
1996736
1984261
1969107
1872394
1767001
1965518
1905161
1918451
1886351
1998329
1958757
1967911
1809744
1972585
1958276
1977838
1828908
1972495
1928778
1942049
1998897
1931620
1984171
1845981
1877116
1824238
1816057
18623...

result:

ok answer: 183975, maximum: 183975

Test #29:

score: 0
Accepted
time: 1871ms
memory: 247696kb

input:

2000000 2000000 2000000
1625116 599613
539469 1308455
812983 176633
874289 461823
1824953 1589033
794027 1271010
178174 1700721
1161616 1322163
1277276 32631
1962706 1017199
282239 1158238
1206051 966351
1745846 987176
361370 985866
857047 470035
637002 976591
1362011 429199
1160438 673497
1007777 1...

output:

184156
1205010
1530636
799870
1377956
1258161
239954
1989647
1208217
364421
625964
40586
1284320
866873
1329027
1708892
1152785
13956
1623245
1921339
1989871
1461252
715771
879062
415638
564211
905208
588946
784603
427466
1494758
1760199
693713
54942
1365250
1278587
1783078
1909789
1739887
597172
77...

result:

ok answer: 184156, maximum: 184156

Test #30:

score: 0
Accepted
time: 285ms
memory: 248480kb

input:

2000000 2000000 2000000
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
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
...

output:

11043
632
1895
3158
4421
5684
6947
8210
9473
10736
11999
13262
14525
15788
17051
18314
19577
20840
22103
23366
24629
25892
27155
28418
29681
30944
32207
33470
34733
35996
37259
38522
39785
41048
42311
43574
44837
46100
47363
48626
49889
51152
52415
53678
54941
56204
57467
58730
59993
61256
62519
637...

result:

ok answer: 11043, maximum: 11043

Test #31:

score: 0
Accepted
time: 281ms
memory: 248404kb

input:

2000000 2000000 2000000
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
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
...

output:

4770
633
1898
3163
4428
5693
6958
8223
9488
10753
12018
13283
14548
15813
17078
18343
19608
20873
22138
23403
24668
25933
27198
28463
29728
30993
32258
33523
34788
36053
37318
38583
39848
41113
42378
43643
44908
46173
47438
48703
49968
51233
52498
53763
55028
56293
57558
58823
60088
61353
62618
6388...

result:

ok answer: 4770, maximum: 4770

Test #32:

score: 0
Accepted
time: 326ms
memory: 248328kb

input:

2000000 2000000 2000000
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
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
...

output:

1505
501
1502
2503
3504
4505
5506
6507
7508
8509
9510
10511
11512
12513
13514
14515
15516
16517
17518
18519
19520
20521
21522
22523
23524
24525
25526
26527
27528
28529
29530
30531
31532
32533
33534
34535
35536
36537
37538
38539
39540
40541
41542
42543
43544
44545
45546
46547
47548
48549
49550
50551
...

result:

ok answer: 1505, maximum: 1505

Test #33:

score: 0
Accepted
time: 305ms
memory: 250508kb

input:

2000000 2000000 2000000
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
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
...

output:

1804
601
1802
3003
4204
5405
6606
7807
9008
10209
11410
12611
13812
15013
16214
17415
18616
19817
21018
22219
23420
24621
25822
27023
28224
29425
30626
31827
33028
34229
35430
36631
37832
39033
40234
41435
42636
43837
45038
46239
47440
48641
49842
51043
52244
53445
54646
55847
57048
58249
59450
6065...

result:

ok answer: 1804, maximum: 1804

Test #34:

score: 0
Accepted
time: 374ms
memory: 248452kb

input:

2000000 2000000 2000000
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
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
...

output:

1356
451
1352
2253
3154
4055
4956
5857
6758
7659
8560
9461
10362
11263
12164
13065
13966
14867
15768
16669
17570
18471
19372
20273
21174
22075
22976
23877
24778
25679
26580
27481
28382
29283
30184
31085
31986
32887
33788
34689
35590
36491
37392
38293
39194
40095
40996
41897
42798
43699
44600
45501
4...

result:

ok answer: 1356, maximum: 1356

Test #35:

score: 0
Accepted
time: 317ms
memory: 248468kb

input:

2000000 2000000 2000000
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
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
...

output:

1051
351
1052
1753
2454
3155
3856
4557
5258
5959
6660
7361
8062
8763
9464
10165
10866
11567
12268
12969
13670
14371
15072
15773
16474
17175
17876
18577
19278
19979
20680
21381
22082
22783
23484
24185
24886
25587
26288
26989
27690
28391
29092
29793
30494
31195
31896
32597
33298
33999
34700
35401
3610...

result:

ok answer: 1051, maximum: 1051

Test #36:

score: 0
Accepted
time: 353ms
memory: 247904kb

input:

2000000 2000000 2000000
1410388 834484
1410388 239410
1410388 1232286
1410388 207365
1410388 1395003
1410388 1968948
1410388 576378
1410388 76728
1410388 1644827
1410388 1278820
1410388 593448
1410388 904665
1410388 1931363
1410388 1889040
1410388 1147950
1410388 218013
1410388 1688590
1410388 13887...

output:

1651
1499301
796951
1289752
539551
899252
1447053
1092853
932254
751855
722156
1288104
1321105
594552
701257
834358
1423956
773859
528553
1407457
1145660
1322758
1042261
1408009
814562
623163
514254
1423410
1483911
1393712
820064
228255
561556
504357
262358
385559
1394263
591260
482361
131462
699065...

result:

ok answer: 1651, maximum: 1651

Test #37:

score: 0
Accepted
time: 1936ms
memory: 248508kb

input:

2000000 2000000 2000000
1686157 1036655
905644 1257773
231391 1553076
1776476 17761
1718008 397514
1502594 1699978
1112572 590070
1128891 1730637
1547654 1908592
1182198 717510
645722 749840
1307572 1364844
1466826 1763992
373885 1613469
12498 321213
265420 1503625
574762 197883
654547 1390192
19624...

output:

1365
1987594
1981446
1990492
1998950
1061784
1997591
1884224
1994525
1278505
1558792
1988738
1638797
1866552
1261116
1987179
1979471
1705749
1996344
1782627
1999742
1965535
1911774
1922766
1987196
1972206
1999611
1738307
1818419
1994476
1924670
1913468
1999905
1870509
1962872
1997904
1934997
1722258...

result:

ok answer: 1365, maximum: 1365

Test #38:

score: 0
Accepted
time: 397ms
memory: 248468kb

input:

2000000 2000000 2000000
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
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
...

output:

1515
501
1502
2503
3504
4505
5506
6507
7508
8509
9510
10511
11512
12513
13514
14515
15516
16517
17518
18519
19520
20521
21522
22523
23524
24525
25526
26527
27528
28529
29530
30531
31532
32533
33534
34535
35536
36537
37538
38539
39540
40541
41542
42543
43544
44545
45546
46547
47548
48549
49550
50551
...

result:

ok answer: 1515, maximum: 1515

Test #39:

score: 0
Accepted
time: 354ms
memory: 250488kb

input:

2000000 2000000 2000000
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
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
...

output:

2565
806
1612
2418
3224
4030
4836
5642
6448
7254
8060
8866
9672
10478
11284
12090
12896
13702
14508
15314
16120
16926
17732
18538
19344
20150
20956
21762
22568
23374
24180
24986
25792
26598
27404
28210
29016
29822
30628
31434
32240
33046
33852
34658
35464
36270
37076
37882
38688
39494
40300
41106
41...

result:

ok answer: 2565, maximum: 2565

Test #40:

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

input:

2000000 2000000 2000000
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
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
...

output:

2998
1000
2000
3000
4000
5000
6000
7000
8000
9000
10000
11000
12000
13000
14000
15000
16000
17000
18000
19000
20000
21000
22000
23000
24000
25000
26000
27000
28000
29000
30000
31000
32000
33000
34000
35000
36000
37000
38000
39000
40000
41000
42000
43000
44000
45000
46000
47000
48000
49000
50000
5100...

result:

ok answer: 2998, maximum: 2998

Test #41:

score: -100
Time Limit Exceeded

input:

2000000 2000000 2000000
194151 1938743
219729 1342843
68564 86794
693354 1338943
702775 386871
836157 501653
625353 1528914
1202559 373185
1190037 460020
109144 7201
1509959 1182372
1303399 1859980
281937 429619
1375375 1140805
1967865 1423773
274895 820740
86914 1312016
745802 1304378
1383905 79192...

output:


result: