title-img


Zurikela's Graph

Zurikela is creating a graph with a special graph maker. At the begining, it is empty and has no nodes or edges. He can perform 3 types of operations: 1. A x : Create a set of x new nodes and name it set-K. 2. B x y: Create edges between nodes of set-x and set-y. 3. C x : Create a set composed of nodes from set-x and its directly and indirectly connected nodes, called set-K. Note that each node can only exist in one set, so other sets become empty. The first set's name will be set-1. In fi

View Solution →

Modify The Sequence

You are given a sequence of integers a1,a2,a3.....an. You are free to replace any integer with any other positive integer. How many integers must be replaced to make the resulting sequence strictly increasing? Input Format The first line of the test case contains an integer N - the number of entries in the sequence. The next line contains N space separated integers where the ith integer is ai. Output Format Output the minimal number of integers that should be replaced to make the sequen

View Solution →

Longest Mod Path

n the middle of a nightmare, Maxine suddenly finds herself in a mysterious room with the following items: A piece of paper with the word score and the integer written on it. A map of the castle where the room is located. There are rooms uniquely labeled from to . There are bidirectional corridors connecting pairs of rooms. The value of score changes every time she travels up or down a corridor, and this value differs depending on her direction of travel along the corridor. Each corrido

View Solution →

P-sequences

We call a sequence of N natural numbers (a1, a2, ..., aN) a P-sequence, if the product of any two adjacent numbers in it is not greater than P. In other words, if a sequence (a1, a2, ..., aN) is a P-sequence, then ai * ai+1 ≤ P ∀ 1 ≤ i < N You are given N and P. Your task is to find the number of such P-sequences of N integers modulo 109+7. Input Format The first line of input consists of N The second line of the input consists of P. Constraints 2 ≤ N ≤ 103 1 ≤ P ≤ 109 1 ≤ ai

View Solution →

Robot

You have two arrays of integers, V = {V1,V2,...Vn} and P = {P1,P2,...,Pn}, where both have N number of elements. Consider the following function: score = 0 int Go(step, energy) { if (step == N) { score += V[step]; return (score); } else { int way = random(1, 2); if (way == 1) { score += V[step]; } else { energy = P[step]; } if (energy > 0) { Go(step + 1, energy - 1)

View Solution →