Static Range Sums
Challenge on lesson: Checkpoint — Read, Then Decide
CHALLENGE
Difficulty: advanced+25 XP
**Bài toán.** Given n integers and q queries. Each query gives l and r (1 ≤ l ≤ r ≤ n); consider the sum s = a[l..r] for each query. **Output:** two numbers — the XOR of all q sums, and the sum of all q sums modulo 1 000 000 007. **Constraints:** 1 ≤ n, q ≤ 200000; |a[i]| ≤ 10^6. The array is static. Ranges may be given with l > r; treat them as [r, l]. **Warning:** a per-query loop is O(n·q) total — the largest test will not finish. Choose the complexity the constraints allow.
Press Submit to check your solution.
Back to lesson: Checkpoint — Read, Then Decide