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.
Problems
B"This is hard version of the problem, it differs from the easy one only by constraints on n and k . Vlad found a row of n tiles and the integer k . The tiles are indexed from left to right and the i -th tile has the color c_i . After a little thought, he decided what to do with it. You can start from any tile and jump to any number of tiles right, forming the path p . Let's call the path p of length m nice if: Your task is to find the number of nice paths of maximum length. Since this number may be too large, print it modulo 10^9 + 7 . The first line of each test contains the integer t ( 1 <= t <= 10^4 ) -- the number of test cases in the test. The first line of each test case contains two integers n and k ( 1 <= k <= n <= 5000 ) -- the number of tiles in a row and the length of the block. The second line of each test case contains n integers c_1, c_2, c_3, ... , c_n ( 1 <= c_i <= n ) -- tile colors. It is guaranteed that the sum of n^2 over all test cases does not exceed 25 cdot 10^6 . Print t numbers, each of which is the answer to the corresponding test case -- the number of nice paths of maximum length modulo 10^9 + 7 . In the first sample, it is impossible to make a nice path with a length greater than 0 . In the second sample, we are interested in the following paths: In the third example, any path of length 8 is nice. "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
200780393 |
xhx114514 |
G2 |
April 4, 2023, 4:48 p.m. |
OK |
GNU C++14 |
TESTS |
28 |
155 |
100761600 |
|
|
200835189 |
Tom66 |
G2 |
April 5, 2023, 5:58 a.m. |
OK |
GNU C++14 |
TESTS |
32 |
155 |
126566400 |
|
|
200834872 |
Sanjay422 |
G2 |
April 5, 2023, 5:55 a.m. |
OK |
GNU C++14 |
TESTS |
32 |
171 |
716800 |
|
|
200822447 |
Anonyme |
G2 |
April 5, 2023, 2:34 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
217 |
113254400 |
|
|
200813474 |
omeganot |
G2 |
April 4, 2023, 10:54 p.m. |
OK |
GNU C++14 |
TESTS |
30 |
218 |
100556800 |
|
|
200819402 |
ringup |
G2 |
April 5, 2023, 1:29 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
218 |
226406400 |
|
|
200790746 |
hsrb |
G2 |
April 4, 2023, 5:59 p.m. |
OK |
GNU C++14 |
TESTS |
28 |
248 |
201318400 |
|
|
200816749 |
Shui_Dream |
G2 |
April 5, 2023, 12:22 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
249 |
200908800 |
|
|
200778967 |
ty_ak |
G2 |
April 4, 2023, 4:46 p.m. |
OK |
GNU C++14 |
TESTS |
28 |
249 |
301260800 |
|
|
200827808 |
ZifanWang |
G2 |
April 5, 2023, 4:11 a.m. |
OK |
GNU C++14 |
TESTS |
31 |
280 |
125440000 |
|
|
200789054 |
a757403 |
G2 |
April 4, 2023, 5:42 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
109 |
102400 |
|
|
200800571 |
Svyat |
G2 |
April 4, 2023, 7:26 p.m. |
OK |
GNU C++17 |
TESTS |
30 |
140 |
100761600 |
|
|
200790565 |
PC_E1052 |
G2 |
April 4, 2023, 5:57 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
171 |
102400 |
|
|
200800575 |
EnAnimant |
G2 |
April 4, 2023, 7:26 p.m. |
OK |
GNU C++17 |
TESTS |
30 |
171 |
512000 |
|
|
200782566 |
BlackPanther112358 |
G2 |
April 4, 2023, 4:55 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
171 |
716800 |
|
|
200831167 |
MohdFaisal |
G2 |
April 5, 2023, 5:05 a.m. |
OK |
GNU C++17 |
TESTS |
31 |
186 |
204800 |
|
|
200784904 |
orangecalculator |
G2 |
April 4, 2023, 5:09 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
186 |
307200 |
|
|
200801811 |
ikaurov |
G2 |
April 4, 2023, 7:41 p.m. |
OK |
GNU C++17 |
TESTS |
30 |
186 |
100454400 |
|
|
200793319 |
Yzm007 |
G2 |
April 4, 2023, 6:26 p.m. |
OK |
GNU C++17 |
TESTS |
30 |
187 |
100659200 |
|
|
200779202 |
Kither |
G2 |
April 4, 2023, 4:46 p.m. |
OK |
GNU C++17 |
TESTS |
28 |
202 |
512000 |
|
|
200784809 |
korokseeds |
G2 |
April 4, 2023, 5:08 p.m. |
OK |
GNU C++17 (64) |
TESTS |
28 |
62 |
614400 |
|
|
200788448 |
HCPS42 |
G2 |
April 4, 2023, 5:37 p.m. |
OK |
GNU C++17 (64) |
TESTS |
28 |
78 |
102400 |
|
|
200785617 |
Ayalla |
G2 |
April 4, 2023, 5:14 p.m. |
OK |
GNU C++17 (64) |
TESTS |
28 |
78 |
1228800 |
|
|
200804988 |
MarcosK |
G2 |
April 4, 2023, 8:23 p.m. |
OK |
GNU C++17 (64) |
TESTS |
30 |
124 |
716800 |
|
|
200785773 |
yeche2023 |
G2 |
April 4, 2023, 5:15 p.m. |
OK |
GNU C++17 (64) |
TESTS |
28 |
139 |
2252800 |
|
|
200818423 |
vora_dev |
G2 |
April 5, 2023, 1:05 a.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
155 |
201420800 |
|
|
200810349 |
ljuba |
G2 |
April 4, 2023, 9:43 p.m. |
OK |
GNU C++17 (64) |
TESTS |
30 |
170 |
100659200 |
|
|
200780377 |
HillSideDonkey |
G2 |
April 4, 2023, 4:48 p.m. |
OK |
GNU C++17 (64) |
TESTS |
28 |
186 |
100659200 |
|
|
200791880 |
VegeDog |
G2 |
April 4, 2023, 6:10 p.m. |
OK |
GNU C++17 (64) |
TESTS |
28 |
217 |
201318400 |
|
|
200822545 |
shiro53 |
G2 |
April 5, 2023, 2:37 a.m. |
OK |
GNU C++17 (64) |
TESTS |
31 |
233 |
201113600 |
|
|
200791793 |
Marckess |
G2 |
April 4, 2023, 6:09 p.m. |
OK |
GNU C++20 (64) |
TESTS |
28 |
61 |
204800 |
|
|
200784008 |
evolvos |
G2 |
April 4, 2023, 5:03 p.m. |
OK |
GNU C++20 (64) |
TESTS |
28 |
61 |
204800 |
|
|
200789985 |
Gesgha |
G2 |
April 4, 2023, 5:52 p.m. |
OK |
GNU C++20 (64) |
TESTS |
28 |
62 |
102400 |
|
|
200834728 |
Uriel |
G2 |
April 5, 2023, 5:53 a.m. |
OK |
GNU C++20 (64) |
TESTS |
32 |
62 |
204800 |
|
|
200801801 |
Sarthak3204 |
G2 |
April 4, 2023, 7:41 p.m. |
OK |
GNU C++20 (64) |
TESTS |
30 |
77 |
307200 |
|
|
200800629 |
rgnerdplayer |
G2 |
April 4, 2023, 7:26 p.m. |
OK |
GNU C++20 (64) |
TESTS |
30 |
78 |
102400 |
|
|
200829361 |
tyagsa |
G2 |
April 5, 2023, 4:37 a.m. |
OK |
GNU C++20 (64) |
TESTS |
31 |
78 |
204800 |
|
|
200826664 |
PanC_ake |
G2 |
April 5, 2023, 3:52 a.m. |
OK |
GNU C++20 (64) |
TESTS |
31 |
78 |
204800 |
|
|
200824643 |
jdurie |
G2 |
April 5, 2023, 3:14 a.m. |
OK |
GNU C++20 (64) |
TESTS |
31 |
78 |
204800 |
|
|
200799858 |
Final_Track |
G2 |
April 4, 2023, 7:17 p.m. |
OK |
GNU C++20 (64) |
TESTS |
30 |
78 |
204800 |
|
|
200791291 |
dzhi |
G2 |
April 4, 2023, 6:04 p.m. |
OK |
Java 11 |
TESTS |
28 |
576 |
144384000 |
|
|
200792406 |
dzhi |
G2 |
April 4, 2023, 6:16 p.m. |
OK |
Java 11 |
TESTS |
28 |
592 |
144384000 |
|
|
200798690 |
TCchen |
G2 |
April 4, 2023, 7:03 p.m. |
OK |
Java 17 |
TESTS |
30 |
358 |
1331200 |
|
|
200833766 |
IanISam |
G2 |
April 5, 2023, 5:40 a.m. |
OK |
Java 8 |
TESTS |
31 |
2371 |
261222400 |
|
|
200788184 |
FlakeLCR |
G2 |
April 4, 2023, 5:35 p.m. |
OK |
PyPy 3-64 |
TESTS |
28 |
187 |
9728000 |
|
|
200787987 |
FlakeLCR |
G2 |
April 4, 2023, 5:33 p.m. |
OK |
PyPy 3-64 |
TESTS |
28 |
202 |
9728000 |
|
|
200788453 |
FlakeLCR |
G2 |
April 4, 2023, 5:37 p.m. |
OK |
PyPy 3-64 |
TESTS |
28 |
218 |
9523200 |
|
|
200785891 |
FlakeLCR |
G2 |
April 4, 2023, 5:16 p.m. |
OK |
PyPy 3-64 |
TESTS |
28 |
265 |
9830400 |
|
|
200788876 |
FreeYourMind |
G2 |
April 4, 2023, 5:41 p.m. |
OK |
PyPy 3-64 |
TESTS |
28 |
295 |
10752000 |
|
|
200777926 |
rajb957 |
G2 |
April 4, 2023, 4:44 p.m. |
OK |
PyPy 3-64 |
TESTS |
28 |
404 |
9932800 |
|
|
200788413 |
FreeYourMind |
G2 |
April 4, 2023, 5:37 p.m. |
OK |
PyPy 3-64 |
TESTS |
28 |
514 |
9932800 |
|
|
200784687 |
FlakeLCR |
G2 |
April 4, 2023, 5:08 p.m. |
OK |
PyPy 3-64 |
TESTS |
28 |
607 |
338432000 |
|
|
200793289 |
sushmanth.dampur8780 |
G2 |
April 4, 2023, 6:25 p.m. |
OK |
PyPy 3-64 |
TESTS |
30 |
623 |
10342400 |
|
|
200824222 |
hxu10 |
G2 |
April 5, 2023, 3:08 a.m. |
OK |
PyPy 3-64 |
TESTS |
31 |
935 |
9420800 |
|
|
remove filters
Back to search problems