[Solution] Not Escaping solution codeforces – What is the minimum amount of health Ram loses if he takes the most optimal path?

Not Escaping solution codeforces Not Escaping solution codeforces – Major Ram is being chased by his arch enemy Raghav. Ram must reach the top of the building to escape via helicopter. The building, however, is on fire. Ram must choose the optimal path to reach the top of the building to lose the minimum amount …

[Solution] Not Escaping solution codeforces – What is the minimum amount of health Ram loses if he takes the most optimal path? Read More »

[Solution] Not Splitting solution codeforces – The first line of each test case contains two space-separated integers nn and kk

Not Splitting solution codeforces Not Splitting solution codeforces – There is a k×kk×k grid, where kk is even. The square in row rr and column cc is denoted by (r,c)(r,c). Two squares (r1,c1)(r1,c1) and (r2,c2)(r2,c2) are considered adjacent if |r1−r2|+|c1−c2|=1|r1−r2|+|c1−c2|=1. An array of adjacent pairs of squares is called strong if it is possible to cut the grid along grid lines into two connected, congruent pieces so that each pair is part of the same piece. …

[Solution] Not Splitting solution codeforces – The first line of each test case contains two space-separated integers nn and kk Read More »

[Solution] Not Assigning solution codeforces – Print any valid assignment of weights such that the resultant tree is a prime tree.

Not Assigning solution codeforces Not Assigning solution codeforces – You are given a tree of 𝑛n vertices numbered from 11 to 𝑛n, with edges numbered from 11 to 𝑛−1n−1. A tree is a connected undirected graph without cycles. You have to assign integer weights to each edge of the tree, such that the resultant graph is a prime tree. A prime tree is a …

[Solution] Not Assigning solution codeforces – Print any valid assignment of weights such that the resultant tree is a prime tree. Read More »

[Solution] Not Adding solution codeforces – Choose two elements from the array 𝑎𝑖ai and 𝑎𝑗aj (𝑖≠𝑗i≠j) such that gcd(𝑎𝑖,𝑎𝑗)gcd(ai,aj) is not present in the array, and add gcd(𝑎𝑖,𝑎𝑗)gcd(ai,aj) to the end of the array.

Not Adding solution codeforces Not Adding solution codeforces – You have an array 𝑎1,𝑎2,…,𝑎𝑛a1,a2,…,an consisting of 𝑛n distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array 𝑎𝑖ai and 𝑎𝑗aj (𝑖≠𝑗i≠j) such that gcd(𝑎𝑖,𝑎𝑗)gcd(ai,aj) is not present in the array, and add gcd(𝑎𝑖,𝑎𝑗)gcd(ai,aj) to the end of the array. Here gcd(𝑥,𝑦)gcd(x,y) denotes greatest common divisor (GCD) of integers 𝑥x and 𝑦y. Note that the array changes …

[Solution] Not Adding solution codeforces – Choose two elements from the array 𝑎𝑖ai and 𝑎𝑗aj (𝑖≠𝑗i≠j) such that gcd(𝑎𝑖,𝑎𝑗)gcd(ai,aj) is not present in the array, and add gcd(𝑎𝑖,𝑎𝑗)gcd(ai,aj) to the end of the array. Read More »

[Solution] Not Sitting solution codeforces – Rahul and Tina are aware of each other’s intentions and they both choose seats as strategically as possible? Please help satisfy Rahul’s curiosity!

Not Sitting solution codeforces Not Sitting solution codeforces – Rahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a n×mn×m grid. The seat in row rr and column cc is denoted by (r,c)(r,c), and the distance between two seats (a,b)(a,b) and (c,d)(c,d) is |a−c|+|b−d||a−c|+|b−d|. As the class …

[Solution] Not Sitting solution codeforces – Rahul and Tina are aware of each other’s intentions and they both choose seats as strategically as possible? Please help satisfy Rahul’s curiosity! Read More »