Codechef

Chodechef long challenge problems

CodeChef: June Challenge | Optimal Xor Set OPTSET | Python, Java, C++ Solution

View problem on codechef Find KK distinct numbers in the range [1,N][1,N] such that the bitwise XOR of all the numbers is maximized. Print any set of these numbers that maximize the XOR. Input The first line contains an integer TT, the number of test cases. Then the test cases follow. Each test case contains a single line of input, two integers NN, KK. …

CodeChef: June Challenge | Optimal Xor Set OPTSET | Python, Java, C++ Solution Read More »

CodeChef: June Challenge | Minimum Subtree Cover | Python, Java, C++ Solution

View problem on Codechef You are given a tree with nn vertices (numbered 1,2,…,n1,2,…,n) and an integer kk. A subtree is defined as a connected subgraph of the tree. That is, a subtree is another tree that can be obtained by removing some (possibly none) vertices and all edges incident to those vertices from TT. A subset SS of vertices is called …

CodeChef: June Challenge | Minimum Subtree Cover | Python, Java, C++ Solution Read More »

CodeChef: June Challenge | Minimum Dual Area DAREA| Python, Java, C++ Solutions

View problem on codechef Given NN points in a 2D2D space, find the minimum sum of areas of rectangles required to cover all the points given that we can use at most 22 non-overlapping rectangles whose sides can touch. The rectangles must be axis-aligned, meaning the sides are vertical and horizontal. For the work from home Internship Programs : Click here …

CodeChef: June Challenge | Minimum Dual Area DAREA| Python, Java, C++ Solutions Read More »

CodeChef: June Challenge | Bitwise Tuples | BITTUP| Python, Java, C++ Solution

View problem on codechef Chef has two numbers NN and MM. Help Chef to find number of integer NN-tuples (A1,A2,…,AN)(A1,A2,…,AN) such that 0≤A1,A2,…,AN≤2M−10≤A1,A2,…,AN≤2M−1 and A1&A2&…&AN=0A1&A2&…&AN=0, where && denotes the bitwise AND operator. Since the number of tuples can be large, output it modulo 109+7109+7. Input The first line contains a single integer TT denoting the number of test cases. The description of TT test cases follows. The first and only line of each …

CodeChef: June Challenge | Bitwise Tuples | BITTUP| Python, Java, C++ Solution Read More »

CodeChef: June Challenge | Shortest Route | Full Solution

View problem on Codechef There are NN cities in Chefland numbered from 11 to NN and every city has a railway station. Some cities have a train and each city has at most one train originating from it. The trains are represented by an array AA, where Ai=0Ai=0 means the ii-th city doesn’t have any train originating from it, Ai=1Ai=1 means the train originating from the ii-th city …

CodeChef: June Challenge | Shortest Route | Full Solution Read More »

CodeChef: June Challenge | Bella ciao | CHFHEIST | Python, Java C++ Solution

Chef is planning a heist in the reserve bank of Chefland. They are planning to hijack the bank for DD days and print the money. The initial rate of printing the currency is PP dollars per day and they increase the production by QQ dollars after every interval of dd days. For example, after dd days the rate is P+QP+Q dollars per day, and after 2d2d days the rate …

CodeChef: June Challenge | Bella ciao | CHFHEIST | Python, Java C++ Solution Read More »

Codechef: June Challenge | Summer Heat | COCONUT | Solution

View on Codechef Chefland has 22 different types of coconut, type AA and type BB. Type AA contains only xaxa milliliters of coconut water and type BB contains only xbxb grams of coconut pulp. Chef’s nutritionist has advised him to consume XaXa milliliters of coconut water and XbXb grams of coconut pulp every week in the summer. Find the total number of coconuts (type AA + type BB) that Chef should buy each week to …

Codechef: June Challenge | Summer Heat | COCONUT | Solution Read More »

CodeChef: May Long Challenge | Valid Paths | VPATH | Solution

View on Codechef You are given a tree with NN nodes numbered from 11 to NN. A set SS of nodes is called valid if there exist two vertices uu and vv (possibly, u=vu=v) such that every node in SS lies on the simple path from uu to vv. Count the number of valid sets modulo 109+7109+7. Two sets are different if one node is included in one set and not in the …

CodeChef: May Long Challenge | Valid Paths | VPATH | Solution Read More »

x