fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long ll;
  5. const int cmx = 1e5 + 5;
  6.  
  7. int n, d, h;
  8. vector<pair<int,int> > edges;
  9.  
  10. int main(){
  11. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  12. cin>>n>>d>>h;
  13. if(d==1 and n > 2){
  14. cout<<-1<<'\n'; return 0;
  15. }
  16. if((((d+1)/2) > h) ){
  17. cout<<-1<<'\n'; return 0;
  18. }
  19. if(h==d and h < (n-1)){
  20. cout<<-1<<'\n'; return 0;
  21. }
  22.  
  23. int pre = 1;
  24. int node = 2;
  25. for(int h1 = 1; h1 <= h and (node <= n); h1++){
  26. edges.push_back({pre,node}); pre = node; node++;
  27. }
  28. pre = 1;
  29. for(int h2 = 1; h2 <= (d-h) and (node <= n); h2++){
  30. edges.push_back({pre,node}); pre = node; node++;
  31. }
  32. while(node <= n){
  33. edges.push_back({1,node}); node++;
  34. }
  35. for(auto p : edges)cout << p.first << " " << p.second << '\n';
  36. return 0;
  37. }
Success #stdin #stdout 0s 3456KB
stdin
5 2 2
stdout
-1