QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#804842#5209. King's PuzzleRaghayev17889WA 0ms3600kbC++172.1kb2024-12-08 06:51:132024-12-08 06:51:14

Judging History

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

  • [2024-12-08 06:51:14]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3600kb
  • [2024-12-08 06:51:13]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

void _()
{
    int n, k;
    cin >> n >> k;
    if(k >= n)
    {
        cout << "NO\n";
        return;
    }
    else
    {
         if(k == 1)
         {
             cout << "YES\n";
             cout << n << endl;
             for(int i = 0; i < n; i++)
             {
                cout << i+1 << " " << (i+1)% n  +1<<endl;
             }
             return;
         }
         else 
         {
            int deg = 1;
            vector<int> a(n, 1);
            vector<vector<int>> e(n);
            int ans = 0;
             deg++;
             for(int i = 1; i < n; i++)
             {
                 e[0].push_back(i);
                 ans++;
             }
             if(k == 2)
             {
                 cout << "YES\n"<<n-1 << endl;
                 for(int i = 1; i < n; i++)
                 {
                     cout << 1 << " " << i+1 << endl;
                 }
                 return;
             }
             a[0] = n-1;
             a[1] = 2;
             a[2] = 2;
             e[1].push_back(2);
             ans++;
             deg = 3;
             int ind = 2;
             int i = 1;
             while(deg < k)
             {
                 deg++;
                 i = 1;
                 while(a[ind] <= a[ind-1])
                 {
                     a[ind]++;
                     a[ind+i]++;
                     e[ind].push_back(ind+i);
                     ans++;
                     i++;
                 }
                 ind++;
             }
             cout << "YES\n" << ans << endl;
             for(int i = 0; i < n; i++)
             {
                 int p = e[i].size();
                 for(int j = 0; j < p; j++)
                 {
                     cout << i+1 << " " << e[i][j]+1 << endl;
                 }
             }
         }
         
    }
    
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int t = 1;
    //cin >> t;
    while(t--) _();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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

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

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

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: -100
Wrong Answer
time: 0ms
memory: 3572kb

input:

11 9

output:

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

result:

wrong answer Integer parameter [name=y_28] equals to 12, violates the range [1, 11]