Codeforces Round 1073 (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
2191 Codeforces Round 1073 (Div. 2) FINISHED False 10800 7745123 Jan. 17, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 27547 ) A Array Coloring PROGRAMMING constructive algorithms

You have (n) cards arranged in a row. The (i)-th card has the integer (a_i) written on it. All integers are distinct. You must color each card either (\color{red}{\text{red}}) or (\color{blue}{\text{blue}}) such that the following conditions are satisfied: Any two adjacent cards in the row have different colors. If you rearrange the cards so that the numbers on them are in increasing order, any two adjacent cards in the new row must also have different colors. Determine if such a coloring exists. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 200)). The description of the test cases follows. The first line of each test case contains a single integer (n) ((2 \le n \le 100)) — the length of the array. The second line of each test case contains (n) integers (a_1, a_2, \ldots, a_n) ((1 \le a_i \le n)). It is guaranteed that all elements of (a) are distinct. For each test case, output " YES " if you can color the cards so that the conditions are satisfied, and " NO " otherwise. You can output the answer in any case (upper or lower). For example, the strings " yEs ", " yes ", " Yes ", and " YES " will be recognized as positive responses. In the first example, the cards are colored as (a = \color{red}{2}, \color{blue}{3}, \color{red}{4}, \color{blue}{1}). After sorting, the cards become (\color{blue}{1}, \color{red}{2}, \color{blue}{3}, \color{red}{4}). Both sequences satisfy the condition, so the answer is YES . In the second example, no valid coloring exists. For instance, if we color the cards as (a = \color{blue}{2}, \color{red}{3}, \color{blue}{1}), the sorted sequence becomes (\color{blue}{1}, \color{blue}{2}, \color{red}{3}). Here, the adjacent elements (1) and (2) have the same color, so the condition is not satisfied. In the third example, a possible coloring is $$$a = [\color{blue}{3}, \color{red}{4}, \color{blu

Tutorials

Codeforces Round 1073 (Div. 1, Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
358406300 Sanjoy_23 A Jan. 18, 2026, 4:52 a.m. OK C# 13 TESTS 3 62 2150400
358380153 Sanjuuuuu A Jan. 17, 2026, 7:20 p.m. OK C++17 (GCC 7-32) TESTS 3 0 0
358384447 Pagani_001 A Jan. 17, 2026, 8:04 p.m. OK C++17 (GCC 7-32) TESTS 3 0 0
358387615 Mostafa_Ezzat A Jan. 17, 2026, 8:47 p.m. OK C++17 (GCC 7-32) TESTS 3 0 102400
358412076 ZED-1 A Jan. 18, 2026, 6 a.m. OK C++17 (GCC 7-32) TESTS 3 15 0
358411541 freak_ A Jan. 18, 2026, 5:55 a.m. OK C++17 (GCC 7-32) TESTS 3 15 0
358410618 kisasa A Jan. 18, 2026, 5:45 a.m. OK C++17 (GCC 7-32) TESTS 3 15 0
358411468 vardhani A Jan. 18, 2026, 5:54 a.m. OK C++17 (GCC 7-32) TESTS 3 15 0
358412997 yogiraj151 A Jan. 18, 2026, 6:09 a.m. OK C++17 (GCC 7-32) TESTS 3 15 0
358412364 safiullahforagy A Jan. 18, 2026, 6:03 a.m. OK C++17 (GCC 7-32) TESTS 3 15 0
358412095 iamAtharv A Jan. 18, 2026, 6:01 a.m. OK C++17 (GCC 7-32) TESTS 3 15 0
358380579 konika07 A Jan. 17, 2026, 7:24 p.m. OK C++20 (GCC 13-64) TESTS 3 0 0
358395121 ayhamzaidd A Jan. 18, 2026, 12:17 a.m. OK C++20 (GCC 13-64) TESTS 3 0 0
358376227 vidit_046 A Jan. 17, 2026, 6:47 p.m. OK C++20 (GCC 13-64) TESTS 3 0 0
358410440 KrishSadar A Jan. 18, 2026, 5:43 a.m. OK C++20 (GCC 13-64) TESTS 3 15 0
358411551 ANISHA7781 A Jan. 18, 2026, 5:55 a.m. OK C++20 (GCC 13-64) TESTS 3 15 0
358408672 Harsh_maheriya A Jan. 18, 2026, 5:24 a.m. OK C++20 (GCC 13-64) TESTS 3 15 0
358408530 dangminh192102 A Jan. 18, 2026, 5:22 a.m. OK C++20 (GCC 13-64) TESTS 3 15 0
358407640 AvYaAn A Jan. 18, 2026, 5:11 a.m. OK C++20 (GCC 13-64) TESTS 3 15 0
358405311 DivebombDijkstra A Jan. 18, 2026, 4:35 a.m. OK C++20 (GCC 13-64) TESTS 3 15 0
358403029 hseerig A Jan. 18, 2026, 3:54 a.m. OK C++20 (GCC 13-64) TESTS 3 15 0
358375630 D-a-K-s-H-1-2 A Jan. 17, 2026, 6:42 p.m. OK C++23 (GCC 14-64, msys2) TESTS 3 0 0
358412162 avnis_mac A Jan. 18, 2026, 6:01 a.m. OK C++23 (GCC 14-64, msys2) TESTS 3 15 0
358411876 Pratyush_007 A Jan. 18, 2026, 5:58 a.m. OK C++23 (GCC 14-64, msys2) TESTS 3 15 0
358410365 kesh06 A Jan. 18, 2026, 5:42 a.m. OK C++23 (GCC 14-64, msys2) TESTS 3 15 0
358409449 V__Akash A Jan. 18, 2026, 5:32 a.m. OK C++23 (GCC 14-64, msys2) TESTS 3 15 0
358409148 Aditya_Dave A Jan. 18, 2026, 5:29 a.m. OK C++23 (GCC 14-64, msys2) TESTS 3 15 0
358409143 Saint_Antares A Jan. 18, 2026, 5:29 a.m. OK C++23 (GCC 14-64, msys2) TESTS 3 15 0
358408418 NlogN_ayan A Jan. 18, 2026, 5:21 a.m. OK C++23 (GCC 14-64, msys2) TESTS 3 15 0
358407480 srujan.karthikey A Jan. 18, 2026, 5:09 a.m. OK C++23 (GCC 14-64, msys2) TESTS 3 15 0
358408287 NorLui A Jan. 18, 2026, 5:19 a.m. OK C++23 (GCC 14-64, msys2) TESTS 3 15 0
358402668 Bhanu_Rishik A Jan. 18, 2026, 3:47 a.m. OK GNU C11 TESTS 3 0 0
358355427 nallabolupranayreddy2527 A Jan. 17, 2026, 4:53 p.m. OK GNU C11 TESTS 3 0 0
358364556 ChinmayGhosh A Jan. 17, 2026, 5:21 p.m. OK GNU C11 TESTS 3 15 0
358392851 Kashmam A Jan. 17, 2026, 10:36 p.m. OK GNU C11 TESTS 3 15 0
358391613 pronob_majumder A Jan. 17, 2026, 9:57 p.m. OK GNU C11 TESTS 3 15 0
358376017 KushDumbo A Jan. 17, 2026, 6:45 p.m. OK GNU C11 TESTS 3 15 0
358363687 Hiten_Shekhawat A Jan. 17, 2026, 5:18 p.m. OK GNU C11 TESTS 3 15 0
358374513 m3vu A Jan. 17, 2026, 6:34 p.m. OK GNU C11 TESTS 3 15 0
358365570 mortifiedrick A Jan. 17, 2026, 5:24 p.m. OK GNU C11 TESTS 3 15 0
358365532 Kabiir1234 A Jan. 17, 2026, 5:24 p.m. OK GNU C11 TESTS 3 15 0
358389676 Ashmit_singh2006 A Jan. 17, 2026, 9:16 p.m. OK Java 21 TESTS 3 109 204800
358378373 strawberry_3012 A Jan. 17, 2026, 7:04 p.m. OK Java 21 TESTS 3 109 512000
358358879 DSPRIDES A Jan. 17, 2026, 5:03 p.m. OK Java 21 TESTS 3 125 409600
358401648 EnvyThunder A Jan. 18, 2026, 3:27 a.m. OK Java 21 TESTS 3 140 0
358398810 aniketHacker A Jan. 18, 2026, 2:19 a.m. OK Java 21 TESTS 3 140 614400
358388915 ayushgoswami669 A Jan. 17, 2026, 9:02 p.m. OK Java 21 TESTS 3 140 716800
358353046 oscar02 A Jan. 17, 2026, 4:47 p.m. OK Java 21 TESTS 3 156 0
358412239 sitaramSahu A Jan. 18, 2026, 6:02 a.m. OK Java 21 TESTS 3 156 0
358378846 Awakendawn A Jan. 17, 2026, 7:08 p.m. OK Java 21 TESTS 3 171 204800
358358900 rithik_14 A Jan. 17, 2026, 5:03 p.m. OK Java 21 TESTS 3 171 307200
358410138 Himavanth_ A Jan. 18, 2026, 5:40 a.m. OK Java 8 TESTS 3 93 0
358410484 Himavanth_ A Jan. 18, 2026, 5:44 a.m. OK Java 8 TESTS 3 109 0
358382196 nikki56 A Jan. 17, 2026, 7:41 p.m. OK Java 8 TESTS 3 125 0
358411094 Himavanth_ A Jan. 18, 2026, 5:50 a.m. OK Java 8 TESTS 3 125 0
358368305 Suhani_sikarwar__ A Jan. 17, 2026, 5:32 p.m. OK Java 8 TESTS 3 125 0
358364594 santhiyaravi58 A Jan. 17, 2026, 5:21 p.m. OK Java 8 TESTS 3 140 0
358410388 janhvi_awasthi A Jan. 18, 2026, 5:42 a.m. OK Java 8 TESTS 3 140 0
358395637 abhi139 A Jan. 18, 2026, 12:41 a.m. OK Java 8 TESTS 3 156 0
358412687 divakar10 A Jan. 18, 2026, 6:06 a.m. OK Java 8 TESTS 3 171 0
358355800 Satyamkrr A Jan. 17, 2026, 4:54 p.m. OK Java 8 TESTS 3 171 0
358367551 asish.bhandari17 A Jan. 17, 2026, 5:30 p.m. OK Node.js TESTS 3 140 5222400
358387863 combuccu18 A Jan. 17, 2026, 8:50 p.m. OK PyPy 3 TESTS 3 78 2560000
358367523 Dangerous_Coder_69 A Jan. 17, 2026, 5:30 p.m. OK PyPy 3 TESTS 3 109 2048000
358375669 titia A Jan. 17, 2026, 6:43 p.m. OK PyPy 3-64 TESTS 3 46 1433600
358399958 Just4Serious A Jan. 18, 2026, 2:48 a.m. OK PyPy 3-64 TESTS 3 46 1433600
358395841 SanyKing239 A Jan. 18, 2026, 12:50 a.m. OK PyPy 3-64 TESTS 3 46 1536000
358351828 ashmit.sahu181207 A Jan. 17, 2026, 4:43 p.m. OK PyPy 3-64 TESTS 3 46 1536000
358389808 CarlosCantCode A Jan. 17, 2026, 9:18 p.m. OK PyPy 3-64 TESTS 3 46 1536000
358375592 SrDhruv A Jan. 17, 2026, 6:42 p.m. OK PyPy 3-64 TESTS 3 46 1536000
358401808 Elephie A Jan. 18, 2026, 3:30 a.m. OK PyPy 3-64 TESTS 3 46 1638400
358399705 917 A Jan. 18, 2026, 2:42 a.m. OK PyPy 3-64 TESTS 3 62 1433600
358404290 omkaar A Jan. 18, 2026, 4:17 a.m. OK PyPy 3-64 TESTS 3 62 1433600
358391399 ShivCodez A Jan. 17, 2026, 9:52 p.m. OK PyPy 3-64 TESTS 3 62 1433600
358364022 Siddhartha_Gopala A Jan. 17, 2026, 5:19 p.m. OK Python 3 TESTS 3 15 0
358410394 mionardele A Jan. 18, 2026, 5:43 a.m. OK Python 3 TESTS 3 31 0
358384686 SulaymanovIrsdavlat A Jan. 17, 2026, 8:06 p.m. OK Python 3 TESTS 3 31 0
358376737 325iitd A Jan. 17, 2026, 6:50 p.m. OK Python 3 TESTS 3 31 0
358375819 arnav_a2025 A Jan. 17, 2026, 6:44 p.m. OK Python 3 TESTS 3 31 0
358367900 jiji_san A Jan. 17, 2026, 5:31 p.m. OK Python 3 TESTS 3 31 0
358364910 govindfromfaraway A Jan. 17, 2026, 5:22 p.m. OK Python 3 TESTS 3 31 0
358364261 Daksh-00 A Jan. 17, 2026, 5:20 p.m. OK Python 3 TESTS 3 31 0
358355539 adarshraicareer A Jan. 17, 2026, 4:54 p.m. OK Python 3 TESTS 3 31 0
358402792 Smile716 A Jan. 18, 2026, 3:49 a.m. OK Python 3 TESTS 3 31 102400
358354576 Ado90 A Jan. 17, 2026, 4:51 p.m. OK Ruby 3 TESTS 3 187 512000
358409264 Tantellam A Jan. 18, 2026, 5:30 a.m. OK Rust 2024 TESTS 3 46 0

remove filters

Back to search problems