QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#303273 | #5209. King's Puzzle | LaStataleBlue# | WA | 12ms | 4116kb | C++23 | 1.2kb | 2024-01-12 01:20:17 | 2024-01-12 01:20:17 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
void solve(int t){
int n,k;
cin>>n>>k;
if(n==k){
if(n==1)cout<<"YES\n";
else cout<<"NO\n";
}else{
vector<int> tmp;
for(int i=1;i<=n;i++)tmp.push_back(i);
vector<pair<int,int>> ans;
while(k>2){
for(int i=0;i+1<(int)tmp.size();i++){
ans.push_back({tmp[i],tmp.back()});
}
tmp.pop_back();
tmp.pop_back();
n-=2;
k-=2;
}
if(k==1){
for(int i=0;i<(int)tmp.size();i++){
for(int j=0;j<i;j++){
ans.push_back({tmp[i],tmp[j]});
}
}
}else{
for(int i=0;i+1<(int)tmp.size();i++){
ans.push_back({tmp[i],tmp[i+1]});
}
}
cout<<"YES\n";
cout<<ans.size()<<"\n";
for(auto [u,v] : ans)cout<<u<<" "<<v<<"\n";
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)solve(i);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3548kb
input:
5 2
output:
YES 4 1 2 2 3 3 4 4 5
result:
ok n = 5, k = 2: nice job dude
Test #2:
score: 0
Accepted
time: 1ms
memory: 3436kb
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: 1ms
memory: 3440kb
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: 1ms
memory: 3476kb
input:
11 2
output:
YES 10 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11
result:
ok n = 11, k = 2: nice job dude
Test #5:
score: 0
Accepted
time: 1ms
memory: 3492kb
input:
11 3
output:
YES 46 1 11 2 11 3 11 4 11 5 11 6 11 7 11 8 11 9 11 10 11 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
result:
ok n = 11, k = 3: nice job dude
Test #6:
score: 0
Accepted
time: 0ms
memory: 3436kb
input:
11 9
output:
YES 31 1 11 2 11 3 11 4 11 5 11 6 11 7 11 8 11 9 11 10 11 1 9 2 9 3 9 4 9 5 9 6 9 7 9 8 9 1 7 2 7 3 7 4 7 5 7 6 7 1 5 2 5 3 5 4 5 2 1 3 1 3 2
result:
ok n = 11, k = 9: nice job dude
Test #7:
score: 0
Accepted
time: 0ms
memory: 3484kb
input:
11 10
output:
YES 30 1 11 2 11 3 11 4 11 5 11 6 11 7 11 8 11 9 11 10 11 1 9 2 9 3 9 4 9 5 9 6 9 7 9 8 9 1 7 2 7 3 7 4 7 5 7 6 7 1 5 2 5 3 5 4 5 1 2 2 3
result:
ok n = 11, k = 10: nice job dude
Test #8:
score: 0
Accepted
time: 0ms
memory: 3488kb
input:
11 11
output:
NO
result:
ok n = 11, k = 11: nice job dude
Test #9:
score: 0
Accepted
time: 1ms
memory: 3472kb
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: 0ms
memory: 3548kb
input:
53 2
output:
YES 52 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 53
result:
ok n = 53, k = 2: nice job dude
Test #11:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
53 3
output:
YES 1327 1 53 2 53 3 53 4 53 5 53 6 53 7 53 8 53 9 53 10 53 11 53 12 53 13 53 14 53 15 53 16 53 17 53 18 53 19 53 20 53 21 53 22 53 23 53 24 53 25 53 26 53 27 53 28 53 29 53 30 53 31 53 32 53 33 53 34 53 35 53 36 53 37 53 38 53 39 53 40 53 41 53 42 53 43 53 44 53 45 53 46 53 47 53 48 53 49 53 50 53 ...
result:
ok n = 53, k = 3: nice job dude
Test #12:
score: 0
Accepted
time: 1ms
memory: 3536kb
input:
53 51
output:
YES 703 1 53 2 53 3 53 4 53 5 53 6 53 7 53 8 53 9 53 10 53 11 53 12 53 13 53 14 53 15 53 16 53 17 53 18 53 19 53 20 53 21 53 22 53 23 53 24 53 25 53 26 53 27 53 28 53 29 53 30 53 31 53 32 53 33 53 34 53 35 53 36 53 37 53 38 53 39 53 40 53 41 53 42 53 43 53 44 53 45 53 46 53 47 53 48 53 49 53 50 53 5...
result:
ok n = 53, k = 51: nice job dude
Test #13:
score: 0
Accepted
time: 0ms
memory: 3496kb
input:
53 52
output:
YES 702 1 53 2 53 3 53 4 53 5 53 6 53 7 53 8 53 9 53 10 53 11 53 12 53 13 53 14 53 15 53 16 53 17 53 18 53 19 53 20 53 21 53 22 53 23 53 24 53 25 53 26 53 27 53 28 53 29 53 30 53 31 53 32 53 33 53 34 53 35 53 36 53 37 53 38 53 39 53 40 53 41 53 42 53 43 53 44 53 45 53 46 53 47 53 48 53 49 53 50 53 5...
result:
ok n = 53, k = 52: nice job dude
Test #14:
score: 0
Accepted
time: 1ms
memory: 3440kb
input:
53 53
output:
NO
result:
ok n = 53, k = 53: nice job dude
Test #15:
score: 0
Accepted
time: 4ms
memory: 3700kb
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: 1ms
memory: 3500kb
input:
267 2
output:
YES 266 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 = 2: nice job dude
Test #17:
score: 0
Accepted
time: 4ms
memory: 3744kb
input:
267 3
output:
YES 35246 1 267 2 267 3 267 4 267 5 267 6 267 7 267 8 267 9 267 10 267 11 267 12 267 13 267 14 267 15 267 16 267 17 267 18 267 19 267 20 267 21 267 22 267 23 267 24 267 25 267 26 267 27 267 28 267 29 267 30 267 31 267 32 267 33 267 34 267 35 267 36 267 37 267 38 267 39 267 40 267 41 267 42 267 43 26...
result:
ok n = 267, k = 3: nice job dude
Test #18:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
267 265
output:
YES 17823 1 267 2 267 3 267 4 267 5 267 6 267 7 267 8 267 9 267 10 267 11 267 12 267 13 267 14 267 15 267 16 267 17 267 18 267 19 267 20 267 21 267 22 267 23 267 24 267 25 267 26 267 27 267 28 267 29 267 30 267 31 267 32 267 33 267 34 267 35 267 36 267 37 267 38 267 39 267 40 267 41 267 42 267 43 26...
result:
ok n = 267, k = 265: nice job dude
Test #19:
score: 0
Accepted
time: 2ms
memory: 3608kb
input:
267 266
output:
YES 17822 1 267 2 267 3 267 4 267 5 267 6 267 7 267 8 267 9 267 10 267 11 267 12 267 13 267 14 267 15 267 16 267 17 267 18 267 19 267 20 267 21 267 22 267 23 267 24 267 25 267 26 267 27 267 28 267 29 267 30 267 31 267 32 267 33 267 34 267 35 267 36 267 37 267 38 267 39 267 40 267 41 267 42 267 43 26...
result:
ok n = 267, k = 266: nice job dude
Test #20:
score: 0
Accepted
time: 0ms
memory: 3476kb
input:
267 267
output:
NO
result:
ok n = 267, k = 267: nice job dude
Test #21:
score: 0
Accepted
time: 8ms
memory: 4116kb
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: 1ms
memory: 3504kb
input:
499 2
output:
YES 498 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 = 2: nice job dude
Test #23:
score: 0
Accepted
time: 11ms
memory: 4064kb
input:
499 3
output:
YES 123754 1 499 2 499 3 499 4 499 5 499 6 499 7 499 8 499 9 499 10 499 11 499 12 499 13 499 14 499 15 499 16 499 17 499 18 499 19 499 20 499 21 499 22 499 23 499 24 499 25 499 26 499 27 499 28 499 29 499 30 499 31 499 32 499 33 499 34 499 35 499 36 499 37 499 38 499 39 499 40 499 41 499 42 499 43 4...
result:
ok n = 499, k = 3: nice job dude
Test #24:
score: 0
Accepted
time: 6ms
memory: 3740kb
input:
499 497
output:
YES 62251 1 499 2 499 3 499 4 499 5 499 6 499 7 499 8 499 9 499 10 499 11 499 12 499 13 499 14 499 15 499 16 499 17 499 18 499 19 499 20 499 21 499 22 499 23 499 24 499 25 499 26 499 27 499 28 499 29 499 30 499 31 499 32 499 33 499 34 499 35 499 36 499 37 499 38 499 39 499 40 499 41 499 42 499 43 49...
result:
ok n = 499, k = 497: nice job dude
Test #25:
score: 0
Accepted
time: 3ms
memory: 3768kb
input:
499 498
output:
YES 62250 1 499 2 499 3 499 4 499 5 499 6 499 7 499 8 499 9 499 10 499 11 499 12 499 13 499 14 499 15 499 16 499 17 499 18 499 19 499 20 499 21 499 22 499 23 499 24 499 25 499 26 499 27 499 28 499 29 499 30 499 31 499 32 499 33 499 34 499 35 499 36 499 37 499 38 499 39 499 40 499 41 499 42 499 43 49...
result:
ok n = 499, k = 498: nice job dude
Test #26:
score: 0
Accepted
time: 1ms
memory: 3432kb
input:
499 499
output:
NO
result:
ok n = 499, k = 499: nice job dude
Test #27:
score: 0
Accepted
time: 12ms
memory: 4116kb
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: 3484kb
input:
500 2
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 = 500, k = 2: nice job dude
Test #29:
score: 0
Accepted
time: 12ms
memory: 4084kb
input:
500 3
output:
YES 124252 1 500 2 500 3 500 4 500 5 500 6 500 7 500 8 500 9 500 10 500 11 500 12 500 13 500 14 500 15 500 16 500 17 500 18 500 19 500 20 500 21 500 22 500 23 500 24 500 25 500 26 500 27 500 28 500 29 500 30 500 31 500 32 500 33 500 34 500 35 500 36 500 37 500 38 500 39 500 40 500 41 500 42 500 43 5...
result:
ok n = 500, k = 3: nice job dude
Test #30:
score: 0
Accepted
time: 6ms
memory: 3740kb
input:
500 498
output:
YES 62499 1 500 2 500 3 500 4 500 5 500 6 500 7 500 8 500 9 500 10 500 11 500 12 500 13 500 14 500 15 500 16 500 17 500 18 500 19 500 20 500 21 500 22 500 23 500 24 500 25 500 26 500 27 500 28 500 29 500 30 500 31 500 32 500 33 500 34 500 35 500 36 500 37 500 38 500 39 500 40 500 41 500 42 500 43 50...
result:
ok n = 500, k = 498: nice job dude
Test #31:
score: 0
Accepted
time: 6ms
memory: 3712kb
input:
500 499
output:
YES 62500 1 500 2 500 3 500 4 500 5 500 6 500 7 500 8 500 9 500 10 500 11 500 12 500 13 500 14 500 15 500 16 500 17 500 18 500 19 500 20 500 21 500 22 500 23 500 24 500 25 500 26 500 27 500 28 500 29 500 30 500 31 500 32 500 33 500 34 500 35 500 36 500 37 500 38 500 39 500 40 500 41 500 42 500 43 50...
result:
ok n = 500, k = 499: nice job dude
Test #32:
score: 0
Accepted
time: 1ms
memory: 3496kb
input:
500 500
output:
NO
result:
ok n = 500, k = 500: nice job dude
Test #33:
score: -100
Wrong Answer
time: 0ms
memory: 3540kb
input:
1 1
output:
YES
result:
wrong output format Unexpected end of file - int32 expected