Codeforces Round 937 (Div. 4)

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
1950 Codeforces Round 937 (Div. 4) FINISHED False 8100 25542863 March 28, 2024, 2:45 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 4619 ) G Shuffling Songs PROGRAMMING bitmasks dp graphs implementation strings

B"Vladislav has a playlist consisting of n songs, numbered from 1 to n . Song i has genre g_i and writer w_i . He wants to make a playlist in such a way that every pair of adjacent songs either have the same writer or are from the same genre (or both). He calls such a playlist exciting. Both g_i and w_i are strings of length no more than 10^4 . It might not always be possible to make an exciting playlist using all the songs, so the shuffling process occurs in two steps. First, some amount (possibly zero) of the songs are removed, and then the remaining songs in the playlist are rearranged to make it exciting. Since Vladislav doesn't like when songs get removed from his playlist, he wants the making playlist to perform as few removals as possible. Help him find the minimum number of removals that need to be performed in order to be able to rearrange the rest of the songs to make the playlist exciting. The first line of the input contains a single integer t ( 1 <= t <= 1000 ) -- the number of test cases. The description of test cases follows. The first line of each test case contains a single integer n ( 1 <= n <= 16 ) -- the number of songs in the original playlist. Then n lines follow, the i -th of which contains two strings of lowercase letters g_i and w_i ( 1 <= q |g_i|, |w_i| <= q 10^4 ) -- the genre and the writer of the i -th song. Where |g_i| and |w_i| are lengths of the strings. The sum of 2^n over all test cases does not exceed 2^{16} . The sum of |g_i| + |w_i| over all test cases does not exceed 4 cdot 10^5 . For each test case, output a single integer -- the minimum number of removals necessary so that the resulting playlist can be made exciting. In the first test case, the playlist is already exciting. In the second test case, if you have the songs in the order 4, 3, 1, 2 , it is exciting, so yo"...

Tutorials

Codeforces Round 937 (Div. 4) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
253878586 justunderdog G March 29, 2024, 3:31 a.m. OK C# 10 TESTS 38 93 5222400
253883696 XingRin G March 29, 2024, 4:38 a.m. OK C++14 (GCC 6-32) TESTS 38 46 5734400
253883654 XingRin G March 29, 2024, 4:37 a.m. OK C++14 (GCC 6-32) TESTS 38 46 5734400
253874860 moon100_fan G March 29, 2024, 2:34 a.m. OK C++14 (GCC 6-32) TESTS 38 46 10956800
253880390 phongphu10097777 G March 29, 2024, 3:57 a.m. OK C++14 (GCC 6-32) TESTS 38 62 2969600
253857118 utility G March 28, 2024, 9:09 p.m. OK C++14 (GCC 6-32) TESTS 38 62 5324800
253869247 somyapal111_ansh G March 29, 2024, 12:51 a.m. OK C++14 (GCC 6-32) TESTS 38 93 2969600
253884107 wuzihan G March 29, 2024, 4:42 a.m. OK C++14 (GCC 6-32) TESTS 38 93 168652800
253870092 wqb G March 29, 2024, 1:08 a.m. OK C++14 (GCC 6-32) TESTS 38 108 109772800
253858599 Emptiness-RR G March 28, 2024, 9:29 p.m. OK C++14 (GCC 6-32) TESTS 38 124 10444800
253839944 CypherDiff G March 28, 2024, 6:27 p.m. OK C++14 (GCC 6-32) TESTS 38 139 4710400
253889700 NeikuiColacat G March 29, 2024, 5:40 a.m. OK C++17 (GCC 7-32) TESTS 38 31 512000
253876038 leesun G March 29, 2024, 2:53 a.m. OK C++17 (GCC 7-32) TESTS 38 31 716800
253874166 Aicu G March 29, 2024, 2:24 a.m. OK C++17 (GCC 7-32) TESTS 38 31 716800
253867921 zengjun G March 29, 2024, 12:21 a.m. OK C++17 (GCC 7-32) TESTS 38 31 716800
253867869 iliyian G March 29, 2024, 12:20 a.m. OK C++17 (GCC 7-32) TESTS 38 31 716800
253845073 Rushdi G March 28, 2024, 7:07 p.m. OK C++17 (GCC 7-32) TESTS 38 31 1945600
253883891 ssaabbeerr G March 29, 2024, 4:40 a.m. OK C++17 (GCC 7-32) TESTS 38 31 11059200
253879677 Jawad.Akbar_JJ G March 29, 2024, 3:47 a.m. OK C++17 (GCC 7-32) TESTS 38 31 84582400
253835622 abab1729 G March 28, 2024, 5:55 p.m. OK C++17 (GCC 7-32) TESTS 38 46 512000
253873977 Sempr G March 29, 2024, 2:21 a.m. OK C++17 (GCC 7-32) TESTS 38 46 614400
253874876 mathwing G March 29, 2024, 2:34 a.m. OK C++20 (GCC 13-64) TESTS 38 30 819200
253858541 1RONMAN G March 28, 2024, 9:28 p.m. OK C++20 (GCC 13-64) TESTS 38 30 819200
253884184 BadMi1k_ G March 29, 2024, 4:43 a.m. OK C++20 (GCC 13-64) TESTS 38 31 819200
253884063 OriginalSeven_ G March 29, 2024, 4:42 a.m. OK C++20 (GCC 13-64) TESTS 38 31 819200
253890205 HVCYM G March 29, 2024, 5:44 a.m. OK C++20 (GCC 13-64) TESTS 38 31 921600
253886075 qwynick G March 29, 2024, 5:05 a.m. OK C++20 (GCC 13-64) TESTS 38 31 1536000
253871346 Pan_ma_ru G March 29, 2024, 1:31 a.m. OK C++20 (GCC 13-64) TESTS 38 31 1536000
253849501 PurpleCrayon G March 28, 2024, 7:46 p.m. OK C++20 (GCC 13-64) TESTS 38 31 4198400
253839339 lolka12343 G March 28, 2024, 6:23 p.m. OK C++20 (GCC 13-64) TESTS 38 31 4710400
253886183 kk110011 G March 29, 2024, 5:06 a.m. OK C++20 (GCC 13-64) TESTS 38 31 7475200
253883795 Chessitof G March 29, 2024, 4:39 a.m. OK Go TESTS 38 46 1433600
253883902 Chessitof G March 29, 2024, 4:40 a.m. OK Go TESTS 38 46 1740800
253884493 Chessitof G March 29, 2024, 4:47 a.m. OK Go TESTS 38 62 1331200
253870821 0x3F G March 29, 2024, 1:21 a.m. OK Go TESTS 38 62 10240000
253870631 0x3F G March 29, 2024, 1:18 a.m. OK Go TESTS 38 78 9728000
253870117 0x3F G March 29, 2024, 1:08 a.m. OK Go TESTS 38 78 10240000
253882887 ManInM00N G March 29, 2024, 4:28 a.m. OK Go TESTS 38 93 9216000
253868739 DedsecKnight G March 29, 2024, 12:40 a.m. OK Go TESTS 38 93 10649600
253836507 vijay_panwar12 G March 28, 2024, 6:01 p.m. OK Java 21 TESTS 38 265 102400
253843868 is_this_greedy G March 28, 2024, 6:56 p.m. OK Java 21 TESTS 38 312 716800
253843781 dineshchandran311 G March 28, 2024, 6:55 p.m. OK Java 21 TESTS 38 312 6553600
253849805 lyongwolf G March 28, 2024, 7:49 p.m. OK Java 21 TESTS 38 327 1331200
253844963 ilovenandini G March 28, 2024, 7:05 p.m. OK Java 21 TESTS 38 343 409600
253865979 regain0002 G March 28, 2024, 11:38 p.m. OK Java 21 TESTS 38 404 7065600
253882214 NerfThis G March 29, 2024, 4:21 a.m. OK Java 8 TESTS 38 171 0
253861891 pchel G March 28, 2024, 10:20 p.m. OK Kotlin 1.9 TESTS 38 295 1740800
253866102 lebron87 G March 28, 2024, 11:41 p.m. OK PyPy 3 TESTS 38 358 10137600
253843783 PhanDinhKhoi G March 28, 2024, 6:55 p.m. OK PyPy 3 TESTS 38 498 11980800
253856559 gardengnome G March 28, 2024, 9:01 p.m. OK PyPy 3-64 TESTS 38 171 12800000
253838213 SegmentedSG G March 28, 2024, 6:14 p.m. OK PyPy 3-64 TESTS 38 186 9216000
253840402 gardengnome G March 28, 2024, 6:31 p.m. OK PyPy 3-64 TESTS 38 203 11878400
253846977 therealTin G March 28, 2024, 7:23 p.m. OK PyPy 3-64 TESTS 38 218 12083200
253843462 ZzimorodockK G March 28, 2024, 6:52 p.m. OK PyPy 3-64 TESTS 38 233 11673600
253888754 smilences G March 29, 2024, 5:32 a.m. OK PyPy 3-64 TESTS 38 249 9523200
253855455 gardengnome G March 28, 2024, 8:48 p.m. OK PyPy 3-64 TESTS 38 265 12902400
253890651 theRealChainman G March 29, 2024, 5:48 a.m. OK PyPy 3-64 TESTS 38 280 20684800
253846882 therealTin G March 28, 2024, 7:23 p.m. OK PyPy 3-64 TESTS 38 296 11980800
253886353 zzzpLu G March 29, 2024, 5:08 a.m. OK PyPy 3-64 TESTS 38 311 12595200
253891841 wyjsdpku G March 29, 2024, 5:59 a.m. OK Python 3 TESTS 38 2077 70451200

remove filters

Back to search problems