-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path003-beautiful-tree.cpp
More file actions
46 lines (42 loc) · 979 Bytes
/
Copy path003-beautiful-tree.cpp
File metadata and controls
46 lines (42 loc) · 979 Bytes
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
/*
* Beautiful Tree [2162G]
* Problem: https://codeforces.com/problemset/problem/2162/G
* Verdict: ACCEPTED Solved: 2025-10-19
* Language: C++20 (GCC 13-64)
* Runtime: 62 ms Memory: 0 KB
* Tags: constructive algorithms, math, probabilities, trees
* Author: team "balls" (HossamIsmail, BidoTeima, a1abay)
* Source: https://codeforces.com/contest/2162/submission/344579114
*/
#include <bits/stdc++.h>
using namespace std;
void solve(){
int n;
cin >> n;
if(n==2){
cout << -1 << '\n';
return;
}
if(n==3){
cout << "1 3\n2 3\n";
return;
}
if(n==4){
cout << "1 2\n3 1\n4 1\n";
return;
}
cout << "1 3\n4 3\n" << n << " 3\n";
for(int i=3; i<n; i++){
if(i==4) continue;
cout << i << " " << 2 << '\n';
}
}
int main(){
ios_base::sync_with_stdio(false);
cout.tie(NULL);
int t=1;
cin >> t;
while(t--)
solve();
return 0;
}