Tree Infection solution codeforces

Tree Infection solution codeforces   A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. The parent of a vertex vv (different from root) is the previous to vv vertex on the shortest path from the root to the vertex vv. Children of the vertex vv are all vertices for which vv is the parent. You … Read more

GCD Guess solution codeforces

GCD Guess solution codeforces   This is an interactive problem. There is a positive integer 1≤x≤1091≤x≤109 that you have to guess. In one query you can choose two positive integers a≠ba≠b. As an answer to this query you will get gcd(x+a,x+b)gcd(x+a,x+b), where gcd(n,m)gcd(n,m) is the greatest common divisor of the numbers nn and mm. To guess one hidden number xx you are allowed to make no more than 3030 queries. … Read more

MinimizOR solution codechef

MinimizOR solution codechef   You are given an array aa of nn non-negative integers, numbered from 11 to nn. Let’s define the cost of the array aa as mini≠jai|ajmini≠jai|aj, where || denotes the bitwise OR operation. There are qq queries. For each query you are given two integers ll and rr (l<rl<r). For each query you should find the cost of the subarray al,al+1,…,aral,al+1,…,ar. Input Each test case consists of several test cases. The first line contains … Read more

GCD Guess solution codechef

GCD Guess solution codechef   This is an interactive problem. There is a positive integer 1≤x≤1091≤x≤109 that you have to guess. In one query you can choose two positive integers a≠ba≠b. As an answer to this query you will get gcd(x+a,x+b)gcd(x+a,x+b), where gcd(n,m)gcd(n,m) is the greatest common divisor of the numbers nn and mm. To guess one hidden number xx you are allowed to make no more than 3030 queries. … Read more

Tree Infection solution codechef

Tree Infection solution codechef   A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. The parent of a vertex vv (different from root) is the previous to vv vertex on the shortest path from the root to the vertex vv. Children of the vertex vv are all vertices for which vv is the parent. You … Read more

Array Cloning Technique solution codechef

Array Cloning Technique solution codechef   You are given an array aa of nn integers. Initially there is only one copy of the given array. You can do operations of two types: Choose any array and clone it. After that there is one more copy of the chosen array. Swap two elements from any two copies (maybe in the same copy) … Read more

GCD vs LCM solution codechef

GCD vs LCM solution codechef You are given a positive integer nn. You have to find 44 positive integers a,b,c,da,b,c,d such that a+b+c+d=na+b+c+d=n, and gcd(a,b)=lcm(c,d)gcd(a,b)=lcm⁡(c,d). If there are several possible answers you can output any of them. It is possible to show that the answer always exists. In this problem gcd(a,b)gcd(a,b) denotes the greatest common divisor of aa and bb, and lcm(c,d)lcm⁡(c,d) denotes the least common multiple of cc and dd. Input The input consists … Read more

Authorities in Sydney closed several beaches in February 2022 due to danger from which marine creature?

Q3 – Authorities in Sydney closed several beaches in February 2022 due to danger from which marine creature?“ …CONTEST AND DETAILS & HOW TO ENTER: 1. This Contest Will Commence OnFri Apr 08 2022 08:26:57 GMT+0530 (India Standard Time)From 08:00:01 A.M. (IST) To 12:00:00 P.M. (IST) (“Contest Period”) 2. In Order To Be Eligible For … Read more

Broken Life solution codechef

Broken Life solution codechef   You are given two strings SS and AA of lengths NN and MM respectively. String SS contains characters from the set {?, a, b, c, d, e}{?, a, b, c, d, e}. String AA contains characters from the set {a, b, c, d, e}{a, b, c, d, e}. Let S′S′ denote the string formed by replacing all the ?? in SS using the characters from the set {a, b, c, d, e}{a, b, c, d, e}.Construct S′S′ such that AA is not a subsequence of S′S′. If multiple such S′S′ exist, output any. If no such S′S′ exists, print −1−1. … Read more

Stable Mex solution codechef

Stable Mex solution codechef   Chef gives you a sequence AA of length NN.Let XX denote the MEXMEX of the sequence AA. Chef is interested in the count of positive values kk, such that, if every element AiAi of AA is replaced by max(Ai−k,0)max(Ai−k,0), the MEXMEX of the sequence still remains XX. Find the count of such values. If there are infinite such values, print −1−1 instead. As a friendly reminder, the MEXMEX of a sequence is the smallest non-negative integer that … Read more