Codeforces Round 585 (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
1215 Codeforces Round 585 (Div. 2) FINISHED False 7200 168895487 Sept. 15, 2019, 10:35 a.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 3112 ) E Marbles PROGRAMMING bitmasks dp 2200

B"Monocarp has arranged n colored marbles in a row. The color of the i -th marble is a_i . Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color). In other words, Monocarp wants to rearrange marbles so that, for every color j , if the leftmost marble of color j is l -th in the row, and the rightmost marble of this color has position r in the row, then every marble from l to r has color j . To achieve his goal, Monocarp can do the following operation any number of times: choose two neighbouring marbles, and swap them. You have to calculate the minimum number of operations Monocarp has to perform to rearrange the marbles. Note that the order of segments of marbles having equal color does not matter, it is only required that, for every color, all the marbles of this color form exactly one contiguous segment. The first line contains one integer n (2 <= n <= 4 cdot 10^5) -- the number of marbles. The second line contains an integer sequence a_1, a_2, ... , a_n (1 <= a_i <= 20) , where a_i is the color of the i -th marble. Print the minimum number of operations Monocarp has to perform to achieve his goal. In the first example three operations are enough. Firstly, Monocarp should swap the third and the fourth marbles, so the sequence of colors is [3, 4, 3, 2, 4, 2, 2] . Then Monocarp should swap the second and the third marbles, so the sequence is [3, 3, 4, 2, 4, 2, 2] . And finally, Monocarp should swap the fourth and the fifth marbles, so the sequence is [3, 3, 4, 4, 2, 2, 2] . In the second example there's no need to perform any operations. "...

Tutorials

Codeforces Round #585 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
60626980 JKLover E Sept. 15, 2019, 11:55 a.m. OK GNU C++11 TESTS 90 78 1638400 2200
60628241 glpstkf E Sept. 15, 2019, 12:02 p.m. OK GNU C++11 TESTS 90 93 0 2200
60633745 alocytus E Sept. 15, 2019, 12:34 p.m. OK GNU C++11 TESTS 90 93 16076800 2200
60620939 xpptxdy E Sept. 15, 2019, 11:23 a.m. OK GNU C++11 TESTS 90 124 49152000 2200
60673985 Soetdit E Sept. 16, 2019, 11:49 a.m. OK GNU C++11 TESTS 107 140 187289600 2200
60674300 Dreamzls E Sept. 16, 2019, 11:55 a.m. OK GNU C++11 TESTS 107 156 190771200 2200
60954114 RXwasd E Sept. 21, 2019, 1:11 a.m. OK GNU C++11 TESTS 108 171 8396800 2200
60930579 M_sea E Sept. 20, 2019, 1:37 p.m. OK GNU C++11 TESTS 108 171 189747200 2200
63783387 luogu_bot3 E Oct. 30, 2019, 11:40 a.m. OK GNU C++11 TESTS 108 187 10035200 2200
64433893 luogu_bot2 E Nov. 6, 2019, 11:38 p.m. OK GNU C++11 TESTS 108 187 190771200 2200
60626402 yytrsk E Sept. 15, 2019, 11:52 a.m. OK GNU C++14 TESTS 90 93 3276800 2200
60633399 xing_mo E Sept. 15, 2019, 12:32 p.m. OK GNU C++14 TESTS 90 109 0 2200
60629189 Ginzaner E Sept. 15, 2019, 12:08 p.m. OK GNU C++14 TESTS 90 109 0 2200
60632944 lfw E Sept. 15, 2019, 12:30 p.m. OK GNU C++14 TESTS 90 109 2048000 2200
60629061 I_love_Y_UME E Sept. 15, 2019, 12:07 p.m. OK GNU C++14 TESTS 90 139 39628800 2200
60625371 zybkl E Sept. 15, 2019, 11:46 a.m. OK GNU C++14 TESTS 90 156 5734400 2200
60630419 yan-zp E Sept. 15, 2019, 12:16 p.m. OK GNU C++14 TESTS 90 171 5529600 2200
60633169 FlyWhite E Sept. 15, 2019, 12:31 p.m. OK GNU C++14 TESTS 90 171 83353600 2200
60658038 yan-zp E Sept. 16, 2019, 2:02 a.m. OK GNU C++14 TESTS 104 249 176537600 2200
60657982 yan-zp E Sept. 16, 2019, 1:58 a.m. OK GNU C++14 TESTS 104 249 176537600 2200
60626702 774269903 E Sept. 15, 2019, 11:54 a.m. OK GNU C++17 TESTS 90 124 1638400 2200
60631132 Maxzz E Sept. 15, 2019, 12:19 p.m. OK GNU C++17 TESTS 90 140 0 2200
60631154 gprano E Sept. 15, 2019, 12:20 p.m. OK GNU C++17 TESTS 90 140 33689600 2200
60627179 Fly_37 E Sept. 15, 2019, 11:56 a.m. OK GNU C++17 TESTS 90 155 7987200 2200
60656581 neal E Sept. 16, 2019, 12:23 a.m. OK GNU C++17 TESTS 103 155 176537600 2200
60656570 neal E Sept. 16, 2019, 12:22 a.m. OK GNU C++17 TESTS 103 171 176537600 2200
60656537 neal E Sept. 16, 2019, 12:19 a.m. OK GNU C++17 TESTS 103 171 176537600 2200
60656049 neal E Sept. 15, 2019, 11:39 p.m. OK GNU C++17 TESTS 103 171 176537600 2200
60656563 neal E Sept. 16, 2019, 12:22 a.m. OK GNU C++17 TESTS 103 186 176537600 2200
60656037 neal E Sept. 15, 2019, 11:37 p.m. OK GNU C++17 TESTS 103 202 176537600 2200
60695675 uwi E Sept. 16, 2019, 7:31 p.m. OK Java 8 TESTS 107 514 258662400 2200
60743996 guillermo_sz E Sept. 17, 2019, 11:02 p.m. OK Java 8 TESTS 107 514 258764800 2200
63954037 mbfeci E Oct. 31, 2019, 11:49 p.m. OK Java 8 TESTS 108 763 6553600 2200
60641036 StayAwayFromBitches E Sept. 15, 2019, 3:25 p.m. OK Java 8 TESTS 91 904 6656000 2200
60813072 4mda4mda E Sept. 18, 2019, 6:38 p.m. OK Java 8 TESTS 108 935 45568000 2200
62334024 icpc_loser E Oct. 10, 2019, 10:57 p.m. OK Java 8 TESTS 108 935 58265600 2200
60815750 4mda4mda E Sept. 18, 2019, 8:12 p.m. OK Java 8 TESTS 108 951 47923200 2200
60768295 prakhar897 E Sept. 18, 2019, 11:47 a.m. OK Java 8 TESTS 108 966 39424000 2200
60777856 7dan E Sept. 18, 2019, 3:06 p.m. OK Java 8 TESTS 108 967 6246400 2200
62972688 satya26 E Oct. 20, 2019, 7:28 a.m. OK Java 8 TESTS 108 982 27955200 2200
60642754 Tlatoani E Sept. 15, 2019, 3:59 p.m. OK Kotlin TESTS 91 998 261836800 2200
60638518 Tlatoani E Sept. 15, 2019, 2:47 p.m. OK Kotlin TESTS 90 998 261939200 2200
60708419 Spheniscine E Sept. 17, 2019, 6:46 a.m. OK Kotlin TESTS 107 2277 15974400 2200
61006096 vjudge3 E Sept. 21, 2019, 11:13 a.m. OK MS C++ TESTS 108 296 16384000 2200
69817818 vjudge2 E Jan. 30, 2020, 6:44 a.m. OK MS C++ TESTS 108 296 186572800 2200
61587370 vjudge1 E Oct. 1, 2019, 5:37 a.m. OK MS C++ TESTS 108 311 33587200 2200
69278808 kwfumou1242 E Jan. 22, 2020, 4:35 a.m. OK MS C++ TESTS 108 405 243712000 2200
69821869 vjudge2 E Jan. 30, 2020, 8:07 a.m. OK MS C++ TESTS 108 577 8396800 2200
62252760 vjudge5 E Oct. 10, 2019, 9:48 a.m. OK MS C++ TESTS 108 639 10035200 2200
61346560 vjudge1 E Sept. 27, 2019, 5:23 a.m. OK MS C++ TESTS 108 1949 18432000 2200
60623129 serg3000 E Sept. 15, 2019, 11:34 a.m. OK MS C++ 2017 TESTS 90 312 3174400 2200
60623140 vpike E Sept. 15, 2019, 11:34 a.m. OK MS C++ 2017 TESTS 90 405 1638400 2200
60632994 AleksanderBalobanov E Sept. 15, 2019, 12:30 p.m. OK MS C++ 2017 TESTS 90 529 264806400 2200
64726087 nyd E Nov. 12, 2019, 6:30 a.m. OK MS C++ 2017 TESTS 108 545 8396800 2200
61763573 ICEY777 E Oct. 3, 2019, 7:53 a.m. OK MS C++ 2017 TESTS 108 624 8396800 2200
60720550 Prokopiy E Sept. 17, 2019, 12:14 p.m. OK MS C++ 2017 TESTS 107 795 12390400 2200
60681015 Yanhui E Sept. 16, 2019, 1:56 p.m. OK MS C++ 2017 TESTS 107 826 18432000 2200
60631320 zjuwyz E Sept. 15, 2019, 12:21 p.m. OK MS C++ 2017 TESTS 90 841 11366400 2200
60661710 Timonnable E Sept. 16, 2019, 5:22 a.m. OK MS C++ 2017 TESTS 107 1404 12288000 2200
60668358 CtrlAlt E Sept. 16, 2019, 9:22 a.m. OK MS C++ 2017 TESTS 107 2011 169676800 2200
60624999 CHelle E Sept. 15, 2019, 11:44 a.m. OK PyPy 3 TESTS 90 389 25292800 2200
60632025 Kirillov_Alexey E Sept. 15, 2019, 12:25 p.m. OK PyPy 3 TESTS 90 1341 25292800 2200
68073943 mitribunskiy E Jan. 2, 2020, 11:41 a.m. OK PyPy 3 TESTS 108 3369 107929600 2200
68080799 mitribunskiy E Jan. 2, 2020, 2:18 p.m. OK PyPy 3 TESTS 108 3650 108441600 2200
60627369 sansen E Sept. 15, 2019, 11:57 a.m. OK Rust TESTS 90 577 12083200 2200
61679292 mjf E Oct. 1, 2019, 11:02 p.m. OK Rust TESTS 108 717 35942400 2200

remove filters

Back to search problems