I have solved the easy version of the problem. But I have no idea how to solve this one. Do I require any new algorithms? Can someone please help me solve this problem?
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3821 |
3 | Benq | 3736 |
4 | Radewoosh | 3631 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3388 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 164 |
1 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 161 |
5 | -is-this-fft- | 158 |
6 | awoo | 157 |
7 | adamant | 156 |
8 | TheScrasse | 154 |
8 | nor | 154 |
10 | Dominater069 | 153 |
I have solved the easy version of the problem. But I have no idea how to solve this one. Do I require any new algorithms? Can someone please help me solve this problem?
Name |
---|
Auto comment: topic has been updated by negetive_iq (previous revision, new revision, compare).
Learn pattern searching algorithms like Z function, KMP, etc. I used Z function to solve this question.
Can you explain a bit more in detail on how to solve this after learning pattern matching algorithms?
The problem after this will turn into "for string $$$s$$$ of length $$$n$$$, find any index $$$i$$$ ($$$2 \le i \le n$$$) such as $$$s(i, n) = s(1, n-i+1)$$$ and $$$i \le n-i+1$$$".
(Here, $$$s(i, j)$$$ means a contiguous substring of $$$s$$$ from index $$$i$$$ to index $$$j$$$, inclusively).
Thanks!
Can you give me the link to the problem?
https://codeforces.me/problemset/problem/2010/C1
To solve the problem, analyze the string
t
to determine if it can be the result of merging two identical consecutive messages. Compute the length of the longest prefix that is also a suffix of the string. If this length is at least half the length oft
plus one, it indicates a possible merging error, and you should print "YES" along with the prefix. If not, print "NO". For this, you can use the KMP algorithm’s LPS (Longest Prefix Suffix) array to efficiently find the longest prefix which is also a suffix.