-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBearAndForgottenTree3.cpp
More file actions
85 lines (82 loc) · 1.6 KB
/
BearAndForgottenTree3.cpp
File metadata and controls
85 lines (82 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
* 658C - Bear and Forgotten Tree 3
* Coded by Ziyi Tang
*
*/
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vpi> vvpi;
const int INF = (int)1E9;
const long INFL = (long)1E18;
const int dir[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
#define REP(i,s,t) for(int i=(s);i<(t);i++)
#define FILL(x,v) memset(x,v,sizeof(x))
#define MAXN 1000
int n,d,h;
vpi edges;
int main(){
cin >> n >> d >> h;
if(n <= d) cout << -1 << endl;
else if(h == 1 && d == 1 && n == 2){
cout << 1 << " " << 2 << endl;
}
else if(d == 1 && n > 2){
cout << -1 << endl;
}
else if(h == 1 && d == 2){
REP(i,2,n+1){
edges.push_back(make_pair(1,i));
}
int sz = edges.size();
REP(i,0,sz){
cout << edges[i].first << " " << edges[i].second << endl;
}
}
else if(d >= h && d <= 2*h && n > d){
int now = 1; // ends with
REP(i,0,h){
edges.push_back(make_pair(now,now+1));
now++;
}
int rd = d-h;
int tmp = 1;
REP(i,0,rd){
edges.push_back(make_pair(tmp, now+1));
tmp = now+1;
now++;
}
int rem = n-now;
REP(i,0,rem){
edges.push_back(make_pair(2,now+1));
now++;
}
int sz = edges.size();
REP(i,0,sz){
cout << edges[i].first << " " << edges[i].second << endl;
}
}
else{
cout << -1 << endl;
}
return 0;
}