Kotlin Heroes: Episode 14

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
2199 Kotlin Heroes: Episode 14 FINISHED False 9000 3943523 March 2, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 89 ) H Sum of MEX PROGRAMMING *special combinatorics data structures dp math

The MEX of a sequence of non-negative integers (s_1, s_2, \dots, s_n) is the smallest non-negative integer that does not appear in this sequence. Given an array (a_1, a_2, \dots, a_n), where each element is an integer from (-1) to (n). For each (i) from (1) to (n), calculate (f(a_1, a_2, \dots, a_i)), where (f(s)) for an array (s) is defined as follows: consider all distinct arrays (s') that can be obtained from the array (s) by replacing all elements equal to (-1) with integers from (0) to (n); (f(s)) is the sum of the MEX of all such arrays (s'). The first line contains a single integer (n) ((1 \le n \le 2 \cdot 10^5)). The second line contains (n) integers (a_1, a_2, \dots, a_n) ((-1 \le a_i \le n)). An additional constraint on the input: the array (a) contains no more than (300) elements equal to (-1). For each (i) from (1) to (n), output a single integer — (f(a_1, a_2, \dots, a_i)), taken modulo (998244353). Consider (i=3) in the first example. We need to calculate (f(-1, 1, -1)). There are (36) different arrays that can be obtained by replacing each element (-1) with an integer from (0) to (5). For (25) of them (those that do not contain (0)), the MEX is (0). Let's consider the remaining (11): The MEX of the array (0, 1, 0) is (2); The MEX of the array (0, 1, 1) is (2); The MEX of the array (0, 1, 2) is (3); The MEX of the array (0, 1, 3) is (2); The MEX of the array (0, 1, 4) is (2); The MEX of the array (0, 1, 5) is (2); The MEX of the array (1, 1, 0) is (2); The MEX of the array (2, 1, 0) is (3); The MEX of the array (3, 1, 0) is (2); The MEX of the array (4, 1, 0) is (2); The MEX of the array (5, 1, 0) is (2). The sum of these values is (24). If we consider (i=4),

Tutorials

151783

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
365121917 rameez0636 H March 2, 2026, 5:03 p.m. OK Kotlin 1.7 TESTS 50 609 30720000
365120631 lzyrapx H March 2, 2026, 4:54 p.m. OK Kotlin 1.7 TESTS 50 718 42188800
365120695 imnhatnguyen H March 2, 2026, 4:54 p.m. OK Kotlin 1.7 TESTS 50 765 72704000
365116829 zoryn H March 2, 2026, 4:24 p.m. OK Kotlin 1.7 TESTS 50 953 34918400
365119411 marajul.haque.cu.bd H March 2, 2026, 4:45 p.m. OK Kotlin 1.7 TESTS 50 968 31334400
365120419 yatuoximeng H March 2, 2026, 4:52 p.m. OK Kotlin 1.7 TESTS 50 984 51507200
365134707 raypraveen47 H March 2, 2026, 6:52 p.m. OK Kotlin 1.7 TESTS 50 1031 48742400
365111283 talgatovvk H March 2, 2026, 3:41 p.m. OK Kotlin 1.7 TESTS 50 1265 143155200
365113975 wuyuetong H March 2, 2026, 4:01 p.m. OK Kotlin 1.7 TESTS 50 1343 128409600
365117563 iamdaukhoi H March 2, 2026, 4:30 p.m. OK Kotlin 1.7 TESTS 50 1437 100044800
365111149 BucketPotato H March 2, 2026, 3:40 p.m. OK Kotlin 1.9 TESTS 50 1906 34201600
365117194 Darren0724 H March 2, 2026, 4:28 p.m. OK Kotlin 1.9 TESTS 50 2250 11059200
365121965 yudedako H March 2, 2026, 5:04 p.m. OK Kotlin 1.9 TESTS 50 2421 28364800
365120269 ktobarsuk H March 2, 2026, 4:51 p.m. OK Kotlin 1.9 TESTS 50 3000 13619200
365119047 Nikrien H March 2, 2026, 4:42 p.m. OK Kotlin 2.2 TESTS 50 265 33792000
365160147 thanhnguyxn07 H March 3, 2026, 2:03 a.m. OK Kotlin 2.2 TESTS 50 437 31334400
365118761 khoand25112007 H March 2, 2026, 4:40 p.m. OK Kotlin 2.2 TESTS 50 453 36659200
365120992 Kude H March 2, 2026, 4:57 p.m. OK Kotlin 2.2 TESTS 50 890 42291200
365116280 PelicanPilot H March 2, 2026, 4:20 p.m. OK Kotlin 2.2 TESTS 50 1140 38809600
365170134 ali2005_syr H March 3, 2026, 5:07 a.m. OK Kotlin 2.2 TESTS 50 1218 42905600
365122461 uwi H March 2, 2026, 5:08 p.m. OK Kotlin 2.2 TESTS 50 1343 36147200
365119997 gleb.astashkin H March 2, 2026, 4:49 p.m. OK Kotlin 2.2 TESTS 50 1375 33280000
365162436 jtrh H March 3, 2026, 2:51 a.m. OK Kotlin 2.2 TESTS 50 1437 45056000
365114525 Fysty H March 2, 2026, 4:06 p.m. OK Kotlin 2.2 TESTS 50 1500 43008000

remove filters

Back to search problems