Codeforces Round 1023 (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
2107 Codeforces Round 1023 (Div. 2) FINISHED False 8100 29949923 May 5, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 22136 ) A LRC and VIP PROGRAMMING greedy number theory

You have an array (a) of size (n) — (a_1, a_2, \ldots a_n). You need to divide the (n) elements into (2) sequences (B) and (C), satisfying the following conditions: Each element belongs to exactly one sequence. Both sequences (B) and (C) contain at least one element. (\gcd) ((B_1, B_2, \ldots, B_{|B|}) \ne \gcd(C_1, C_2, \ldots, C_{|C|})) (^{\text{∗}}) (^{\text{∗}})(\gcd(x, y)) denotes the greatest common divisor (GCD) of integers (x) and (y). Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 500)). The description of the test cases follows. The first line of each test case contains an integer (n) ((2 \le n \le 100)). The second line of each test case contains (n) integers (a_1,a_2,\ldots,a_n) ((1 \le a_i \le 10^4)). For each test case, first output (Yes) if a solution exists or (No) if no solution exists. You may print each character in either case, for example (YES) and (yEs) will also be accepted. Only when there is a solution, output (n) integers on the second line. The (i)-th number should be either (1) or (2). (1) represents that the element belongs to sequence (B) and (2) represents that the element belongs to sequence (C). You should guarantee that (1) and (2) both appear at least once. In the first test case, (B = 51, 9) and (C = 1, 20). You can verify (\gcd(B_1, B_2) = 3 \ne 1 = \gcd(C_1, C_2)). In the second test case, it is impossible to find a solution. For example, suppose you distributed the first (3) elements to array (B) and then the last element to array (C). You have (B = 5, 5, 5) and (C = 5), but (\gcd(B_1, B_2, B_3) = 5 = \gcd(C_1)). Hence it is invalid.

Tutorials

Codeforces Round 1023 (Div 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
318550395 nezotiq A May 5, 2025, 7:45 p.m. OK C# 10 TESTS 5 93 3379200
318570618 shahadat26 A May 6, 2025, 2:01 a.m. OK C# 10 TESTS 5 109 2969600
318570704 darkpulse_10 A May 6, 2025, 2:03 a.m. OK C++17 (GCC 7-32) TESTS 5 31 0
318547666 an_illusion A May 5, 2025, 7:09 p.m. OK C++17 (GCC 7-32) TESTS 5 31 0
318546232 Ahmed_Sieam A May 5, 2025, 6:53 p.m. OK C++17 (GCC 7-32) TESTS 5 31 0
318543936 _Nehal2005_ A May 5, 2025, 6:28 p.m. OK C++17 (GCC 7-32) TESTS 5 31 0
318572042 Coder_404. A May 6, 2025, 2:34 a.m. OK C++17 (GCC 7-32) TESTS 5 31 0
318578145 starshines A May 6, 2025, 4:27 a.m. OK C++17 (GCC 7-32) TESTS 5 31 102400
318583859 nagar007sachin A May 6, 2025, 5:52 a.m. OK C++17 (GCC 7-32) TESTS 5 46 0
318584416 Tyrion_Lanister A May 6, 2025, 5:59 a.m. OK C++17 (GCC 7-32) TESTS 5 46 0
318584265 sauravgn A May 6, 2025, 5:57 a.m. OK C++17 (GCC 7-32) TESTS 5 46 0
318583914 Shorya-12 A May 6, 2025, 5:52 a.m. OK C++17 (GCC 7-32) TESTS 5 46 0
318567415 123GG A May 6, 2025, 12:44 a.m. OK C++20 (GCC 13-64) TESTS 5 30 0
318542852 BeGukesh A May 5, 2025, 6:18 p.m. OK C++20 (GCC 13-64) TESTS 5 30 102400
318542271 shoaibhasan600 A May 5, 2025, 6:12 p.m. OK C++20 (GCC 13-64) TESTS 5 30 102400
318578096 AkaiLemon A May 6, 2025, 4:26 a.m. OK C++20 (GCC 13-64) TESTS 5 31 0
318578367 AI_2512 A May 6, 2025, 4:31 a.m. OK C++20 (GCC 13-64) TESTS 5 31 0
318571732 BLUEJOKE A May 6, 2025, 2:28 a.m. OK C++20 (GCC 13-64) TESTS 5 31 0
318568135 wxzeya A May 6, 2025, 1:04 a.m. OK C++20 (GCC 13-64) TESTS 5 31 0
318566375 wang_you A May 6, 2025, 12:16 a.m. OK C++20 (GCC 13-64) TESTS 5 31 0
318559857 Luimas A May 5, 2025, 11:14 p.m. OK C++20 (GCC 13-64) TESTS 5 31 0
318542109 ImCurseDD A May 5, 2025, 6:11 p.m. OK C++20 (GCC 13-64) TESTS 5 31 0
318568393 yurril A May 6, 2025, 1:10 a.m. OK C++23 (GCC 14-64, msys2) TESTS 5 30 0
318571710 jogas_451 A May 6, 2025, 2:27 a.m. OK C++23 (GCC 14-64, msys2) TESTS 5 30 0
318579043 Akshat_j2602 A May 6, 2025, 4:43 a.m. OK C++23 (GCC 14-64, msys2) TESTS 5 31 0
318576778 C0ldSmi1e A May 6, 2025, 4:02 a.m. OK C++23 (GCC 14-64, msys2) TESTS 5 31 0
318571324 xing_suo A May 6, 2025, 2:19 a.m. OK C++23 (GCC 14-64, msys2) TESTS 5 31 0
318571120 Feliks_Zem A May 6, 2025, 2:13 a.m. OK C++23 (GCC 14-64, msys2) TESTS 5 31 0
318543315 sadnessnsorrow A May 5, 2025, 6:22 p.m. OK C++23 (GCC 14-64, msys2) TESTS 5 31 0
318537748 fhrc15904 A May 5, 2025, 5:36 p.m. OK C++23 (GCC 14-64, msys2) TESTS 5 31 0
318538434 ricaxov A May 5, 2025, 5:40 p.m. OK C++23 (GCC 14-64, msys2) TESTS 5 31 0
318582684 shuanglin A May 6, 2025, 5:36 a.m. OK C++23 (GCC 14-64, msys2) TESTS 5 31 0
318568731 bluemegane A May 6, 2025, 1:17 a.m. OK C# 8 TESTS 5 108 2969600
318522399 AyushPravin A May 5, 2025, 4:33 p.m. OK GNU C11 TESTS 5 187 102400
318571819 Loser_Monster. A May 6, 2025, 2:29 a.m. OK GNU C11 TESTS 5 202 102400
318545415 hw3901 A May 5, 2025, 6:44 p.m. OK GNU C11 TESTS 5 202 102400
318522061 Divyang_Joshi A May 5, 2025, 4:32 p.m. OK GNU C11 TESTS 5 217 0
318582749 Divya0612_ A May 6, 2025, 5:37 a.m. OK GNU C11 TESTS 5 218 102400
318519840 Shafeen_code4ever A May 5, 2025, 4:25 p.m. OK GNU C11 TESTS 5 233 0
318547705 LaRagde A May 5, 2025, 7:10 p.m. OK Go TESTS 5 186 3072000
318554541 bomakhamchha A May 5, 2025, 8:53 p.m. OK Java 21 TESTS 5 187 819200
318537224 priyaroy3370 A May 5, 2025, 5:32 p.m. OK Java 21 TESTS 5 217 307200
318579871 Raj_Borad_1729 A May 6, 2025, 4:57 a.m. OK Java 21 TESTS 5 218 409600
318545529 yenugantirahul A May 5, 2025, 6:46 p.m. OK Java 21 TESTS 5 233 512000
318540709 sahil_14 A May 5, 2025, 5:58 p.m. OK Java 21 TESTS 5 249 0
318538765 HalfBlood007 A May 5, 2025, 5:43 p.m. OK Java 21 TESTS 5 249 307200
318549285 fatal-98 A May 5, 2025, 7:29 p.m. OK Java 21 TESTS 5 249 512000
318557591 singhdevansh024 A May 5, 2025, 9:57 p.m. OK Java 21 TESTS 5 249 819200
318544076 hemanthkumar6843 A May 5, 2025, 6:30 p.m. OK Java 21 TESTS 5 264 0
318543961 hemanthvandrangi3 A May 5, 2025, 6:29 p.m. OK Java 21 TESTS 5 264 0
318577433 Purav_Shah07 A May 6, 2025, 4:14 a.m. OK Java 8 TESTS 5 124 0
318575672 Pranav_45 A May 6, 2025, 3:43 a.m. OK Java 8 TESTS 5 124 0
318536173 y_a_s A May 5, 2025, 5:27 p.m. OK Java 8 TESTS 5 140 0
318536383 adibhai0845R A May 5, 2025, 5:28 p.m. OK Java 8 TESTS 5 233 0
318584038 Avinashchy7061 A May 6, 2025, 5:54 a.m. OK Java 8 TESTS 5 249 0
318581833 sriram20011002 A May 6, 2025, 5:24 a.m. OK Java 8 TESTS 5 249 0
318568930 Dduo A May 6, 2025, 1:22 a.m. OK Java 8 TESTS 5 249 0
318539225 priyanshu3003 A May 5, 2025, 5:46 p.m. OK Java 8 TESTS 5 249 0
318538570 Ishaan__23 A May 5, 2025, 5:41 p.m. OK Java 8 TESTS 5 250 0
318550377 vive02-xo A May 5, 2025, 7:45 p.m. OK Java 8 TESTS 5 265 0
318520456 iitamansharma A May 5, 2025, 4:27 p.m. OK Kotlin 1.7 TESTS 5 390 19353600
318544258 swseverance A May 5, 2025, 6:31 p.m. OK Node.js TESTS 5 140 6451200
318557163 AyushSinghCF A May 5, 2025, 9:47 p.m. OK PyPy 3 TESTS 5 156 5017600
318559639 JuanCoder64 A May 5, 2025, 11:07 p.m. OK PyPy 3 TESTS 5 171 4300800
318547202 placeholder101 A May 5, 2025, 7:04 p.m. OK PyPy 3 TESTS 5 171 7270400
318573136 Akash_123 A May 6, 2025, 2:54 a.m. OK PyPy 3 TESTS 5 233 9216000
318526495 eyustarX A May 5, 2025, 4:44 p.m. OK PyPy 3 TESTS 5 249 6246400
318541808 Akash_123 A May 5, 2025, 6:08 p.m. OK PyPy 3 TESTS 5 265 8192000
318582384 santhoshsparky A May 6, 2025, 5:32 a.m. OK PyPy 3 TESTS 5 296 8499200
318578599 Charararar A May 6, 2025, 4:35 a.m. OK PyPy 3-64 TESTS 5 92 2560000
318555965 theodoraj A May 5, 2025, 9:21 p.m. OK PyPy 3-64 TESTS 5 93 2662400
318575058 von2401 A May 6, 2025, 3:31 a.m. OK PyPy 3-64 TESTS 5 93 2764800
318579719 Canyonzzzzz A May 6, 2025, 4:54 a.m. OK PyPy 3-64 TESTS 5 93 5017600
318576461 cold_beans A May 6, 2025, 3:57 a.m. OK PyPy 3-64 TESTS 5 93 6246400
318542869 Gas4078 A May 5, 2025, 6:18 p.m. OK PyPy 3-64 TESTS 5 108 2560000
318549000 pusheen_1024 A May 5, 2025, 7:25 p.m. OK PyPy 3-64 TESTS 5 108 2662400
318576667 chaostude A May 6, 2025, 4 a.m. OK PyPy 3-64 TESTS 5 108 2867200
318537981 TerryYangUSA A May 5, 2025, 5:37 p.m. OK PyPy 3-64 TESTS 5 108 3174400
318551849 abdelhakimzetati A May 5, 2025, 8:09 p.m. OK PyPy 3-64 TESTS 5 108 4710400
318528402 more_sleep A May 5, 2025, 4:49 p.m. OK Python 3 TESTS 5 61 409600
318540949 The_geek_deep A May 5, 2025, 6 p.m. OK Python 3 TESTS 5 62 204800
318553333 shia177 A May 5, 2025, 8:32 p.m. OK Python 3 TESTS 5 77 204800
318550546 madhur_rathod A May 5, 2025, 7:48 p.m. OK Python 3 TESTS 5 77 204800
318553258 Noraldim A May 5, 2025, 8:31 p.m. OK Python 3 TESTS 5 77 307200
318538372 amitcad A May 5, 2025, 5:40 p.m. OK Python 3 TESTS 5 77 307200
318520605 Artinzer0 A May 5, 2025, 4:27 p.m. OK Python 3 TESTS 5 77 409600
318545532 saqlain2204 A May 5, 2025, 6:46 p.m. OK Python 3 TESTS 5 77 1843200
318578109 hegdeniranjan144 A May 6, 2025, 4:26 a.m. OK Python 3 TESTS 5 78 204800
318552692 shia177 A May 5, 2025, 8:22 p.m. OK Python 3 TESTS 5 78 204800
318549898 0x81 A May 5, 2025, 7:38 p.m. OK Rust 2021 TESTS 5 46 0
318567467 silicalet A May 6, 2025, 12:45 a.m. OK Rust 2021 TESTS 5 77 0

remove filters

Back to search problems