A Serious Referee solution codeforces

A Serious Referee solution codeforces Andrea has come up with what he believes to be a novel sorting algorithm for arrays of length nn. The algorithm works as follows. Initially there is an array of nn integers a1,a2,…,ana1,a2,…,an. Then, kk steps are executed. For each 1≤i≤k1≤i≤k, during the ii-th step the subsequence of the array aa with indexes ji,1<ji,2<⋯<ji,qiji,1<ji,2<⋯<ji,qi is sorted, without changing the values with the remaining indexes. So, the subsequence aji,1,aji,2,…,aji,qiaji,1,aji,2,…,aji,qi is … Read more

Telepanting solution codeforces

Telepanting solution codeforces An ant moves on the real line with constant speed of 11 unit per second. It starts at 00 and always moves to the right (so its position increases by 11 each second). There are nn portals, the ii-th of which is located at position xixi and teleports to position yi<xiyi<xi. Each portal can be either active or inactive. The initial state of the ii-th portal is determined by sisi: if si=0si=0 then the ii-th portal is … Read more

Colors and Intervals solution codeforces

Colors and Intervals solution codeforces The numbers 1,2,…,n⋅k1,2,…,n⋅k are colored with nn colors. These colors are indexed by 1,2,…,n1,2,…,n. For each 1≤i≤n1≤i≤n, there are exactly kk numbers colored with color ii. Let [a,b][a,b] denote the interval of integers between aa and bb inclusive, that is, the set {a,a+1,…,b}{a,a+1,…,b}. You must choose nn intervals [a1,b1],[a2,b2],…,[an,bn][a1,b1],[a2,b2],…,[an,bn] such that: for each 1≤i≤n1≤i≤n, it holds 1≤ai<bi≤n⋅k1≤ai<bi≤n⋅k; for each 1≤i≤n1≤i≤n, the numbers aiai and bibi are colored with color ii; each number 1≤x≤n⋅k1≤x≤n⋅k belongs to at most ⌈nk−1⌉⌈nk−1⌉ intervals. One can show that such a family of … Read more