Codeforces Round 1098 (Div. 2)

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
2228 Codeforces Round 1098 (Div. 2) FINISHED False 8100 1437887 May 16, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 6859 ) C1 Cirno and Number (Easy Version) PROGRAMMING binary search brute force dp implementation

This is the easy version of the problem. The difference between the versions is that in this version, (n=2). You can hack only if you solved all versions of this problem. You are given a non-negative integer (a) and a non-empty, strictly increasing sequence of digits (d) of length (n), where (0 \le d_i \le 9). Find the minimum value of (|a - b|) over all non-negative integers (b) whose decimal representation contains only digits from (d). 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 two integers (a) and (n) ((0\le a\le 10^{17}), (n=2)). The second line contains (n) integers (d_1,d_2,\ldots,d_n). It is guaranteed that (0\le d_1 \lt d_2 \lt \ldots \lt d_n\le 9). For each test case, output the minimum value of (|a - b|). In the first test case, (a=0), (b=0), and (|a - b|=0). In the second test case, (a=11), (b=11), and (|a - b|=0). In the third test case, (a=222), (b=333), and (|a - b|=111). In the fourth test case, (a=3333), (b=777), and (|a - b|=2556).

Tutorials

Codeforces Round 1098 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
374878124 Tfman C1 May 16, 2026, 10:30 p.m. OK C# 10 TESTS 10 93 5324800
374847027 Pranav_SSS C1 May 16, 2026, 4:35 p.m. OK C++17 (GCC 7-32) TESTS 10 31 0
374846484 vyshnavi_kolasani C1 May 16, 2026, 4:34 p.m. OK C++17 (GCC 7-32) TESTS 10 31 0
374877352 Abu3en C1 May 16, 2026, 10:08 p.m. OK C++17 (GCC 7-32) TESTS 10 31 102400
374898657 Cake_Roll C1 May 17, 2026, 5:04 a.m. OK C++17 (GCC 7-32) TESTS 10 46 0
374898280 ice-gruel C1 May 17, 2026, 5 a.m. OK C++17 (GCC 7-32) TESTS 10 46 0
374898147 MinecraftQE C1 May 17, 2026, 4:59 a.m. OK C++17 (GCC 7-32) TESTS 10 46 0
374895279 permanent_delegate C1 May 17, 2026, 4:24 a.m. OK C++17 (GCC 7-32) TESTS 10 46 0
374893518 mengmeng123456 C1 May 17, 2026, 3:59 a.m. OK C++17 (GCC 7-32) TESTS 10 46 0
374893088 PRIYANK25 C1 May 17, 2026, 3:52 a.m. OK C++17 (GCC 7-32) TESTS 10 46 0
374892911 Pek_RESURRECTION_ C1 May 17, 2026, 3:50 a.m. OK C++17 (GCC 7-32) TESTS 10 46 0
374896681 silvered C1 May 17, 2026, 4:43 a.m. OK C++20 (GCC 13-64) TESTS 10 31 0
374887543 LLDhahaha C1 May 17, 2026, 3:03 a.m. OK C++20 (GCC 13-64) TESTS 10 31 0
374886993 PelicanPilot C1 May 17, 2026, 2:52 a.m. OK C++20 (GCC 13-64) TESTS 10 31 0
374870255 Roc_ C1 May 16, 2026, 7:59 p.m. OK C++20 (GCC 13-64) TESTS 10 31 0
374868636 nope6 C1 May 16, 2026, 7:39 p.m. OK C++20 (GCC 13-64) TESTS 10 31 0
374854719 Rajdeep_P1 C1 May 16, 2026, 4:49 p.m. OK C++20 (GCC 13-64) TESTS 10 31 0
374850659 lfreecs C1 May 16, 2026, 4:42 p.m. OK C++20 (GCC 13-64) TESTS 10 31 0
374850200 12paterium C1 May 16, 2026, 4:41 p.m. OK C++20 (GCC 13-64) TESTS 10 31 0
374849106 KrishxKK C1 May 16, 2026, 4:39 p.m. OK C++20 (GCC 13-64) TESTS 10 31 0
374847037 eaeaeaea C1 May 16, 2026, 4:35 p.m. OK C++20 (GCC 13-64) TESTS 10 31 0
374899889 atharvsharma3219 C1 May 17, 2026, 5:17 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 31 0
374895379 k1tush C1 May 17, 2026, 4:25 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 31 0
374883698 OOZYXOO C1 May 17, 2026, 1:43 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 31 0
374882966 cxycec C1 May 17, 2026, 1:26 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 31 0
374882743 se_tsu_na C1 May 17, 2026, 1:19 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 31 0
374868072 AbdullahYounes C1 May 16, 2026, 7:32 p.m. OK C++23 (GCC 14-64, msys2) TESTS 10 31 0
374867578 B0udy_ C1 May 16, 2026, 7:27 p.m. OK C++23 (GCC 14-64, msys2) TESTS 10 31 0
374866266 zwhea C1 May 16, 2026, 7:17 p.m. OK C++23 (GCC 14-64, msys2) TESTS 10 31 0
374866130 osvarp C1 May 16, 2026, 7:16 p.m. OK C++23 (GCC 14-64, msys2) TESTS 10 31 0
374865517 discontinuous C1 May 16, 2026, 7:10 p.m. OK C++23 (GCC 14-64, msys2) TESTS 10 31 0
374850515 1435730 C1 May 16, 2026, 4:42 p.m. OK GNU C11 TESTS 10 15 102400
374852031 pmculer26 C1 May 16, 2026, 4:44 p.m. OK GNU C11 TESTS 10 62 0
374846406 123fdr C1 May 16, 2026, 4:34 p.m. OK GNU C11 TESTS 10 62 0
374850310 mannatraj C1 May 16, 2026, 4:41 p.m. OK GNU C11 TESTS 10 78 0
374846070 happy032 C1 May 16, 2026, 4:33 p.m. OK GNU C11 TESTS 10 828 0
374867923 AviNlogN C1 May 16, 2026, 7:31 p.m. OK Java 21 TESTS 10 218 1945600
374846508 aaryansaxena1810 C1 May 16, 2026, 4:34 p.m. OK Java 21 TESTS 10 218 2048000
374847567 Shinjini100255 C1 May 16, 2026, 4:36 p.m. OK Java 21 TESTS 10 234 102400
374852503 nkit_dev01 C1 May 16, 2026, 4:45 p.m. OK Java 21 TESTS 10 234 204800
374853303 SathyaRoopanM C1 May 16, 2026, 4:47 p.m. OK Java 21 TESTS 10 234 409600
374851780 animesh1024 C1 May 16, 2026, 4:44 p.m. OK Java 21 TESTS 10 234 512000
374903823 TIMETABLE1 C1 May 17, 2026, 5:57 a.m. OK Java 21 TESTS 10 234 716800
374848645 pushkar_shinde C1 May 16, 2026, 4:38 p.m. OK Java 21 TESTS 10 234 1024000
374869792 NpHardcore_05 C1 May 16, 2026, 7:53 p.m. OK Java 21 TESTS 10 234 1536000
374900955 Shubham_02_bhardwaj C1 May 17, 2026, 5:29 a.m. OK Java 21 TESTS 10 234 1843200
374895240 TheJavaGuy C1 May 17, 2026, 4:23 a.m. OK Java 8 TESTS 10 156 0
374878674 Jawdat8 C1 May 16, 2026, 10:47 p.m. OK Java 8 TESTS 10 156 0
374873347 harsh08 C1 May 16, 2026, 8:45 p.m. OK Java 8 TESTS 10 171 0
374850327 mahangarerohan C1 May 16, 2026, 4:41 p.m. OK Java 8 TESTS 10 171 0
374870621 karma_guy C1 May 16, 2026, 8:05 p.m. OK Java 8 TESTS 10 218 0
374852575 suriyathiru666 C1 May 16, 2026, 4:45 p.m. OK Java 8 TESTS 10 265 0
374870413 gauravkrgupta0954 C1 May 16, 2026, 8:02 p.m. OK Kotlin 2.2 TESTS 10 312 26521600
374901022 eigen_loop C1 May 17, 2026, 5:29 a.m. OK PyPy 3 TESTS 10 359 9932800
374852549 Shyam414 C1 May 16, 2026, 4:45 p.m. OK PyPy 3 TESTS 10 421 9932800
374846695 Yuvraj_Rathod C1 May 16, 2026, 4:34 p.m. OK PyPy 3 TESTS 10 500 9728000
374849109 rohankarvekar C1 May 16, 2026, 4:39 p.m. OK PyPy 3 TESTS 10 750 10752000
374877178 scooley C1 May 16, 2026, 10:04 p.m. OK PyPy 3-64 TESTS 10 171 9216000
374851674 Sneaky_Attack C1 May 16, 2026, 4:44 p.m. OK PyPy 3-64 TESTS 10 203 9113600
374851485 Greninja2005 C1 May 16, 2026, 4:43 p.m. OK PyPy 3-64 TESTS 10 218 8499200
374853730 ANISH_not_so_GREAT C1 May 16, 2026, 4:47 p.m. OK PyPy 3-64 TESTS 10 218 8601600
374847524 amega09122190 C1 May 16, 2026, 4:36 p.m. OK PyPy 3-64 TESTS 10 218 9216000
374874538 ep268gza C1 May 16, 2026, 9:06 p.m. OK PyPy 3-64 TESTS 10 234 8601600
374880179 54skyxenon C1 May 16, 2026, 11:34 p.m. OK PyPy 3-64 TESTS 10 265 9011200
374866011 orangekid C1 May 16, 2026, 7:14 p.m. OK PyPy 3-64 TESTS 10 265 9113600
374889465 abdullah_iw C1 May 17, 2026, 3:34 a.m. OK PyPy 3-64 TESTS 10 265 9625600
374888336 jvatsal0709 C1 May 17, 2026, 3:16 a.m. OK PyPy 3-64 TESTS 10 281 9113600
374850129 l_pavan_l C1 May 16, 2026, 4:41 p.m. OK Python 3 TESTS 10 125 2048000
374852003 sandeepkumar2005 C1 May 16, 2026, 4:44 p.m. OK Python 3 TESTS 10 125 2662400
374846447 VishrutGrover C1 May 16, 2026, 4:34 p.m. OK Python 3 TESTS 10 156 102400
374846741 Ekshith C1 May 16, 2026, 4:35 p.m. OK Python 3 TESTS 10 156 204800
374850674 themayankjashnani C1 May 16, 2026, 4:42 p.m. OK Python 3 TESTS 10 156 307200
374855239 Nik-mak C1 May 16, 2026, 4:49 p.m. OK Python 3 TESTS 10 171 409600
374850026 ValeryKulishov C1 May 16, 2026, 4:41 p.m. OK Python 3 TESTS 10 171 1843200
374899417 gooonn C1 May 17, 2026, 5:12 a.m. OK Python 3 TESTS 10 187 102400
374850033 Philosviper2266 C1 May 16, 2026, 4:41 p.m. OK Python 3 TESTS 10 187 204800
374852524 AeroSol_can C1 May 16, 2026, 4:45 p.m. OK Python 3 TESTS 10 187 307200

remove filters

Back to search problems