CF2170F.Build XOR on a Segment
省选/NOI-
通过率:0%
时间限制:5.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an array of n integers a1,a2,…,an, where all numbers are from 1 to 212−1.
You have to process q queries. Each query is defined by three integers li,ri,xi: you need to find the smallest set S=s1,s2,…,sk that satisfies the following conditions:
- each sj is equal to some element from the subarray from the li-th position to the ri-th position inclusive;
- s1⊕s2⊕⋯⊕sk=xi, where ⊕ denotes bitwise XOR.
给你一个包含 n 个整数的数组 a1,a2,…,an,其中所有数均在 1 到 212−1 之间。
你需要处理 q 个查询。每个查询由三个整数 li,ri,xi 定义:你需要找出满足以下条件的最小集合 S={s1,s2,…,sk}:
- 每个 sj 等于子数组(从第 li 个位置到第 ri 个位置,含端点)中的某个元素;
- s1⊕s2⊕⋯⊕sk=xi,其中 ⊕ 表示按位异或运算。
输入格式
The first line contains one integer n (2≤n≤104).
The second line contains n integers a1,a2,…,an (1≤ai≤212−1).
The third line contains one integer q (1≤q≤106).
Then q lines follow. The i-th of them contains three integers li,ri,xi (1≤li≤ri≤n; 1≤xi≤212−1).
第一行包含一个整数 n(2≤n≤104)。
第二行包含 n 个整数 a1,a2,…,an(1≤ai≤212−1)。
第三行包含一个整数 q(1≤q≤106)。
接下来是 q 行。其中第 i 行包含三个整数 li,ri,xi(1≤li≤ri≤n;1≤xi≤212−1)。
输出格式
For each query, print one integer — the minimum size of the required set. If such a set does not exist, print 0.
对于每个查询,输出一个整数——所需集合的最小大小。如果这样的集合不存在,则输出 0。
输入输出样例
输入#1
7 3 5 4 1 7 3 1 5 1 3 1 1 4 1 1 3 2 4 7 5 1 7 8
输出#1
2 1 3 3 0
说明/提示
Consider the queries from the example:
- in the first query, you can choose S=5,4;
- in the second query, you can choose S=1;
- in the third query, you can choose S=4,3,5;
- in the fourth query, you can choose S=1,3,7.
考虑示例中的查询:
- 在第一个查询中,你可以选择 S=5,4;
- 在第二个查询中,你可以选择 S=1;
- 在第三个查询中,你可以选择 S=4,3,5;
- 在第四个查询中,你可以选择 S=1,3,7。
输入解题思路,AI测评打分。不知道怎么写?