很容易想到的一个构造法,从1开始往左建到h高,然后在h - 1的位置不断增加结点,直到剩下d - h个结点,然后放在1的右边不断往下建立,但要注意一个特殊情况,即n>2时,d=h=1时,其他的-1的情况显然时h > 2 * d的时候。
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <list>
#include <stack>
#include <cstring>
#include <queue>
#include <map>
#include <string>
using namespace std;
#define MAX 205
#define ll long long
#define INF 0x3f3f3f3f
#define mod 1000000007
int n, d, h;
int main()
{
freopen("a.txt", "r", stdin);
freopen("b.txt", "w", stdout);
cin >> n >> d >> h;
if (d > h * 2 || (n > 2 && d == 1 && h == 1)) {
puts("-1");
return 0;
}
for (int i = 2; i <= h + 1; ++i) {
printf("%d %d\n", i - 1, i);
}
for (int i = h + 2; i <= n - (d - h); ++i) {
printf("%d %d\n", h, i);
}
int s = 1;
for (int i = n - (d - h) + 1; i <= n; ++i) {
printf("%d %d\n", s, i);
s = i;
}
return 0;
}