To Go Or Not To Go solution codeforces – Dima overslept the alarm clock, which was supposed to raise him to school. 2021

To Go Or Not To Go solution codeforces Dima overslept the alarm clock, which was supposed to raise him to school. Dima wonders if he will have time to come to the first lesson. To do this, he needs to know the minimum time it will take him to get from home to school. The city where Dima lives is a rectangular … Read more

Guess the K-th Zero (Hard version) solution codeforces – This is a hard version of the problem. 2021

Guess the K-th Zero (Hard version) solution codeforces This is an interactive problem. This is a hard version of the problem. The difference from the easy version is that in the hard version 1≤t≤min(n,104)1≤t≤min(n,104) and the total number of queries is limited to 6⋅1046⋅104. Polycarp is playing a computer game. In this game, an array consisting of zeros and ones is hidden. Polycarp wins … Read more

[SOLUTION] Guess the K-th Zero (Easy version) solution codeforces 2021

Guess the K-th Zero (Easy version) solution codeforces This is an interactive problem. This is an easy version of the problem. The difference from the hard version is that in the easy version t=1t=1 and the number of queries is limited to 2020. Polycarp is playing a computer game. In this game, an array consisting of zeros and ones is hidden. Polycarp wins … Read more

Arranging The Sheep solution codeforces – You are playing the game “Arranging The Sheep” 2021

Arranging The Sheep solution codeforces You are playing the game “Arranging The Sheep”. The goal of this game is to make the sheep line up. The level in the game is described by a string of length nn, consisting of the characters ‘.‘ (empty space) and ‘*‘ (sheep). In one move, you can move any sheep one square to the left or … Read more

Same Differences solution codeforces – You are given an array aa of nn integers 2021

Same Differences solution codeforces You are given an array aa of nn integers. Count the number of pairs of indices (i,j)(i,j) such that i<ji<j and aj−ai=j−iaj−ai=j−i. Input Same Differences solution codeforces The first line contains one integer tt (1≤t≤1041≤t≤104). Then tt test cases follow. The first line of each test case contains one integer nn (1≤n≤2⋅1051≤n≤2⋅105). The second line of each test case contains nn integers a1,a2,…,ana1,a2,…,an (1≤ai≤n1≤ai≤n) — array aa. It is guaranteed that the sum of nn over all test cases does not … Read more

Not Adjacent Matrix solution codeforces – We will consider the numbers aa and bb as adjacent if they differ by exactly one, that is, |a−b|=1|a−b|=1.

Not Adjacent Matrix solution codeforces We will consider the numbers aa and bb as adjacent if they differ by exactly one, that is, |a−b|=1|a−b|=1. We will consider cells of a square matrix n×nn×n as adjacent if they have a common side, that is, for cell (r,c)(r,c) cells (r,c−1)(r,c−1), (r,c+1)(r,c+1), (r−1,c)(r−1,c) and (r+1,c)(r+1,c) are adjacent to it. For a given number nn, construct a square matrix n×nn×n such that: Each integer from 11 to n2n2 occurs in this matrix exactly once; If (r1,c1)(r1,c1) and (r2,c2)(r2,c2) are adjacent cells, … Read more

Ordinary Numbers solution codeforces – Let’s call a positive integer nn ordinary if in the decimal notation all its digits are the same

Ordinary Numbers solution codeforces  Let’s call a positive integer nn ordinary if in the decimal notation all its digits are the same. For example, 11, 22 and 9999 are ordinary numbers, but 719719 and 20212021 are not ordinary numbers. For a given number nn, find the number of ordinary numbers among the numbers from 11 to nn. Input Ordinary Numbers solution codeforces The first line contains one integer tt (1≤t≤1041≤t≤104). Then tt test cases follow. Each test case is characterized by … Read more

Do Not Be Distracted solution codeforces – Polycarp has 2626 tasks. Each task is designated by a capital letter of the Latin alphabet.

Do Not Be Distracted solution codeforces Polycarp has 2626 tasks. Each task is designated by a capital letter of the Latin alphabet. The teacher asked Polycarp to solve tasks in the following way: if Polycarp began to solve some task, then he must solve it to the end, without being distracted by another task. After switching to another task, Polycarp cannot return … Read more

Phoenix and Diamonds solution codeforces – Phoenix wonders what it is like to rob diamonds from a jewelry store! 2021

Phoenix and Diamonds solution codeforces Phoenix and Diamonds solution codeforces Phoenix and Diamonds solution codeforces Phoenix and Diamonds solution codeforces Phoenix wonders what it is like to rob diamonds from a jewelry store! There are nn types of diamonds. The ii-th type has weight wiwi and value vivi. The store initially has aiai diamonds of the ii-th type. Each day, for qq days, one of the following will happen: A new … Read more

Phoenix and Bits solution codeforces – Phoenix loves playing with bits , 2021

Phoenix and Bits solution codeforces Phoenix and Bits solution codeforces Phoenix and Bits solution codeforces Phoenix and Bits solution codeforces Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has nn integers a1,a2,…,ana1,a2,…,an, and will perform qq of the following queries: replace all numbers aiai where l≤ai≤rl≤ai≤r with aiai AND xx; replace all numbers aiai where l≤ai≤rl≤ai≤r with aiai OR xx; replace all numbers aiai where l≤ai≤rl≤ai≤r with aiai XOR xx; output how many distinct integers aiai where l≤ai≤rl≤ai≤r. For each query, Phoenix is given ll, rr, and xx. Note … Read more