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 |
---|---|---|---|---|---|---|
1572 | Codeforces Round 743 (Div. 1) | FINISHED | False | 7200 | 105290663 | Sept. 18, 2021, 2:35 p.m. |
Solved$ |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
---|---|---|---|---|---|---|
( 1521 ) | C | Paint | PROGRAMMING | dp greedy | 2700 |
B'You are given a 1 by n pixel image. The i -th pixel of the image has color a_i . For each color, the number of pixels of that color is at most 20 . You can perform the following operation, which works like the bucket tool in paint programs, on this image: Compute the minimum number of operations needed to make all the pixels in the image have the same color. Each test contains multiple test cases. The first line contains the number of test cases t ( 1 <= t <= 10^3 ). The first line of each test case contains a single integer n ( 1 <= n <= 3 cdot10^3 ) -- the number of pixels in the image. The second line of each test case contains n integers a_1, a_2, ldots, a_n ( 1 <= a_i <= n ) -- the colors of the pixels in the image. Note: for each color, the number of pixels of that color is at most 20 . It is guaranteed that the sum of n over all test cases does not exceed 3 cdot10^3 . For each test case, print one integer: the minimum number of operations needed to make all the pixels in the image have the same color. In the first example, the optimal solution is to apply the operation on the third pixel changing its color to 2 and then to apply the operation on any pixel that has color 2 changing its color and the color of all pixels connected to it to 1 . The sequence of operations is then: [1, 2, 3, 2, 1] to [1, 2, 2, 2, 1] to [1, 1, 1, 1, 1] . In the second example, we can either change the 1 s to 2 s in one operation or change the 2 s to 1 s also in one operation. In the third example, one possible way to make all the pixels have the same color is to apply the operation on the first, third and the fourth pixel each time changing its color to 2 . '... |
Tutorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
---|---|---|---|---|---|---|---|---|---|---|---|
129198454 | dlalswp25 | C | Sept. 18, 2021, 3:53 p.m. | OK | GNU C++14 | TESTS | 95 | 156 | 40652800 | 2700 | |
129230821 | Alex_Wei | C | Sept. 19, 2021, 4:19 a.m. | OK | GNU C++14 | TESTS | 95 | 187 | 40140800 | 2700 | |
129198239 | soltanbh | C | Sept. 18, 2021, 3:52 p.m. | OK | GNU C++14 | TESTS | 95 | 218 | 42496000 | 2700 | |
129183693 | Karry5307_AK_NOI2021 | C | Sept. 18, 2021, 3 p.m. | OK | GNU C++14 | TESTS | 95 | 233 | 104038400 | 2700 | |
129177817 | newbin | C | Sept. 18, 2021, 2:49 p.m. | OK | GNU C++14 | TESTS | 95 | 265 | 105984000 | 2700 | |
129201579 | MeRia | C | Sept. 18, 2021, 4:08 p.m. | OK | GNU C++14 | TESTS | 95 | 295 | 105984000 | 2700 | |
129193651 | lzr_010506 | C | Sept. 18, 2021, 3:29 p.m. | OK | GNU C++14 | TESTS | 95 | 452 | 205004800 | 2700 | |
129184888 | Radewoosh | C | Sept. 18, 2021, 3:03 p.m. | OK | GNU C++14 | TESTS | 95 | 498 | 112742400 | 2700 | |
129205142 | dai | C | Sept. 18, 2021, 4:25 p.m. | OK | GNU C++14 | TESTS | 95 | 608 | 4300800 | 2700 | |
129201166 | ugly2333 | C | Sept. 18, 2021, 4:06 p.m. | OK | GNU C++14 | TESTS | 95 | 623 | 48742400 | 2700 | |
129226012 | maxplus | C | Sept. 19, 2021, 1:54 a.m. | OK | GNU C++17 | TESTS | 95 | 77 | 21811200 | 2700 | |
129224977 | maxplus | C | Sept. 19, 2021, 1:14 a.m. | OK | GNU C++17 | TESTS | 95 | 77 | 21811200 | 2700 | |
129224315 | maxplus | C | Sept. 19, 2021, 12:44 a.m. | OK | GNU C++17 | TESTS | 95 | 77 | 21811200 | 2700 | |
129225628 | maxplus | C | Sept. 19, 2021, 1:40 a.m. | OK | GNU C++17 | TESTS | 95 | 78 | 21811200 | 2700 | |
129225375 | maxplus | C | Sept. 19, 2021, 1:30 a.m. | OK | GNU C++17 | TESTS | 95 | 78 | 21811200 | 2700 | |
129224899 | maxplus | C | Sept. 19, 2021, 1:10 a.m. | OK | GNU C++17 | TESTS | 95 | 78 | 21811200 | 2700 | |
129224883 | maxplus | C | Sept. 19, 2021, 1:09 a.m. | OK | GNU C++17 | TESTS | 95 | 78 | 21811200 | 2700 | |
129224710 | maxplus | C | Sept. 19, 2021, 1:02 a.m. | OK | GNU C++17 | TESTS | 95 | 78 | 21811200 | 2700 | |
129224620 | maxplus | C | Sept. 19, 2021, 12:59 a.m. | OK | GNU C++17 | TESTS | 95 | 78 | 21811200 | 2700 | |
129224556 | maxplus | C | Sept. 19, 2021, 12:55 a.m. | OK | GNU C++17 | TESTS | 95 | 78 | 21811200 | 2700 | |
129193150 | ecnerwala | C | Sept. 18, 2021, 3:27 p.m. | OK | GNU C++17 (64) | TESTS | 95 | 93 | 5222400 | 2700 | |
129216891 | maroonrk | C | Sept. 18, 2021, 7:46 p.m. | OK | GNU C++17 (64) | TESTS | 95 | 124 | 40652800 | 2700 | |
129187496 | iamhpp | C | Sept. 18, 2021, 3:10 p.m. | OK | GNU C++17 (64) | TESTS | 95 | 124 | 104755200 | 2700 | |
129188185 | szb | C | Sept. 18, 2021, 3:11 p.m. | OK | GNU C++17 (64) | TESTS | 95 | 140 | 104960000 | 2700 | |
129193192 | LLJ | C | Sept. 18, 2021, 3:27 p.m. | OK | GNU C++17 (64) | TESTS | 95 | 156 | 40652800 | 2700 | |
129191513 | Benq | C | Sept. 18, 2021, 3:21 p.m. | OK | GNU C++17 (64) | TESTS | 95 | 171 | 40550400 | 2700 | |
129192589 | KevinWan | C | Sept. 18, 2021, 3:25 p.m. | OK | GNU C++17 (64) | TESTS | 95 | 171 | 40755200 | 2700 | |
129221212 | shivensinha4 | C | Sept. 18, 2021, 9:43 p.m. | OK | GNU C++17 (64) | TESTS | 95 | 171 | 42291200 | 2700 | |
129192016 | SSRS_ | C | Sept. 18, 2021, 3:23 p.m. | OK | GNU C++17 (64) | TESTS | 95 | 187 | 42291200 | 2700 | |
129201427 | SpyCheese | C | Sept. 18, 2021, 4:07 p.m. | OK | GNU C++17 (64) | TESTS | 95 | 187 | 42700800 | 2700 | |
129227193 | clyring | C | Sept. 19, 2021, 2:33 a.m. | OK | Haskell | TESTS | 95 | 998 | 48435200 | 2700 | |
129199691 | Hemose | C | Sept. 18, 2021, 3:59 p.m. | OK | Java 11 | TESTS | 95 | 608 | 102912000 | 2700 | |
129191232 | SergeyMelnikov | C | Sept. 18, 2021, 3:20 p.m. | OK | Java 11 | TESTS | 95 | 982 | 64204800 | 2700 | |
129197957 | dalt | C | Sept. 18, 2021, 3:50 p.m. | OK | Java 11 | TESTS | 95 | 998 | 66048000 | 2700 | |
129220622 | TheSawan | C | Sept. 18, 2021, 9:20 p.m. | OK | Java 8 | TESTS | 95 | 811 | 60928000 | 2700 | |
129200550 | Tlatoani | C | Sept. 18, 2021, 4:03 p.m. | OK | Kotlin | TESTS | 95 | 982 | 62361600 | 2700 | |
129209475 | sansen | C | Sept. 18, 2021, 5:46 p.m. | OK | Rust | TESTS | 95 | 186 | 22835200 | 2700 |
Back to search problems