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
This is the hard version of the problem. The difference between the versions is that in this version, (n\le 2\cdot 10^7), and the sum of (n) over all test cases does not exceed (10^8). You can hack only if you solved all versions of this problem. For a binary string(^{\text{∗}}) (r), we define (f(r)) as the result of the following process: Delete all (10) substrings(^{\text{†}}) simultaneously from (r); Repeat the above operation until there are no (10) substrings in (r). For example, (f(\mathtt{100110001})=\mathtt{001}) because (r) changes as follows: (\mathtt{\underline{10}01\underline{10}001}\to \mathtt{0\underline{10}01}\to\mathtt{001}). We call a binary string (s) almost-palindrome if and only if (f(s)=f(\mathrm{rev}(s)))(^{\text{‡}}). Aquawave has given you an integer (n). You have to help him find the number of distinct almost-palindrome binary strings of length (n), modulo (998\,244\,353). (^{\text{∗}})A binary string is a string where each character is either (0) or (1). (^{\text{†}})A string (a) is a substring of a string (b) if (a) can be obtained from (b) by the deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end. (^{\text{‡}})(\mathrm{rev}(s)) is the string obtained by writing (s) from right to left. For example, (\mathrm{rev(\mathtt{10100})=\mathtt{00101}}). 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 only line of each test case contains a single integer (n) ((1\le n\le 2\cdot 10^7)) — the length of the binary strings. It is guaranteed that the sum of (n) over all test cases does not exceed (10^8). For each test case, output a single integer — the number of dist |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|
336077903 |
NKheyuxiang |
E2 |
Aug. 29, 2025, 3:36 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
49 |
1139 |
428851200 |
|
|
|
336089299 |
BurnedChicken |
E2 |
Aug. 29, 2025, 6:02 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
49 |
2608 |
557260800 |
|
|
|
336051855 |
244mhq |
E2 |
Aug. 28, 2025, 7:29 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
49 |
2687 |
641331200 |
|
|
|
336077967 |
qiuzx |
E2 |
Aug. 29, 2025, 3:37 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
49 |
2843 |
400793600 |
|
|
|
336043692 |
BurnedChicken |
E2 |
Aug. 28, 2025, 5:33 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
49 |
2968 |
557260800 |
|
|
|
336025643 |
jiangly |
E2 |
Aug. 28, 2025, 4:44 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
49 |
1983 |
727142400 |
|
|
|
336052356 |
rainboy |
E2 |
Aug. 28, 2025, 7:34 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
49 |
2280 |
400793600 |
|
|
|
336035025 |
Nachia |
E2 |
Aug. 28, 2025, 5:09 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
49 |
2609 |
477184000 |
|
|
|
336058543 |
maspy |
E2 |
Aug. 28, 2025, 8:46 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
49 |
2827 |
287641600 |
|
|
|
336028886 |
hos.lyric |
E2 |
Aug. 28, 2025, 4:52 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
49 |
2889 |
240537600 |
|
|
remove filters
Back to search problems