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 |
|---|---|---|---|---|---|---|
| 2085 | Codeforces Round 1011 (Div. 2) | FINISHED | False | 7200 | 33751523 | March 22, 2025, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 17011 ) | B | Serval and Final MEX | PROGRAMMING | constructive algorithms implementation |
You are given an array (a) consisting of (n\ge 4) non-negative integers. You need to perform the following operation on (a) until its length becomes (1): Select two indices (l) and (r) ((1\le {\color{red}{ l < r }} \le |a|)), and replace the subarray (a_l,a_{l+1},\ldots,a_r) with a single integer (\operatorname{mex}(a_l,a_{l+1},\ldots,a_r)), where (\operatorname{mex}(b)) denotes the minimum excluded (MEX)(^{\text{∗}}) of the integers in (b). In other words, let (x=\operatorname{mex}(a_l,a_{l+1},\ldots,a_r)), the array (a) will become (a_1,a_2,\ldots,a_{l-1},x,a_{r+1},a_{r+2},\ldots,a_{|a|}). Note that the length of (a) decreases by ((r-l)) after this operation. Serval wants the final element in (a) to be (0). Help him! More formally, you have to find a sequence of operations, such that after performing these operations in order, the length of (a) becomes (1), and the final element in (a) is (0). It can be shown that at least one valid operation sequence exists under the constraints of the problem, and the length of any valid operation sequence does not exceed (n). Note that you do not need to minimize the number of operations. (^{\text{∗}})The minimum excluded (MEX) of a collection of integers (b_1, b_2, \ldots, b_k) is defined as the smallest non-negative integer (x) which does not occur in the collection (b). Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 1000)). The description of the test cases follows. The first line of each test case contains a single integer (n) ((4\le n\le 5000)) — the length of the array (a). The second line contains (n) integers (a_1, a_2, \ldots, a_n) ((0\le a_i\le n)) — the elements of the array (a). It is guaranteed that the sum of (n) over all test cases does not exceed (5000). For each test case, output a |
| Codeforces Round #1011 (Div. 2) Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 311950927 | yuzou | B | March 23, 2025, 3:42 a.m. | OK | C++17 (GCC 7-32) | TESTS | 8 | 31 | 102400 | ||
| 311960019 | nah_broo | B | March 23, 2025, 5:33 a.m. | OK | C++17 (GCC 7-32) | TESTS | 8 | 46 | 0 | ||
| 311959751 | Sachin446 | B | March 23, 2025, 5:30 a.m. | OK | C++17 (GCC 7-32) | TESTS | 8 | 46 | 0 | ||
| 311959210 | Alamin_20 | B | March 23, 2025, 5:25 a.m. | OK | C++17 (GCC 7-32) | TESTS | 8 | 46 | 0 | ||
| 311958615 | Niravpokiya | B | March 23, 2025, 5:20 a.m. | OK | C++17 (GCC 7-32) | TESTS | 8 | 46 | 0 | ||
| 311958591 | Euph0r1a | B | March 23, 2025, 5:20 a.m. | OK | C++17 (GCC 7-32) | TESTS | 8 | 46 | 0 | ||
| 311957493 | Tarun5371 | B | March 23, 2025, 5:09 a.m. | OK | C++17 (GCC 7-32) | TESTS | 8 | 46 | 0 | ||
| 311957386 | krishna_Gopal | B | March 23, 2025, 5:08 a.m. | OK | C++17 (GCC 7-32) | TESTS | 8 | 46 | 0 | ||
| 311956621 | unknown1818 | B | March 23, 2025, 4:59 a.m. | OK | C++17 (GCC 7-32) | TESTS | 8 | 46 | 0 | ||
| 311955878 | hcm10hung__nh | B | March 23, 2025, 4:50 a.m. | OK | C++17 (GCC 7-32) | TESTS | 8 | 46 | 0 | ||
| 311949461 | zhensama-- | B | March 23, 2025, 3:18 a.m. | OK | C++20 (GCC 13-64) | TESTS | 8 | 31 | 0 | ||
| 311943047 | HouJiawen | B | March 23, 2025, 1:18 a.m. | OK | C++20 (GCC 13-64) | TESTS | 8 | 31 | 0 | ||
| 311941233 | nennokrah | B | March 23, 2025, 12:28 a.m. | OK | C++20 (GCC 13-64) | TESTS | 8 | 31 | 0 | ||
| 311913279 | mehnatt | B | March 22, 2025, 7:02 p.m. | OK | C++20 (GCC 13-64) | TESTS | 8 | 31 | 0 | ||
| 311903962 | MohamedSaeed | B | March 22, 2025, 5:46 p.m. | OK | C++20 (GCC 13-64) | TESTS | 8 | 31 | 0 | ||
| 311959536 | scnair23 | B | March 23, 2025, 5:29 a.m. | OK | C++20 (GCC 13-64) | TESTS | 8 | 31 | 102400 | ||
| 311948680 | ryuuko_ | B | March 23, 2025, 3:05 a.m. | OK | C++20 (GCC 13-64) | TESTS | 8 | 31 | 102400 | ||
| 311947984 | Ajayy | B | March 23, 2025, 2:54 a.m. | OK | C++20 (GCC 13-64) | TESTS | 8 | 31 | 102400 | ||
| 311944651 | uditmehra3224 | B | March 23, 2025, 1:54 a.m. | OK | C++20 (GCC 13-64) | TESTS | 8 | 31 | 102400 | ||
| 311919820 | gocode15 | B | March 22, 2025, 8:05 p.m. | OK | C++20 (GCC 13-64) | TESTS | 8 | 31 | 102400 |
Back to search problems