fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4.  
  5. const ll MaxN=2e5;
  6. ll T,N,A,B;
  7.  
  8. int main() {
  9. ios::sync_with_stdio(0);
  10. cin.tie(0); cout.tie(0);
  11. cin>>T;
  12. while(T--){
  13. cin>>N>>A>>B;
  14. //cout << T << '\n';
  15. if(A+B>N){
  16. cout << "NO" << '\n';
  17. continue;
  18. }else if((A==0 or B==0) and A+B!=0){
  19. cout << "NO" << '\n';
  20. continue;
  21. }
  22. vector<int> v1;
  23. vector<int> v2;
  24. int s1=1; int s2=1;
  25. int num=N-A-B;
  26. while(num--){
  27. v1.push_back(s1);
  28. v2.push_back(s2);
  29. s1++;
  30. s2++;
  31. }
  32. int t1=s1+B;
  33. while(t1<=N){
  34. v1.push_back(t1);
  35. v2.push_back(s2);
  36. t1++;
  37. s2++;
  38. }
  39. t1=s1+B;
  40. while(s1<t1){
  41. v1.push_back(s1);
  42. v2.push_back(s2);
  43. s1++;
  44. s2++;
  45. }
  46. cout << "YES" << '\n';
  47. for(int i=0;i<v1.size();i++){
  48. cout << v1[i] << ' ';
  49. }cout << '\n';
  50. for(int i=0;i<v2.size();i++){
  51. cout << v2[i] << ' ';
  52. }cout << '\n';
  53. }
  54. }
  55.  
Success #stdin #stdout 0.01s 5320KB
stdin
5
4 1 2
2 0 1
3 0 0
2 1 1
4 4 1
stdout
YES
1 4 2 3 
1 2 3 4 
NO
YES
1 2 3 
1 2 3 
YES
2 1 
1 2 
NO