#CC0000071. Đếm số lớn hơn ngưỡng với truy vấn XOR (KQUERYO - K-Query Online)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Đếm số lớn hơn ngưỡng với truy vấn XOR (KQUERYO - K-Query Online)
KQUERYO - K-Query Online
Source: SPOJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given an array, each query provides encoded integers . Decode , , , where is the previous answer (initially ). Clamp to at least and to at most . If , answer ; otherwise count values strictly greater than in . Set to this answer.
Input
The first line contains ; the second contains array values; the third contains ; then each of the lines contains encoded integers .
Output
Print one count per query; each printed count is used to decode the next query.
Subtasks
Original constraints: ; ; . Queries are XOR-encoded; out-of-range indices follow the rules above.
- Subtask 1 (20 points): ; ; for decoded threshold ; the index-adjustment rule still applies.
- Subtask 2 (30 points): ; ; for decoded threshold ; the index-adjustment rule still applies.
- Subtask 3 (50 points): ; ; for decoded threshold ; the index-adjustment rule still applies.
Examples
Input
6
8 9 3 5 1 9
5
2 3 5
3 3 7
0 0 11
0 0 2
3 7 4
Output
1
1
0
0
2
Explanation
The first decoded query is with threshold , giving . In the second query, XOR with yields and , giving again.