QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#373600#5209. King's PuzzleInfinityNS#AC ✓10ms4428kbC++141.4kb2024-04-01 20:54:102024-04-01 20:54:10

Judging History

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

  • [2024-04-01 20:54:10]
  • 评测
  • 测评结果:AC
  • 用时:10ms
  • 内存:4428kb
  • [2024-04-01 20:54:10]
  • 提交

answer

#include<bits/stdc++.h>

#define f first
#define s second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) x.begin(),x.end()

using namespace std;

int main(){
    int n,k;
    scanf("%i %i",&n,&k);
    if(n==1){
        printf("YES\n0\n");
        return 0;
    }
    if(n==k){
        printf("NO\n");
        return 0;
    }
    printf("YES\n");
    vector<pair<int,int>> ans;
    if(k==1){
        for(int i=0;i<n;i++){for(int j=0;j<i;j++){
            ans.pb({i,j});
        }
        }
    }
    else{
        assert(n>=3);
        vector<int> ostali;
        vector<int> deg(n,0);
        int mx=0,lst=2;
        ans.pb({mx,1});
        ans.pb({mx,2});
        deg[mx]=2;
        deg[1]=deg[2]=1;
        ostali.pb(1);
        int trk=2;
        for(int i=3;i<n;i++){
            if(trk==k){
                ans.pb({mx,i});
                continue;
            }
            for(auto p:ostali){
                if(deg[p]>=deg[lst]){
                    ans.pb({p,i});
                    deg[i]++;
                    deg[p]++;
                }
            }
            ans.pb({mx,i});
            deg[mx]++;
            deg[i]++;
            ostali.pb(lst);
            lst=i;
            trk++;
        }
    }
    printf("%i\n",sz(ans));
    for(auto p:ans){
        printf("%i %i\n",p.f+1,p.s+1);
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3728kb

input:

5 2

output:

YES
4
1 2
1 3
1 4
1 5

result:

ok n = 5, k = 2: nice job dude

Test #2:

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

input:

4 1

output:

YES
6
2 1
3 1
3 2
4 1
4 2
4 3

result:

ok n = 4, k = 1: nice job dude

Test #3:

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

input:

11 1

output:

YES
55
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 2
8 3
8 4
8 5
8 6
8 7
9 1
9 2
9 3
9 4
9 5
9 6
9 7
9 8
10 1
10 2
10 3
10 4
10 5
10 6
10 7
10 8
10 9
11 1
11 2
11 3
11 4
11 5
11 6
11 7
11 8
11 9
11 10

result:

ok n = 11, k = 1: nice job dude

Test #4:

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

input:

11 2

output:

YES
10
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11

result:

ok n = 11, k = 2: nice job dude

Test #5:

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

input:

11 3

output:

YES
11
1 2
1 3
2 4
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11

result:

ok n = 11, k = 3: nice job dude

Test #6:

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

input:

11 9

output:

YES
26
1 2
1 3
2 4
1 4
2 5
1 5
2 6
4 6
1 6
2 7
4 7
1 7
2 8
4 8
6 8
1 8
2 9
4 9
6 9
1 9
2 10
4 10
6 10
8 10
1 10
1 11

result:

ok n = 11, k = 9: nice job dude

Test #7:

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

input:

11 10

output:

YES
30
1 2
1 3
2 4
1 4
2 5
1 5
2 6
4 6
1 6
2 7
4 7
1 7
2 8
4 8
6 8
1 8
2 9
4 9
6 9
1 9
2 10
4 10
6 10
8 10
1 10
2 11
4 11
6 11
8 11
1 11

result:

ok n = 11, k = 10: nice job dude

Test #8:

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

input:

11 11

output:

NO

result:

ok n = 11, k = 11: nice job dude

Test #9:

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

input:

53 1

output:

YES
1378
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 2
8 3
8 4
8 5
8 6
8 7
9 1
9 2
9 3
9 4
9 5
9 6
9 7
9 8
10 1
10 2
10 3
10 4
10 5
10 6
10 7
10 8
10 9
11 1
11 2
11 3
11 4
11 5
11 6
11 7
11 8
11 9
11 10
12 1
12 2
12 3
12 4
12 5
12 6
12 7
12 8
12 9
12 10
...

result:

ok n = 53, k = 1: nice job dude

Test #10:

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

input:

53 2

output:

YES
52
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

result:

ok n = 53, k = 2: nice job dude

Test #11:

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

input:

53 3

output:

YES
53
1 2
1 3
2 4
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

result:

ok n = 53, k = 3: nice job dude

Test #12:

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

input:

53 51

output:

YES
677
1 2
1 3
2 4
1 4
2 5
1 5
2 6
4 6
1 6
2 7
4 7
1 7
2 8
4 8
6 8
1 8
2 9
4 9
6 9
1 9
2 10
4 10
6 10
8 10
1 10
2 11
4 11
6 11
8 11
1 11
2 12
4 12
6 12
8 12
10 12
1 12
2 13
4 13
6 13
8 13
10 13
1 13
2 14
4 14
6 14
8 14
10 14
12 14
1 14
2 15
4 15
6 15
8 15
10 15
12 15
1 15
2 16
4 16
6 16
8 16
10 16
...

result:

ok n = 53, k = 51: nice job dude

Test #13:

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

input:

53 52

output:

YES
702
1 2
1 3
2 4
1 4
2 5
1 5
2 6
4 6
1 6
2 7
4 7
1 7
2 8
4 8
6 8
1 8
2 9
4 9
6 9
1 9
2 10
4 10
6 10
8 10
1 10
2 11
4 11
6 11
8 11
1 11
2 12
4 12
6 12
8 12
10 12
1 12
2 13
4 13
6 13
8 13
10 13
1 13
2 14
4 14
6 14
8 14
10 14
12 14
1 14
2 15
4 15
6 15
8 15
10 15
12 15
1 15
2 16
4 16
6 16
8 16
10 16
...

result:

ok n = 53, k = 52: nice job dude

Test #14:

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

input:

53 53

output:

NO

result:

ok n = 53, k = 53: nice job dude

Test #15:

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

input:

267 1

output:

YES
35511
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 2
8 3
8 4
8 5
8 6
8 7
9 1
9 2
9 3
9 4
9 5
9 6
9 7
9 8
10 1
10 2
10 3
10 4
10 5
10 6
10 7
10 8
10 9
11 1
11 2
11 3
11 4
11 5
11 6
11 7
11 8
11 9
11 10
12 1
12 2
12 3
12 4
12 5
12 6
12 7
12 8
12 9
12 10...

result:

ok n = 267, k = 1: nice job dude

Test #16:

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

input:

267 2

output:

YES
266
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
1 60
1 61
...

result:

ok n = 267, k = 2: nice job dude

Test #17:

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

input:

267 3

output:

YES
267
1 2
1 3
2 4
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
1 60
1...

result:

ok n = 267, k = 3: nice job dude

Test #18:

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

input:

267 265

output:

YES
17690
1 2
1 3
2 4
1 4
2 5
1 5
2 6
4 6
1 6
2 7
4 7
1 7
2 8
4 8
6 8
1 8
2 9
4 9
6 9
1 9
2 10
4 10
6 10
8 10
1 10
2 11
4 11
6 11
8 11
1 11
2 12
4 12
6 12
8 12
10 12
1 12
2 13
4 13
6 13
8 13
10 13
1 13
2 14
4 14
6 14
8 14
10 14
12 14
1 14
2 15
4 15
6 15
8 15
10 15
12 15
1 15
2 16
4 16
6 16
8 16
10 1...

result:

ok n = 267, k = 265: nice job dude

Test #19:

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

input:

267 266

output:

YES
17822
1 2
1 3
2 4
1 4
2 5
1 5
2 6
4 6
1 6
2 7
4 7
1 7
2 8
4 8
6 8
1 8
2 9
4 9
6 9
1 9
2 10
4 10
6 10
8 10
1 10
2 11
4 11
6 11
8 11
1 11
2 12
4 12
6 12
8 12
10 12
1 12
2 13
4 13
6 13
8 13
10 13
1 13
2 14
4 14
6 14
8 14
10 14
12 14
1 14
2 15
4 15
6 15
8 15
10 15
12 15
1 15
2 16
4 16
6 16
8 16
10 1...

result:

ok n = 267, k = 266: nice job dude

Test #20:

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

input:

267 267

output:

NO

result:

ok n = 267, k = 267: nice job dude

Test #21:

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

input:

499 1

output:

YES
124251
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 2
8 3
8 4
8 5
8 6
8 7
9 1
9 2
9 3
9 4
9 5
9 6
9 7
9 8
10 1
10 2
10 3
10 4
10 5
10 6
10 7
10 8
10 9
11 1
11 2
11 3
11 4
11 5
11 6
11 7
11 8
11 9
11 10
12 1
12 2
12 3
12 4
12 5
12 6
12 7
12 8
12 9
12 1...

result:

ok n = 499, k = 1: nice job dude

Test #22:

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

input:

499 2

output:

YES
498
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
1 60
1 61
...

result:

ok n = 499, k = 2: nice job dude

Test #23:

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

input:

499 3

output:

YES
499
1 2
1 3
2 4
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
1 60
1...

result:

ok n = 499, k = 3: nice job dude

Test #24:

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

input:

499 497

output:

YES
62002
1 2
1 3
2 4
1 4
2 5
1 5
2 6
4 6
1 6
2 7
4 7
1 7
2 8
4 8
6 8
1 8
2 9
4 9
6 9
1 9
2 10
4 10
6 10
8 10
1 10
2 11
4 11
6 11
8 11
1 11
2 12
4 12
6 12
8 12
10 12
1 12
2 13
4 13
6 13
8 13
10 13
1 13
2 14
4 14
6 14
8 14
10 14
12 14
1 14
2 15
4 15
6 15
8 15
10 15
12 15
1 15
2 16
4 16
6 16
8 16
10 1...

result:

ok n = 499, k = 497: nice job dude

Test #25:

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

input:

499 498

output:

YES
62250
1 2
1 3
2 4
1 4
2 5
1 5
2 6
4 6
1 6
2 7
4 7
1 7
2 8
4 8
6 8
1 8
2 9
4 9
6 9
1 9
2 10
4 10
6 10
8 10
1 10
2 11
4 11
6 11
8 11
1 11
2 12
4 12
6 12
8 12
10 12
1 12
2 13
4 13
6 13
8 13
10 13
1 13
2 14
4 14
6 14
8 14
10 14
12 14
1 14
2 15
4 15
6 15
8 15
10 15
12 15
1 15
2 16
4 16
6 16
8 16
10 1...

result:

ok n = 499, k = 498: nice job dude

Test #26:

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

input:

499 499

output:

NO

result:

ok n = 499, k = 499: nice job dude

Test #27:

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

input:

500 1

output:

YES
124750
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 2
8 3
8 4
8 5
8 6
8 7
9 1
9 2
9 3
9 4
9 5
9 6
9 7
9 8
10 1
10 2
10 3
10 4
10 5
10 6
10 7
10 8
10 9
11 1
11 2
11 3
11 4
11 5
11 6
11 7
11 8
11 9
11 10
12 1
12 2
12 3
12 4
12 5
12 6
12 7
12 8
12 9
12 1...

result:

ok n = 500, k = 1: nice job dude

Test #28:

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

input:

500 2

output:

YES
499
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
1 60
1 61
...

result:

ok n = 500, k = 2: nice job dude

Test #29:

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

input:

500 3

output:

YES
500
1 2
1 3
2 4
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
1 60
1...

result:

ok n = 500, k = 3: nice job dude

Test #30:

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

input:

500 498

output:

YES
62251
1 2
1 3
2 4
1 4
2 5
1 5
2 6
4 6
1 6
2 7
4 7
1 7
2 8
4 8
6 8
1 8
2 9
4 9
6 9
1 9
2 10
4 10
6 10
8 10
1 10
2 11
4 11
6 11
8 11
1 11
2 12
4 12
6 12
8 12
10 12
1 12
2 13
4 13
6 13
8 13
10 13
1 13
2 14
4 14
6 14
8 14
10 14
12 14
1 14
2 15
4 15
6 15
8 15
10 15
12 15
1 15
2 16
4 16
6 16
8 16
10 1...

result:

ok n = 500, k = 498: nice job dude

Test #31:

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

input:

500 499

output:

YES
62500
1 2
1 3
2 4
1 4
2 5
1 5
2 6
4 6
1 6
2 7
4 7
1 7
2 8
4 8
6 8
1 8
2 9
4 9
6 9
1 9
2 10
4 10
6 10
8 10
1 10
2 11
4 11
6 11
8 11
1 11
2 12
4 12
6 12
8 12
10 12
1 12
2 13
4 13
6 13
8 13
10 13
1 13
2 14
4 14
6 14
8 14
10 14
12 14
1 14
2 15
4 15
6 15
8 15
10 15
12 15
1 15
2 16
4 16
6 16
8 16
10 1...

result:

ok n = 500, k = 499: nice job dude

Test #32:

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

input:

500 500

output:

NO

result:

ok n = 500, k = 500: nice job dude

Test #33:

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

input:

1 1

output:

YES
0

result:

ok n = 1, k = 1: nice job dude

Test #34:

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

input:

2 1

output:

YES
1
2 1

result:

ok n = 2, k = 1: nice job dude

Test #35:

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

input:

2 2

output:

NO

result:

ok n = 2, k = 2: nice job dude

Test #36:

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

input:

3 1

output:

YES
3
2 1
3 1
3 2

result:

ok n = 3, k = 1: nice job dude

Test #37:

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

input:

3 2

output:

YES
2
1 2
1 3

result:

ok n = 3, k = 2: nice job dude

Test #38:

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

input:

3 3

output:

NO

result:

ok n = 3, k = 3: nice job dude

Test #39:

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

input:

4 1

output:

YES
6
2 1
3 1
3 2
4 1
4 2
4 3

result:

ok n = 4, k = 1: nice job dude

Test #40:

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

input:

4 2

output:

YES
3
1 2
1 3
1 4

result:

ok n = 4, k = 2: nice job dude

Test #41:

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

input:

4 3

output:

YES
4
1 2
1 3
2 4
1 4

result:

ok n = 4, k = 3: nice job dude

Test #42:

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

input:

4 4

output:

NO

result:

ok n = 4, k = 4: nice job dude

Test #43:

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

input:

5 1

output:

YES
10
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4

result:

ok n = 5, k = 1: nice job dude

Test #44:

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

input:

5 2

output:

YES
4
1 2
1 3
1 4
1 5

result:

ok n = 5, k = 2: nice job dude

Test #45:

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

input:

5 3

output:

YES
5
1 2
1 3
2 4
1 4
1 5

result:

ok n = 5, k = 3: nice job dude

Test #46:

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

input:

5 4

output:

YES
6
1 2
1 3
2 4
1 4
2 5
1 5

result:

ok n = 5, k = 4: nice job dude

Test #47:

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

input:

5 5

output:

NO

result:

ok n = 5, k = 5: nice job dude

Test #48:

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

input:

6 1

output:

YES
15
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5

result:

ok n = 6, k = 1: nice job dude

Test #49:

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

input:

6 2

output:

YES
5
1 2
1 3
1 4
1 5
1 6

result:

ok n = 6, k = 2: nice job dude

Test #50:

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

input:

6 3

output:

YES
6
1 2
1 3
2 4
1 4
1 5
1 6

result:

ok n = 6, k = 3: nice job dude

Test #51:

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

input:

6 4

output:

YES
7
1 2
1 3
2 4
1 4
2 5
1 5
1 6

result:

ok n = 6, k = 4: nice job dude

Test #52:

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

input:

6 5

output:

YES
9
1 2
1 3
2 4
1 4
2 5
1 5
2 6
4 6
1 6

result:

ok n = 6, k = 5: nice job dude

Test #53:

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

input:

6 6

output:

NO

result:

ok n = 6, k = 6: nice job dude

Test #54:

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

input:

103 85

output:

YES
1866
1 2
1 3
2 4
1 4
2 5
1 5
2 6
4 6
1 6
2 7
4 7
1 7
2 8
4 8
6 8
1 8
2 9
4 9
6 9
1 9
2 10
4 10
6 10
8 10
1 10
2 11
4 11
6 11
8 11
1 11
2 12
4 12
6 12
8 12
10 12
1 12
2 13
4 13
6 13
8 13
10 13
1 13
2 14
4 14
6 14
8 14
10 14
12 14
1 14
2 15
4 15
6 15
8 15
10 15
12 15
1 15
2 16
4 16
6 16
8 16
10 16...

result:

ok n = 103, k = 85: nice job dude

Test #55:

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

input:

373 203

output:

YES
10573
1 2
1 3
2 4
1 4
2 5
1 5
2 6
4 6
1 6
2 7
4 7
1 7
2 8
4 8
6 8
1 8
2 9
4 9
6 9
1 9
2 10
4 10
6 10
8 10
1 10
2 11
4 11
6 11
8 11
1 11
2 12
4 12
6 12
8 12
10 12
1 12
2 13
4 13
6 13
8 13
10 13
1 13
2 14
4 14
6 14
8 14
10 14
12 14
1 14
2 15
4 15
6 15
8 15
10 15
12 15
1 15
2 16
4 16
6 16
8 16
10 1...

result:

ok n = 373, k = 203: nice job dude

Test #56:

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

input:

443 143

output:

YES
5483
1 2
1 3
2 4
1 4
2 5
1 5
2 6
4 6
1 6
2 7
4 7
1 7
2 8
4 8
6 8
1 8
2 9
4 9
6 9
1 9
2 10
4 10
6 10
8 10
1 10
2 11
4 11
6 11
8 11
1 11
2 12
4 12
6 12
8 12
10 12
1 12
2 13
4 13
6 13
8 13
10 13
1 13
2 14
4 14
6 14
8 14
10 14
12 14
1 14
2 15
4 15
6 15
8 15
10 15
12 15
1 15
2 16
4 16
6 16
8 16
10 16...

result:

ok n = 443, k = 143: nice job dude

Test #57:

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

input:

124 30

output:

YES
333
1 2
1 3
2 4
1 4
2 5
1 5
2 6
4 6
1 6
2 7
4 7
1 7
2 8
4 8
6 8
1 8
2 9
4 9
6 9
1 9
2 10
4 10
6 10
8 10
1 10
2 11
4 11
6 11
8 11
1 11
2 12
4 12
6 12
8 12
10 12
1 12
2 13
4 13
6 13
8 13
10 13
1 13
2 14
4 14
6 14
8 14
10 14
12 14
1 14
2 15
4 15
6 15
8 15
10 15
12 15
1 15
2 16
4 16
6 16
8 16
10 16
...

result:

ok n = 124, k = 30: nice job dude

Test #58:

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

input:

194 6

output:

YES
199
1 2
1 3
2 4
1 4
2 5
1 5
2 6
4 6
1 6
2 7
4 7
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...

result:

ok n = 194, k = 6: nice job dude

Test #59:

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

input:

464 369

output:

YES
34319
1 2
1 3
2 4
1 4
2 5
1 5
2 6
4 6
1 6
2 7
4 7
1 7
2 8
4 8
6 8
1 8
2 9
4 9
6 9
1 9
2 10
4 10
6 10
8 10
1 10
2 11
4 11
6 11
8 11
1 11
2 12
4 12
6 12
8 12
10 12
1 12
2 13
4 13
6 13
8 13
10 13
1 13
2 14
4 14
6 14
8 14
10 14
12 14
1 14
2 15
4 15
6 15
8 15
10 15
12 15
1 15
2 16
4 16
6 16
8 16
10 1...

result:

ok n = 464, k = 369: nice job dude

Test #60:

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

input:

45 42

output:

YES
464
1 2
1 3
2 4
1 4
2 5
1 5
2 6
4 6
1 6
2 7
4 7
1 7
2 8
4 8
6 8
1 8
2 9
4 9
6 9
1 9
2 10
4 10
6 10
8 10
1 10
2 11
4 11
6 11
8 11
1 11
2 12
4 12
6 12
8 12
10 12
1 12
2 13
4 13
6 13
8 13
10 13
1 13
2 14
4 14
6 14
8 14
10 14
12 14
1 14
2 15
4 15
6 15
8 15
10 15
12 15
1 15
2 16
4 16
6 16
8 16
10 16
...

result:

ok n = 45, k = 42: nice job dude

Test #61:

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

input:

115 106

output:

YES
2870
1 2
1 3
2 4
1 4
2 5
1 5
2 6
4 6
1 6
2 7
4 7
1 7
2 8
4 8
6 8
1 8
2 9
4 9
6 9
1 9
2 10
4 10
6 10
8 10
1 10
2 11
4 11
6 11
8 11
1 11
2 12
4 12
6 12
8 12
10 12
1 12
2 13
4 13
6 13
8 13
10 13
1 13
2 14
4 14
6 14
8 14
10 14
12 14
1 14
2 15
4 15
6 15
8 15
10 15
12 15
1 15
2 16
4 16
6 16
8 16
10 16...

result:

ok n = 115, k = 106: nice job dude

Test #62:

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

input:

285 220

output:

YES
12274
1 2
1 3
2 4
1 4
2 5
1 5
2 6
4 6
1 6
2 7
4 7
1 7
2 8
4 8
6 8
1 8
2 9
4 9
6 9
1 9
2 10
4 10
6 10
8 10
1 10
2 11
4 11
6 11
8 11
1 11
2 12
4 12
6 12
8 12
10 12
1 12
2 13
4 13
6 13
8 13
10 13
1 13
2 14
4 14
6 14
8 14
10 14
12 14
1 14
2 15
4 15
6 15
8 15
10 15
12 15
1 15
2 16
4 16
6 16
8 16
10 1...

result:

ok n = 285, k = 220: nice job dude

Test #63:

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

input:

143 106

output:

YES
2898
1 2
1 3
2 4
1 4
2 5
1 5
2 6
4 6
1 6
2 7
4 7
1 7
2 8
4 8
6 8
1 8
2 9
4 9
6 9
1 9
2 10
4 10
6 10
8 10
1 10
2 11
4 11
6 11
8 11
1 11
2 12
4 12
6 12
8 12
10 12
1 12
2 13
4 13
6 13
8 13
10 13
1 13
2 14
4 14
6 14
8 14
10 14
12 14
1 14
2 15
4 15
6 15
8 15
10 15
12 15
1 15
2 16
4 16
6 16
8 16
10 16...

result:

ok n = 143, k = 106: nice job dude