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 |
|---|---|---|---|---|---|---|
| 2227 | Codeforces Round 1096 (Div. 3) | FINISHED | False | 9000 | 2820287 | April 30, 2026, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 11401 ) | D | Palindromex | PROGRAMMING | binary search brute force constructive algorithms data structures greedy implementation two pointers |
Yousef has given you an array (a) of (2n) integers. Every integer (x \in 0, n - 1) appears exactly twice in the array. Your task is to find a subarray (a_l, a_{l + 1}, \dots, a_r) that is a palindrome(^{\text{∗}}) such that its (\operatorname{mex}(a_l, a_{l + 1}, \dots, a_r))(^{\text{†}}) is maximized. Output this maximum possible value. (^{\text{∗}})A palindrome is a string that reads the same backward as forward, for example, strings "z" , "aaa" , "aba" , "abccba" are palindromes, but strings "codeforces" , "reality" , "ab" are not. (^{\text{†}})The (\operatorname{mex}) (minimum excludant) of an array of integers is defined as the smallest non-negative integer which does not occur in the array. For example: The (\operatorname{mex}) of (2,2,1) is (0), because (0) does not belong to the array. The (\operatorname{mex}) of (3,1,0,1) is (2), because (0) and (1) belong to the array, but (2) does not. The (\operatorname{mex}) of (0,3,1,2) is (4), because (0), (1), (2) and (3) belong to the array, but (4) does not. The first line contains a single integer (t) ((1 \le t \le 10^4)) — the number of test cases. The first line of each test case contains a single integer (n) ((1 \le n \le 10^5)). The second line of each test case contains (2n) integers (a_1, a_2, \dots, a_{2n}) ((0 \le a_i \le n-1)). It is guaranteed that every integer in the range (0, n-1) appears exactly twice. It is guaranteed that the sum of (2n) over all test cases does not exceed (2 \cdot 10^5). For each test case, output a single integer — the maximum (\operatorname{mex}) of any palindromic subarray. In the first test case, the only optimal subarray to choose is (a1, 8 = 1, 2, 0, 3, 3, 0, 2, 1), which is palindromic and has a (\operatorname{mex}) of (4). In the second test case, one of the optimal subarrays to choos |
| Codeforces Round 1096 (Div. 3) — Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 373155268 | sasafied | D | April 30, 2026, 4:46 p.m. | OK | C# 10 | TESTS | 7 | 93 | 6246400 | ||
| 373154201 | IRON-PROGRAMMER | D | April 30, 2026, 4:43 p.m. | OK | C# 13 | TESTS | 7 | 109 | 40038400 | ||
| 373149056 | Ron47 | D | April 30, 2026, 4:27 p.m. | OK | C# 13 | TESTS | 7 | 156 | 44134400 | ||
| 373170444 | ShivendraCodeF | D | April 30, 2026, 6:46 p.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 46 | 0 | ||
| 373154808 | nmany | D | April 30, 2026, 4:45 p.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 46 | 0 | ||
| 373153008 | mqhuy2006 | D | April 30, 2026, 4:39 p.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 46 | 0 | ||
| 373156120 | dra_silver | D | April 30, 2026, 4:49 p.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 46 | 1638400 | ||
| 373195323 | VickyKumar45 | D | May 1, 2026, 4:55 a.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 62 | 0 | ||
| 373194311 | loveisblind | D | May 1, 2026, 4:39 a.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 62 | 0 | ||
| 373190817 | annekyl404 | D | May 1, 2026, 3:23 a.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 62 | 0 | ||
| 373187024 | qwertyui66 | D | May 1, 2026, 1:44 a.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 62 | 0 | ||
| 373183433 | Prince_ji | D | April 30, 2026, 11:05 p.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 62 | 0 | ||
| 373181138 | imran67 | D | April 30, 2026, 9:56 p.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 62 | 0 |
Back to search problems