Professional Documents
Culture Documents
Flip 1
Flip 1
Flip
Input file: standard input
Output file: standard output
Time limit: 2 seconds
Memory limit: 1024 MB
Having been an amazing skateboarder, you know how cool flips are: Heelflips, Kickflips, Frontflips and
so on. You know what it’s all about!
Because you retired, today you are going to have fun with a different type of flip.
P
ai ⊕ aj
1≤i<j≤N
Input
The first line contains integers N , K and P . It is guaranteed that 1 ≤ N ≤ 105 , 1 ≤ K ≤ 30 and
1 ≤ P ≤ N ∗ K.
The next line contains N integers, the array a. It is guaranteed that 0 ≤ ai < 2K for all 1 ≤ i ≤ N .
Output
The output file should contain exactly P lines each containing two integers i and j such that 1 ≤ i ≤ N
and 0 ≤ j < K, which represent flipping bit j of number ai . Namely, ai ⇐ ai ⊕ 2j .
You are allowed to flip the same bit multiple times. Any solution that maximizes the sum
is valid. The order in which you output the operations is not important.
Example
standard input standard output
4 2 2 4 0
0 0 2 2 3 0
2 5 1 1 0
0 31
5 6 4 5 5
63 15 0 10 5 4 5
4 4
5 4
Page 1 of 1