fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3.  
  4. using namespace std;
  5.  
  6. const int MOD = 1e9 + 7;
  7.  
  8. void solve()
  9. {
  10. int n, d, l;
  11. cin >> n >> d >> l;
  12.  
  13. int rem = (n - 1) - l;
  14. if(rem < 0){
  15. cout << -1 << "\n";
  16. return;
  17.  
  18. }
  19. if(rem + 2 == d){
  20. int x = 2;
  21. for(int i = 0; i < l; i++){
  22. cout << 1 << " " << x << "\n";
  23. x++;
  24. }
  25. while(x <= n){
  26. cout << x - 1 << " " << x << "\n";
  27. x++;
  28. }
  29. }else if(rem + 1 == d){
  30. int x = 1;
  31. for(int i = 0; i < d; i++){
  32. cout << x << " " << x + 1 << "\n";
  33. x++;
  34. }
  35. int p = x - 1;
  36. x++;
  37. for(int i = 0; i < l - 1; i++){
  38. cout << p << " " << x << "\n";
  39. x++;
  40. }
  41. }else{
  42. cout << -1 << "\n";
  43. }
  44. }
  45.  
  46. int main()
  47. {
  48. ios_base::sync_with_stdio(false);
  49. cin.tie(NULL);
  50.  
  51. // cout << fixed << setprecision(7);
  52. int t = 1;
  53. cin >> t;
  54. for (int i = 1; i <= t; i++)
  55. {
  56. // cout << "Case #" << i << ": ";
  57. solve();
  58. }
  59. return 0;
  60. }
Success #stdin #stdout 0.01s 5284KB
stdin
5
2 1 1
4 1 4
3 2 3
4 2 3
7 3 4
stdout
1 2
-1
-1
1 2
1 3
1 4
1 2
2 3
3 4
3 5
3 6
3 7