0% found this document useful (0 votes)
12 views

Problem - 1747D - Codeforces

The document describes a programming problem from Codeforces Round 832 (Div. 2), where participants must handle queries on a subarray of integers. The task is to determine the minimum number of operations needed to make all elements in the specified subarray equal to 0 using XOR operations. Input includes the size of the array, the number of queries, and the queries themselves, while output is the result for each query.

Uploaded by

Yhlas Yklymow
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Problem - 1747D - Codeforces

The document describes a programming problem from Codeforces Round 832 (Div. 2), where participants must handle queries on a subarray of integers. The task is to determine the minimum number of operations needed to make all elements in the specified subarray equal to 0 using XOR operations. Input includes the size of the array, the number of queries, and the queries themselves, while output is the result for each query.

Uploaded by

Yhlas Yklymow
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

5/22/24, 12:09 PM Problem - 1747D - Codeforces

|
stdfloat | Logout

HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP

PROBLEMS SUBMIT STATUS STANDINGS CUSTOM TEST

Codeforces Round 832 (Div. 2)


D. Yet Another Problem Finished
time limit per test: 1 second Practice
memory limit per test: 256 megabytes
input: standard input
output: standard output

You are given an array a of n integers a1 , a2 , a3 , … , an . → Virtual participation 

You have to answer q independent queries, each consisting of two integers l and r .
→ Clone Contest to Mashup 
Consider the subarray a[l : r] = [al , al+1 , … , ar ] . You can apply the following
operation to the subarray any number of times (possibly zero)-
→ Submit?
1. Choose two integers L , R such that l ≤ L ≤ R ≤ r and R − L + 1 is odd.
2. Replace each element in the subarray from L to R with the XOR of the elements in Language: GNU G++20 13.2 (64 bit, winlibs)

the subarray [L, R] . Choose


Choose File No file chosen
file:
The answer to the query is the minimum number of operations required to make all
Submit
elements of the subarray a[l : r] equal to 0 or −1 if it is impossible to make all of them
equal to 0 .

You can find more details about XOR operation here. → Contest materials

Input Announcement (en)


The first line contains two integers n and q (1 ≤ n, q ≤ 2 ⋅ 105 ) — the length of the array a Tutorial (en)
and the number of queries.

The next line contains n integers a1 , a2 , … , an (0 ≤ ai < 230 ) — the elements of the
array a.

The i -th of the next q lines contains two integers li and ri (1 ≤ li ≤ ri ≤ n) — the
description of the i -th query.

Output
For each query, output a single integer — the answer to that query.

Example
input Copy

7 6
3 0 3 3 1 2 3
3 4
4 6
3 7
5 6
1 6
2 2

output Copy

-1
1
1
-1
2
0

Note

https://mirror.codeforces.com/problemset/problem/1747/D 1/2
5/22/24, 12:09 PM Problem - 1747D - Codeforces
In the first query, l = 3, r = 4, subarray = [3, 3]. We can apply operation only to the
subarrays of length 1 , which won't change the array; hence it is impossible to make all
elements equal to 0 .

In the second query, l = 4, r = 6, subarray = [3, 1, 2] . We can choose the whole subarray
(L = 4, R = 6) and replace all elements by their XOR (3 ⊕ 1 ⊕ 2) = 0, making the
subarray [0, 0, 0] .

In the fifth query, l = 1, r = 6, subarray = [3, 0, 3, 3, 1, 2]. We can make the operations as
follows:

1. Choose L = 4, R = 6, making the subarray [3, 0, 3, 0, 0, 0].


2. Choose L = 1, R = 5, making the subarray [0, 0, 0, 0, 0, 0].

Codeforces (c) Copyright 2010-2024 Mike Mirzayanov


The only programming contests Web 2.0 platform
Server time: May/22/2024 12:06:39UTC+5 (l1).
Desktop version, switch to mobile version.
Privacy Policy

Supported by

https://mirror.codeforces.com/problemset/problem/1747/D 2/2

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy