Good Indices solution codechef

Good Indices solution codechef Chef has an array AA of length NN. He calls an index ii (1≤i≤N)(1≤i≤N) good if there exists some j≠ij≠i such that Ai=AjAi=Aj. Chef can perform the following operation at most once: Choose any subsequence of the array AA and add any positive integer to all the elements of the chosen subsequence. Determine the maximum number of good indices Chef can get. Input Format The first line of input will …

Good Indices solution codechef Read More »

Mark and the Online Exam solution codeforces

Mark and the Online Exam solution codeforces Solution – CLICK HERE Mark is administering an online exam consisting of n true-false questions. However, he has lost all answer keys. He needs a way to retrieve the answers before his client gets infuriated. Fortunately, he has access to the grading system. Thus, for each query, you can input the …

Mark and the Online Exam solution codeforces Read More »

Mark and Professor Koro solution codeforces

Mark and Professor Koro solution codeforces Solution – CLICK HERE After watching a certain anime before going to sleep, Mark dreams of standing in an old classroom with a blackboard that has a sequence of n positive integers 1,2,…,a1,a2,…,an on it. Then, professor Koro comes in. He can perform the following operation: select an integer x that appears at least 22 times on the …

Mark and Professor Koro solution codeforces Read More »

Mark and Lightbulbs solution codeforces

Mark and Lightbulbs solution codeforces Solution – CLICK HERE   Mark has just purchased a rack of n lightbulbs. The state of the lightbulbs can be described with binary string =12…s=s1s2…sn, where =si=1 means that the i-th lightbulb is turned on, while =si=0 means that the i-th lightbulb is turned off. Unfortunately, the lightbulbs are broken, and the only operation he can perform to change …

Mark and Lightbulbs solution codeforces Read More »

Mark and His Unfinished Essay solution codeforces

Mark and His Unfinished Essay solution codeforces Solution – CLICK HERE One night, Mark realized that there is an essay due tomorrow. He hasn’t written anything yet, so Mark decided to randomly copy-paste substrings from the prompt to make the essay. More formally, the prompt is a string s of initial length n. Mark will perform the copy-pasting operation c times. …

Mark and His Unfinished Essay solution codeforces Read More »

Mark the Dust Sweeper solution codeforces

Mark the Dust Sweeper solution codeforces Solution – CLICK HERE Mark is cleaning a row of n rooms. The i-th room has a nonnegative dust level ai. He has a magical cleaning machine that can do the following three-step operation. Select two indices <i<j such that the dust levels ai, +1ai+1, ……, −1aj−1 are all strictly greater than 00. Set ai to −1ai−1. Set aj to +1aj+1. Mark’s goal is to make 1=2=…=−1=0a1=a2=…=an−1=0 so that he …

Mark the Dust Sweeper solution codeforces Read More »

Mark the Photographer solution codeforces

Mark the Photographer solution codeforces Solution – CLICK HERE Mark is asked to take a group photo of 22n people. The i-th person has height ℎhi units. To do so, he ordered these people into two rows, the front row and the back row, each consisting of n people. However, to ensure that everyone is seen properly, the j-th person of the back row …

Mark the Photographer solution codeforces Read More »

The XOR-OR Dilemma solution codechef

The XOR-OR Dilemma solution codechef Chef has an array AA of length NN such that Ai=iAi=i. In one operation, Chef can pick any two elements of the array, delete them from AA, and append either their bitwise XOR or their bitwise OR to AA. Note that after each operation, the length of the array decreases by 11. Let FF be the final number obtained after N−1N−1 operations are made. You are …

The XOR-OR Dilemma solution codechef Read More »

Copy and Push Back solution codechef

Copy and Push Back solution codechef Anton loves creating strings! Anton now wants to create a string SS following some specific rules. They are as follows: Initially, SS is empty. Then, Anton can perform two types of operations on SS: Choose a lowercase Latin character (an element of {a,b,c,…,z}{a,b,c,…,z}) and append it to SS. For example, if currently S=S=clap, Anton can turn it …

Copy and Push Back solution codechef Read More »