atcoder#ZONE2021F. 出会いと別れ
出会いと別れ
Score : points
Problem Statement
As your startup's new product, you are planning to build warp gates that allow travel between all planets. There are planets, numbered through , where there is an integer such that . To allow fast travel between all these planets, you want to make warp gates, each of which allows instant travel between two planets. However, for some pairs of planets that are incompatible with each other, you cannot make a warp gate between them. More specifically, such pairs of planets incompatible with each other are represented by a sequence . If and only if there is an integer such that , you cannot make a warp gate between Planet and Planet . Determine whether it is possible to make a network of warp gates allowing travel between every two planets. If it is possible, find one such way to make warp gates.
What is $\mathrm{xor}$?
The bitwise of integers and , , is defined as follows:
- When is written in base two, the digit in the 's place () is if exactly one of and is , and otherwise.
Constraints
- All values in input are integers.
- There exists an integer such that and .
Input
Input is given from Standard Input in the following format:
Output
If it is impossible to make a network of warp gates allowing travel between every two planets, print -1
.
If it is possible to make such a network, print one way to make such warp gates in the following format:
It means you make a warp gate between Planet and Planet .
4 1
3
1 0
1 3
0 2
Since $1\ \mathrm{xor}\ 0 = 1,\ 1\ \mathrm{xor}\ 3 = 2,\ 0\ \mathrm{xor}\ 2 = 2$, we can make those warp gates, and they allow travel between every two planets, so this output will be considered correct. There are many other possible outputs that will also be considered correct.
8 0
1 0
1 3
1 5
6 7
6 4
6 2
3 2
8 7
1 2 3 4 5 6 7
-1