Maximizing the Function
Consider an array of binary integers (i.e., 's and 's) defined as . Let be the bitwise XOR of all elements in the inclusive range between index and index in array . In other words, . Next, we'll define another function, : Given array and independent queries, perform each query on and print the result on a new line. A query consists of three integers, , , and , and you must find the maximum possible you can get by changing at most elements in the array from to or from to . No
View Solution →XOR Subsequences
onsider an array, , of integers (). We take all consecutive subsequences of integers from the array that satisfy the following: For example, if our subsequences will be: For each subsequence, we apply the bitwise XOR () operation on all the integers and record the resultant value. Since there are subsequences, this will result in numbers. Given array , find the XOR sum of every subsequence of and determine the frequency at which each number occurs. Then print the number and its res
View Solution →Iterate It
Consider the following pseudocode, run on an array of length : rep := 0 while A not empty: B := [] for x in A, y in A: if x != y: append absolute_value(x - y) to B A := B rep := rep + 1 Given the values of and array , compute and print the final value of after the pseudocode above terminates; if the loop will never terminate, print -1 instead. Input Format The first line contains a single integer, , denoting the length of array . The second line contai
View Solution →Hamming Distance
You are given a string , consisting of small latin letters 'a' and 'b'. You are also given queries to process. The queries are as follows: C : all the symbols in the string, starting at the , ending at the become equal to ; S : swap two consecutive fragments of the string, where the first is denoted by a substring starting from ending at and the second is denoted by a substring starting at ending at ; R : reverse the fragment of the string that starts at the symbol and ends at
View Solution →Mixing proteins
Some scientists are working on protein recombination, and during their research, they have found a remarkable fact: there are 4 proteins in the protein ring that mutate after every second according to a fixed pattern. For simplicity, proteins are called (you know, protein names can be very complicated). A protein mutates into another one depending on itself and the protein right after it. Scientists determined that the mutation table goes like this: Here rows denote the protein at current
View Solution →