#P8955. 「VUSC」Card Tricks
「VUSC」Card Tricks
Background
upd 2023.1.17 The testdata has been strengthened.
upd 2023.10.18 The memory limit has been adjusted to 100 MiB.
Bessie is playing a card game.
This game has some mysterious rules. Bessie needs to use some programming skills to speed up the computation.
Problem Description
The deck can be seen as a sequence of length , where the value at position is . .
There are operations. Each operation gives , and for all , do .
Here means the bitwise OR operation, i.e. | in C++.
For , find after which operation becomes strictly greater than for the first time, where is a given constant.
The testdata guarantees that initially, .
Input Format
The first line contains three integers .
The second line contains integers; the -th number is the initial value of .
The next lines each contain three integers .
Output Format
Output numbers . The -th number means that after the -th operation, becomes strictly greater than for the first time.
If is always less than or equal to , output at this position.
5 7 10
1 2 3 4 5
1 1 1
1 1 10
2 5 4
2 3 8
5 5 2
5 5 1
5 5 16
2 4 4 -1 7
10 10 86
26 27 33 1 21 31 9 22 17 14
6 10 76
5 8 85
4 5 89
3 9 87
2 9 100
7 10 83
1 6 75
1 4 66
3 10 68
3 4 72
7 5 4 3 3 1 2 1 1 6
Hint
Sample #1 Explanation
After the first operation, the sequence is .
After the second operation, the sequence is .
After the third operation, the sequence is .
……
The final sequence is .
Constraints
All testdata satisfies: , , .
Test points additionally satisfy .
Test point additionally satisfies .
Test point additionally satisfies .
Test points have no additional constraints.
The data size of this problem is large, so please pay attention to constant-factor optimizations.
Translated by ChatGPT 5