QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#720164#5209. King's Puzzleydzr00000WA 0ms3944kbC++17909b2024-11-07 11:00:572024-11-07 11:00:57

Judging History

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

  • [2024-11-07 11:00:57]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3944kb
  • [2024-11-07 11:00:57]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int>>E;
int deg[501];
int main(){
    int n,k;
    scanf("%d %d",&n,&k);
    if(n==1)
    {
        puts("YES");
        printf("0\n");
        return 0;
    }
    if(n==k)
    {
        puts("NO");
        return 0;
    }
    if(k==1)
    {
        puts("YES");
        if(n==2)
        {
            printf("1\n1 2\n");
            return 0;
        }
        printf("%d\n",n);
        for(int i=1;i<=n;i++)
            printf("%d %d\n",i,i%n+1);
        return 0;
    }
    int t=k+1;
    for(int i=t+1;i<=n;i++)
        E.push_back({i-1,i});
    for(int i=1;i<=t/2;i++)
    {
        int deg=k-(i-1);
        for(int j=1;j<=deg;j++)
            E.push_back({i,i+j});
    }
    puts("YES");
    printf("%d\n",(int)E.size());
    for(auto [u,v]: E)
        printf("%d %d\n",u,v);
    
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3812kb

input:

5 2

output:

YES
4
3 4
4 5
1 2
1 3

result:

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

Test #2:

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

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: 0ms
memory: 3844kb

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: 0ms
memory: 3912kb

input:

11 2

output:

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

result:

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

Test #5:

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

input:

11 3

output:

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

result:

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

Test #6:

score: -100
Wrong Answer
time: 0ms
memory: 3836kb

input:

11 9

output:

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

result:

wrong answer There should be 9 distinct degrees, not 4