## [Solution] Kirill and Company solution codeforces

Kirill and Company solution codeforces Kirill and Company solution codeforces – Kirill lives on a connected undirected graph of šnĀ vertices andĀ šmĀ edges at vertexĀ 11. One fine evening he gatheredĀ šfĀ friends, theĀ ši-th friend lives at the vertexĀ āšhi. So all friends are now in the vertexĀ 11, theĀ ši-th friend must get to his home to the vertexĀ āšhi. The evening is … Read more

## [Solution] Multi-Colored Segments solution codeforces

Multi-Colored Segments solution codeforces Multi-Colored Segments solution codeforces – Dmitry has šnĀ segments of different colors on the coordinate axisĀ šš„Ox. Each segment is characterized by three integersĀ ššli,Ā ššriĀ andĀ ššciĀ (1ā¤ššā¤ššā¤109,1ā¤ššā¤š1ā¤liā¤riā¤109,1ā¤ciā¤n), whereĀ ššliĀ andĀ ššriĀ are are the coordinates of the ends of theĀ ši-th segment, andĀ ššciĀ is its color. Dmitry likes to find the minimum distances between segments. However, he considers pairs of segments of … Read more

## [Solution] Sending a Sequence Over the Network solution codeforces

Sending a Sequence Over the Network solution codeforces Sending a Sequence Over the Network solution codeforces – The sequence šaĀ is sent over the network as follows: sequenceĀ šaĀ is split into segments (each element of the sequence belongs to exactly one segment, each segment is a group of consecutive elements of sequence); for each segment, its length … Read more

## [Solution] Masha and a Beautiful Tree solution codeforces

Masha and a Beautiful Tree solution codeforces Masha and a Beautiful Tree solution codeforces – The girl named Masha was walking in the forest and found a complete binary tree of height šnĀ and a permutationĀ špĀ of lengthĀ š=2šm=2n. A complete binary tree of heightĀ šnĀ is a rooted tree such that every vertex except the leaves has exactly two … Read more

## [Solution] Minimize the Thickness solution codeforces

Minimize the Thickness solution codeforces Minimize the Thickness solution codeforces – You are given a sequence š=[š1,š2,ā¦,šš]a=[a1,a2,ā¦,an]Ā consisting ofĀ šnĀ positiveĀ integers. Let’s call a group of consecutive elements aĀ segment. EachĀ segmentĀ is characterized by two indices: the index of its left end and the index of its right end. Denote byĀ š[š,š]a[l,r]Ā aĀ segmentĀ of the sequenceĀ šaĀ with the left end inĀ šlĀ and the right end … Read more

## [Solution] Funny Permutation solution codeforces

Funny Permutation solution codeforces Funny Permutation solution codeforces – A sequence of šnĀ numbers is calledĀ permutationĀ if it contains all numbers fromĀ 11Ā toĀ šnĀ exactly once. For example, the sequencesĀ [3,1,4,2][3,1,4,2], [11] andĀ [2,1][2,1]Ā are permutations, butĀ [1,2,1][1,2,1],Ā [0,1][0,1]Ā andĀ [1,3,4][1,3,4]Ā are not. For a given numberĀ šnĀ you need to make a permutationĀ špĀ such that two requirements are satisfied at the same time: For each elementĀ ššpi, at least one of … Read more

## [Solution] Compare T-Shirt Sizes solution codeforces

Compare T-Shirt Sizes solution codeforces Compare T-Shirt Sizes solution codeforces – Two T-shirt sizes are given: šaĀ andĀ šb. The T-shirt size is either a stringĀ MĀ or a string consisting of several (possibly zero) charactersĀ XĀ and one of the charactersĀ SĀ orĀ L. For example, stringsĀ M,Ā XXL,Ā S,Ā XXXXXXXSĀ could be the size of some T-shirts. And the stringsĀ XM,Ā LL,Ā SXĀ are not sizes. The letterĀ MĀ stands for medium,Ā SĀ for small,Ā LĀ for … Read more

## [Solution] Swap and Take solution codeforces

Swap and Take solution codeforces – You’re given an array consisting of šnĀ integers. You have to performĀ šnĀ turns. [Solution] Swap and Take solution codeforces Initially your score isĀ 00. On theĀ ši-th turn, you are allowed to leave the array as it is or swap any one pair ofĀ 22Ā adjacent elements in the array and change exactly one of … Read more

## [Solution] Equal Binary Subsequences solution codeforces

Equal Binary Subsequences solution codeforces – Everool has a binary string š sĀ of lengthĀ 2š2n. Note that a binary string is a string consisting of only charactersĀ 00Ā andĀ 11. He wants to partitionĀ š sĀ into twoĀ disjoint equalĀ subsequences. He needs your help to do it. [Solution] Equal Binary Subsequences solution codeforces You are allowed to do the following operationĀ exactlyĀ once. You can choose … Read more

## [Solution] Good Subarrays (Hard Version) solution codeforces

Good Subarrays (Hard Version) solution codeforces – An array šbĀ of lengthĀ šmĀ isĀ goodĀ if for allĀ šiĀ theĀ ši-th element is greater than or equal toĀ ši. In other words,Ā šbĀ isĀ goodĀ if and only ifĀ ššā„šbiā„iĀ for allĀ šiĀ (1ā¤šā¤š1ā¤iā¤m). [Solution] Good Subarrays (Hard Version) solution codeforces You are given an arrayĀ šaĀ consisting ofĀ šnĀ positive integers, and you are askedĀ šqĀ queries. In each query, you are given two integersĀ špĀ andĀ š„xĀ (1ā¤š,š„ā¤š1ā¤p,xā¤n). You have … Read more