Educational Codeforces Round 186 (Rated for Div. 2)

Solutions are presented as using the least memory and the fastest execution time. It also takes the top 10 most recent solutions from each language. If you want to limit to a specific index, click the "Solved" button and go to that problem.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
2182 Educational Codeforces Round 186 (Rated for Div. 2) FINISHED False 7200 9386723 Dec. 29, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 8855 ) D Christmas Tree Decoration PROGRAMMING combinatorics dp greedy math

A group of (n) people decided to decorate the Christmas tree. They have ((n+1)) boxes of decorations, numbered from (0) to (n). Initially, the (i)-th box contains (a_i) decorations. We say that a permutation (p) of size (n) (an array of size (n) where each number from (1) to (n) appears exactly once) is fair if it is possible to hang all the decorations on the tree using the following process: person (p_1) takes a decoration either from box (0) or from box (p_1), and hangs it on the tree; person (p_2) takes a decoration either from box (0) or from box (p_2), and hangs it on the tree; and so on; after person (p_n), person (p_1) follows, and the process repeats until all the decoration are on the tree. During this process, there should never be a situation where person (i) needs to hang a decoration, but both box (0) and box (i) are empty. If such a situation cannot be avoided, the permutation is not fair. However, if the people can choose from which box to take a decoration during each step in such a way that this situation does not arise, then the permutation is fair. Your task is to calculate the number of fair permutations. Since the answer may be large, output it modulo (998244353). The first line contains a single integer (t) ((1 \le t \le 5000)) — the number of test cases. The first line of each test case contains a single integer (n) ((1 \le n \le 50)). The second line contains ((n+1)) integers (a_0, a_1, \dots, a_n) ((0 \le a_i \le 10^6)). For each test case, print a single integer — the number of fair permutations, taken modulo (998244353). In the first example, the fair permutations are (1, 2, 3) and (1, 3, 2). Let's take a closer look at the Christmas tree decoration for permutation (1, 3, 2): the person (p_1=1) hangs a decoration from the box (1); the person (p_2=3) hangs a decoration from the

Tutorials

Educational Codeforces Round 186 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
355901891 Lecorbio D Dec. 30, 2025, 4:50 p.m. OK C++17 (GCC 7-32) TESTS 11 62 0
355843452 TavenDo D Dec. 30, 2025, 7:58 a.m. OK C++17 (GCC 7-32) TESTS 11 62 0
355871842 agamGK1 D Dec. 30, 2025, 12:26 p.m. OK C++17 (GCC 7-32) TESTS 11 62 102400
355858949 little_happy D Dec. 30, 2025, 10:26 a.m. OK C++17 (GCC 7-32) TESTS 11 62 102400
355931656 qwertyui66 D Dec. 31, 2025, 12:42 a.m. OK C++17 (GCC 7-32) TESTS 11 62 48128000
355947197 youiaOO D Dec. 31, 2025, 6:07 a.m. OK C++17 (GCC 7-32) TESTS 11 78 0
355944043 usernameson D Dec. 31, 2025, 5:23 a.m. OK C++17 (GCC 7-32) TESTS 11 78 0
355926970 leneza_41 D Dec. 30, 2025, 10:05 p.m. OK C++17 (GCC 7-32) TESTS 11 78 0
355915101 stevie_x D Dec. 30, 2025, 6:45 p.m. OK C++17 (GCC 7-32) TESTS 11 78 0
355908255 yorichi13 D Dec. 30, 2025, 5:43 p.m. OK C++17 (GCC 7-32) TESTS 11 78 0
355823668 WHITEINK D Dec. 30, 2025, 3:11 a.m. OK C++20 (GCC 13-64) TESTS 11 46 13107200
355934917 SpinVoid D Dec. 31, 2025, 2:22 a.m. OK C++20 (GCC 13-64) TESTS 11 62 0
355926840 Qzxell D Dec. 30, 2025, 10:02 p.m. OK C++20 (GCC 13-64) TESTS 11 62 0
355916964 Abdelhamid_ D Dec. 30, 2025, 7:06 p.m. OK C++20 (GCC 13-64) TESTS 11 62 0
355893793 a12doncf D Dec. 30, 2025, 3:41 p.m. OK C++20 (GCC 13-64) TESTS 11 62 0
355879961 Vidhansh101 D Dec. 30, 2025, 1:40 p.m. OK C++20 (GCC 13-64) TESTS 11 62 0
355879850 daoqi D Dec. 30, 2025, 1:39 p.m. OK C++20 (GCC 13-64) TESTS 11 62 0
355878546 bertwaver D Dec. 30, 2025, 1:28 p.m. OK C++20 (GCC 13-64) TESTS 11 62 0
355876632 arjun_77 D Dec. 30, 2025, 1:12 p.m. OK C++20 (GCC 13-64) TESTS 11 62 0
355867189 kxdyll D Dec. 30, 2025, 11:41 a.m. OK C++20 (GCC 13-64) TESTS 11 62 0
355817038 EternalHeart1314 D Dec. 30, 2025, 12:08 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 2150400
355945795 arseniy.burlutskiy29 D Dec. 31, 2025, 5:49 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 62 0
355928011 AshuSahu D Dec. 30, 2025, 10:33 p.m. OK C++23 (GCC 14-64, msys2) TESTS 11 62 0
355921889 Nola_The_Great D Dec. 30, 2025, 8:19 p.m. OK C++23 (GCC 14-64, msys2) TESTS 11 62 0
355916899 doomist D Dec. 30, 2025, 7:06 p.m. OK C++23 (GCC 14-64, msys2) TESTS 11 62 0
355896347 Arsud D Dec. 30, 2025, 4:03 p.m. OK C++23 (GCC 14-64, msys2) TESTS 11 62 0
355894153 quang2009 D Dec. 30, 2025, 3:44 p.m. OK C++23 (GCC 14-64, msys2) TESTS 11 62 0
355879385 _kratos_ D Dec. 30, 2025, 1:35 p.m. OK C++23 (GCC 14-64, msys2) TESTS 11 62 0
355878562 Naman2251 D Dec. 30, 2025, 1:28 p.m. OK C++23 (GCC 14-64, msys2) TESTS 11 62 0
355874554 zcxdr D Dec. 30, 2025, 12:53 p.m. OK C++23 (GCC 14-64, msys2) TESTS 11 62 0
355792107 ruban D Dec. 29, 2025, 5:36 p.m. OK FPC TESTS 11 93 26931200
355871881 ShenDev D Dec. 30, 2025, 12:26 p.m. OK GNU C11 TESTS 11 78 102400
355789196 zhanzhijiea D Dec. 29, 2025, 5:11 p.m. OK GNU C11 TESTS 11 93 0
355866248 Zongb D Dec. 30, 2025, 11:32 a.m. OK GNU C11 TESTS 11 93 1228800
355791833 Sisyphean D Dec. 29, 2025, 5:33 p.m. OK Go TESTS 11 46 2252800
355805268 Sisyphean D Dec. 29, 2025, 7:54 p.m. OK Go TESTS 11 140 4198400
355885121 Leeeee D Dec. 30, 2025, 2:24 p.m. OK Go TESTS 11 140 20480000
355827022 NanDemo D Dec. 30, 2025, 4:15 a.m. OK Java 21 TESTS 11 234 409600
355877360 Ayush_Chauhan025 D Dec. 30, 2025, 1:18 p.m. OK Java 21 TESTS 11 234 819200
355806371 aniketHacker D Dec. 29, 2025, 8:12 p.m. OK Java 21 TESTS 11 250 819200
355840764 the_unseen D Dec. 30, 2025, 7:34 a.m. OK Java 21 TESTS 11 250 1126400
355807616 tobiiiii D Dec. 29, 2025, 8:31 p.m. OK Java 21 TESTS 11 250 1126400
355848138 gurp1242005 D Dec. 30, 2025, 8:41 a.m. OK Java 21 TESTS 11 265 921600
355810485 GuLLu05 D Dec. 29, 2025, 9:24 p.m. OK Java 21 TESTS 11 265 19251200
355872226 StressOnTest2 D Dec. 30, 2025, 12:30 p.m. OK Java 21 TESTS 11 281 921600
355861944 minhkhoajapan0701 D Dec. 30, 2025, 10:54 a.m. OK Java 21 TESTS 11 296 512000
355931277 dzhi D Dec. 31, 2025, 12:29 a.m. OK Java 21 TESTS 11 296 614400
355858730 Vishalll_ D Dec. 30, 2025, 10:24 a.m. OK Java 8 TESTS 11 437 0
355801803 golions D Dec. 29, 2025, 7:12 p.m. OK Java 8 TESTS 11 687 232140800
355915606 Fun_Coder_1231 D Dec. 30, 2025, 6:51 p.m. OK Java 8 TESTS 11 984 0
355854147 code__ccc D Dec. 30, 2025, 9:40 a.m. OK Node.js TESTS 11 203 14745600
355854955 code__ccc D Dec. 30, 2025, 9:48 a.m. OK Node.js TESTS 11 218 13107200
355852851 TLE_King D Dec. 30, 2025, 9:27 a.m. OK Node.js TESTS 11 218 13926400
355916024 mani_tyuG D Dec. 30, 2025, 6:55 p.m. OK PHP TESTS 11 125 102400
355789538 ps2006 D Dec. 29, 2025, 5:14 p.m. OK PyPy 3 TESTS 11 531 10342400
355827570 leetgoat_dot_dev D Dec. 30, 2025, 4:26 a.m. OK PyPy 3 TESTS 11 1093 121856000
355820240 smilences D Dec. 30, 2025, 1:57 a.m. OK PyPy 3-64 TESTS 11 125 6041600
355838258 OAY71011 D Dec. 30, 2025, 7:09 a.m. OK PyPy 3-64 TESTS 11 125 6348800
355864185 mirkocoric D Dec. 30, 2025, 11:14 a.m. OK PyPy 3-64 TESTS 11 125 6553600
355875696 _ARYA_ D Dec. 30, 2025, 1:03 p.m. OK PyPy 3-64 TESTS 11 140 4403200
355801801 Harshal_Kanani D Dec. 29, 2025, 7:12 p.m. OK PyPy 3-64 TESTS 11 140 4915200
355913914 jvatsal0709 D Dec. 30, 2025, 6:33 p.m. OK PyPy 3-64 TESTS 11 140 8704000
355910406 samya63 D Dec. 30, 2025, 6:01 p.m. OK PyPy 3-64 TESTS 11 156 7065600
355802888 masao D Dec. 29, 2025, 7:25 p.m. OK PyPy 3-64 TESTS 11 156 7168000
355870845 -Neel- D Dec. 30, 2025, 12:16 p.m. OK PyPy 3-64 TESTS 11 156 8806400
355788582 profenc1ng D Dec. 29, 2025, 5:07 p.m. OK PyPy 3-64 TESTS 11 156 8908800
355842292 Azusa D Dec. 30, 2025, 7:48 a.m. OK Python 3 TESTS 11 93 409600
355867540 ddungsam D Dec. 30, 2025, 11:44 a.m. OK Python 3 TESTS 11 140 102400
355809052 garuda_07 D Dec. 29, 2025, 8:56 p.m. OK Python 3 TESTS 11 140 307200
355870739 hhu_yjh D Dec. 30, 2025, 12:15 p.m. OK Python 3 TESTS 11 140 19558400
355840290 fwsafdawd10 D Dec. 30, 2025, 7:29 a.m. OK Python 3 TESTS 11 140 20889600
355816639 wbximy D Dec. 29, 2025, 11:56 p.m. OK Python 3 TESTS 11 156 102400
355906113 MEZBAH-UDDIN D Dec. 30, 2025, 5:25 p.m. OK Python 3 TESTS 11 156 204800
355867575 ddungsam D Dec. 30, 2025, 11:45 a.m. OK Python 3 TESTS 11 156 204800
355813400 telegrapher D Dec. 29, 2025, 10:31 p.m. OK Python 3 TESTS 11 156 21913600
355788973 KobayashiTohru D Dec. 29, 2025, 5:09 p.m. OK Python 3 TESTS 11 250 102400
355941837 Spheniscine D Dec. 31, 2025, 4:46 a.m. OK Rust 2021 TESTS 11 62 0
355825008 chreh D Dec. 30, 2025, 3:36 a.m. OK Rust 2024 TESTS 11 62 0

remove filters

Back to search problems