Neowise Labs Contest 1 (Codeforces Round 1018, Div. 1 + 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
2096 Neowise Labs Contest 1 (Codeforces Round 1018, Div. 1 + Div. 2) FINISHED False 7200 31332323 April 19, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 2028 ) E Wonderful Teddy Bears PROGRAMMING greedy implementation sortings

You are the proud owner of (n) teddy bears, which are arranged in a row on a shelf. Each teddy bear is colored either black or pink. An arrangement of teddy bears is beautiful if all the black teddy bears are to the left of all the pink teddy bears. In other words, there does not exist a pair of indices ((i, j)) ((1 \leq i < j \leq n)) such that the (i)-th teddy bear is pink, and the (j)-th teddy bear is black. You want to reorder the teddy bears into a beautiful arrangement. You are too short to reach the shelf, but luckily, you can send instructions to a robot to move the teddy bears around. In a single instruction, the robot can: Choose an index (i) ((1 \le i \le n - 2)) and reorder the teddy bears at positions (i), (i + 1) and (i + 2) so that all the black teddy bears are to the left of all the pink teddy bears. What is the minimum number of instructions needed to reorder the teddy bears? 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 a single integer (n) ((3 \le n \le 2 \cdot 10^5)) — the number of teddy bears. The second line of each test case contains a single string (s) of length (n) consisting of characters B and P — the colors of the teddy bears. For each (i) from (1) to (n), the (i)-th teddy bear is colored black if (s_i = B) and pink if (s_i = P). It is guaranteed that the sum of (n) over all test cases does not exceed (2 \cdot 10^5). For each test case, output a single integer — the minimum number of instructions needed to reorder the teddy bears. For the first test case, all the teddy bears are pink. Thus, the arrangement is already beautiful, so the answer is (0). For the second test case, all the black teddy bears are to the left of all the pink teddy bears. Thus, the answer

Tutorials

Neowise Labs Contest 1 (Codeforces Round 1018, 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
316322506 Hamed5001 E April 20, 2025, 1:08 a.m. OK C++17 (GCC 7-32) TESTS 26 46 0
316324657 Mr.Gengar E April 20, 2025, 2:01 a.m. OK C++17 (GCC 7-32) TESTS 26 46 0
316321086 _dlwlrma_ E April 20, 2025, 12:24 a.m. OK C++17 (GCC 7-32) TESTS 26 46 0
316320115 Cody473 E April 19, 2025, 11:51 p.m. OK C++17 (GCC 7-32) TESTS 26 46 0
316324274 qianjin476 E April 20, 2025, 1:52 a.m. OK C++17 (GCC 7-32) TESTS 26 46 102400
316321788 mango_lassi E April 20, 2025, 12:46 a.m. OK C++17 (GCC 7-32) TESTS 26 46 102400
316305920 AU25_kirill E April 19, 2025, 7:23 p.m. OK C++17 (GCC 7-32) TESTS 26 46 102400
316294219 LoganGD E April 19, 2025, 5:30 p.m. OK C++17 (GCC 7-32) TESTS 26 46 102400
316327222 sjmahmud21 E April 20, 2025, 2:56 a.m. OK C++17 (GCC 7-32) TESTS 26 46 819200
316328744 aaryaj E April 20, 2025, 3:25 a.m. OK C++17 (GCC 7-32) TESTS 26 61 0
316336876 Brovko E April 20, 2025, 5:37 a.m. OK C++20 (GCC 13-64) TESTS 26 46 102400
316323809 caoshurui E April 20, 2025, 1:41 a.m. OK C++20 (GCC 13-64) TESTS 26 46 102400
316321481 tin.le2 E April 20, 2025, 12:37 a.m. OK C++20 (GCC 13-64) TESTS 26 46 102400
316318055 weirdflexbutok E April 19, 2025, 10:44 p.m. OK C++20 (GCC 13-64) TESTS 26 46 102400
316317291 inkvizytor E April 19, 2025, 10:24 p.m. OK C++20 (GCC 13-64) TESTS 26 46 102400
316312768 Aditya8676 E April 19, 2025, 8:55 p.m. OK C++20 (GCC 13-64) TESTS 26 46 102400
316304594 Nxxlt E April 19, 2025, 7:08 p.m. OK C++20 (GCC 13-64) TESTS 26 46 102400
316300280 zsombor E April 19, 2025, 6:23 p.m. OK C++20 (GCC 13-64) TESTS 26 46 102400
316294257 Ferume E April 19, 2025, 5:30 p.m. OK C++20 (GCC 13-64) TESTS 26 46 614400
316332566 Faizal E April 20, 2025, 4:36 a.m. OK C++20 (GCC 13-64) TESTS 26 46 921600
316332002 Zyc77 E April 20, 2025, 4:26 a.m. OK C++23 (GCC 14-64, msys2) TESTS 26 46 0
316329163 Yue_chen E April 20, 2025, 3:33 a.m. OK C++23 (GCC 14-64, msys2) TESTS 26 46 0
316329149 pengpeng_fudan E April 20, 2025, 3:33 a.m. OK C++23 (GCC 14-64, msys2) TESTS 26 46 0
316315806 yatharthsinghal1 E April 19, 2025, 9:50 p.m. OK C++23 (GCC 14-64, msys2) TESTS 26 46 0
316313803 kaka_haha E April 19, 2025, 9:12 p.m. OK C++23 (GCC 14-64, msys2) TESTS 26 46 0
316312607 C0DET1GER E April 19, 2025, 8:53 p.m. OK C++23 (GCC 14-64, msys2) TESTS 26 46 0
316328087 Fido_Puppy E April 20, 2025, 3:13 a.m. OK C++23 (GCC 14-64, msys2) TESTS 26 46 102400
316331072 rgrgtgrf E April 20, 2025, 4:10 a.m. OK C++23 (GCC 14-64, msys2) TESTS 26 46 102400
316326405 KuroAkane E April 20, 2025, 2:38 a.m. OK C++23 (GCC 14-64, msys2) TESTS 26 46 102400
316323240 bieybay E April 20, 2025, 1:27 a.m. OK C++23 (GCC 14-64, msys2) TESTS 26 46 102400
316309937 rainboy E April 19, 2025, 8:16 p.m. OK GNU C11 TESTS 26 77 307200
316288823 Dominion948 E April 19, 2025, 4:34 p.m. OK Go TESTS 26 62 1536000
316292108 Lilypad E April 19, 2025, 5:15 p.m. OK Java 21 TESTS 26 280 1433600
316277306 arnabmanna E April 19, 2025, 4 p.m. OK Java 8 TESTS 26 186 0
316286277 golions E April 19, 2025, 4:27 p.m. OK Java 8 TESTS 26 187 0
316282392 just_man_ E April 19, 2025, 4:16 p.m. OK Java 8 TESTS 26 249 0
316302847 alexey.enkov E April 19, 2025, 6:48 p.m. OK Kotlin 1.9 TESTS 26 140 0
316294413 SPD_9X2 E April 19, 2025, 5:31 p.m. OK PyPy 3 TESTS 26 171 9113600
316311210 LMeyling E April 19, 2025, 8:33 p.m. OK PyPy 3-64 TESTS 26 108 3174400
316279377 tassei903 E April 19, 2025, 4:06 p.m. OK PyPy 3-64 TESTS 26 124 8089600
316286452 bicucixi E April 19, 2025, 4:28 p.m. OK PyPy 3-64 TESTS 26 125 9523200
316327078 Little_Sheep_Yawn E April 20, 2025, 2:52 a.m. OK PyPy 3-64 TESTS 26 140 7782400
316277239 hxu10 E April 19, 2025, 4 p.m. OK PyPy 3-64 TESTS 26 140 8499200
316323432 DarkTemplarDrop E April 20, 2025, 1:32 a.m. OK PyPy 3-64 TESTS 26 155 7372800
316322570 LMeyling E April 20, 2025, 1:09 a.m. OK PyPy 3-64 TESTS 26 171 4300800
316274904 ITIS_DuyAnh E April 19, 2025, 3:53 p.m. OK PyPy 3-64 TESTS 26 186 4608000
316326237 yinyao E April 20, 2025, 2:34 a.m. OK PyPy 3-64 TESTS 26 186 6246400
316288961 Z_actuary E April 19, 2025, 4:34 p.m. OK PyPy 3-64 TESTS 26 186 10854400
316280721 Jimanbanashi E April 19, 2025, 4:10 p.m. OK Python 2 TESTS 26 124 0
316287104 TefaKing E April 19, 2025, 4:30 p.m. OK Python 3 TESTS 26 125 12288000
316277695 shashanksp851 E April 19, 2025, 4:01 p.m. OK Python 3 TESTS 26 218 18329600
316287456 Mayank_jindal E April 19, 2025, 4:31 p.m. OK Python 3 TESTS 26 249 38400000
316295505 tanriol E April 19, 2025, 5:40 p.m. OK Rust 2021 TESTS 26 62 0
316319756 esrever E April 19, 2025, 11:39 p.m. OK Rust 2021 TESTS 26 62 102400
316276158 DanielAnker E April 19, 2025, 3:57 p.m. OK Rust 2021 TESTS 26 93 0

remove filters

Back to search problems