QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#561987#8191. Kingdom ConnectivityAfterlife#AC ✓160ms88348kbC++202.2kb2024-09-13 14:01:162024-09-13 14:01:16

Judging History

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

  • [2024-09-13 14:01:16]
  • 评测
  • 测评结果:AC
  • 用时:160ms
  • 内存:88348kb
  • [2024-09-13 14:01:16]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

#define int long long

const int N=1e6+1e3+7;

struct P {
    int x,y,id;
}p[N];

int det(const P &a,const P &b)
{
    return a.x*b.y-a.y*b.x;
}

P operator -(const P &a,const P &b)
{
    return {a.x-b.x,a.y-b.y};
}

bool operator <(const P &a,const P &b)
{
    int pa=(a.x>0||(a.x==0&&a.y<0));
    int pb=(b.x>0||(b.x==0&&b.y<0));
    if(pa!=pb)
        return pa>pb;
    int d=det(a,b);
    if(d!=0)
        return d>0;
    return a.id<b.id;
}

int n,m,u[N],v[N],c[N];

set<P> g[N];

int vis[N];

int cnt,nr[N];

vector<tuple<int,int,int,int> >E;

int fa[N];

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

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>p[i].x>>p[i].y;
    for(int i=0;i<m;i++)
    {
        cin>>u[i]>>v[i]>>c[i];
        P d=p[v[i]]-p[u[i]];
        d.id=i<<1;
        g[u[i]].insert(d);
        d=p[u[i]]-p[v[i]];
        d.id=i<<1|1;
        g[v[i]].insert(d);
    }
    for(int i=0;i<m*2;i++)
    {
        if(vis[i])
            continue; 
        int e=i>>1;
        int x=((i&1)?v[e]:u[e]);
        int now=i;
        ++cnt;
        while(!vis[now])
        {
            nr[now]=cnt;
            vis[now]=1;
            e=now>>1;
            int t=(u[e]^v[e]^x);
            P d=p[x]-p[t];
            d.id=now^1;
            auto it=g[t].find(d);
            if(it==g[t].begin())
                it=g[t].end();
            it--;
            now=it->id;
            x=t;
        }
    }
    for(int i=0;i<m*2;i+=2)
    {
        int j=i^1;
        if(nr[i]!=nr[j])
            E.push_back({c[i>>1],nr[i],nr[j],i>>1});
    }
    sort(E.begin(),E.end());
    for(int i=1;i<=cnt;i++)
        fa[i]=i;
    int ans=0;
    vector<pair<int,int> > edge;
    for(auto [w,x,y,id]:E)
    {
        int fx=find(x),fy=find(y);
        if(fx==fy)
            continue;
        edge.push_back({u[id],v[id]});
        ans+=w;
        fa[fx]=fy;
    }
    cout<<ans<<"\n";
    cout<<edge.size()<<"\n";
    for(auto [x,y]:edge)
        cout<<x<<" "<<y<<"\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 60916kb

input:

3 3
0 0
0 1
1 0
1 2 1
1 3 2
2 3 3

output:

1
1
1 2

result:

ok OK

Test #2:

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

input:

4 5
1 0
2 1
1 2
0 1
1 2 1
2 3 2
3 4 3
4 1 4
1 3 5

output:

4
2
1 2
3 4

result:

ok OK

Test #3:

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

input:

2 1
0 0
1 1
1 2 3

output:

0
0

result:

ok OK

Test #4:

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

input:

20 10
40 78
-41 29
-91 6
6 -59
-88 23
-90 -1
74 -95
40 5
46 68
-65 36
43 95
-29 -5
-71 55
59 -18
100 72
-22 -80
51 94
90 -59
-30 -61
23 84
11 19 22179
8 14 70541
15 17 864638
7 9 709730
11 18 465599
5 10 896921
17 18 856994
13 19 906850
9 14 334413
3 19 164501

output:

0
0

result:

ok OK

Test #5:

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

input:

100 10
43 58
-15 77
-36 69
8 42
-55 97
-82 3
14 -8
-85 -2
-80 -67
-67 83
-99 91
79 -9
-14 22
-10 95
4 55
61 -5
47 -100
-77 -85
35 -86
-69 71
63 60
94 75
24 -4
94 31
-75 -71
-33 -54
9 53
34 67
-6 -54
46 -33
-72 -71
-29 90
-88 55
95 17
4 50
91 -92
-76 -74
-28 -92
28 27
-68 45
-56 98
-61 71
-70 -27
53 ...

output:

0
0

result:

ok OK

Test #6:

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

input:

100 100
-33 94
51 45
-13 66
-23 -65
-68 -93
-97 47
5 -43
58 59
49 -59
73 -91
-48 -35
-21 -50
-95 77
92 -19
60 -8
5 -3
-45 -65
7 42
83 -4
-94 22
89 -74
-7 89
70 -23
-68 60
29 -11
69 52
-5 -78
-20 -27
96 -66
95 -41
-75 15
-50 -51
77 -32
46 27
14 -34
-70 -41
47 -79
-98 98
70 -97
28 4
-72 -46
-98 -68
-1...

output:

4802547
20
33 54
21 68
24 44
42 99
79 100
55 57
55 83
39 69
9 16
24 62
40 82
68 93
25 83
36 52
3 25
6 31
41 94
82 100
6 51
28 62

result:

ok OK

Test #7:

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

input:

500 500
6461 -5605
-8688 1639
1016 -5464
7977 -5495
-9846 -8729
-7872 3185
7947 -5489
7208 -2290
1965 1940
-4033 -1639
7215 7013
8011 397
9227 7589
1691 9224
-6036 -2441
5943 4974
-8250 7617
-9671 -1695
-8306 -4673
4901 -4512
-3240 4973
-3762 -2965
4714 1996
-8754 -939
3145 865
-1310 -2770
2109 9346...

output:

21635503
104
34 302
26 163
58 258
70 229
210 269
243 432
237 251
277 449
92 250
115 154
63 193
83 461
308 415
134 143
217 304
32 221
23 395
163 418
68 234
88 214
199 283
440 468
257 319
120 127
17 269
7 454
67 468
125 391
154 373
44 277
72 245
228 257
17 218
154 449
69 412
66 102
102 135
160 211
163...

result:

ok OK

Test #8:

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

input:

500 800
4509 19686
-43881 26133
-10785 -37505
36138 15293
-38226 28343
-47776 -24540
15718 2240
27738 -45824
-35961 -20929
-42168 -14457
-40960 -40512
33525 44947
-12069 21068
-7695 -34744
-49327 4426
-45251 -49553
-46825 -8442
-23555 -44887
29437 -49019
-35077 -22250
24288 -44752
-11204 -3431
-2909...

output:

88362770
329
117 382
11 222
231 236
91 270
185 444
148 246
238 461
124 259
5 60
109 344
274 488
286 369
22 28
314 357
169 355
179 227
71 382
79 159
278 327
152 478
216 262
186 424
234 270
166 179
180 395
40 184
22 275
38 86
164 264
3 403
121 404
73 282
15 67
203 456
130 433
333 452
126 260
276 340
1...

result:

ok OK

Test #9:

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

input:

1000 1500
27206 66987
-19138 -62032
-97926 50623
-40883 -67683
-89886 96843
67593 -6084
20306 -17427
-69821 64898
-4554 66845
-75286 56609
66317 -33647
81960 2250
-66852 -14519
77723 -78517
-3989 -11276
-16425 -91506
38368 -55696
-69503 8295
97540 48931
-98669 80040
-84756 34181
74350 30950
-69857 -...

output:

151217768
580
269 621
743 913
387 526
58 994
270 287
190 653
305 847
529 661
199 972
863 873
656 664
414 427
366 555
670 894
91 928
383 389
113 684
186 723
653 674
431 726
366 552
536 812
152 785
148 719
716 858
168 360
37 206
54 760
118 371
640 844
417 760
46 155
236 973
49 94
183 580
239 613
286 4...

result:

ok OK

Test #10:

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

input:

1000 2000
-506817 -323552
-859539 123701
-305467 -627254
-744334 772220
610505 43370
376279 -797951
205444 -565161
160064 -99270
-94678 208755
807789 -22557
453419 -283534
835911 165526
915021 -291782
-925807 -197634
889108 -886360
15927 -915822
-114868 739279
512085 -414379
29150 -192704
632258 -85...

output:

307722155
1027
395 653
479 868
501 634
746 807
621 967
8 239
78 305
452 589
101 155
696 775
302 587
696 905
442 836
254 694
203 983
68 849
545 667
763 770
193 399
262 834
58 117
977 987
478 740
916 950
266 948
399 839
351 406
653 768
207 225
395 507
296 732
316 621
598 967
721 748
110 291
612 896
25...

result:

ok OK

Test #11:

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

input:

100000 95464
-994304 -982067
-981394 -969497
-961410 -998038
-963765 -985648
-991473 -996321
-981679 -968783
-993114 -976087
-963476 -972265
-983386 -963144
-983795 -980557
-992397 -988738
-972895 -992292
-993001 -987113
-972323 -960348
-970327 -998054
-970542 -978077
-979914 -970036
-991329 -983611...

output:

7516863746
27038
80077 80085
61200 61203
61223 61226
66295 66298
37869 37878
37397 37405
13760 13765
56101 56117
90378 90379
34051 34064
67877 67887
53719 53726
63848 63857
66193 66206
98388 98401
39454 39468
22266 22276
63085 63109
95350 95351
26015 26031
896 923
48296 48308
20555 20592
9135 9140
1...

result:

ok OK

Test #12:

score: 0
Accepted
time: 62ms
memory: 81044kb

input:

100000 84355
-978830 -977530
-993610 -996974
-977797 -978085
-995848 -998135
-989848 -995378
-994012 -979183
-996211 -979321
-998701 -992462
-996698 -974183
-992388 -967983
-976653 -952476
-977741 -958669
-996107 -959921
-993684 -969037
-987693 -950984
-994898 -968085
-984612 -926658
-986364 -929520...

output:

5328880476
19903
67484 67502
23463 23471
41807 41816
92267 92275
75728 75730
30522 30527
66250 66255
58236 58244
14170 14173
77551 77552
71034 71041
78240 78243
49249 49255
8596 8604
48990 48992
92072 92074
98976 98978
75087 75092
60491 60498
67760 67767
87666 87667
96423 96429
10235 10236
69317 693...

result:

ok OK

Test #13:

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

input:

100000 95145
-998301 -995613
-999595 -779952
-997609 -448596
-999162 -780021
-996111 -869574
-998688 -823757
-996152 -524906
-998192 -739820
-998269 -702062
-997530 -562347
-998420 -787781
-996631 -385177
-997551 -675832
-999396 -548203
-999099 -384741
-996201 -525195
-999495 -603338
-996549 -808405...

output:

7326776246
26482
47572 47585
61852 61898
28332 28340
20772 20787
29195 29201
69156 69176
14702 14715
79401 79416
29474 29499
19194 19241
31515 31526
24089 24096
99301 99307
55801 55806
14708 14719
68601 68620
27384 27389
38802 38804
75672 75760
55243 55261
64885 64977
42774 42786
14924 14999
23954 2...

result:

ok OK

Test #14:

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

input:

9990 9990
-999764 -21746
-999562 -29627
-998536 -54100
-992662 -120927
-990566 -137041
-990019 -140940
-985299 -170844
-983454 -181159
-979191 -202942
-977978 -208710
-968884 -247518
-964016 -265848
-958967 -283521
-950751 -309959
-945906 -324444
-943491 -331400
-939441 -342712
-927627 -373510
-9244...

output:

99868
30
4145 4146
8293 8294
9557 9558
5806 5807
7833 7834
4577 4578
3462 3463
8843 8844
796 797
6845 6846
6523 6524
1622 1623
5615 5616
544 545
7552 7553
1778 1779
39 40
7043 7044
5194 5195
3755 3756
4977 4978
3304 3305
9184 9185
9823 9824
2520 2521
8511 8512
1169 1170
2095 2096
2784 2785
6118 6119

result:

ok OK

Test #15:

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

input:

20000 20000
-1000000 -1154
-999919 -12753
-999729 -23289
-998189 -60164
-994552 -104248
-991628 -129134
-990876 -134778
-990280 -139094
-986779 -162075
-986019 -166635
-984775 -173839
-982990 -183660
-981737 -190249
-981534 -191293
-973890 -227021
-968491 -249050
-965203 -261505
-957728 -287679
-953...

output:

100310
50
17033 17034
7311 7312
1638 1639
9517 9518
12998 12999
10183 10184
14787 14788
19857 19858
5023 5024
11042 11043
14956 14957
9660 9661
8484 8485
14074 14075
2009 2010
8271 8272
17392 17393
18118 18119
10756 10757
18705 18706
5422 5423
13594 13595
12606 12607
13786 13787
4556 4557
1373 1374
...

result:

ok OK

Test #16:

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

input:

5000 5000
-998015 -62988
-997099 -76121
-996440 -84306
-993700 -112077
-989058 -147534
-988543 -150945
-987686 -156454
-984955 -172814
-984882 -173229
-981831 -189759
-981306 -192459
-980609 -195978
-955576 -294748
-944299 -329090
-905821 -423663
-904985 -425444
-893211 -449639
-869309 -494270
-8673...

output:

92999
20
1445 1446
3115 3116
1636 1637
150 151
731 732
4962 4963
1210 1211
3624 3625
332 333
2086 2087
779 780
4282 4283
2400 2401
2552 2553
4627 4628
2811 2812
4148 4149
1765 1766
3844 3845
3395 3396

result:

ok OK

Test #17:

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

input:

4 5
481026 -876706
-952300 -305161
838269 545257
-355722 934591
1 2 881823
1 3 827884
3 4 468427
3 2 851603
4 2 690717

output:

1296311
2
3 4
1 3

result:

ok OK

Test #18:

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

input:

5 7
645225 -763991
-393302 -919408
-993929 110019
129373 991596
895425 445213
4 3 318765
2 1 105557
1 5 352994
3 1 888572
4 1 979578
4 5 233285
3 2 979736

output:

657607
3
2 1
4 5
4 3

result:

ok OK

Test #19:

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

input:

10 17
96541 260723
4676 998906
-15137 -988474
80951 -587100
-97401 -226454
-91866 395026
-72668 -686965
-34217 939635
43576 -900061
60077 799420
10 7 110402
1 10 334019
4 1 769669
9 4 57302
6 7 14998
3 10 199517
10 8 720599
10 6 363803
9 1 54557
10 2 376582
6 5 705835
2 8 215372
5 7 250471
8 6 95873...

output:

1232234
8
6 7
9 1
9 4
10 7
3 10
2 8
3 1
10 6

result:

ok OK

Test #20:

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

input:

15 27
-999690 24877
-52265 -998632
-487971 -872858
-109545 993982
448052 -894006
-952472 -304621
946720 -322057
-788450 -615096
-855418 517937
793370 -608738
644785 764364
-603218 797575
999702 24392
185444 982655
837465 546491
2 14 190266
3 2 163218
7 15 224175
15 14 767165
14 4 784337
12 6 759737
...

output:

3977444
13
12 1
9 1
11 14
3 2
2 14
10 14
7 15
2 5
2 12
10 7
2 6
13 15
14 4

result:

ok OK

Test #21:

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

input:

20 37
-999928 -11957
966237 -257655
62621 -998036
-729862 -683593
-598543 801090
-195015 -980799
383823 -923406
-885971 463740
991162 132654
456934 889501
164815 986324
-920717 -390227
782537 622604
822897 -568190
631443 -775421
-532069 -846699
-983196 182549
904346 426799
-8838 999961
-418165 90837...

output:

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

result:

ok OK

Test #22:

score: 0
Accepted
time: 12ms
memory: 60924kb

input:

20 43
2 -2
3 3
1 1
6 0
0 0
6 -2
3 1
5 1
1 -1
4 -2
7 -1
3 -3
2 2
3 -1
5 -1
2 0
4 0
4 -4
5 -3
4 2
16 7 793409
12 18 895628
8 15 513609
10 18 790846
14 12 291776
1 14 873377
15 19 223927
9 16 977633
3 16 691351
15 4 739073
19 6 863477
3 9 521905
7 20 538816
2 7 753129
14 17 643481
3 13 35718
1 12 38060...

output:

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

result:

ok OK

Test #23:

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

input:

6 10
-993929 110019
0 0
895425 445213
129373 991596
645225 -763991
-393302 -919408
2 6 893853
4 1 591148
2 3 693109
2 1 436339
3 4 435093
6 5 801121
2 4 94119
5 3 78615
2 5 736604
1 6 783022

output:

1780770
5
5 3
2 4
3 4
2 1
2 5

result:

ok OK

Test #24:

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

input:

11 20
-955215 -295909
-107757 -994176
-459806 888019
-938206 346073
682650 730745
834497 -551012
540597 -841281
0 0
-751546 -659679
999336 36443
307317 951607
1 9 447695
3 4 437905
8 6 354926
8 2 39719
8 7 880369
8 5 258551
8 10 821647
9 2 733976
6 10 76474
10 5 475422
2 7 373584
4 1 171815
8 3 5626...

output:

2054985
10
8 1
8 2
8 9
6 10
11 3
4 1
8 5
8 6
3 4
10 5

result:

ok OK

Test #25:

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

input:

20 38
478810 877918
-966188 -257834
-990820 135183
692579 721342
-895164 445735
-56605 -998396
-848216 -529648
948745 -316042
157536 987513
587604 -809147
-254745 -967007
793398 -608703
-414742 909939
941307 337551
0 0
999813 19317
-684680 728843
-229445 973321
-661508 -749936
271819 -962347
10 12 1...

output:

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

result:

ok OK

Test #26:

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

input:

50 97
-806860 -590741
759929 -650005
67467 -997720
-755623 655006
585289 -810823
176385 984321
673019 -739624
973666 -227978
-959135 -282944
999997 2507
-885800 464065
-62740 -998029
619276 785174
795653 605752
292656 956218
935101 -354381
994855 -101306
-908562 -417747
-629819 -776740
871471 490447...

output:

13499181
48
17 40
32 15
2 42
47 19
3 22
2 44
9 18
43 7
28 21
29 20
26 34
41 21
25 45
17 10
32 2
6 50
27 37
33 3
40 31
23 9
4 38
40 15
34 40
23 32
48 2
48 33
24 43
46 15
2 15
17 15
38 11
6 36
6 35
49 23
32 47
5 7
49 11
48 7
8 17
32 48
32 19
19 30
19 39
49 27
2 8
21 32
27 23
14 40

result:

ok OK

Test #27:

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

input:

100 197
931642 -363375
-991101 -133102
-561984 827147
869922 493190
992265 -124138
-935537 353225
812062 -583571
-642754 766072
-470740 -882270
204702 -978823
-864513 -502608
-40373 -999184
687174 -726492
-601903 798569
-212183 977230
-854776 518996
316742 -948511
-997773 -66691
677027 735958
-74366...

output:

29184716
98
63 50
4 95
40 27
18 88
36 51
89 10
55 70
88 25
31 82
45 59
41 32
64 60
68 4
45 71
9 17
92 93
28 93
46 9
15 82
41 17
86 47
26 1
75 10
74 41
87 65
59 61
42 67
48 36
79 85
15 33
68 96
96 35
89 17
82 16
58 90
73 15
97 54
51 9
5 54
44 43
9 94
83 38
83 79
54 81
20 43
67 96
40 59
22 40
21 59
51...

result:

ok OK

Test #28:

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

input:

1000 1997
-956536 -291609
169782 -985481
-822499 -568764
447057 894505
494494 -869180
912295 409534
984939 -172900
-767437 641123
603249 -797552
688371 725359
-871246 490845
-978093 -208165
993062 -117595
676641 -736312
270192 962806
14865 -999889
441010 897502
598281 -801285
-634209 773161
-158384 ...

output:

306834931
998
420 648
56 294
682 929
625 298
335 238
621 434
626 18
229 337
653 77
430 398
413 386
401 137
59 718
215 192
435 420
905 522
905 710
285 936
643 749
38 607
740 978
869 5
100 11
449 105
631 479
190 358
10 276
669 613
453 971
536 830
743 560
169 999
256 784
228 960
411 265
912 233
285 630...

result:

ok OK

Test #29:

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

input:

1000 1997
50755 -998710
-961105 276179
996924 78368
604018 -796969
841037 -540977
-997905 -64679
91999 995759
-710854 -703337
277245 960799
8565 -999962
158903 -987293
-962055 272851
695214 -718802
753624 657306
-29442 -999565
116490 993192
929466 368909
-411185 911552
-968202 -250166
998906 46773
3...

output:

282092976
998
777 927
176 228
154 999
176 105
176 72
243 415
232 17
176 741
176 750
176 714
445 401
176 495
341 781
481 557
176 97
176 784
727 443
524 304
176 674
184 733
176 835
176 237
110 841
176 926
176 562
176 19
176 119
361 969
199 809
176 59
176 841
488 145
394 324
496 920
176 673
176 929
512...

result:

ok OK

Test #30:

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

input:

1000 1997
-736773 -676138
919894 392166
-935010 354618
-885984 463714
995417 95634
-574165 818739
-432088 901831
781697 623659
995862 90881
881685 471839
112908 -993604
-888235 459387
-410140 912022
-137451 -990507
78861 996886
-854431 519564
33217 -999447
-761203 -648511
-873495 486831
-859030 5119...

output:

293595609
998
854 485
789 183
548 906
8 906
600 906
46 906
605 906
111 242
206 906
985 906
964 906
643 906
2 313
262 994
241 492
949 434
919 383
247 906
39 906
995 906
994 663
551 906
681 906
199 859
185 906
417 301
767 99
75 906
319 975
511 906
854 906
699 906
516 107
594 801
343 413
540 955
731 90...

result:

ok OK

Test #31:

score: 0
Accepted
time: 13ms
memory: 61648kb

input:

1000 1997
961910 273366
-492262 -870445
148619 988895
-111858 -993723
-274497 961588
-611202 -791473
-511884 -859053
559445 -828867
-618945 785434
975505 219979
552400 -833579
-939246 343242
-997707 67664
-955735 294225
-344056 -938948
-603397 797440
-982855 184376
167483 985875
-909944 -414728
-753...

output:

296154049
998
890 233
378 255
238 163
673 886
459 17
169 920
236 252
837 30
615 941
639 217
800 119
670 720
465 895
975 99
44 544
786 307
953 624
717 178
126 964
791 650
501 267
508 575
733 918
512 441
508 596
332 642
545 65
587 64
247 804
102 781
865 595
603 845
261 861
514 309
864 473
361 528
946 ...

result:

ok OK

Test #32:

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

input:

1000 1997
88 -88
18 -18
372 -372
97 -97
395 -393
80 -78
201 -199
297 -295
252 -250
188 -188
113 -113
28 -28
27 -27
2 0
124 -122
71 -69
249 -247
247 -247
195 -195
280 -278
50 -48
165 -165
290 -290
285 -283
321 -321
308 -308
443 -441
167 -165
34 -32
385 -383
132 -130
453 -451
217 -217
465 -465
3 -1
73...

output:

302410609
998
426 918
992 568
672 73
678 804
334 862
52 259
635 234
471 601
854 632
761 516
30 694
226 940
668 459
38 193
568 473
801 612
773 131
293 319
799 78
509 15
215 202
649 743
786 771
175 190
821 42
667 417
63 828
659 68
150 912
331 656
612 13
184 773
578 501
239 778
666 212
588 342
493 507
...

result:

ok OK

Test #33:

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

input:

1000 1997
178 178
36 34
136 136
320 318
6 6
483 483
272 272
42 42
105 103
443 441
332 330
54 52
341 341
415 413
295 295
328 326
379 377
300 300
191 189
144 144
133 133
395 393
191 191
103 101
282 282
390 390
335 335
427 425
29 29
5 3
137 137
142 142
151 151
204 204
82 80
416 416
326 326
81 79
186 18...

output:

289583597
998
764 230
120 372
728 64
205 415
255 489
814 243
855 993
198 167
605 362
361 393
693 232
112 623
194 710
742 149
273 804
704 579
606 810
847 589
428 157
757 75
895 433
40 507
426 452
242 756
626 747
129 416
792 425
202 384
522 954
614 594
193 439
749 429
692 773
807 27
669 449
131 168
96...

result:

ok OK

Test #34:

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

input:

998 1993
257 257
201 -200
137 -264
30 -371
85 85
115 115
355 -46
410 9
114 -287
15 15
416 15
440 39
454 53
205 205
284 -117
419 18
130 130
56 56
439 38
245 -156
27 27
83 -318
413 413
338 -63
276 276
55 55
210 210
222 -179
281 -120
384 384
153 153
477 477
362 -39
20 20
343 343
472 71
219 219
441 40
2...

output:

283115824
996
642 799
229 735
243 627
411 438
115 37
417 788
41 26
278 632
346 814
921 372
754 601
641 297
265 232
551 363
116 6
536 32
246 837
429 677
265 560
598 967
846 117
122 227
402 77
590 307
913 50
324 732
547 92
392 251
338 652
69 993
964 880
219 568
747 111
371 570
679 40
971 479
4 219
777...

result:

ok OK

Test #35:

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

input:

1000 1997
-956536 -291609
169782 -985481
-822499 -568764
447057 894505
494494 -869180
912295 409534
984939 -172900
-767437 641123
603249 -797552
688371 725359
-871246 490845
-978093 -208165
993062 -117595
676641 -736312
270192 962806
14865 -999889
441010 897502
598281 -801285
-634209 773161
-158384 ...

output:

299154023
998
137 394
149 552
232 463
404 622
190 245
561 505
29 809
717 919
838 906
560 862
910 494
344 332
219 697
91 908
302 590
749 928
630 94
899 832
465 698
805 971
392 745
14 568
177 881
581 926
59 865
512 417
588 679
76 605
28 307
920 862
531 682
413 95
40 870
997 156
805 518
924 765
671 407...

result:

ok OK

Test #36:

score: 0
Accepted
time: 16ms
memory: 62576kb

input:

5000 9997
195408 980722
-863230 -504808
-925060 -379818
447539 -894264
-912854 408284
47921 -998850
764742 644336
-650840 -759213
-964489 264120
859810 510614
-961133 276083
432381 901691
-459422 -888217
999864 16511
994491 -104821
-839408 -543500
931358 -364103
199865 -979823
-947392 -320072
-61250...

output:

1446426524
4998
1523 812
2669 2738
2669 4509
3008 1920
2669 1638
4953 4563
2669 825
3636 2666
4820 4033
2669 2945
2669 12
4121 2940
4138 4678
131 1625
3967 4222
1184 172
2263 1275
2669 3491
4254 2634
176 1655
2669 627
2669 2435
3300 1996
2669 3879
4313 1664
2669 3696
2669 1590
2669 2129
2276 669
333...

result:

ok OK

Test #37:

score: 0
Accepted
time: 20ms
memory: 62632kb

input:

5000 9997
574847 -818260
361619 -932325
275949 -961171
758683 -651459
270205 962803
-354746 -934961
-646747 -762702
968037 -250806
-887521 -460764
-994033 109072
-732379 -680895
-878268 478167
-972599 232484
-481638 -876369
982150 -188098
-410686 -911775
-470317 -882496
-999721 23595
938565 345102
-...

output:

1456335310
4998
641 4596
1781 3016
4176 1227
1807 4147
3924 4517
4839 81
681 4918
1766 2916
3642 4519
4261 3083
1042 2193
2146 394
122 217
1684 391
2276 4435
2769 2810
4207 707
4099 110
210 1948
1291 1375
2251 2058
2387 4610
2662 1624
1906 3178
2776 2062
3150 3569
3803 1382
4717 3478
2921 2605
1442 ...

result:

ok OK

Test #38:

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

input:

50000 99997
22375 -22373
20951 -20951
560 -560
14314 -14314
17905 -17903
14763 -14761
3233 -3233
11932 -11930
19661 -19661
2017 -2017
24994 -24994
1605 -1605
7909 -7907
21261 -21259
15413 -15411
13483 -13481
17012 -17010
22562 -22562
4216 -4216
11890 -11890
3251 -3251
12138 -12136
11909 -11909
21412...

output:

14590783298
49998
24968 11825
40411 22965
7333 48663
16336 11315
49153 11721
18178 2801
37086 4007
47323 30544
47896 31469
36691 720
32628 30376
7057 31512
6433 23863
30788 29724
37424 19860
36209 40825
26614 36991
48531 22429
32233 14260
4284 15487
37976 15530
49443 3186
47528 23150
24503 3817
2955...

result:

ok OK

Test #39:

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

input:

1000 1998
743042 -669244
595139 803623
-874191 -485579
-511148 859492
653139 -757237
994203 107519
999995 3095
4389 999990
-690253 -723567
446729 894669
-549348 835593
959631 281261
-632260 -774755
-950840 309681
-925247 -379362
-990922 134432
274465 -961596
-775389 -631481
748767 662834
669390 7429...

output:

282357251
999
96 751
712 377
28 121
712 535
712 873
712 39
826 928
749 897
712 871
109 545
746 931
84 955
712 900
712 811
712 20
637 211
338 395
712 924
493 296
524 480
255 39
712 468
712 595
712 616
712 100
712 563
712 135
441 243
712 634
276 982
419 442
279 141
476 806
605 876
5 138
315 536
13 78
...

result:

ok OK

Test #40:

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

input:

932 1862
-658956 752181
819403 573217
775409 631460
-99631 -995023
305036 -952340
992175 -124851
-253674 -967288
44816 998995
-742993 -669297
-574765 818318
701484 -712684
-850373 526178
-776712 -629854
827495 561473
913910 -405915
-296957 954891
-96612 995322
512836 -858486
933330 359019
186881 -98...

output:

276607687
931
909 102
188 920
188 478
182 211
188 599
541 210
849 8
85 796
332 598
188 224
188 48
188 207
188 847
463 510
922 156
188 655
762 437
188 730
10 55
449 553
407 13
364 877
188 664
188 717
188 662
789 463
104 728
188 178
112 475
485 52
188 113
539 80
77 554
188 804
809 142
688 315
188 911
...

result:

ok OK

Test #41:

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

input:

441 1240
14 6
17 1
15 1
21 -7
17 -17
18 14
27 -13
29 9
26 -4
29 5
35 3
24 10
8 2
7 3
12 -12
30 10
20 -6
29 -11
34 -2
6 6
11 9
32 -8
22 -18
22 18
32 2
22 4
8 -4
15 -9
0 0
17 -3
18 2
12 4
21 9
18 8
15 -1
15 7
20 -8
9 -1
27 -7
26 4
21 1
23 -7
17 -11
16 10
25 -9
34 -4
12 -4
25 -11
24 14
10 0
25 -1
23 11...

output:

270950102
800
228 219
416 160
43 182
140 417
139 278
298 9
252 23
332 129
75 340
13 60
80 207
226 6
1 123
428 14
106 312
345 222
10 412
182 283
380 71
310 436
190 158
124 176
401 290
87 19
28 73
189 3
305 431
42 368
136 368
243 400
31 238
110 26
294 19
307 229
66 325
406 204
101 235
402 171
438 406
...

result:

ok OK

Test #42:

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

input:

1000 2861
16 -14
26 -2
23 -23
21 -15
22 -8
34 -4
43 -35
57 -27
29 -11
16 6
16 -10
26 6
49 -27
54 -38
46 -10
29 7
18 2
54 -28
37 -23
43 -41
50 -14
54 -42
33 -25
47 -31
38 -14
31 -9
45 -25
6 -4
44 -12
39 -15
13 1
37 -5
22 8
47 -15
31 -3
32 4
28 -22
52 -14
26 0
44 -38
13 3
50 -20
35 1
9 -1
48 -44
27 1
...

output:

626061904
1862
299 199
836 73
388 154
804 467
32 130
49 936
43 863
254 433
563 535
646 679
259 172
108 558
706 518
80 199
362 749
776 856
98 645
875 216
648 795
265 282
461 254
495 292
933 749
854 192
224 274
701 574
410 546
282 702
488 348
1 282
872 693
913 80
379 257
72 476
438 949
553 366
544 183...

result:

ok OK

Test #43:

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

input:

484 1365
1050 3504
1770 1356
3100 2323
2040 5145
2580 3534
1870 2419
240 4389
730 715
520 1852
2050 4945
1000 1441
790 2578
2280 3408
1670 3356
280 3589
320 2789
610 3115
580 3715
590 452
3000 1260
1620 1293
260 3989
1180 904
2100 3945
-160 3200
600 252
-180 3600
110 863
1030 3904
1750 1756
2820 486...

output:

300176030
882
359 351
105 19
11 222
334 254
68 45
63 35
453 37
282 160
116 6
379 417
253 316
135 358
20 349
258 446
464 173
404 139
474 240
212 408
184 346
27 180
457 259
270 86
203 274
424 132
96 412
45 398
463 168
278 174
449 380
66 151
460 341
166 322
413 248
429 408
407 101
47 250
325 269
17 484...

result:

ok OK

Test #44:

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

input:

462 1301
4969 1941
10679 4227
2114 798
6664 2657
4420 1712
5813 2314
1558 599
10686 4197
9231 3626
7426 2912
6177 2397
4962 1971
7474 2941
5724 2226
9972 3971
11633 4598
7076 2769
10981 4341
8325 3284
5120 1998
4667 1827
5875 2283
5772 2255
8682 3397
10233 4026
7968 3171
5621 2198
10480 4141
3816 14...

output:

277864612
840
389 193
320 271
158 333
287 2
344 105
114 258
319 356
54 445
15 159
457 31
214 166
186 154
364 26
304 344
322 360
98 188
441 155
346 35
1 180
64 14
50 398
244 356
101 80
260 361
135 129
436 461
208 6
447 125
209 412
241 236
92 186
40 38
227 174
360 209
174 225
4 97
345 39
413 364
429 9...

result:

ok OK

Test #45:

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

input:

1000 2781
42 -741
60 -2856
74 -2870
68 -2864
21 -2817
61 -5653
32 -3527
44 -44
50 -1448
82 -4975
27 -2823
22 -4216
41 -4235
71 -4265
82 -3577
2 -1400
97 -796
22 -5614
49 -2146
70 -70
31 -730
43 -4237
36 -6327
46 -3541
24 -723
14 -1412
85 -5677
92 -2189
58 -4951
82 -4276
31 -31
58 -4252
21 -3516
32 -...

output:

595437187
1782
204 457
714 231
843 657
158 555
354 542
276 103
956 993
29 32
685 821
513 591
299 990
725 345
588 703
97 32
808 626
549 727
992 74
644 148
126 858
9 629
155 446
414 939
609 400
101 124
377 961
405 912
207 309
811 298
597 372
871 372
210 29
882 653
577 601
576 879
115 371
312 475
245 5...

result:

ok OK

Test #46:

score: 0
Accepted
time: 160ms
memory: 88348kb

input:

50000 99998
895518 445026
-773285 634057
37326 -999302
982499 -186267
-872810 488058
835301 549792
982268 -187482
571668 820485
951826 306638
-917330 398126
996856 79232
138620 990346
967816 251660
-370292 928915
517841 855477
615906 -787818
-945709 325011
-937870 -346983
-809510 587104
-731758 6815...

output:

14552026705
49999
46808 1950
21047 7905
45894 2803
26618 6760
28796 44497
48345 12553
34112 24183
20768 17640
32729 32679
34112 40942
34112 6871
34112 44335
34112 27758
34112 41598
34112 35729
34112 309
37916 18128
34112 11500
11358 12242
34112 26504
12790 5764
30021 38422
46739 18832
34112 464
3041...

result:

ok OK

Test #47:

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

input:

43158 86314
-801947 -597393
47219 -998884
937233 -348702
1000000 -859
258974 -965883
-969481 245161
746564 -665313
67442 -997722
-493991 869466
425278 905063
953777 -300515
483670 -875249
-997528 -70253
999971 7617
-855483 -517828
993984 -109526
-155829 -987783
993695 -112113
704422 -709780
683917 7...

output:

12501387972
43157
36067 25586
36067 26029
26283 42523
10356 31201
36067 12022
31981 36165
36067 37321
36067 42927
39880 21694
36067 20133
21969 29669
36067 34349
23520 1410
36067 26194
36067 8444
36067 14488
16961 22792
39146 37240
36067 3510
13259 3999
36067 8139
36067 19675
31298 12041
16661 19215...

result:

ok OK

Test #48:

score: 0
Accepted
time: 32ms
memory: 66736kb

input:

10201 30200
41 17
80 42
84 40
40 -2
115 -53
153 -13
75 59
90 50
99 -83
96 -32
76 -4
109 -15
17 11
8 0
164 -36
154 36
156 24
93 71
158 18
136 44
97 -73
104 60
84 -10
110 84
106 -54
109 75
37 -5
114 -40
117 43
135 -17
77 -41
30 14
106 0
88 -52
135 17
105 -75
88 -2
32 30
98 42
128 0
29 27
95 -73
84 -62...

output:

6798830915
20000
9712 3926
7203 10038
5685 7499
4989 2056
3165 9077
3788 907
3057 1053
9359 7384
8361 1611
3697 2292
1286 2762
9838 1074
730 5424
9975 4612
7825 9656
4073 6252
6942 221
10130 8345
213 9446
3659 1868
2433 9196
9163 5396
1881 7970
8637 2209
8192 2087
5501 2491
5211 5718
1360 8933
1227 ...

result:

ok OK

Test #49:

score: 0
Accepted
time: 32ms
memory: 68212kb

input:

13000 38541
96 -52
128 -32
133 -7
156 -70
89 49
62 -58
100 -4
161 25
109 -73
130 -54
80 -64
120 -4
134 -70
134 46
75 17
164 -4
167 -45
80 60
194 -44
174 -8
120 -40
102 -84
43 43
180 14
105 53
122 28
94 -10
49 21
115 17
166 -58
112 -68
106 -36
90 34
89 -53
146 -84
70 -30
139 -59
87 43
163 -71
16 -12
...

output:

8745854394
25542
12644 3398
6365 2302
10296 561
2744 12020
10925 5127
4062 12928
1282 106
6213 6154
6142 4004
11107 10387
2053 10602
5136 9018
9678 1197
11118 11685
7386 10658
5749 123
8008 12620
527 6127
6071 91
534 7791
10705 9581
12379 12401
11622 3671
12514 1861
6110 10858
1163 7546
2914 11520
1...

result:

ok OK

Test #50:

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

input:

23104 68705
864782 198422
-90917 408491
430138 166418
323606 327006
834353 287977
505252 710932
696467 188555
376933 552421
800159 367991
585615 129863
724982 364982
564876 348140
61413 30629
740103 708855
-13332 49548
20305 607009
515684 272092
719550 573438
399523 609667
230900 342076
773063 44515...

output:

15619069349
45602
18786 14326
10619 13150
19658 11795
5406 7304
11048 4456
17723 16833
11561 4962
22712 2687
15420 5090
6846 18771
16238 7308
16937 18523
9212 20654
4278 11512
1425 7653
5103 15742
20914 8014
13320 22489
16400 2951
120 2451
11984 801
7607 39
1433 287
6494 11062
7059 3424
20747 11017
...

result:

ok OK

Test #51:

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

input:

15762 46781
473918 101848
783222 564068
177724 58396
155117 24344
699330 556432
478809 515580
596969 638480
591692 39344
442820 362228
666435 455476
782545 597320
562682 442404
449938 53488
307874 205476
364749 354792
536013 607864
876725 671860
630756 164280
320155 11000
643771 178988
552103 594156...

output:

10615410672
31020
3292 6617
3139 702
1634 2554
1365 7210
13289 6180
3486 7756
2053 13439
12598 8336
6325 7628
91 5571
6917 7883
11587 11403
9809 12634
6320 469
12749 5815
13031 12718
15604 6600
4932 2780
10867 2211
11551 4885
13572 5594
8514 10222
5243 10484
806 5840
12217 10891
7955 215
9832 2717
6...

result:

ok OK

Test #52:

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

input:

26700 79367
176 -19049
271 -55492
34 -23800
196 -56116
78 -16854
210 -32364
129 -63039
219 -47751
103 -12685
146 -33698
32 -13313
257 -21926
128 -59543
230 -10715
143 -20414
321 -63231
175 -40717
330 -54153
45 -18219
206 -32360
221 -13502
165 -29523
127 -38572
274 -48505
119 -69320
269 -38015
299 -3...

output:

18072458474
52668
3365 19503
25493 25570
26039 16444
8527 10768
2591 21881
14615 11395
20851 2801
6129 6810
10252 8172
4508 2432
17424 21704
15478 14991
21275 4606
25209 16860
14165 17349
1443 6692
13562 22255
14440 5070
22420 3494
22082 15432
14896 13284
11743 17187
9441 13187
8011 13059
19729 660
...

result:

ok OK

Test #53:

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

input:

39003 91002
11436 11436
12763 12763
10046 10046
107006 7005
105857 5856
104058 4057
102957 2956
107027 7026
212219 12217
210006 10004
4447 4447
9459 9459
201951 1949
112330 12329
7056 7056
206340 6338
101937 1936
204772 4770
11771 11771
108598 8597
209445 9443
107149 7148
208448 8446
205726 5724
111...

output:

16156441344
52000
30689 15282
14132 23784
37653 24619
4521 13118
24977 19117
7688 26080
10191 12346
1426 16266
6231 24272
30113 19348
2000 38138
28690 32670
13863 1297
34776 9761
24900 6362
15969 8033
26196 31121
11625 12069
21459 13983
16861 33972
15526 12
6815 22158
19490 23239
208 3979
30028 1486...

result:

ok OK