Introducction

Solutions

Problem A - In-Game Chat

Problem Link

This is a simple problem. Just count ‘)’ from right side and check the given condition.

Code

Codeforces Solution

Problem B - Fair Numbers

Problem Link

So Number should be divided by all digits in it.

whenevery anything need to be divided by each of number of a set, that thing must be divided by the LCM of the whole set.

so there can be at max 1-9 digit.

LCM[1,2,...,9] < 2580

Hence, All multiples of 2580 will for sure satisfy the condition hence will be need at max 2579 iterations.

Hence we can do brute Force

Code

Codeforces Solution

Problem C - Peaceful Rooks

Problem Link

So after going through a few examples, we can see that if we make edges between x –> y for rook placed at (x,y) then

1. for every rook (x,x) ans does not increment
2. for every rook (x,y) ,x!=y ans increment by 1
3. for every cycle in graph ans increasess by 1

Code

Codeforces Solution

Problem D - Grime Zoo

Problem Link

if(x>y) then it’s always better to change 01 to 10

if(y>x) then it’s always better to change 10 to 01

Answer will be of the form

if x>y  111111s0000000s
if y>x  000000s1111111s

Now, we can form a linear solution

Code

I have not coded this problem yet

Problem E - Poman Numbers

Problem Link

A -> +A

AB -> B-A

ABC -> C-B+A, 
       C-B-A

ABCD -> D-C+B-A,
        D-C+B+A,
        D-C-B+A,
        D-C-B-A

ABCDE -> E-D+C-B+A,
         E-D+C-B-A,
         E-D+C+B+A,
         E-D+C+B-A,

         E-D-C-B+A,
         E-D-C-B-A,
         E-D-C+B+A,
         E-D-C+B-A,

We can observe that expect last 2 every one can be any sign + or -

Now, Left is we have list of numbers then $ (\sum (+=2^{b[i]})) = Target $

If we are provided with many powers of 2, and we can select any set out of all power2 of 2 to form a target value. We can easily sove this problem by going from 0 to MSB and

if cur bit(b) of tar is 1 then cnt[b]--
cnt[b+1]+=cnt[b]/2

But problem is, In this problem , either we choose with positive sign or with negative sign but we can not ignore.

So,

+-2^{b[i]} = 2^{b[i]} - (0,2^{b[i]+1})

Using above transormation, we can change this problem to above problem.

Code

Codeforces Solution

Discussion

In contest, I did only ABC. I was able to do ABC quicky so I got okish rank which increased by rating to 1948.