Codeforces Round 1069 (Div. 1)

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
2174 Codeforces Round 1069 (Div. 1) FINISHED False 7200 11396723 Dec. 6, 2025, 8:15 a.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 14103 ) A Needle in a Haystack PROGRAMMING greedy strings two pointers

You got lucky to know the answer to all important questions in the world. This time, the answer is the string (s), consisting of lowercase English letters only. You want to hide this string. You have another string (t) also consisting of lowercase English letters only. You need to shuffle the letters in (t) so that the string (s) appears at least once in (t) as a subsequence(^{\text{∗}}). Among all possible reorderings of (t) containing (s) as a subsequence, find the lexicographically smallest(^{\text{†}}) one. (^{\text{∗}})A sequence (a) is a subsequence of a sequence (b) if (a) can be obtained from (b) by the deletion of several (possibly, zero or all) element from arbitrary positions. (^{\text{†}})A string (a) is lexicographically smaller than string (b) if and only if one of the following holds: (a) is a prefix of (b), but (a \ne b); or in the first position where (a) and (b) differ, the string (a) has a letter that appears earlier in the alphabet than the corresponding letter in (b). Each test contains multiple test cases. The first line contains the number of test cases (T) ((1 \le T \le 10^4)). The description of the test cases follows. The first line of each test case contains the string (s) ((1 \le |s| \le 10^5)), where (|s|) is the length of the string (s). The second line of each test case contains the string (t) ((|s| \le |t| \le 10^5)). Both strings consist of lowercase English letters only. The sum of (|t|) over all test cases does not exceed (10^5). For each test case, print a single string: the lexicographically smallest reordering of letters in the string (t) that contains (s) as a subsequence. If no such string exists, print " Impossible " instead. In the first test case, (\mathtt{abc}\,\mathtt{dcbe}\,\mathtt{ef}) contains (\mathtt{dcbe}). In the second test case, $$$\mathtt{aaaaa}\,\matht

Tutorials

Codeforces Round 1069 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
352192361 mban259 A Dec. 6, 2025, 8:23 a.m. OK C# 13 TESTS 5 78 3276800
352194444 -firefly- A Dec. 6, 2025, 8:26 a.m. OK C# 13 TESTS 5 78 4915200
352337657 rounakpatra A Dec. 7, 2025, 5:02 a.m. OK C++17 (GCC 7-32) TESTS 5 31 0
352337106 BotiT48 A Dec. 7, 2025, 4:53 a.m. OK C++17 (GCC 7-32) TESTS 5 31 0
352266580 18666926691 A Dec. 6, 2025, 1:57 p.m. OK C++17 (GCC 7-32) TESTS 5 31 0
352261367 Architcp A Dec. 6, 2025, 1:23 p.m. OK C++17 (GCC 7-32) TESTS 5 31 0
352206915 johnny8337 A Dec. 6, 2025, 8:49 a.m. OK C++17 (GCC 7-32) TESTS 5 31 0
352198080 Terme A Dec. 6, 2025, 8:33 a.m. OK C++17 (GCC 7-32) TESTS 5 31 0
352196965 cute_hater A Dec. 6, 2025, 8:30 a.m. OK C++17 (GCC 7-32) TESTS 5 31 0
352196903 Frosted_maze A Dec. 6, 2025, 8:30 a.m. OK C++17 (GCC 7-32) TESTS 5 31 0
352196035 mircea_007 A Dec. 6, 2025, 8:29 a.m. OK C++17 (GCC 7-32) TESTS 5 31 0
352194672 PokeSam9 A Dec. 6, 2025, 8:26 a.m. OK C++17 (GCC 7-32) TESTS 5 31 0
352330186 HSSZ-shensy A Dec. 7, 2025, 2:42 a.m. OK C++20 (GCC 13-64) TESTS 5 15 0
352309745 csk2005 A Dec. 6, 2025, 7:36 p.m. OK C++20 (GCC 13-64) TESTS 5 15 0
352203787 t98slider A Dec. 6, 2025, 8:44 a.m. OK C++20 (GCC 13-64) TESTS 5 15 0
352200385 Irmuun.Ch A Dec. 6, 2025, 8:37 a.m. OK C++20 (GCC 13-64) TESTS 5 15 0
352191447 Teja-Smart A Dec. 6, 2025, 8:22 a.m. OK C++20 (GCC 13-64) TESTS 5 15 0
352189742 VerweliuZ A Dec. 6, 2025, 8:19 a.m. OK C++20 (GCC 13-64) TESTS 5 15 0
352287953 lucaski2 A Dec. 6, 2025, 4:33 p.m. OK C++20 (GCC 13-64) TESTS 5 15 102400
352193569 emthrm A Dec. 6, 2025, 8:25 a.m. OK C++20 (GCC 13-64) TESTS 5 15 102400
352192799 AC-Automation A Dec. 6, 2025, 8:24 a.m. OK C++20 (GCC 13-64) TESTS 5 15 102400
352192629 atkubo A Dec. 6, 2025, 8:24 a.m. OK C++20 (GCC 13-64) TESTS 5 15 102400
352323412 valiii A Dec. 6, 2025, 11:56 p.m. OK C++23 (GCC 14-64, msys2) TESTS 5 15 0
352271906 cse23070 A Dec. 6, 2025, 2:35 p.m. OK C++23 (GCC 14-64, msys2) TESTS 5 15 0
352198975 zenlog A Dec. 6, 2025, 8:34 a.m. OK C++23 (GCC 14-64, msys2) TESTS 5 15 0
352196207 BaarishBoy A Dec. 6, 2025, 8:29 a.m. OK C++23 (GCC 14-64, msys2) TESTS 5 15 0
352192535 Sirantic A Dec. 6, 2025, 8:23 a.m. OK C++23 (GCC 14-64, msys2) TESTS 5 15 0
352192519 ymmparsa A Dec. 6, 2025, 8:23 a.m. OK C++23 (GCC 14-64, msys2) TESTS 5 15 0
352192417 tebiezhichu326c A Dec. 6, 2025, 8:23 a.m. OK C++23 (GCC 14-64, msys2) TESTS 5 15 0
352190274 risujiroh A Dec. 6, 2025, 8:20 a.m. OK C++23 (GCC 14-64, msys2) TESTS 5 15 0
352189938 cooluo A Dec. 6, 2025, 8:20 a.m. OK C++23 (GCC 14-64, msys2) TESTS 5 15 2252800
352195647 zhangzheng2026 A Dec. 6, 2025, 8:28 a.m. OK C++23 (GCC 14-64, msys2) TESTS 5 15 3174400
352197437 pengin_2000 A Dec. 6, 2025, 8:31 a.m. OK GNU C11 TESTS 5 406 204800
352294224 Parthesh28 A Dec. 6, 2025, 5:25 p.m. OK Java 21 TESTS 5 218 819200
352270613 lucifer55 A Dec. 6, 2025, 2:26 p.m. OK Java 8 TESTS 5 93 0
352195572 gua069 A Dec. 6, 2025, 8:28 a.m. OK Java 8 TESTS 5 125 0
352335155 krishnandu01 A Dec. 7, 2025, 4:22 a.m. OK Java 8 TESTS 5 156 0
352262967 ashishprajapat A Dec. 6, 2025, 1:34 p.m. OK Java 8 TESTS 5 156 0
352294583 SalicylicAcid A Dec. 6, 2025, 5:28 p.m. OK PyPy 3 TESTS 5 281 9420800
352194040 fatalerror A Dec. 6, 2025, 8:26 a.m. OK PyPy 3-64 TESTS 5 125 6144000
352316088 ndelisle A Dec. 6, 2025, 9:05 p.m. OK PyPy 3-64 TESTS 5 140 6041600
352189197 gawkmaster069 A Dec. 6, 2025, 8:19 a.m. OK PyPy 3-64 TESTS 5 140 20275200
352281703 BoomTiwari A Dec. 6, 2025, 3:45 p.m. OK PyPy 3-64 TESTS 5 156 6246400
352197281 Pulkit_gupta A Dec. 6, 2025, 8:31 a.m. OK PyPy 3-64 TESTS 5 156 6348800
352197242 krism A Dec. 6, 2025, 8:31 a.m. OK PyPy 3-64 TESTS 5 156 11980800
352192143 SirMrGuy A Dec. 6, 2025, 8:23 a.m. OK PyPy 3-64 TESTS 5 171 8806400
352196166 Ayis137 A Dec. 6, 2025, 8:29 a.m. OK PyPy 3-64 TESTS 5 171 10137600
352194356 alphaGem A Dec. 6, 2025, 8:26 a.m. OK PyPy 3-64 TESTS 5 203 6348800
352190445 sfiisf A Dec. 6, 2025, 8:20 a.m. OK PyPy 3-64 TESTS 5 203 9932800
352196301 Jimanbanashi A Dec. 6, 2025, 8:29 a.m. OK Python 2 TESTS 5 125 102400
352280863 codersannitw A Dec. 6, 2025, 3:39 p.m. OK Python 3 TESTS 5 109 2150400
352222602 snv2 A Dec. 6, 2025, 9:25 a.m. OK Python 3 TESTS 5 156 2048000
352276803 siddhantbashisth A Dec. 6, 2025, 3:08 p.m. OK Python 3 TESTS 5 171 2048000
352194985 ACr0bat A Dec. 6, 2025, 8:27 a.m. OK Python 3 TESTS 5 218 2764800
352336481 maxymien A Dec. 7, 2025, 4:43 a.m. OK Python 3 TESTS 5 515 2764800
352192122 toomer A Dec. 6, 2025, 8:23 a.m. OK Rust 2021 TESTS 5 15 102400
352190234 sansen A Dec. 6, 2025, 8:20 a.m. OK Rust 2021 TESTS 5 31 0
352195307 Monster027 A Dec. 6, 2025, 8:28 a.m. OK Rust 2024 TESTS 5 31 0
352192089 Egor A Dec. 6, 2025, 8:23 a.m. OK Rust 2024 TESTS 5 31 0
352212199 despair A Dec. 6, 2025, 9 a.m. OK Rust 2024 TESTS 5 46 0
352192254 kanra824 A Dec. 6, 2025, 8:23 a.m. OK Rust 2024 TESTS 5 46 0

remove filters

Back to search problems