QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#132642#5209. King's PuzzleSwarthmore#AC ✓7ms3920kbC++174.1kb2023-07-30 22:27:392023-07-30 22:27:42

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-30 22:27:42]
  • 评测
  • 测评结果:AC
  • 用时:7ms
  • 内存:3920kb
  • [2023-07-30 22:27:39]
  • 提交

answer

#include "bits/stdc++.h"
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef DEBUG
#define dbg(x...) cerr << "\e[91m"<<__func__<<":"<<__LINE__<<" [" << #x << "] = ["; _print(x); cerr << "\e[39m" << endl;
#else
#define dbg(x...)
#endif


const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; 

void solve() {
    int N, K; cin >> N >> K;
    if (N == 1) {
        cout << "YES" << nl;
        cout << 0 << nl;
        return;
    }
    if (N == 2) {
        if (K == 2) {
            cout << "NO" << nl; 
        } else {
            cout << "YES" << nl;
            cout << 1 << nl;
            cout << "1 2" << nl;
        }
        return;
    }
    if (N == K) {
        cout << "NO" << nl; return;
    }
    cout << "YES" << nl;
    if (K == 1) {
        cout << N << nl;
        F0R(i, N) {
            cout << i+1 << " " << (i+1)%N+1 << nl;
        }
        return;
    }
    vpi vals;
    int cnt[N]; F0R(i, N) cnt[i] = 0;
    int deg[N]; F0R(i, N) deg[i] = 0;
    cnt[0] = N;
    int cur = 1;
    F0R(i, N) {
        FOR(j, i+1, N) {
            if (i+j < N) {
                cnt[deg[i]]--;
                if (cnt[deg[i]] == 0) cur--;
                deg[i]++;
                if (cnt[deg[i]] == 0) cur++;
                cnt[deg[i]]++;

                cnt[deg[j]]--;
                if (cnt[deg[j]] == 0) cur--;
                deg[j]++;
                if (cnt[deg[j]] == 0) cur++;
                cnt[deg[j]]++;
                vals.pb({i+1, j+1});
                if ((i != 0 || j == N-1) && cur == K) goto done;
            }
        }
    }
    assert(false);
    done:
    ;
    cout << sz(vals) << nl;
    trav(a, vals) {
        cout << a.f << " " << a.s << nl;
    }

}
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);

    int T = 1;
//    cin >> T;
    while(T--) {
        solve();
    }

	return 0;
}



Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 1ms
memory: 3472kb

input:

4 1

output:

YES
4
1 2
2 3
3 4
4 1

result:

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

Test #3:

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

input:

11 1

output:

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

result:

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

Test #4:

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

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: 3524kb

input:

11 3

output:

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

result:

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

Test #6:

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

input:

11 9

output:

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

result:

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

Test #7:

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

input:

11 10

output:

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

result:

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

Test #8:

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

input:

11 11

output:

NO

result:

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

Test #9:

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

input:

53 1

output:

YES
53
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 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52 5...

result:

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

Test #10:

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

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: 1ms
memory: 3588kb

input:

53 3

output:

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

result:

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

Test #12:

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

input:

53 51

output:

YES
701
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
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2 10
2 11
2 ...

result:

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

Test #13:

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

input:

53 52

output:

YES
702
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
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2 10
2 11
2 ...

result:

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

Test #14:

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

input:

53 53

output:

NO

result:

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

Test #15:

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

input:

267 1

output:

YES
267
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 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52 ...

result:

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

Test #16:

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

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: 3540kb

input:

267 3

output:

YES
267
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 = 3: nice job dude

Test #18:

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

input:

267 265

output:

YES
17821
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 6...

result:

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

Test #19:

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

input:

267 266

output:

YES
17822
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 6...

result:

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

Test #20:

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

input:

267 267

output:

NO

result:

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

Test #21:

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

input:

499 1

output:

YES
499
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 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52 ...

result:

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

Test #22:

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

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: 3484kb

input:

499 3

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 = 499, k = 3: nice job dude

Test #24:

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

input:

499 497

output:

YES
62249
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 6...

result:

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

Test #25:

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

input:

499 498

output:

YES
62250
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 6...

result:

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

Test #26:

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

input:

499 499

output:

NO

result:

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

Test #27:

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

input:

500 1

output:

YES
500
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 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52 ...

result:

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

Test #28:

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

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: 3532kb

input:

500 3

output:

YES
500
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 = 3: nice job dude

Test #30:

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

input:

500 498

output:

YES
62498
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 6...

result:

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

Test #31:

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

input:

500 499

output:

YES
62500
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 6...

result:

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

Test #32:

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

input:

500 500

output:

NO

result:

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

Test #33:

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

input:

1 1

output:

YES
0

result:

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

Test #34:

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

input:

2 1

output:

YES
1
1 2

result:

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

Test #35:

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

input:

2 2

output:

NO

result:

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

Test #36:

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

input:

3 1

output:

YES
3
1 2
2 3
3 1

result:

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

Test #37:

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

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: 1ms
memory: 3592kb

input:

3 3

output:

NO

result:

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

Test #39:

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

input:

4 1

output:

YES
4
1 2
2 3
3 4
4 1

result:

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

Test #40:

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

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: 1ms
memory: 3564kb

input:

4 3

output:

YES
4
1 2
1 3
1 4
2 3

result:

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

Test #42:

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

input:

4 4

output:

NO

result:

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

Test #43:

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

input:

5 1

output:

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

result:

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

Test #44:

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

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: 1ms
memory: 3468kb

input:

5 3

output:

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

result:

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

Test #46:

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

input:

5 4

output:

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

result:

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

Test #47:

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

input:

5 5

output:

NO

result:

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

Test #48:

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

input:

6 1

output:

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

result:

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

Test #49:

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

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: 3528kb

input:

6 3

output:

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

result:

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

Test #51:

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

input:

6 4

output:

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

result:

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

Test #52:

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

input:

6 5

output:

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

result:

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

Test #53:

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

input:

6 6

output:

NO

result:

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

Test #54:

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

input:

103 85

output:

YES
2563
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 = 103, k = 85: nice job dude

Test #55:

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

input:

373 203

output:

YES
27473
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 6...

result:

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

Test #56:

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

input:

443 143

output:

YES
26413
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 6...

result:

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

Test #57:

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

input:

124 30

output:

YES
1542
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 = 124, k = 30: nice job dude

Test #58:

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

input:

194 6

output:

YES
386
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 = 194, k = 6: nice job dude

Test #59:

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

input:

464 369

output:

YES
51521
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 6...

result:

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

Test #60:

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

input:

45 42

output:

YES
502
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
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 ...

result:

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

Test #61:

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

input:

115 106

output:

YES
3278
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 = 115, k = 106: nice job dude

Test #62:

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

input:

285 220

output:

YES
19186
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 6...

result:

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

Test #63:

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

input:

143 106

output:

YES
4734
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 = 143, k = 106: nice job dude