Password Decryption
Time limit2sMemory limit512 MB
Given M range-XOR constraints on an unknown array of N numbers, find any array satisfying all constraints or report that none exists.
- Level
Medium7 of 10
- Topics
- Union-find, Graph, Bit manipulation, Prefix sum
- Solved
- No attempts yet
Problem
Junki invented a new rule for encrypting a sequence of () numbers. Junki's encryption consists of () clues.
The -th clue consists of three values (, ), which means that the bitwise XOR of the -th through -th numbers in Junki's sequence equals .
Seungwon heard Junki's encryption rule and tried to find a way to recover numbers satisfying the given rule, but failed in the end. Help Seungwon by writing a program that, given Junki's encryption rule, outputs numbers satisfying the given rule.
Input
The first line gives separated by a space ().
From the second line, lines follow, each giving (, ) separated by spaces. This means that the bitwise XOR of the -th through -th numbers in the array equals .
Output
Print numbers separated by spaces that satisfy all given rules. The numbers making up the resulting array must be between and inclusive. If multiple sequences satisfy the conditions, output any one of them. If no sequence satisfies all conditions, print .