Prefix as a Substring 2 Solution codechef

Prefix as a Substring 2 Solution codechef Given 33 strings S1S1, S2S2 and XX, find the number of distinct ordered pairs of strings (P,Q)(P,Q) such that : String P+QP+Q is a substring of XX. String PP is some prefix of S1S1 (possibly empty). String QQ is some prefix of S2S2 (possibly empty). Prefix as a Substring 2 Solution codechef A substring of a Continue reading Prefix as a Substring 2 Solution codechef

Minimise Difference Solution codechef

Minimise Difference Solution codechef You’re given a simple undirected graph G with N vertices and M edges. You have to assign, to each vertex i, a number Ci such that 1≤Ci≤N and ∀i≠j,Ci≠Cj. For any such assignment, we define Di to be the number of neighbours j of i such that Cj<Ci. You want to minimise maxi∈{1..N}Di−mini∈{1..N}Di. Output the minimum Continue reading Minimise Difference Solution codechef

Maximum Number Of Distinct Elements Solution codechef

Maximum Number Of Distinct Elements Solution codechef Given an array B of length N, find an array A of length N where 0≤Ai≤109 such that array C where Ci=AimodBi, ∀i∈{1,N} has maximum number of distinct integers. In case of multiple answers, print any. Input Format Maximum Number Of Distinct Elements Solution codechef First-line will Continue reading Maximum Number Of Distinct Elements Solution codechef