[Solution] Christmas Game Codeforces Round #711

Christmas Game Solution Codeforces Alice and Bob are going to celebrate Christmas by playing a game with a tree of presents. The tree has nn nodes (numbered 11 to nn, with some node rr as its root). There are aiai presents are hanging from the ii-th node. Before beginning the game, a special integer kk is chosen. The game proceeds as follows: Alice begins the game, with … Read more

[Solution] Bananas in a Microwave Codeforces Round #711

Bananas in a Microwave Solution Codeforces You have a malfunctioning microwave in which you want to put some bananas. You have nn time-steps before the microwave stops working completely. At each time-step, it displays a new operation. Let kk be the number of bananas in the microwave currently. Initially, k=0k=0. In the ii-th operation, you are given three parameters titi, xixi, yiyi in the input. … Read more

[Solution] Two Houses Codeforces Round #711

Two Houses Solution Codeforces This is an interactive problem. Remember to flush your output while communicating with the testing program. You may use fflush(stdout) in C++, system.out.flush() in Java, stdout.flush() in Python or flush(output) in Pascal to flush the output. If you use some other programming language, consult its documentation. You may also refer to the guide on interactive problems: https://codeforces.com/blog/entry/45307. There is a city … Read more

[Solution] Planar Reflection Codeforces Round #711

Planar Reflection Solution Codeforces Gaurang has grown up in a mystical universe. He is faced by nn consecutive 2D planes. He shoots a particle of decay age kk at the planes. A particle can pass through a plane directly, however, every plane produces an identical copy of the particle going in the opposite direction with a decay age k−1k−1. If … Read more

[Solution] Box Fitting Codeforces Round #711

Box Fitting Solution Codeforces You are given nn rectangles, each of height 11. Each rectangle’s width is a power of 22 (i. e. it can be represented as 2x2x for some non-negative integer xx). You are also given a two-dimensional box of width WW. Note that WW may or may not be a power of 22. Moreover, WW is at least as large as the width of the largest rectangle. … Read more

[Solution] Cheating Detection Solution Code Jam 2021

[Solution] Cheating Detection Solution Code Jam 2021 Problem 100 players are competing in a 10000-question trivia tournament; the players are numbered from 1 to 100. Player ii has a skill level of SiSi and question jj has a difficulty level of QjQj. Each skill level and each question difficulty are chosen uniformly at random from the range [−3.00,3.00][−3.00,3.00], and independently of all other … Read more

[Solution] Reversort Engineering Solution Code Jam 2021

Reversort engineering solution codejam 2021 Problem Note: The main parts of the statements of the problems “Reversort” and “Reversort Engineering” are identical, except for the last paragraph. The problems can otherwise be solved independently. Reversort is an algorithm to sort a list of distinct integers in increasing order. The algorithm is based on the “Reverse” … Read more

[Solution] Moons and Umbrellas Solution Code Jam 2021

Moons and Umbrellas solution codejam 2021 Problem Cody-Jamal is working on his latest piece of abstract art: a mural consisting of a row of waning moons and closed umbrellas. Unfortunately, greedy copyright trolls are claiming that waning moons look like an uppercase C and closed umbrellas look like a J, and they have a copyright … Read more

[Solution] Reversort solution Code Jam 2021

Reversort solution Codejam 2021 Problem Note: The main parts of the statements of the problems “Reversort” and “Reversort Engineering” are identical, except for the last paragraph. The problems can otherwise be solved independently. Reversort solution codejam 2021 Reversort is an algorithm to sort a list of distinct integers in increasing order. The algorithm is based … Read more

Maximize the Remaining String Solution Codeforces Round #710 Div. 3

You are given a string ss, consisting of lowercase Latin letters. While there is at least one character in the string ss that is repeated at least twice, you perform the following operation: you choose the index ii (1≤i≤|s|1≤i≤|s|) such that the character at position ii occurs at least two times in the string ss, and delete the character at position ii, that is, replace ss with s1s2…si−1si+1si+2…sns1s2…si−1si+1si+2…sn. For example, … Read more

Triangular Paths Solution Codeforces Round #710 Div. 3

Consider an infinite triangle made up of layers. Let’s number the layers, starting from one, from the top of the triangle (from top to bottom). The kk-th layer of the triangle contains kk points, numbered from left to right. Each point of an infinite triangle is described by a pair of numbers (r,c)(r,c) (1≤c≤r1≤c≤r), where rr is the number of the layer, … Read more

Restoring the Permutation Solution Codeforces Round #710 Div. 3

A permutation is a sequence of nn integers from 11 to nn, in which all numbers occur exactly once. For example, [1][1], [3,5,2,1,4][3,5,2,1,4], [1,3,2][1,3,2] are permutations, and [2,3,2][2,3,2], [4,3,1][4,3,1], [0][0] are not. Polycarp was presented with a permutation pp of numbers from 11 to nn. However, when Polycarp came home, he noticed that in his pocket, the permutation pp had turned into an array qq according to the following rule: qi=max(p1,p2,…,pi)qi=max(p1,p2,…,pi). Now Polycarp wondered what lexicographically minimal … Read more

Epic Transformation Solution Codeforces Round #710 Div. 3

You are given an array aa of length nn consisting of integers. You can apply the following operation, consisting of several steps, on the array aa zero or more times: you select two different numbers in the array aiai and ajaj; you remove ii-th and jj-th elements from the array. For example, if n=6n=6 and a=[1,6,1,1,4,4]a=[1,6,1,1,4,4], then you can perform the following sequence of operations: select i=1,j=5i=1,j=5. The array aa becomes equal to [6,1,1,4][6,1,1,4]; select i=1,j=2i=1,j=2. The … Read more

Double-ended Strings Solution Codeforces Round #710 Div. 3

You are given the strings aa and bb, consisting of lowercase Latin letters. You can do any number of the following operations in any order: if |a|>0|a|>0 (the length of the string aa is greater than zero), delete the first character of the string aa, that is, replace aa with a2a3…ana2a3…an; if |a|>0|a|>0, delete the last character of the string aa, that is, replace aa with a1a2…an−1a1a2…an−1; if |b|>0|b|>0 (the length of the … Read more