Codeforces Round 1059 (Div. 3)

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
2162 Codeforces Round 1059 (Div. 3) FINISHED False 8100 15693923 Oct. 17, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 9244 ) E Beautiful Palindromes PROGRAMMING constructive algorithms greedy schedules

We call an array (b_1, b_2, \dots, b_m) of length (m) palindromic if the following condition holds: (b_i = b_{m-i+1}) for all (1 \le i \le m) In other words, an array is palindromic if it reads the same forward and backward. You are given an array (a_1, a_2, \dots , a_n) of (n) integers where (1 \le a_i \le n) and an integer (k). You are required to perform the following operation exactly (k) times: choose an integer (x) such that (1 \le x \le n), append (x) to the end of the array (a). Your goal is to perform these (k) operations in such a way that the number of palindromic subarrays(^{\text{∗}}) in the resulting array is minimized. Output the (k) integers you chose for each operation, in the order they were appended. (^{\text{∗}})An array (b) is a subarray of an array (a) if (b) can be obtained from (a) by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end. In particular, an array is a subarray of itself. The first line of input contains a single integer (t) ((1 \le t \le 10^4)) — the number of test cases. The first line of each test case contains two integers (n) and (k) ((3 \le n \le 2\cdot10^5, 1 \le k \le n)) — the length of the array (a). The second line of each test case contains (n) integers (a_1, a_2, \ldots , a_n) ((1 \le a_i \le n)) — the elements of the array (a). It is guaranteed that the sum of (n) over all the test cases does not exceed (2\cdot10^5). For each test case, print the (k) integers chosen for the append operations, in the order they were appended, such that the total number of palindromic subarrays in the resulting array is minimized. If there are multiple answers, you may output any one of them. For the first test case, if we append (2) to the end of the array, (a) becomes (1, 3, 3, 4, 2). Now $$$a$$

Tutorials

Codeforces Round 1059 (Div. 3) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
344510333 og.kostya E Oct. 18, 2025, 2:04 p.m. OK C# 10 TESTS 17 124 4608000
344505873 og.kostya E Oct. 18, 2025, 1:40 p.m. OK C# 13 TESTS 17 140 5836800
344525304 Equinox_Ya E Oct. 18, 2025, 3:30 p.m. OK C# 13 TESTS 17 171 15872000
344588093 Harssha_10 E Oct. 19, 2025, 5:34 a.m. OK C++17 (GCC 7-32) TESTS 17 93 0
344580747 aihan_11 E Oct. 19, 2025, 3:41 a.m. OK C++17 (GCC 7-32) TESTS 17 93 0
344417224 WHGG E Oct. 18, 2025, 1:28 a.m. OK C++17 (GCC 7-32) TESTS 17 93 1024000
344493776 threebear E Oct. 18, 2025, 12:29 p.m. OK C++17 (GCC 7-32) TESTS 17 93 1126400
344589648 reqiv E Oct. 19, 2025, 5:50 a.m. OK C++17 (GCC 7-32) TESTS 17 108 0
344588930 _modern E Oct. 19, 2025, 5:43 a.m. OK C++17 (GCC 7-32) TESTS 17 108 0
344587148 lpychemistry E Oct. 19, 2025, 5:23 a.m. OK C++17 (GCC 7-32) TESTS 17 108 0
344578035 RoOoOoKie E Oct. 19, 2025, 2:49 a.m. OK C++17 (GCC 7-32) TESTS 17 108 0
344530366 rafieefatemeh995 E Oct. 18, 2025, 4:02 p.m. OK C++17 (GCC 7-32) TESTS 17 108 0
344526550 VaiseIamHere E Oct. 18, 2025, 3:37 p.m. OK C++17 (GCC 7-32) TESTS 17 108 0
344577872 ethan7sky E Oct. 19, 2025, 2:46 a.m. OK C++20 (GCC 13-64) TESTS 17 78 0
344573916 PVB.TungLam E Oct. 19, 2025, 1:03 a.m. OK C++20 (GCC 13-64) TESTS 17 78 1536000
344494163 conexposys E Oct. 18, 2025, 12:31 p.m. OK C++20 (GCC 13-64) TESTS 17 78 2355200
344434498 ntk7643 E Oct. 18, 2025, 5:20 a.m. OK C++20 (GCC 13-64) TESTS 17 78 16076800
344528681 huanhuanonly E Oct. 18, 2025, 3:52 p.m. OK C++20 (GCC 13-64) TESTS 17 92 1536000
344591299 MelonHiker E Oct. 19, 2025, 6:05 a.m. OK C++20 (GCC 13-64) TESTS 17 93 0
344588458 Deepak_2004 E Oct. 19, 2025, 5:39 a.m. OK C++20 (GCC 13-64) TESTS 17 93 0
344587729 Red_Tea E Oct. 19, 2025, 5:30 a.m. OK C++20 (GCC 13-64) TESTS 17 93 0
344586119 arimakanaa E Oct. 19, 2025, 5:11 a.m. OK C++20 (GCC 13-64) TESTS 17 93 0
344582605 NGC3842 E Oct. 19, 2025, 4:15 a.m. OK C++20 (GCC 13-64) TESTS 17 93 0
344501053 RomanLin E Oct. 18, 2025, 1:11 p.m. OK C++23 (GCC 14-64, msys2) TESTS 17 77 1024000
344574788 exccc E Oct. 19, 2025, 1:31 a.m. OK C++23 (GCC 14-64, msys2) TESTS 17 78 0
344506248 fishcathu E Oct. 18, 2025, 1:42 p.m. OK C++23 (GCC 14-64, msys2) TESTS 17 78 1024000
344589638 LioHein E Oct. 19, 2025, 5:50 a.m. OK C++23 (GCC 14-64, msys2) TESTS 17 92 0
344575301 555eiei E Oct. 19, 2025, 1:46 a.m. OK C++23 (GCC 14-64, msys2) TESTS 17 92 0
344423476 Franxx_ E Oct. 18, 2025, 3:12 a.m. OK C++23 (GCC 14-64, msys2) TESTS 17 92 819200
344430958 ryuuko__ E Oct. 18, 2025, 4:46 a.m. OK C++23 (GCC 14-64, msys2) TESTS 17 92 1024000
344529881 devanshudubey7349 E Oct. 18, 2025, 3:59 p.m. OK C++23 (GCC 14-64, msys2) TESTS 17 92 1638400
344588590 ddhw111 E Oct. 19, 2025, 5:40 a.m. OK C++23 (GCC 14-64, msys2) TESTS 17 93 0
344585341 gos626 E Oct. 19, 2025, 5 a.m. OK C++23 (GCC 14-64, msys2) TESTS 17 93 0
344559134 Parth_Singhal E Oct. 18, 2025, 7:42 p.m. OK GNU C11 TESTS 17 859 1638400
344514987 owi8270 E Oct. 18, 2025, 2:29 p.m. OK Go TESTS 17 171 10752000
344520090 icpc_loser E Oct. 18, 2025, 2:58 p.m. OK Java 21 TESTS 17 358 1331200
344424433 _mi_ka_java E Oct. 18, 2025, 3:26 a.m. OK Java 21 TESTS 17 374 716800
344567931 kartik__sethi E Oct. 18, 2025, 9:48 p.m. OK Java 21 TESTS 17 499 20275200
344418619 BoredAF1 E Oct. 18, 2025, 1:53 a.m. OK Java 21 TESTS 17 577 34201600
344434783 Kh0909 E Oct. 18, 2025, 5:23 a.m. OK Java 21 TESTS 17 624 3276800
344506749 sahil_2448_coder E Oct. 18, 2025, 1:45 p.m. OK Java 21 TESTS 17 640 16691200
344501008 NooB__C0der E Oct. 18, 2025, 1:10 p.m. OK Java 21 TESTS 17 655 12185600
344551560 h_maano E Oct. 18, 2025, 6:28 p.m. OK Java 21 TESTS 17 656 2969600
344494788 shivam24121 E Oct. 18, 2025, 12:34 p.m. OK Java 21 TESTS 17 750 19968000
344417447 upindiasarvesh E Oct. 18, 2025, 1:32 a.m. OK Java 21 TESTS 17 765 18329600
344427818 deepthisuddapalli05 E Oct. 18, 2025, 4:11 a.m. OK Java 8 TESTS 17 202 3686400
344426004 suntansoker E Oct. 18, 2025, 3:48 a.m. OK Java 8 TESTS 17 218 3993600
344588682 prime29 E Oct. 19, 2025, 5:41 a.m. OK Java 8 TESTS 17 249 3686400
344522110 KrishnaDuby E Oct. 18, 2025, 3:10 p.m. OK Java 8 TESTS 17 796 0
344550960 Radhe_1 E Oct. 18, 2025, 6:23 p.m. OK Java 8 TESTS 17 967 15769600
344493114 KLU2300033802 E Oct. 18, 2025, 12:26 p.m. OK Java 8 TESTS 17 1109 53964800
344567977 TNTNTN E Oct. 18, 2025, 9:49 p.m. OK PyPy 3 TESTS 17 561 18534400
344567503 Om_Singh_ E Oct. 18, 2025, 9:40 p.m. OK PyPy 3-64 TESTS 17 156 29696000
344586075 hundunlilun1 E Oct. 19, 2025, 5:10 a.m. OK PyPy 3-64 TESTS 17 171 26009600
344420381 udayan8 E Oct. 18, 2025, 2:23 a.m. OK PyPy 3-64 TESTS 17 202 32153600
344590296 EIR94326 E Oct. 19, 2025, 5:56 a.m. OK PyPy 3-64 TESTS 17 217 28672000
344504796 DivyamAwasthy E Oct. 18, 2025, 1:34 p.m. OK PyPy 3-64 TESTS 17 234 26931200
344587497 EIR94326 E Oct. 19, 2025, 5:27 a.m. OK PyPy 3-64 TESTS 17 234 28160000
344505988 iN_siDious E Oct. 18, 2025, 1:41 p.m. OK PyPy 3-64 TESTS 17 234 36147200
344493014 Hanyilin E Oct. 18, 2025, 12:25 p.m. OK PyPy 3-64 TESTS 17 249 30208000
344534242 eric899 E Oct. 18, 2025, 4:27 p.m. OK PyPy 3-64 TESTS 17 249 31948800
344501601 movement124 E Oct. 18, 2025, 1:14 p.m. OK PyPy 3-64 TESTS 17 250 25600000
344536692 Coder_Ayush_ E Oct. 18, 2025, 4:43 p.m. OK Python 3 TESTS 17 218 35635200
344536090 anonymousdv E Oct. 18, 2025, 4:39 p.m. OK Python 3 TESTS 17 343 31436800
344494689 a_0dnok1 E Oct. 18, 2025, 12:34 p.m. OK Python 3 TESTS 17 359 23040000
344562464 Rcrocks E Oct. 18, 2025, 8:21 p.m. OK Python 3 TESTS 17 390 25088000
344523962 jvatsal0709 E Oct. 18, 2025, 3:22 p.m. OK Python 3 TESTS 17 515 30515200

remove filters

Back to search problems