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'Grigory loves strings. Recently he found a metal strip on a loft. The strip had length n and consisted of letters "V" and "K". Unfortunately, rust has eaten some of the letters so that it 's now impossible to understand which letter was written. Grigory couldn 't understand for a long time what these letters remind him of, so he became interested in the following question: if we put a letter "V" or "K" on each unreadable position, which values can the period of the resulting string be equal to? A period of a string is such an integer d from 1 to the length of the string that if we put the string shifted by d positions to the right on itself, then all overlapping letters coincide. For example, 3 and 5 are periods of "VKKVK". There are several (at least one) test cases in the input. The first line contains single integer -- the number of test cases. There is an empty line before each test case. Each test case is described in two lines: the first line contains single integer n (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n xe2 x80 x89 xe2 x89 xa4 xe2 x80 x895 xc2 xb7105) -- the length of the string, the second line contains the string of length n, consisting of letters "V", "K" and characters "?". The latter means the letter on its position is unreadable. It is guaranteed that the sum of lengths among all test cases doesn 't exceed 5 xc2 xb7105. For hacks you can only use tests with one test case. For each test case print two lines. In the first line print the number of possible periods after we replace each unreadable letter with "V" or "K". In the next line print all these values in increasing order. In the first test case from example we can obtain, for example, "VKKVK", which has periods 3 and 5. In the second test case we can obtain "VVVVVV" which has all periods from 1 to 6. In the third test case string "KVKV" has periods 2 and 4, and string "KVKK" has periods 3 and 4. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
36249795 |
FalseMirror |
E |
March 13, 2018, 1:14 p.m. |
OK |
D |
TESTS |
59 |
2324 |
103936000 |
|
2700 |
36249730 |
FalseMirror |
E |
March 13, 2018, 1:12 p.m. |
OK |
D |
TESTS |
59 |
2324 |
103936000 |
|
2700 |
36249860 |
FalseMirror |
E |
March 13, 2018, 1:15 p.m. |
OK |
D |
TESTS |
59 |
2386 |
103936000 |
|
2700 |
29555152 |
vjudge3 |
E |
Aug. 18, 2017, 2:14 p.m. |
OK |
GNU C++ |
TESTS |
59 |
249 |
1024000 |
|
2700 |
29962811 |
imone |
E |
Sept. 1, 2017, 2:06 a.m. |
OK |
GNU C++ |
TESTS |
59 |
264 |
52736000 |
|
2700 |
41582240 |
vjudge3 |
E |
Aug. 14, 2018, 8:43 a.m. |
OK |
GNU C++ |
TESTS |
59 |
265 |
1024000 |
|
2700 |
41582044 |
vjudge1 |
E |
Aug. 14, 2018, 8:37 a.m. |
OK |
GNU C++ |
TESTS |
59 |
265 |
1024000 |
|
2700 |
29591169 |
vjudge1 |
E |
Aug. 19, 2017, 7:08 a.m. |
OK |
GNU C++ |
TESTS |
59 |
265 |
4300800 |
|
2700 |
34942620 |
DreamLolita |
E |
Feb. 5, 2018, 11:47 a.m. |
OK |
GNU C++ |
TESTS |
59 |
280 |
3072000 |
|
2700 |
41581695 |
vjudge4 |
E |
Aug. 14, 2018, 8:26 a.m. |
OK |
GNU C++ |
TESTS |
59 |
311 |
53964800 |
|
2700 |
41592460 |
wuminghui |
E |
Aug. 14, 2018, 2:51 p.m. |
OK |
GNU C++ |
TESTS |
59 |
312 |
53964800 |
|
2700 |
41581669 |
wuminghui |
E |
Aug. 14, 2018, 8:25 a.m. |
OK |
GNU C++ |
TESTS |
59 |
312 |
53964800 |
|
2700 |
41582172 |
vjudge3 |
E |
Aug. 14, 2018, 8:41 a.m. |
OK |
GNU C++ |
TESTS |
59 |
327 |
46796800 |
|
2700 |
40980541 |
ReaLNero1 |
E |
July 30, 2018, 5:34 p.m. |
OK |
GNU C++11 |
TESTS |
59 |
171 |
30515200 |
|
2700 |
40673740 |
diogo |
E |
July 23, 2018, 2:07 p.m. |
OK |
GNU C++11 |
TESTS |
59 |
171 |
30515200 |
|
2700 |
40672909 |
diogo |
E |
July 23, 2018, 1:37 p.m. |
OK |
GNU C++11 |
TESTS |
59 |
171 |
30515200 |
|
2700 |
40673761 |
maratonando |
E |
July 23, 2018, 2:08 p.m. |
OK |
GNU C++11 |
TESTS |
59 |
186 |
30515200 |
|
2700 |
40673054 |
diogo |
E |
July 23, 2018, 1:43 p.m. |
OK |
GNU C++11 |
TESTS |
59 |
218 |
30515200 |
|
2700 |
40672759 |
diogo |
E |
July 23, 2018, 1:33 p.m. |
OK |
GNU C++11 |
TESTS |
59 |
218 |
30515200 |
|
2700 |
40672322 |
diogo |
E |
July 23, 2018, 1:19 p.m. |
OK |
GNU C++11 |
TESTS |
59 |
218 |
30515200 |
|
2700 |
57874020 |
lopare |
E |
July 28, 2019, 4 a.m. |
OK |
GNU C++11 |
TESTS |
59 |
249 |
4300800 |
|
2700 |
57769514 |
py_ultron |
E |
July 25, 2019, 11:14 p.m. |
OK |
GNU C++11 |
TESTS |
59 |
249 |
4300800 |
|
2700 |
33254843 |
Durant_Lee |
E |
Dec. 15, 2017, 4:56 a.m. |
OK |
GNU C++11 |
TESTS |
59 |
264 |
3072000 |
|
2700 |
34194313 |
CQzhangyu |
E |
Jan. 15, 2018, 10:35 a.m. |
OK |
GNU C++14 |
TESTS |
59 |
295 |
42188800 |
|
2700 |
35336788 |
superguymj |
E |
Feb. 16, 2018, 12:27 p.m. |
OK |
GNU C++14 |
TESTS |
59 |
312 |
6553600 |
|
2700 |
34647050 |
vjudge1 |
E |
Jan. 29, 2018, 1:43 a.m. |
OK |
GNU C++14 |
TESTS |
59 |
327 |
71782400 |
|
2700 |
34647048 |
Lylist |
E |
Jan. 29, 2018, 1:43 a.m. |
OK |
GNU C++14 |
TESTS |
59 |
327 |
71782400 |
|
2700 |
29514119 |
vjudge4 |
E |
Aug. 16, 2017, 8:52 p.m. |
OK |
GNU C++14 |
TESTS |
59 |
342 |
85094400 |
|
2700 |
29514072 |
vjudge1 |
E |
Aug. 16, 2017, 8:48 p.m. |
OK |
GNU C++14 |
TESTS |
59 |
342 |
85094400 |
|
2700 |
29514107 |
vjudge2 |
E |
Aug. 16, 2017, 8:51 p.m. |
OK |
GNU C++14 |
TESTS |
59 |
358 |
85094400 |
|
2700 |
29514007 |
vjudge4 |
E |
Aug. 16, 2017, 8:44 p.m. |
OK |
GNU C++14 |
TESTS |
59 |
358 |
85094400 |
|
2700 |
29513905 |
vjudge1 |
E |
Aug. 16, 2017, 8:36 p.m. |
OK |
GNU C++14 |
TESTS |
59 |
358 |
85094400 |
|
2700 |
29513150 |
vjudge1 |
E |
Aug. 16, 2017, 7:47 p.m. |
OK |
GNU C++14 |
TESTS |
59 |
358 |
85094400 |
|
2700 |
remove filters
Back to search problems