Tree Coloring solution codeforces

Tree Coloring solution codeforces For Solution Click Here! You are given a rooted tree consisting of nn vertices numbered from 11 to nn. The root of the tree is the vertex 11. You have to color all vertices of the tree into nn colors (also numbered from 11 to nn) so that there is exactly one vertex for each color. Let cici be the color of vertex ii, and pipi be … Read more

Crazy Robot solution codeforces

Crazy Robot solution codeforces For Solution Click Here! There is a grid, consisting of nn rows and mm columns. Each cell of the grid is either free or blocked. One of the free cells contains a lab. All the cells beyond the borders of the grid are also blocked. A crazy robot has escaped from this lab. It is … Read more

MEX Sequences solution codeforces

MEX Sequences solution codeforces For Solution Click Here! Let’s call a sequence of integers x1,x2,…,xkx1,x2,…,xk MEX-correct if for all ii (1≤i≤k1≤i≤k) |xi−MEX(x1,x2,…,xi)|≤1|xi−MEX⁡(x1,x2,…,xi)|≤1 holds. Where MEX(x1,…,xk)MEX⁡(x1,…,xk) is the minimum non-negative integer that doesn’t belong to the set x1,…,xkx1,…,xk. For example, MEX(1,0,1,3)=2MEX⁡(1,0,1,3)=2 and MEX(2,1,5)=0MEX⁡(2,1,5)=0. You are given an array aa consisting of nn non-negative integers. Calculate the number of non-empty MEX-correct subsequences of a given array. The number of subsequences can be very large, so print … Read more

Poisoned Dagger solution codeforces

Poisoned Dagger solution codeforces For Solution Click Here! Monocarp is playing yet another computer game. In this game, his character has to kill a dragon. The battle with the dragon lasts 100500100500 seconds, during which Monocarp attacks the dragon with a poisoned dagger. The ii-th attack is performed at the beginning of the aiai-th second from the battle start. … Read more

Absent Remainder solution codeforces

Absent Remainder solution codeforces For Solution Click Here! You are given a sequence a1,a2,…,ana1,a2,…,an consisting of nn pairwise distinct positive integers. Find ⌊n2⌋⌊n2⌋ different pairs of integers xx and yy such that: x≠yx≠y; xx and yy appear in aa; x mod yx mod y doesn’t appear in aa. Note that some xx or yy can belong to multiple pairs. ⌊x⌋⌊x⌋ denotes the floor function — the largest integer less than or equal to xx. x mod yx mod y denotes the remainder from dividing xx by yy. If there are multiple … Read more

Long Comparison solution codeforces

Long Comparison solution codeforces For Solution Click Here! Monocarp wrote down two numbers on a whiteboard. Both numbers follow a specific format: a positive integer xx with pp zeros appended to its end. Now Monocarp asks you to compare these two numbers. Can you help him? Long Comparison solution codeforces Input The first line contains a single integer tt (1≤t≤1041≤t≤104) — the … Read more