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**.

Before contest

Codeforces Round #647 (Div. 1) - Thanks, Algo Muse!

24:59:48

Register now »

Codeforces Round #647 (Div. 1) - Thanks, Algo Muse!

24:59:48

Register now »

*has extra registration

Before contest

Codeforces Round #647 (Div. 2) - Thanks, Algo Muse!

24:59:48

Register now »

Codeforces Round #647 (Div. 2) - Thanks, Algo Muse!

24:59:48

Register now »

*has extra registration

# | User | Rating |
---|---|---|

1 | MiFaFaOvO | 3681 |

2 | Um_nik | 3544 |

3 | maroonrk | 3431 |

4 | tourist | 3409 |

5 | apiadu | 3397 |

6 | 300iq | 3317 |

7 | ecnerwala | 3260 |

7 | Benq | 3260 |

9 | LHiC | 3229 |

10 | TLE | 3223 |

# | User | Contrib. |
---|---|---|

1 | Errichto | 193 |

2 | antontrygubO_o | 191 |

3 | vovuh | 178 |

4 | pikmike | 177 |

5 | tourist | 166 |

6 | Um_nik | 165 |

7 | McDic | 164 |

8 | ko_osaga | 163 |

9 | Radewoosh | 161 |

10 | Geothermal | 158 |

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**.

↑

↓

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jun/03/2020 16:35:14 (g1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

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.