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

Problem - 1718A1 - Codeforces

The document describes a problem from Codeforces Round 814 (Div. 1) titled 'Burenka and Traditions'. Burenka, the crown princess, must turn an array of integers into zeros using a specific two-step operation, and the goal is to calculate the minimum time required for this task. The input consists of multiple test cases, each specifying the size of the array and its elements, with constraints on the values.

Uploaded by

yhlasyklymov08
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)
19 views

Problem - 1718A1 - Codeforces

The document describes a problem from Codeforces Round 814 (Div. 1) titled 'Burenka and Traditions'. Burenka, the crown princess, must turn an array of integers into zeros using a specific two-step operation, and the goal is to calculate the minimum time required for this task. The input consists of multiple test cases, each specifying the size of the array and its elements, with constraints on the values.

Uploaded by

yhlasyklymov08
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:12 PM Problem - 1718A1 - Codeforces

|
stdfloat | Logout

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

PROBLEMS SUBMIT STATUS STANDINGS CUSTOM TEST

Codeforces Round 814 (Div. 1)


A1. Burenka and Traditions (easy version) Finished
time limit per test: 1 second Practice
memory limit per test: 256 megabytes
input: standard input
output: standard output

This is the easy version of this problem. The difference between easy and hard versions → Virtual participation 
is only the constraints on ai and on n . You can make hacks only if both versions of the
problem are solved. → Clone Contest to Mashup 
Burenka is the crown princess of Buryatia, and soon she will become the n -th queen of the
country. There is an ancient tradition in Buryatia — before the coronation, the ruler must show → Submit?
their strength to the inhabitants. To determine the strength of the n -th ruler, the inhabitants of
the country give them an array of a of exactly n numbers, after which the ruler must turn all
Language: GNU G++20 13.2 (64 bit, winlibs)
the elements of the array into zeros in the shortest time. The ruler can do the following two-
step operation any number of times: Choose
Choose File No file chosen
file:

select two indices l and r , so that 1 ≤ l ≤ r ≤ n and a non-negative integer x , then


Submit
for all l ≤ i ≤ r assign ai := ai ⊕ x, where ⊕ denotes the bitwise XOR operation. It
takes ⌈ ⌉ seconds to do this operation, where
r−l+1
2
⌈y⌉ denotes y rounded up to the
nearest integer. → Contest materials

Help Burenka calculate how much time she will need. Codeforces Round #814

Tutorial (en)
Input
The first line contains a single integer t (1 ≤ t ≤ 500) — the number of test cases. The
description of the test cases follows.

The first line of each test case contains a single integer n (1 ≤ n ≤ 5000) — the size of the
array.

The second line of each test case contains n integers a1 , a2 , … , an (0 ≤ ai ≤ 5000 ) —


elements of the array.

It is guaranteed that the sum of n in all tests does not exceed 5000.

Output
For each test case, output a single number — the minimum time that Burenka will need.

Example
input Copy

7
4
5 5 5 5
3
1 3 2
2
0 0
3
2 5 7
6
1 2 3 3 2 1
10
27 27 34 32 2 31 23 56 52 4
5
1822 1799 57 23 55

https://mirror.codeforces.com/problemset/problem/1718/A1 1/2
5/22/24, 12:12 PM Problem - 1718A1 - Codeforces

output Copy

2
2
0
2
4
7
4

Note
In the first test case, Burenka can choose segment l = 1, r = 4 , and x = 5 . so it will fill the
array with zeros in 2 seconds.

In the second test case, Burenka first selects segment l = 1, r = 2 , and x = 1 , after which
a = [0, 2, 2], and then the segment l = 2, r = 3 , and x = 2 , which fills the array with
zeros. In total, Burenka will spend 2 seconds.

Codeforces (c) Copyright 2010-2024 Mike Mirzayanov


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

Supported by

https://mirror.codeforces.com/problemset/problem/1718/A1 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