QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#584083#6414. Classical Maximization Problemship2077WA 97ms21884kbC++231.6kb2024-09-23 08:04:242024-09-23 08:04:24

Judging History

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

  • [2024-09-23 08:04:24]
  • 评测
  • 测评结果:WA
  • 用时:97ms
  • 内存:21884kb
  • [2024-09-23 08:04:24]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int M=8e5+5;
bool vis[M],flag[M];
int n,num,x[M],y[M],lsh[M],dep[M];
vector<pair<int,int>>ans,adj[M];
int read(){
    int x=0;char ch=getchar();
    while (!isdigit(ch)) ch=getchar();
    while (isdigit(ch)) x=x*10+ch-48,ch=getchar();
    return x;
}
void dfs(int x,int f){
    vis[x]=1;int tmp=0;
    for (auto [y,z]:adj[x]){
        if (z==f) continue;
        if (!vis[y]) dep[y]=dep[x]+1,dfs(y,z);
        if (dep[y]>dep[x]){
            if (flag[z]) continue;
            if (!tmp) {tmp=z;continue;}
            ans.emplace_back(tmp,z);flag[tmp]=flag[z]=1;tmp=0;
        }
    }
    if (tmp&&f) ans.emplace_back(tmp,f),flag[tmp]=flag[f]=1;
}
void solve(){
    n=read()<<1;num=0;ans.clear();
    for (int i=1;i<=n;i++)
        x[i]=read(),y[i]=read(),
        lsh[++num]=x[i],lsh[++num]=y[i];
    sort(lsh+1,lsh+num+1);num=unique(lsh+1,lsh+num+1)-lsh-1;
    for (int i=1;i<=num<<1;i++) adj[i].clear(),vis[i]=0;
    for (int i=1;i<=n;i++) flag[i]=0;
    for (int i=1;i<=n;i++)
        x[i]=lower_bound(lsh+1,lsh+num+1,x[i])-lsh,
        y[i]=lower_bound(lsh+1,lsh+num+1,y[i])-lsh,
        adj[x[i]].emplace_back(y[i]+num,i),
        adj[y[i]+num].emplace_back(x[i],i);
    for (int i=1;i<=num<<1;i++)
        if (!vis[i]) dep[i]=0,dfs(i,0);
    printf("%d\n",(int)ans.size());
    for (int i=1,lst=0;i<=n;i++)
        if (!flag[i]){
            if (!lst) {lst=i;continue;}
            ans.emplace_back(lst,i);lst=0;
        }
    for (auto [x,y]:ans) printf("%d %d\n",x,y);
}
int main(){int T=read();while (T--) solve();return 0;}

詳細信息

Test #1:

score: 100
Accepted
time: 3ms
memory: 11956kb

input:

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

output:

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

result:

ok ok (3 test cases)

Test #2:

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

input:

10000
2
-107276936 -310501829
419434212 585811870
-65754386 -491212232
381152038 897148193
3
-474045168 493506332
299114415 540203303
165808153 983551
-506936261 -694189769
766718170 -725540031
975267148 -593051087
1
-818952276 -762387923
584023914 -612401389
6
-77701228 -266484128
659434465 6322062...

output:

0
1 2
3 4
0
1 2
3 4
5 6
0
1 2
0
1 2
3 4
5 6
7 8
9 10
11 12
0
1 2
3 4
5 6
7 8
9 10
11 12
13 14
0
1 2
0
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
21 22
23 24
25 26
27 28
29 30
31 32
33 34
35 36
37 38
39 40
41 42
43 44
45 46
47 48
49 50
51 52
53 54
55 56
57 58
59 60
61 62
63 64
65 66
0
1 2
3 4...

result:

ok ok (10000 test cases)

Test #3:

score: 0
Accepted
time: 53ms
memory: 9952kb

input:

10000
1
999855386 999580905
999342928 999615227
21
999601032 999015398
999155628 999176944
999309856 999524434
999121011 999509537
999323572 999685730
999272272 999769606
999450559 999390758
999632027 999178534
999024993 999463838
999784856 999374197
999980525 999366771
999241260 999516879
999599548...

output:

0
1 2
0
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
21 22
23 24
25 26
27 28
29 30
31 32
33 34
35 36
37 38
39 40
41 42
0
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
21 22
23 24
25 26
27 28
29 30
0
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
21 22
23 24
25 26
27 28
0
1 2
3 4
5 6
7...

result:

ok ok (10000 test cases)

Test #4:

score: 0
Accepted
time: 46ms
memory: 12048kb

input:

10000
5
999984799 999981445
999958394 999984217
999994978 999981258
999955539 999938710
999936554 999963561
999907222 999907508
999938166 999941959
999910567 999986887
999901446 999961092
999994730 999963038
5
999916115 999962400
999948250 999940355
999954204 999920844
999928148 999990369
999978118 ...

output:

0
1 2
3 4
5 6
7 8
9 10
0
1 2
3 4
5 6
7 8
9 10
0
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
21 22
0
1 2
3 4
5 6
7 8
0
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
21 22
23 24
25 26
27 28
29 30
31 32
0
1 2
3 4
5 6
7 8
9 10
0
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
0
1 2
3 4
5 6
7 8
9 10
1...

result:

ok ok (10000 test cases)

Test #5:

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

input:

10000
1
999990146 999993828
999995909 999996353
56
999999851 999991179
999997250 999997987
999990590 999997316
999997350 999996856
999997034 999996236
999999396 999996897
999991180 999993309
999991265 999995185
999993952 999994054
999990210 999994471
999993201 999995893
999997170 999998971
999998201...

output:

0
1 2
1
76 111
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
21 22
23 24
25 26
27 28
29 30
31 32
33 34
35 36
37 38
39 40
41 42
43 44
45 46
47 48
49 50
51 52
53 54
55 56
57 58
59 60
61 62
63 64
65 66
67 68
69 70
71 72
73 74
75 77
78 79
80 81
82 83
84 85
86 87
88 89
90 91
92 93
94 95
96 97
98 99
...

result:

ok ok (10000 test cases)

Test #6:

score: 0
Accepted
time: 50ms
memory: 12040kb

input:

10000
5
999999432 999999813
999999271 999999233
999999043 999999606
999999523 999999406
999999564 999999274
999999641 999999102
999999903 999999858
999999058 999999098
999999974 999999119
999999643 999999620
5
999999370 999999738
999999181 999999907
999999163 999999783
999999393 999999086
999999661 ...

output:

0
1 2
3 4
5 6
7 8
9 10
0
1 2
3 4
5 6
7 8
9 10
0
1 2
3 4
5 6
0
1 2
3 4
5 6
7 8
9 10
1
9 10
1 2
3 4
5 6
7 8
11 12
13 14
15 16
17 18
19 20
21 22
23 24
25 26
27 28
29 30
31 32
33 34
1
12 13
1 2
3 4
5 6
7 8
9 10
11 14
15 16
0
1 2
3 4
0
1 2
3 4
1
10 44
1 2
3 4
5 6
7 8
9 11
12 13
14 15
16 17
18 19
20 21
22...

result:

ok ok (10000 test cases)

Test #7:

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

input:

10000
14
-369804569 -904204119
526374829 -824374353
-127549933 -904204119
-68608787 929413707
-68608787 -363454459
526374829 929413707
693313139 -824374353
-127549933 -726843762
526374829 -904204119
526374829 -363454459
526374829 -409731440
693313139 -726843762
693313139 929413707
-68608787 -8243743...

output:

14
20 25
1 3
17 19
26 8
12 24
27 28
7 21
22 2
9 10
11 15
6 13
18 4
5 14
16 23
20
8 3
1 10
9 27
13 37
11 18
31 34
2 14
19 25
39 26
33 35
15 24
28 12
21 30
7 22
32 38
4 17
23 29
5 6
16 20
36 40
8
9 10
12 14
16 5
1 6
8 7
11 2
3 4
13 15
1
1 2
1
2 1
34
8 41
17 1
57 7
18 30
37 63
3 16
52 59
15 40
43 10
12...

result:

ok ok (10000 test cases)

Test #8:

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

input:

10000
5
-536123007 813600068
870612905 -192916365
-891077277 -192916365
-169354047 -86845158
-204880568 -86845158
-909192812 -613162163
-536123007 -613162163
602684169 -613162163
-909192812 813600068
602684169 -86845158
3
-296375355 579758813
-296375355 253508589
-296375355 -927878827
267975935 -927...

output:

5
1 9
6 7
8 10
5 4
3 2
3
1 2
6 3
4 5
5
7 10
5 4
2 6
8 1
3 9
5
6 3
4 5
7 1
10 9
8 2
5
1 2
3 4
5 6
7 8
9 10
2
4 6
3 5
1 2
1
1 2
13
2 3
14 15
11 13
16 6
20 26
1 9
19 18
12 10
8 22
23 24
25 4
5 21
7 17
4
4 10
6 8
1 9
3 2
5 7
3
6 4
1 5
3 2
2
2 3
4 1
5
1 5
8 10
9 6
2 3
7 4
7
7 13
3 10
8 1
15 5
16 11
6 9
4...

result:

ok ok (10000 test cases)

Test #9:

score: 0
Accepted
time: 54ms
memory: 12012kb

input:

10000
13
38708650 -400244265
805800882 -207412170
-922757982 569623504
330308285 -400244265
-922757982 193222226
330308285 -701148819
-28889088 854967427
284328781 704931219
-397379302 854967427
284328781 252366771
-699696493 -701148819
953729077 -601089169
-858131099 -701148819
-397379302 193222226...

output:

12
3 5
10 8
22 26
1 4
17 18
15 13
11 6
24 14
20 9
7 16
12 25
2 21
19 23
18
1 3
2 10
11 14
15 17
20 22
23 25
26 28
30 33
34 36
31 4
6 7
8 9
12 13
16 18
19 21
24 27
29 32
35 5
7
3 6
1 2
14 13
4 9
8 11
5 7
10 16
12 15
3
1 2
3 5
6 4
1
3 4
1 2
2
1 4
3 2
8
1 4
5 6
9 12
16 13
2 3
7 8
11 14
15 10
3
8 4
1 7
...

result:

ok ok (10000 test cases)

Test #10:

score: 0
Accepted
time: 39ms
memory: 12120kb

input:

10000
2
-254673318 743896676
326182652 743896676
115024593 743896676
989112001 743896676
1
453875458 284043499
869627863 284043499
8
-68955663 625858753
-621253434 625858753
-315653340 625858753
-85160525 625858753
-592616333 625858753
114285020 625858753
618762545 625858753
524402507 625858753
1512...

output:

2
1 2
4 3
1
2 1
8
2 3
4 5
6 7
8 9
10 11
12 13
14 15
16 1
12
1 2
3 4
6 7
8 9
10 11
12 13
14 15
16 17
18 19
20 21
22 23
24 5
8
1 2
4 5
6 7
8 9
10 11
12 13
14 15
16 3
6
1 2
3 4
5 6
7 8
9 10
12 11
13
1 2
3 4
5 6
8 9
10 11
12 13
14 15
16 17
18 19
20 21
22 23
24 25
26 7
6
1 2
3 5
6 7
8 9
10 11
12 4
1
1 2
...

result:

ok ok (10000 test cases)

Test #11:

score: 0
Accepted
time: 42ms
memory: 12032kb

input:

10000
10
-302093372 -991014187
542702243 714369751
-370626462 -991014187
-700169063 714369751
-982732066 -991014187
-763837020 -991014187
320477527 -991014187
290144737 -991014187
18975042 -991014187
-339021181 -991014187
-525462052 -991014187
290144737 714369751
-538375359 714369751
15943074 -99101...

output:

10
1 3
2 4
12 13
15 19
20 16
5 6
7 8
9 10
11 17
18 14
10
1 3
6 7
8 9
17 19
20 18
2 4
5 10
11 13
14 16
12 15
18
3 6
7 10
11 15
21 22
25 26
28 31
33 35
36 14
1 2
4 5
8 9
12 13
16 17
18 19
20 23
24 27
30 34
29 32
35
1 2
5 6
12 13
14 16
17 20
23 24
26 27
30 31
32 35
38 39
41 42
48 51
52 57
61 63
65 66
6...

result:

ok ok (10000 test cases)

Test #12:

score: 0
Accepted
time: 46ms
memory: 12116kb

input:

10000
5
192354975 -209258445
955055576 -209258445
286707627 -209258445
-574795734 -209258445
-305243931 -209258445
-629755833 -209258445
-337515030 -209258445
980285884 -209258445
501317910 -209258445
312382135 -209258445
24
272466007 467288536
-963587196 -778274012
240097765 -778274012
-926564605 4...

output:

5
2 3
4 5
6 7
8 9
10 1
24
1 4
8 10
13 18
20 21
23 25
31 32
35 36
39 41
43 44
47 9
2 3
5 6
7 11
14 15
16 19
22 24
26 27
28 29
30 33
34 37
38 40
42 45
46 48
12 17
30
1 5
6 7
11 13
14 18
21 23
24 28
29 30
31 32
33 39
43 45
46 49
53 54
55 58
59 60
41 2
3 4
8 9
10 12
15 16
17 20
22 25
26 27
34 35
36 37
3...

result:

ok ok (10000 test cases)

Test #13:

score: 0
Accepted
time: 30ms
memory: 10132kb

input:

10000
11
135813326 608040171
135813326 -96255413
135813326 -31734533
135813326 -423296887
135813326 999444876
135813326 946760362
135813326 -599331154
135813326 -441599790
135813326 233339336
135813326 -759375115
135813326 163868817
135813326 321091518
135813326 -402236877
135813326 625124369
135813...

output:

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

result:

ok ok (10000 test cases)

Test #14:

score: 0
Accepted
time: 46ms
memory: 12032kb

input:

10000
19
321791336 -226466052
321791336 138757626
321791336 -613429828
944682716 -446131303
321791336 -927463006
944682716 280242351
944682716 229347131
944682716 155568891
321791336 389911916
944682716 72836839
944682716 -613429828
321791336 229347131
944682716 -927463006
944682716 138757626
321791...

output:

19
4 6
7 8
10 11
13 14
18 19
20 23
26 27
29 31
32 33
36 37
16 1
2 3
5 9
12 15
17 21
22 24
25 28
30 34
35 38
19
1 2
4 9
10 11
14 15
20 21
22 24
25 28
30 32
36 12
3 5
6 7
8 13
16 17
18 19
23 26
27 29
31 33
34 35
37 38
8
1 2
3 5
8 9
16 4
6 7
10 11
12 13
14 15
4
1 3
6 8
7 2
4 5
6
1 2
3 4
5 6
7 8
9 10
11...

result:

ok ok (10000 test cases)

Test #15:

score: 0
Accepted
time: 41ms
memory: 10036kb

input:

10000
2
414226098 -53411011
414226098 -515361565
-572270323 -515361565
-572270323 -53411011
36
660074753 623771687
-917096747 533975361
660074753 337851674
-917096747 -902052044
-917096747 846238046
660074753 197157825
660074753 533975361
660074753 626049519
-917096747 -108293477
-917096747 64055247...

output:

2
3 4
1 2
36
2 4
5 9
10 13
14 16
18 19
20 22
23 25
30 31
32 33
35 36
38 40
42 43
46 48
51 58
62 63
68 69
71 52
1 3
6 7
8 11
12 15
17 21
24 26
27 28
29 34
37 39
41 44
45 47
49 50
53 54
55 56
57 59
60 61
64 65
66 67
70 72
1
1 2
27
2 6
8 11
12 14
15 16
17 18
19 20
22 23
25 31
32 33
35 38
39 40
42 44
46...

result:

ok ok (10000 test cases)

Test #16:

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

input:

10000
6
475408912 -758469962
-99052258 -758469962
-716758863 872897211
-66386054 -170278720
388817201 174925294
-776227900 -285032873
475408912 872897211
-997698204 -236300379
-716758863 -85108619
-776227900 -85108619
-716758863 -236300379
-66386054 -85108619
26
879874105 877328664
-286895493 621573...

output:

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

result:

ok ok (10000 test cases)

Test #17:

score: 0
Accepted
time: 53ms
memory: 12004kb

input:

10000
9
-980409638 -116749812
830791554 -690170434
984923479 323045898
984923479 -116749812
-197520273 323045898
-858897130 -43820432
258471629 -979749918
258471629 -690170434
-858897130 323045898
105960247 -690170434
-197520273 -841854666
-234415044 -116749812
105960247 323045898
-358435325 -202957...

output:

8
16 14
15 18
7 8
2 10
1 12
4 3
11 5
6 9
13 17
14
9 24
5 1
31 12
25 23
15 32
16 26
2 6
14 8
29 7
4 10
13 27
11 18
22 19
30 17
3 20
21 28
33 34
11
8 2
3 16
21 4
19 20
9 11
12 22
10 5
15 7
17 1
6 13
14 18
4
1 5
8 2
4 3
6 7
9
11 20
8 13
3 5
12 17
16 22
6 18
7 1
4 14
2 15
9 10
19 21
4
3 5
6 8
1 2
4 7
13...

result:

ok ok (10000 test cases)

Test #18:

score: 0
Accepted
time: 63ms
memory: 12276kb

input:

1000
45
840710004 395646135
-851514725 100215150
-423513540 -649756636
464326407 -482837664
-179781718 755995077
492651722 -268519233
367302062 -111998374
494634876 842096727
973319201 399526783
-703731734 -989899930
758934136 -959677785
-682507454 58961947
394206800 272218663
752299573 489795348
89...

output:

0
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
21 22
23 24
25 26
27 28
29 30
31 32
33 34
35 36
37 38
39 40
41 42
43 44
45 46
47 48
49 50
51 52
53 54
55 56
57 58
59 60
61 62
63 64
65 66
67 68
69 70
71 72
73 74
75 76
77 78
79 80
81 82
83 84
85 86
87 88
89 90
0
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15...

result:

ok ok (1000 test cases)

Test #19:

score: 0
Accepted
time: 64ms
memory: 12296kb

input:

1000
113
999827252 999728856
999923862 999631025
999319008 999580013
999333375 999174260
999509073 999545469
999194399 999278837
999715162 999728030
999881205 999764413
999917667 999953211
999651496 999869003
999693536 999169883
999545275 999786246
999969774 999735073
999892216 999697498
999954099 9...

output:

0
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
21 22
23 24
25 26
27 28
29 30
31 32
33 34
35 36
37 38
39 40
41 42
43 44
45 46
47 48
49 50
51 52
53 54
55 56
57 58
59 60
61 62
63 64
65 66
67 68
69 70
71 72
73 74
75 76
77 78
79 80
81 82
83 84
85 86
87 88
89 90
91 92
93 94
95 96
97 98
99 100
101 10...

result:

ok ok (1000 test cases)

Test #20:

score: 0
Accepted
time: 60ms
memory: 10192kb

input:

1000
16
999918424 999907758
999901558 999910407
999969229 999929343
999986216 999968746
999977167 999921267
999967186 999932634
999999615 999951539
999964903 999931387
999942189 999989158
999990624 999917294
999964661 999935732
999971224 999975496
999972707 999972034
999935060 999934824
999992448 99...

output:

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

result:

ok ok (1000 test cases)

Test #21:

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

input:

1000
227
999994296 999999816
999998835 999994618
999998487 999991646
999995178 999996563
999996865 999996231
999990660 999996917
999995746 999998295
999993178 999995596
999994361 999991179
999990519 999991221
999996210 999992041
999991924 999992546
999991346 999991081
999998929 999995904
999992182 9...

output:

21
148 177
340 442
9 363
10 163
145 135
180 203
100 176
322 235
22 49
128 436
172 367
43 351
112 231
263 300
278 109
124 368
3 253
297 405
142 448
90 247
315 378
1 2
4 5
6 7
8 11
12 13
14 15
16 17
18 19
20 21
23 24
25 26
27 28
29 30
31 32
33 34
35 36
37 38
39 40
41 42
44 45
46 47
48 50
51 52
53 54
5...

result:

ok ok (1000 test cases)

Test #22:

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

input:

1000
87
999999138 999999640
999999785 999999342
999999914 999999854
999999771 999999416
999999011 999999479
999999217 999999865
999999423 999999937
999999684 999999301
999999323 999999399
999999071 999999949
999999226 999999154
999999770 999999090
999999778 999999735
999999034 999999517
999999803 99...

output:

23
80 54
47 165
135 139
10 75
92 132
104 26
110 71
70 6
29 86
166 111
142 155
15 23
51 124
131 149
83 27
16 162
72 112
65 115
12 98
143 161
158 168
159 164
121 56
1 2
3 4
5 7
8 9
11 13
14 17
18 19
20 21
22 24
25 28
30 31
32 33
34 35
36 37
38 39
40 41
42 43
44 45
46 48
49 50
52 53
55 57
58 59
60 61
6...

result:

ok ok (1000 test cases)

Test #23:

score: 0
Accepted
time: 44ms
memory: 10140kb

input:

1000
154
825004796 802565417
-88001579 364640592
778546546 -57508543
283686672 -57508543
473326798 -826011553
152069566 -577222261
528378065 -577222261
-56296909 -700802856
-711386984 953035370
-711386984 -577222261
895677144 -359290436
840183000 364640592
528378065 -752921798
895677144 -577222261
8...

output:

154
207 215
278 292
104 158
62 132
183 1
76 302
116 144
250 9
28 170
185 17
38 152
196 290
22 192
217 231
284 18
108 165
198 234
289 53
212 219
240 291
303 35
45 49
122 201
261 282
97 111
180 228
236 251
272 60
92 147
239 267
283 29
129 131
232 260
268 307
13 47
70 95
102 195
298 299
80 127
174 176
...

result:

ok ok (1000 test cases)

Test #24:

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

input:

1000
63
859289659 -203061342
831821977 -778714404
640602188 478366497
205686723 -232506600
831821977 -498015901
-494818974 35295117
612307834 -234198721
612307834 -495294231
-898414633 476295237
995217164 -232506600
831821977 934046031
-441937174 432603845
995217164 938111737
874550198 -309423823
87...

output:

63
3 76
6 41
13 36
96 10
35 115
14 15
104 110
124 116
70 79
106 109
4 90
94 99
22 31
62 78
30 39
52 86
120 71
56 123
103 63
42 54
74 97
119 12
38 72
98 107
117 32
51 83
113 121
126 19
57 81
9 47
50 100
40 93
118 2
5 11
37 69
80 87
88 111
43 49
33 44
61 67
102 108
53 55
17 105
66 20
46 77
64 26
29 85...

result:

ok ok (1000 test cases)

Test #25:

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

input:

1000
83
-242219535 -952757420
753940135 -13368420
-180286961 -530756654
586180284 -625675517
-437809383 472014390
-242857851 -924097244
-382920283 -625675517
-630990620 -349004314
-242219535 122507147
208821889 -495849186
-736086757 -489441806
-996984615 -974276781
-275306966 -25109596
967186464 -65...

output:

83
77 3
39 46
158 17
114 125
6 146
24 120
135 32
8 93
162 161
49 107
75 73
23 109
122 136
153 50
145 106
59 119
67 87
105 134
160 110
138 21
38 62
16 65
70 157
141 97
57 123
76 129
90 88
149 54
41 64
155 164
80 18
33 36
99 127
132 35
83 98
140 147
5 152
19 31
126 156
163 43
85 96
45 111
10 115
25 13...

result:

ok ok (1000 test cases)

Test #26:

score: 0
Accepted
time: 39ms
memory: 13876kb

input:

1000
142
-28949259 975363136
-628367037 975363136
786525293 975363136
-8339801 975363136
868048337 975363136
208733157 975363136
-724415150 975363136
213367214 975363136
-686387505 975363136
-970451747 975363136
761135553 975363136
-551594491 975363136
-925080593 975363136
-243465321 975363136
-6722...

output:

142
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
21 22
23 24
25 26
27 28
29 30
31 32
33 34
35 36
37 38
39 40
41 42
43 44
45 46
47 48
49 50
51 52
53 54
55 56
57 58
59 60
61 62
64 65
66 67
68 69
70 71
72 73
74 75
76 77
78 79
80 81
82 83
84 85
86 87
88 89
90 91
92 93
94 95
96 97
98 99
100 101
102...

result:

ok ok (1000 test cases)

Test #27:

score: 0
Accepted
time: 46ms
memory: 13300kb

input:

1000
458
102600109 754726017
-66999931 951825513
-767202008 951825513
-845069119 754726017
-448344214 754726017
174342794 754726017
176530329 754726017
553731053 754726017
-69189351 754726017
-455330522 951825513
-261324017 754726017
809818684 951825513
745593756 951825513
-130095774 754726017
-2737...

output:

458
1 4
5 6
7 8
9 11
14 16
17 18
19 22
24 27
29 30
31 32
35 41
43 45
47 54
55 58
59 61
62 65
66 68
69 73
74 81
82 83
85 87
90 94
100 103
104 105
107 109
112 113
114 115
116 118
120 121
124 129
130 131
132 136
137 139
141 142
144 145
146 147
148 154
156 157
158 159
160 161
162 164
167 169
171 172
173...

result:

ok ok (1000 test cases)

Test #28:

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

input:

1000
273
638010636 -796267612
299279783 -796267612
321987052 -571635029
-388046291 -571635029
-491314021 -796267612
130988206 -571635029
32427063 -571635029
51875304 -571635029
-508530089 -796267612
269379692 -571635029
214241513 -796267612
720122947 -796267612
-678543365 -796267612
158504867 -79626...

output:

273
3 4
6 7
8 10
16 17
20 21
22 24
25 26
30 34
43 44
45 50
52 53
56 57
58 60
61 62
64 66
67 68
70 73
79 81
83 84
86 89
92 93
94 99
100 101
106 107
110 114
117 119
121 124
125 127
130 131
133 134
135 138
140 145
148 149
157 160
161 163
166 172
173 176
177 179
180 181
185 186
187 188
190 192
193 194
1...

result:

ok ok (1000 test cases)

Test #29:

score: 0
Accepted
time: 43ms
memory: 13276kb

input:

1000
75
429681826 802800421
429681826 -608943566
429681826 -787858696
429681826 507047252
429681826 485971873
429681826 -346306621
429681826 -612405192
429681826 -13671560
429681826 -816374335
429681826 513226316
429681826 892335083
429681826 -352600432
429681826 -556540475
429681826 -504699273
4296...

output:

75
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
21 22
23 24
25 26
27 28
29 30
31 32
33 34
35 36
37 38
39 40
41 42
43 44
45 46
47 48
49 50
51 52
53 54
55 56
57 58
59 60
61 62
63 64
65 66
67 68
69 70
71 72
73 74
75 76
77 78
79 80
81 82
83 84
85 86
87 88
89 90
91 92
93 94
95 96
97 98
99 100
101 1...

result:

ok ok (1000 test cases)

Test #30:

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

input:

1000
81
403001151 -229966312
-27290952 -941247950
-27290952 -872808715
403001151 -81762908
403001151 825473197
403001151 730971412
403001151 -886560490
-27290952 394200417
-27290952 808677817
-27290952 -961778274
-27290952 -245434545
403001151 318019109
-27290952 792029613
403001151 390473732
-27290...

output:

81
2 3
1 4
5 6
7 12
14 16
18 20
22 28
29 31
34 36
37 41
42 43
48 49
51 52
53 54
55 57
58 60
61 62
65 66
67 68
69 70
73 74
75 79
80 85
86 87
88 89
90 92
93 95
96 98
103 104
105 113
117 118
119 120
121 124
125 129
134 137
141 142
144 145
147 148
149 158
159 161
162 56
8 9
10 11
13 15
17 19
21 23
24 25...

result:

ok ok (1000 test cases)

Test #31:

score: 0
Accepted
time: 50ms
memory: 12756kb

input:

1000
257
-24981531 -524783010
-24981531 376842743
132542945 905111237
-24981531 -663183576
132542945 238995240
-24981531 -904084630
132542945 330336577
-24981531 -424310756
132542945 26224857
-24981531 573604180
132542945 -531956470
132542945 583434945
132542945 620552707
-24981531 -351085713
132542...

output:

257
3 5
7 9
11 12
13 15
20 22
23 25
28 29
34 35
36 38
39 40
41 42
44 46
49 51
52 53
56 57
58 61
62 64
65 66
68 74
75 76
77 78
81 82
83 85
86 87
89 92
94 99
100 107
110 114
117 118
120 121
122 124
128 129
130 131
133 136
139 142
143 144
149 151
152 153
154 155
157 163
168 174
179 188
189 190
191 193
...

result:

ok ok (1000 test cases)

Test #32:

score: 0
Accepted
time: 45ms
memory: 12848kb

input:

1000
21
541263298 571344162
-338833794 258719906
814556806 571344162
749911951 -730958945
-737751671 400747496
880311857 -204125795
-555645311 -832036787
-338833794 -832036787
582588235 -915718735
-124654808 394321598
-202932677 571344162
541263298 -975674793
880311857 -730958945
-126659351 25871990...

output:

21
33 9
3 11
14 2
8 28
32 7
10 19
24 42
31 41
15 16
20 39
17 18
25 26
36 40
1 12
4 29
13 27
6 37
30 21
5 34
38 22
23 35
37
38 54
61 74
7 5
19 28
34 35
39 48
51 2
3 18
32 49
47 25
24 30
37 57
62 69
71 21
12 20
31 41
65 58
6 9
13 17
29 43
53 56
66 67
70 64
10 16
22 44
46 52
55 4
33 36
60 15
23 63
8 27...

result:

ok ok (1000 test cases)

Test #33:

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

input:

1000
82
620344713 761205214
564192450 -149133296
855072748 -725730286
-369866361 761205214
-126903403 123500699
521658307 -238068427
564192450 -575382074
424528213 639391487
160949070 -238068427
490683515 736060786
-861287945 -430077137
92203881 -414548921
-228263452 -161807552
-739623881 619906932
...

output:

79
16 76
39 69
131 142
6 9
12 148
161 90
15 50
33 160
129 49
34 25
3 27
127 44
46 10
71 158
17 23
55 91
13 51
121 122
68 40
62 45
119 11
77 87
20 47
59 64
140 141
106 19
113 100
30 52
36 56
139 99
22 28
118 2
7 98
120 159
112 73
37 128
89 94
85 83
104 134
152 21
66 81
107 136
133 58
65 93
96 101
41 ...

result:

ok ok (1000 test cases)

Test #34:

score: 0
Accepted
time: 83ms
memory: 14604kb

input:

100
715
-716037174 449787280
-179603495 267807227
-85847745 -339745287
531498593 906672966
-65182647 -249655497
196101865 -917254384
569704541 175181937
408949063 -60772621
-471098833 -180592225
452882519 -173474204
518554869 504642822
-610596606 -43048739
-173418328 49620755
-490214353 129314297
-8...

output:

0
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
21 22
23 24
25 26
27 28
29 30
31 32
33 34
35 36
37 38
39 40
41 42
43 44
45 46
47 48
49 50
51 52
53 54
55 56
57 58
59 60
61 62
63 64
65 66
67 68
69 70
71 72
73 74
75 76
77 78
79 80
81 82
83 84
85 86
87 88
89 90
91 92
93 94
95 96
97 98
99 100
101 10...

result:

ok ok (100 test cases)

Test #35:

score: 0
Accepted
time: 71ms
memory: 13896kb

input:

100
1180
999939181 999607824
999877463 999501538
999725395 999197028
999578614 999669422
999691207 999388141
999798382 999350154
999515140 999686861
999804739 999722876
999059909 999779016
999988075 999795096
999394228 999790648
999357316 999130743
999834412 999146926
999533794 999419507
999164265 9...

output:

2
294 1956
485 2069
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
21 22
23 24
25 26
27 28
29 30
31 32
33 34
35 36
37 38
39 40
41 42
43 44
45 46
47 48
49 50
51 52
53 54
55 56
57 58
59 60
61 62
63 64
65 66
67 68
69 70
71 72
73 74
75 76
77 78
79 80
81 82
83 84
85 86
87 88
89 90
91 92
93 94
95 96
9...

result:

ok ok (100 test cases)

Test #36:

score: 0
Accepted
time: 75ms
memory: 13788kb

input:

100
10
999949463 999921247
999942779 999933524
999900374 999919960
999913527 999977190
999963539 999919222
999986393 999982382
999960627 999912715
999955900 999934316
999962876 999904282
999944172 999923360
999974177 999993968
999960412 999941887
999902083 999920318
999906832 999942948
999934454 999...

output:

0
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
0
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
21 22
23 24
25 26
27 28
29 30
31 32
33 34
35 36
37 38
39 40
41 42
43 44
45 46
47 48
49 50
51 52
53 54
55 56
57 58
59 60
61 62
63 64
65 66
67 68
69 70
71 72
73 74
75 76
77 78
79 80
81 82
83 84
85...

result:

ok ok (100 test cases)

Test #37:

score: 0
Accepted
time: 78ms
memory: 13360kb

input:

100
2795
999995625 999994422
999997406 999998890
999996073 999998910
999996365 999992345
999992211 999999534
999990826 999998894
999990827 999999648
999991569 999997094
999997323 999994792
999990812 999994722
999994392 999998879
999994441 999990381
999992051 999993298
999997822 999994423
999998285 9...

output:

1710
2563 926
78 2540
4669 1569
1970 530
4891 2589
5338 1024
2582 3056
851 3839
51 351
3380 5194
2356 4777
1974 4263
2538 4787
3834 2709
1959 588
158 1607
3344 1648
3887 700
1632 879
294 1159
4795 36
1614 3252
2089 3987
4316 1870
1230 443
3450 3500
5564 1756
1240 2785
199 4124
1115 3580
559 4535
108...

result:

ok ok (100 test cases)

Test #38:

score: 0
Accepted
time: 67ms
memory: 10552kb

input:

100
1005
999999258 999999564
999999716 999999506
999999057 999999959
999999274 999999385
999999562 999999714
999999749 999999926
999999159 999999330
999999060 999999408
999999218 999999582
999999097 999999761
999999853 999999231
999999424 999999841
999999744 999999186
999999400 999999073
999999445 9...

output:

985
185 1837
1645 112
719 303
1287 102
529 971
516 1636
286 930
1103 1120
264 324
427 632
240 727
702 64
1830 564
531 694
651 660
1846 735
482 1537
771 131
1441 414
1127 650
497 1434
1530 1021
1921 222
273 1767
115 141
957 454
150 368
899 224
223 1320
1470 122
942 1660
315 327
1209 505
1911 800
22 7...

result:

ok ok (100 test cases)

Test #39:

score: 0
Accepted
time: 43ms
memory: 14552kb

input:

100
174
-958876330 -846470800
-796741809 -131152725
574295122 764287642
-958876330 -825762193
185468313 -971066749
-287559769 764287642
-904746093 -825762193
-438778854 -825762193
5267152 609322023
185468313 77515090
185468313 -131152725
-287559769 247199580
-491475497 260165013
719679418 -179087066...

output:

174
303 127
13 129
32 48
68 234
278 59
217 35
126 174
195 181
221 296
297 40
41 97
188 283
54 158
196 299
339 21
51 87
124 176
250 79
99 130
238 253
346 85
113 145
169 175
224 274
117 167
192 200
230 275
306 14
162 163
164 258
272 315
316 15
78 141
151 153
284 312
333 77
116 139
157 173
198 252
307 ...

result:

ok ok (100 test cases)

Test #40:

score: 0
Accepted
time: 63ms
memory: 13356kb

input:

100
454
292487349 -708917766
-446575764 -920302303
373857024 -525302786
236159958 -877034512
240035307 -28559828
-156425976 29793081
-683968223 -28559828
658545653 -892201965
-485118423 -349005511
-677465608 102959577
-241309351 -615266668
-857580103 -877034512
590882873 69859569
-961101806 -2385646...

output:

454
34 89
49 60
33 77
21 50
145 148
112 113
68 108
142 170
40 117
174 193
226 256
298 334
354 412
432 471
473 574
602 604
645 719
771 824
882 605
16 26
86 98
105 147
169 209
212 215
265 307
309 315
318 332
338 415
11 84
177 258
267 319
347 359
4 12
69 300
335 369
391 406
410 535
714 795
3 55
57 158
...

result:

ok ok (100 test cases)

Test #41:

score: 0
Accepted
time: 66ms
memory: 14164kb

input:

100
140
229220674 878836488
-506767178 293730975
960642833 878836488
485659386 878836488
-225376185 16183205
-322465048 -460955536
-635701181 878836488
-578723152 374559636
956924322 878836488
-666563369 -550449367
-240963901 374559636
9519098 374559636
404598294 16183205
-188062738 467646265
937074...

output:

140
2 19
5 13
16 21
44 47
84 91
111 112
134 139
152 159
167 176
177 180
212 225
252 256
264 277
25 33
26 67
81 86
87 89
92 93
101 137
153 155
163 174
175 178
214 233
246 253
255 266
271 238
28 37
43 46
59 64
65 72
77 97
109 113
116 130
138 143
146 158
168 190
197 206
215 219
222 224
228 231
240 259
...

result:

ok ok (100 test cases)

Test #42:

score: 0
Accepted
time: 42ms
memory: 12144kb

input:

100
453
-9728842 -879506383
723264369 -879506383
-617602947 -879506383
-883543546 -879506383
-365459776 -879506383
259863014 -879506383
-229024413 -879506383
-357634378 -879506383
45613473 -879506383
897413515 -879506383
142722904 -879506383
308356916 -879506383
-528467703 -879506383
45803942 -87950...

output:

453
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
21 22
23 24
25 26
27 28
29 30
31 32
33 34
35 36
37 38
39 40
41 42
43 44
45 46
47 48
49 50
51 52
53 54
55 56
57 58
59 60
61 62
63 64
65 66
67 68
69 70
71 72
73 74
75 76
77 78
79 80
81 82
83 84
85 86
87 88
89 90
91 92
93 94
95 96
97 98
99 100
101 ...

result:

ok ok (100 test cases)

Test #43:

score: 0
Accepted
time: 54ms
memory: 14336kb

input:

100
1681
-648014211 -216027092
-372352298 95789050
-678908480 95789050
-382412165 95789050
214922606 95789050
45021991 95789050
131451784 95789050
926607022 -216027092
-500711391 95789050
527775426 -216027092
860331657 95789050
-255764825 95789050
314154093 -216027092
-631103238 95789050
292792358 9...

output:

1681
1 8
2 3
4 5
6 7
9 11
12 14
15 18
19 21
22 25
26 28
30 31
32 33
34 37
39 40
41 44
46 47
48 49
50 52
54 56
59 60
61 65
68 69
74 75
77 79
80 81
82 87
88 90
93 94
95 97
99 100
102 103
104 107
108 110
111 113
116 120
123 125
126 127
128 129
131 132
134 135
136 138
140 141
143 144
146 147
148 150
154...

result:

ok ok (100 test cases)

Test #44:

score: 0
Accepted
time: 57ms
memory: 14028kb

input:

100
476
218894313 -685169320
967098661 -16626457
-797375436 -16626457
955557493 -16626457
54133572 -16626457
-722192690 -16626457
791557373 -16626457
-208166285 -685169320
185917393 -16626457
-338707386 -16626457
49911294 -16626457
-359502368 -685169320
-359176146 -685169320
430103061 -16626457
-744...

output:

476
2 3
4 5
6 7
9 10
11 14
15 16
17 21
24 27
28 29
34 35
36 37
41 42
43 44
45 46
47 48
50 51
52 55
59 60
61 62
63 64
67 69
70 73
76 78
79 83
85 88
90 91
92 94
97 98
100 101
102 105
107 109
111 113
118 119
121 125
126 127
137 138
139 142
143 145
148 150
151 153
156 161
162 163
164 165
171 172
173 174...

result:

ok ok (100 test cases)

Test #45:

score: 0
Accepted
time: 54ms
memory: 16408kb

input:

100
1281
-7127937 -551225280
-7127937 -63829747
-7127937 50255920
-7127937 685959203
-7127937 -474730627
-7127937 205475943
-7127937 894868084
-7127937 -262984557
-7127937 858324856
-7127937 257534742
-7127937 -640954010
-7127937 -111367493
-7127937 892100661
-7127937 696606550
-7127937 136498536
-7...

output:

1281
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
21 22
23 24
25 26
27 28
29 30
31 32
33 34
35 36
37 38
39 40
41 42
43 44
45 46
47 48
49 50
51 52
53 54
55 56
57 58
59 60
61 62
63 64
65 66
67 68
69 70
71 72
73 74
75 76
77 78
79 80
81 82
83 84
85 86
87 88
89 90
91 92
93 94
95 96
97 98
99 100
101...

result:

ok ok (100 test cases)

Test #46:

score: 0
Accepted
time: 57ms
memory: 12088kb

input:

100
2300
930979038 -865442548
56354538 569246647
930979038 209346563
930979038 -402151796
56354538 9788037
930979038 349210639
930979038 113353815
56354538 -508882748
56354538 -390359400
930979038 881411592
56354538 328521324
56354538 569030395
56354538 749112678
930979038 -492654973
930979038 -5806...

output:

2300
1 3
4 6
7 10
14 15
16 17
19 20
21 24
25 30
31 33
35 36
39 44
45 46
51 52
54 55
56 57
58 59
67 68
69 73
75 77
79 80
81 82
84 86
89 90
91 92
93 98
99 101
102 103
104 109
110 114
115 117
118 119
120 121
122 125
126 127
128 129
131 134
143 144
145 146
147 148
149 151
152 154
157 158
160 161
164 166...

result:

ok ok (100 test cases)

Test #47:

score: 0
Accepted
time: 57ms
memory: 14616kb

input:

100
393
484804995 -671233294
484804995 45381500
-343734967 483744892
-343734967 -678278044
-343734967 430018594
484804995 -536133521
-343734967 972761171
-343734967 188883545
484804995 291634094
484804995 161326893
484804995 43447237
-343734967 81642646
-343734967 905579532
484804995 -838456546
4848...

output:

393
1 2
6 9
10 11
14 15
17 18
19 20
21 22
23 26
27 28
30 31
35 37
38 41
45 50
51 52
54 55
56 57
58 59
60 62
65 66
69 71
73 74
80 81
82 87
89 91
92 93
94 95
96 97
107 108
109 113
119 122
125 128
129 130
131 132
134 135
136 137
139 142
145 146
152 155
156 158
159 164
165 166
167 170
172 176
179 181
18...

result:

ok ok (100 test cases)

Test #48:

score: 0
Accepted
time: 57ms
memory: 12808kb

input:

100
2245
257511569 -570888823
-409065975 834451934
972932318 -206332685
-220073979 -895107571
819486773 -206332685
819823298 -570888823
116295608 282026121
589205449 -895107571
-54658019 -895107571
987042524 -206332685
-196884689 282026121
-940822451 993058719
402874649 -895107571
633334868 99305871...

output:

2245
12 14
24 40
47 63
70 74
77 82
83 84
94 112
143 149
180 189
202 205
206 209
216 226
229 237
242 243
244 245
246 259
273 281
289 290
291 294
300 302
303 306
308 314
327 330
341 344
355 368
378 387
398 408
413 415
438 477
486 491
501 510
520 529
535 541
548 555
557 560
561 566
570 572
576 582
587 ...

result:

ok ok (100 test cases)

Test #49:

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

input:

100
116
-28349829 -267772969
-181233169 605639981
-221792554 885875755
-8847461 376377302
-527881168 376377302
-794286947 885875755
-442516480 365428090
60367949 59687335
844852200 -267772969
70152464 -267772969
-326579976 59687335
-382146420 885875755
-305012413 376377302
-255659827 495623398
84485...

output:

116
8 11
7 24
46 61
78 86
109 131
135 165
186 210
213 215
170 31
37 42
43 50
65 67
82 83
90 92
113 127
168 176
179 181
197 198
211 227
228 162
2 20
21 26
44 68
79 85
112 116
124 132
145 150
172 188
190 192
202 41
206 4
5 13
29 45
58 76
93 97
105 121
125 137
152 155
166 167
200 209
69 54
74 89
99 100...

result:

ok ok (100 test cases)

Test #50:

score: -100
Wrong Answer
time: 97ms
memory: 21884kb

input:

10
10568
266619539 928993099
644537002 -163339024
-965315605 131093436
-873401839 -319727236
-682029920 -699502948
-857838819 -528950378
126750467 -72275669
623580094 410832833
287731394 -865265684
-71034303 515678565
-897514612 929674238
-794392375 895647772
811715826 600060479
640892543 -557248887...

output:

1
10705 17482
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
21 22
23 24
25 26
27 28
29 30
31 32
33 34
35 36
37 38
39 40
41 42
43 44
45 46
47 48
49 50
51 52
53 54
55 56
57 58
59 60
61 62
63 64
65 66
67 68
69 70
71 72
73 74
75 76
77 78
79 80
81 82
83 84
85 86
87 88
89 90
91 92
93 94
95 96
97 98
9...

result:

wrong answer wrong number of friendly pairs: printed 1, but it is actually 0 (test case 1)