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 |
|---|---|---|---|---|---|---|
| 2084 | Teza Round 1 (Codeforces Round 1015, Div. 1 + Div. 2) | FINISHED | False | 10800 | 32541923 | April 5, 2025, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 111 ) | H | Turtle and Nediam 2 | PROGRAMMING | dp |
You are given a binary sequence (s) of length (n) which only consists of (0) and (1). You can do the following operation at most (n - 2) times (possibly zero): Let (m) denote the current length of (s). Choose an integer (i) such that (1 \le i \le m - 2). Let the median(^{\text{∗}}) of the subarray (s_i, s_{i + 1}, s_{i + 2}) be (x), and let (j) be the smallest integer such that (j \ge i) and (s_j = x). Remove (s_j) from the sequence and concatenate the remaining parts. In other words, replace (s) with (s_1, s_2, \ldots, s_{j - 1}, s_{j + 1}, s_{j + 2}, \ldots, s_m). Note that after every operation, the length of (s) decreases by (1). Find how many different binary sequences can be obtained after performing the operation, modulo (10^9 + 7). (^{\text{∗}})The median of an array of odd length (k) is the (\frac{k + 1}{2})-th element when sorted. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. The first line of each test case contains a single integer (n) ((3 \le n \le 2 \cdot 10^6)) — the length of the binary sequence. The second line of each test case contains a string (s) of length (n), consisting of only (0) and (1). It is guaranteed that the sum of (n) over all test cases does not exceed (2 \cdot 10^6). For each test case, output a single integer — the number of binary sequences that can be obtained, modulo (10^9 + 7). In the first test case, the following binary sequences can be obtained: (1, 1), (1, 1, 1), (1, 1, 1, 1), (1, 1, 1, 1, 1). In the second test case, the following binary sequences can be obtained: (0, 1), (0, 1, 1), (1, 0, 1), (1, 0, 0, 1), (1, 0, 1, 1), (1, 0, 0, 0, 1), (1, 0, 0, 1, 1), (1, 0, 0, 0, 1, 1). For example, to o |
| 141155 |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 314161253 | Benq | H | April 5, 2025, 6:48 p.m. | OK | C++20 (GCC 13-64) | TESTS | 37 | 124 | 15257600 | ||
| 314152641 | Ormlis | H | April 5, 2025, 5:28 p.m. | OK | C++20 (GCC 13-64) | TESTS | 37 | 124 | 54988800 | ||
| 314160492 | tourist | H | April 5, 2025, 6:42 p.m. | OK | C++20 (GCC 13-64) | TESTS | 37 | 140 | 38092800 | ||
| 314186521 | Sparkle_Twilight | H | April 6, 2025, 2:20 a.m. | OK | C++20 (GCC 13-64) | TESTS | 37 | 156 | 30924800 | ||
| 314182408 | Benq | H | April 6, 2025, 12:36 a.m. | OK | C++20 (GCC 13-64) | TESTS | 37 | 171 | 30924800 | ||
| 314145269 | orzdevinwang | H | April 5, 2025, 5:03 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 37 | 108 | 42598400 | ||
| 314144885 | ecnerwala | H | April 5, 2025, 5:02 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 37 | 124 | 44236800 | ||
| 314188258 | thanhson0411 | H | April 6, 2025, 2:55 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 37 | 124 | 58163200 | ||
| 314192538 | rqoi031 | H | April 6, 2025, 4:14 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 37 | 155 | 50176000 | ||
| 314186689 | NKheyuxiang | H | April 6, 2025, 2:23 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 37 | 171 | 50176000 | ||
| 314159109 | jiangly | H | April 5, 2025, 6:32 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 37 | 421 | 131788800 | ||
| 314198732 | ahmedafeef | H | April 6, 2025, 5:37 a.m. | OK | GNU C11 | TESTS | 37 | 187 | 50176000 |
Back to search problems