Codeforces Round 1087 (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
2209 Codeforces Round 1087 (Div. 2) FINISHED False 7200 2301923 March 21, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 5108 ) D Ghostfires PROGRAMMING constructive algorithms greedy

OtterZ decided to make a weapon using ghostfires. He collected several ghostfires in colors red, green, and blue. He will put some of the ghostfires in a row to build the weapon. To make the weapon more powerful, OtterZ will use as many ghostfires as possible, but the weapon will be out of control if there are two ghostfires of the same color adjacent or separated by exactly two ghostfires in the row. Formally, OtterZ collected (r) red ghostfires, (g) green ghostfires, and (b) blue ghostfires. He wants to construct a string (s) consisting of the characters ' R ', ' G ', and ' B ' that satisfies the following conditions: The number of occurrences of ' R ', ' G ', and ' B ' in (s) does not exceed (r), (g), and (b), respectively. For all (1 \le i \le |s|-1), (s_i \ne s_{i+1}). For all (1 \le i \le |s|-3), (s_i \ne s_{i+3}). The length of (s) is the maximum possible. Help OtterZ to construct the row. Although there may be several possible rows, OtterZ just requires one of them. 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 only line of each test case contains three integers (r), (g), and (b) ((0\le r,g,b \le 10 ^ 6), (r+g+b \gt 0)), representing the number of red, green, and blue ghostfires, respectively. It is guaranteed that the sum of (r + g + b) over all test cases does not exceed (10 ^ 6). For each query, output a string (s) consisting of the characters ' R ', ' G ', and ' B ', where (s_i) equals ' R ', ' G ' or ' B ' indicates that the (i)-th ghostfire is colored red, green, or blue, respectively. If there are multiple answers, output any. For the first test case, " B " is the only valid construction. For the second test case, " RGB ", " RBG ", " GRB ", " GRB ", " BRG ", and " BGR " are all correct. For the third test case, " GG " and " GGG "

Tutorials

Codeforces Round 1087 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
367683820 RiverEvening D March 21, 2026, 4:32 p.m. OK C++17 (GCC 7-32) TESTS 23 31 0
367679276 Shattajit- D March 21, 2026, 4:23 p.m. OK C++17 (GCC 7-32) TESTS 23 31 0
367706752 XiaXia7 D March 21, 2026, 8:23 p.m. OK C++17 (GCC 7-32) TESTS 23 31 102400
367690212 GradientDrifter D March 21, 2026, 5:31 p.m. OK C++17 (GCC 7-32) TESTS 23 31 102400
367734915 chandangc666 D March 22, 2026, 6:08 a.m. OK C++17 (GCC 7-32) TESTS 23 46 0
367732429 Ravi___09 D March 22, 2026, 5:40 a.m. OK C++17 (GCC 7-32) TESTS 23 46 0
367731585 sahil_rathod D March 22, 2026, 5:30 a.m. OK C++17 (GCC 7-32) TESTS 23 46 0
367730680 anhadsinghjaj D March 22, 2026, 5:18 a.m. OK C++17 (GCC 7-32) TESTS 23 46 0
367730023 GordonGu D March 22, 2026, 5:07 a.m. OK C++17 (GCC 7-32) TESTS 23 46 0
367725819 _Mohammed_Yasser_ D March 22, 2026, 3:55 a.m. OK C++17 (GCC 7-32) TESTS 23 46 0
367730204 noscf D March 22, 2026, 5:10 a.m. OK C++20 (GCC 13-64) TESTS 23 31 0
367714493 dryeab D March 21, 2026, 11:30 p.m. OK C++20 (GCC 13-64) TESTS 23 31 102400
367712884 rayenbbs D March 21, 2026, 10:36 p.m. OK C++20 (GCC 13-64) TESTS 23 31 102400
367712645 rayenbbs D March 21, 2026, 10:29 p.m. OK C++20 (GCC 13-64) TESTS 23 31 102400
367708272 FatihCihan D March 21, 2026, 8:49 p.m. OK C++20 (GCC 13-64) TESTS 23 31 102400
367702345 iarsh D March 21, 2026, 7:23 p.m. OK C++20 (GCC 13-64) TESTS 23 31 102400
367691713 bismayswain D March 21, 2026, 5:41 p.m. OK C++20 (GCC 13-64) TESTS 23 31 102400
367690784 takeonicky D March 21, 2026, 5:35 p.m. OK C++20 (GCC 13-64) TESTS 23 31 102400
367688735 KresLux D March 21, 2026, 5:23 p.m. OK C++20 (GCC 13-64) TESTS 23 31 102400
367688241 krishg_ D March 21, 2026, 5:19 p.m. OK C++20 (GCC 13-64) TESTS 23 31 102400
367690701 Cubber D March 21, 2026, 5:34 p.m. OK C++23 (GCC 14-64, msys2) TESTS 23 31 0
367720247 xiaogan882 D March 22, 2026, 1:53 a.m. OK C++23 (GCC 14-64, msys2) TESTS 23 31 102400
367709011 Yashwardhan_03 D March 21, 2026, 9:04 p.m. OK C++23 (GCC 14-64, msys2) TESTS 23 31 102400
367704734 Leelasai_2004 D March 21, 2026, 7:52 p.m. OK C++23 (GCC 14-64, msys2) TESTS 23 31 102400
367702201 FiniteMoves D March 21, 2026, 7:21 p.m. OK C++23 (GCC 14-64, msys2) TESTS 23 31 102400
367698295 JZX D March 21, 2026, 6:37 p.m. OK C++23 (GCC 14-64, msys2) TESTS 23 31 102400
367678458 Aadi_Paneru D March 21, 2026, 4:22 p.m. OK C++23 (GCC 14-64, msys2) TESTS 23 31 102400
367720786 hao907452386 D March 22, 2026, 2:08 a.m. OK C++23 (GCC 14-64, msys2) TESTS 23 31 204800
367716903 lucasaamorim D March 22, 2026, 12:13 a.m. OK C++23 (GCC 14-64, msys2) TESTS 23 31 204800
367699843 MartinezMiners D March 21, 2026, 6:54 p.m. OK C++23 (GCC 14-64, msys2) TESTS 23 31 204800
367679484 dhiraj_pgcat D March 21, 2026, 4:24 p.m. OK GNU C11 TESTS 23 62 921600
367694220 uchihieu2k7 D March 21, 2026, 6:01 p.m. OK GNU C11 TESTS 23 62 1024000
367680634 Tishow__Liuche D March 21, 2026, 4:26 p.m. OK GNU C11 TESTS 23 62 2048000
367707041 Nishant_12345 D March 21, 2026, 8:28 p.m. OK GNU C11 TESTS 23 1875 0
367706884 Nishant_12345 D March 21, 2026, 8:25 p.m. OK GNU C11 TESTS 23 1906 0
367682232 Sh0ckwave D March 21, 2026, 4:29 p.m. OK Go TESTS 23 46 2969600
367710942 abezr882 D March 21, 2026, 9:45 p.m. OK Go TESTS 23 46 17100800
367717624 0x3F D March 22, 2026, 12:38 a.m. OK Go TESTS 23 62 1945600
367679075 dub-otrezkov D March 21, 2026, 4:23 p.m. OK Go TESTS 23 125 8089600
367685482 Sarthak1712 D March 21, 2026, 4:34 p.m. OK Java 21 TESTS 23 218 1126400
367676969 prathmesh-d D March 21, 2026, 4:19 p.m. OK Java 21 TESTS 23 234 307200
367682046 lybord D March 21, 2026, 4:29 p.m. OK Java 21 TESTS 23 234 614400
367679274 MdKhanBahadurSadi D March 21, 2026, 4:23 p.m. OK Java 21 TESTS 23 234 1024000
367681352 prachiiiiii D March 21, 2026, 4:28 p.m. OK Java 21 TESTS 23 234 1228800
367677184 Preetham_22 D March 21, 2026, 4:19 p.m. OK Java 21 TESTS 23 250 614400
367678607 Aryan_Yadav123 D March 21, 2026, 4:22 p.m. OK Java 21 TESTS 23 250 819200
367689080 Avi1921 D March 21, 2026, 5:24 p.m. OK Java 21 TESTS 23 250 2150400
367681101 _MShadow_ D March 21, 2026, 4:27 p.m. OK Java 21 TESTS 23 265 512000
367676984 Snigdha67 D March 21, 2026, 4:19 p.m. OK Java 21 TESTS 23 265 1331200
367721544 CreAdiTv D March 22, 2026, 2:25 a.m. OK Java 8 TESTS 23 125 0
367684258 sahupyl D March 21, 2026, 4:33 p.m. OK Java 8 TESTS 23 125 0
367677447 kshivasai D March 21, 2026, 4:20 p.m. OK Java 8 TESTS 23 140 0
367679511 StackKernel D March 21, 2026, 4:24 p.m. OK Java 8 TESTS 23 171 0
367685219 mittalriya D March 21, 2026, 4:34 p.m. OK Java 8 TESTS 23 218 0
367680556 Arpan_2005 D March 21, 2026, 4:26 p.m. OK Java 8 TESTS 23 218 0
367727209 SilverBullet4869 D March 22, 2026, 4:22 a.m. OK Java 8 TESTS 23 234 0
367697605 forsaken724 D March 21, 2026, 6:30 p.m. OK Java 8 TESTS 23 234 41472000
367691802 Sagnik.Mahapatra D March 21, 2026, 5:42 p.m. OK Java 8 TESTS 23 250 0
367676772 aditya9579 D March 21, 2026, 4:18 p.m. OK PyPy 3 TESTS 23 281 18636800
367680209 pseudo404 D March 21, 2026, 4:25 p.m. OK PyPy 3 TESTS 23 312 23142400
367681487 amanv2 D March 21, 2026, 4:28 p.m. OK PyPy 3-64 TESTS 23 125 36556800
367713779 weii2000 D March 21, 2026, 11:07 p.m. OK PyPy 3-64 TESTS 23 140 22118400
367696057 biy D March 21, 2026, 6:17 p.m. OK PyPy 3-64 TESTS 23 156 7475200
367708532 gardengnome D March 21, 2026, 8:53 p.m. OK PyPy 3-64 TESTS 23 156 21606400
367677888 Akshar_7 D March 21, 2026, 4:21 p.m. OK PyPy 3-64 TESTS 23 156 28569600
367677013 Klass_Mars D March 21, 2026, 4:19 p.m. OK PyPy 3-64 TESTS 23 171 25292800
367688310 akane646 D March 21, 2026, 5:20 p.m. OK PyPy 3-64 TESTS 23 171 47513600
367721688 kamio-misuzu D March 22, 2026, 2:28 a.m. OK PyPy 3-64 TESTS 23 187 21606400
367722322 AdTerram D March 22, 2026, 2:44 a.m. OK PyPy 3-64 TESTS 23 187 22425600
367684951 ashukrsinghcse D March 21, 2026, 4:34 p.m. OK PyPy 3-64 TESTS 23 187 28876800
367680431 Jimanbanashi D March 21, 2026, 4:26 p.m. OK Python 2 TESTS 23 109 819200
367680892 Student_.com D March 21, 2026, 4:27 p.m. OK Python 3 TESTS 23 93 20172800
367681832 MihailLoginov D March 21, 2026, 4:29 p.m. OK Python 3 TESTS 23 125 5017600
367680642 Normie96 D March 21, 2026, 4:26 p.m. OK Python 3 TESTS 23 812 18534400
367684933 KokebT D March 21, 2026, 4:34 p.m. OK Python 3 TESTS 23 1359 27545600
367678547 Baakaa D March 21, 2026, 4:22 p.m. OK Python 3 TESTS 23 1640 18534400
367729300 imayankhandelwal D March 22, 2026, 4:57 a.m. OK Python 3 TESTS 23 1671 18432000
367677783 codelearner41 D March 21, 2026, 4:20 p.m. OK Python 3 TESTS 23 1734 19148800
367676855 teling D March 21, 2026, 4:18 p.m. OK Python 3 TESTS 23 1953 17715200
367676716 Shr1mp_ D March 21, 2026, 4:18 p.m. OK Rust 2024 TESTS 23 46 11776000

remove filters

Back to search problems