np_soo_hard's blog

By np_soo_hard, history, 5 weeks ago, In English,

Hi all, I am not able to understand the problem AtCoder RGB-B. Can someone help me explain the statement? How the answer for example-1 is 216.

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

»
5 weeks ago, # |
  Vote: I like it -7 Vote: I do not like it

You have 3N balls with you numbered from 1 to 3N. Also, the color of each ball is given in the string i.e the i'th character of the string corresponds to the i'th ball color (indexing starts from 1). Also, the input will have N balls of each color. Now you need to give 3 balls to each of the N persons such that each one of them should get (1R, 1G, 1B). Now if you take the indices of these colors from the string and write them in ascending order the gap between the farthest colored ball and the nearest colored ball i.e a < b < c, then (c-a) should be minimized. And you should find the number of ways in which we can distribute the balls. Since the answer can be enormous, compute it modulo 998244353. We consider two ways to distribute the balls different if and only if there is a person who receives different sets of balls.