Truck Delivery Solution Google Kickstart 2021

Truck Delivery Solution Google Kickstart 2021 Problem Charles is a truck driver in the city of Googleland. Googleland is built in form of a tree with NN nodes where each node represents a city and each edge represents a road between two cities. The cities are numbered 11 to NN. The capital of Googleland is city 11. Each day Charles picks … Read more

Longest Progression Solution Google Kickstart 2021

Longest Progression Solution Google Kickstart 2021 Problem Sarasvati learned about arithmetic arrays. An arithmetic array is an array that contains at least two integers and the differences between consecutive integers are equal. For example, [9,10][9,10], [3,3,3][3,3,3], and [9,7,5,3][9,7,5,3] are arithmetic arrays, while [1,3,3,7][1,3,3,7], [2,1,2][2,1,2], and [1,2,4][1,2,4] are not. Sarasvati again has an array of NN non-negative integers. The ii-th integer of the array is AiAi. She can … Read more

Increasing Substring Solution Google Kickstart 2021

Increasing Substring Solution Google Kickstart 2021 Problem Your friend John just came back from vacation, and he would like to share with you a new property that he learned about strings. John learned that a string CC of length LL consisting of uppercase English characters is strictly increasing if, for every pair of indices ii and jj such that 1≤i<j≤L1≤i<j≤L (11-based), the character at position ii is … Read more

Binary Operator Solution Google Kickstart 2021

Binary Operator Solution Google Kickstart 2021 Problem You are given a list of valid arithmetic expressions using non-negative integers, parentheses (), plus +, multiply *, and an extra operator #. The expressions are fully parenthesized and in infix notation. A fully parenthesized expression is an expression where every operator and its operands are wrapped in a single parenthesis.For example, the expression x+yx+y becomes (x+y)(x+y) when … Read more

Rock Paper Scissors Solution Google Kickstart 2021

Rock Paper Scissors Solution Google Kickstart 2021 Problem You and your friend like to play Rock Paper Scissors. Each day you play exactly 6060 rounds and at the end of each day, you tally up the score from these 6060 rounds. During each round, without any knowledge of the other person’s choice, you each make your choice. Then, you both … Read more

Alien Generator Solution Google Kickstart 2021

Alien Generator Solution Google Kickstart 2021 Problem Astronauts have landed on a new planet, Kickstartos. They have discovered a machine on the planet: a generator that creates gold bars. The generator works as follows. On the first day, an astronaut inputs a positive integer KK into the generator. The generator will produce KK gold bars that day. The next … Read more

Smaller Strings Solution Google Kickstart 2021

Smaller Strings Solution Google Kickstart 2021 Problem You are given an integer KK and a string SS of length NN, consisting of lowercase letters from the first KK letters of the English alphabet. Find the number of palindrome strings of length NN which are lexicographically smaller than SS and consist of lowercase letters from the first KK letters of the English alphabet. A string composed of ordered letters a1,a2,…,ana1,a2,…,an is … Read more

Double or NOTing Solution Code Jam 2021

Double or NOTing Solution Code Jam 2021 Problem You are given a starting non-negative integer SS and an ending non-negative integer EE. Both SS and EE are given by their binary representation (that is, they are given written in base 22). Your goal is to transform SS into EE. The following two operations are available to you: Double your current value. Take the bitwise NOT of … Read more

Roaring Years Solution Code Jam 2021

Problem Something is happening in 20212021 that has not happened in over a century. 20212021, like 19201920 before it, is a roaring year. A year represented by a positive integer yy is roaring if the decimal writing (without leading zeroes) of yy is the concatenation of the decimal writing (without leading zeroes) of two or more distinct consecutive positive integers, in increasing order. In … Read more

Closest Pick Solution Code Jam 2021

Problem You are entering a raffle for a lifetime supply of pancakes. NN tickets have already been sold. Each ticket contains a single integer between 11 and KK, inclusive. Different tickets are allowed to contain the same integer. You know exactly which numbers are on all of the tickets already sold and would like to maximize your odds of winning … Read more

[Solution] GCD Sum Codeforces Round #711

The gcdSumgcdSum of a positive integer is the gcdgcd of that integer with its sum of digits. Formally, gcdSum(x)=gcd(x, sum of digits of x)gcdSum(x)=gcd(x, sum of digits of x) for a positive integer xx. gcd(a,b)gcd(a,b) denotes the greatest common divisor of aa and bb — the largest integer dd such that both integers aa and bb are divisible by dd. For example: gcdSum(762)=gcd(762,7+6+2)=gcd(762,15)=3gcdSum(762)=gcd(762,7+6+2)=gcd(762,15)=3. Given an integer nn, find the smallest integer x≥nx≥n such that gcdSum(x)>1gcdSum(x)>1.Input The first line of input contains one integer tt (1≤t≤104)(1≤t≤104) — the … Read more

[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