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

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

1 | tourist | 3557 |

2 | Um_nik | 3395 |

3 | Radewoosh | 3344 |

4 | Benq | 3316 |

5 | LHiC | 3302 |

6 | Petr | 3293 |

7 | wxhtxdy | 3286 |

8 | mnbvmar | 3274 |

9 | yutaka1999 | 3190 |

10 | ainta | 3180 |

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

1 | Errichto | 192 |

2 | Radewoosh | 176 |

3 | PikMike | 164 |

4 | Vovuh | 163 |

5 | rng_58 | 161 |

6 | majk | 157 |

6 | 300iq | 157 |

8 | antontrygubO_o | 156 |

9 | Um_nik | 149 |

10 | kostka | 148 |

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-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Sep/23/2019 00:24:18 (e1).

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.