How to solve this?
https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_e
# | User | Rating |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 156 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
How to solve this?
https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_e
Name |
---|
First for each pair of string $$$(S1, S2)$$$, we find out the indices $$$\ 0 \leq i \leq S1.size ()\ $$$ such that $$$\ S1[i:]\ $$$ can overlap with $$$ S2[\ : min (\ S1.size() - i,\ S2.size())] $$$
Now it is always better to have one of the strings start from start of original string so we can do three checks with each string being the in start of the original string.
Then we can check all the possible start points for other $$$\ 2\ $$$ strings. The only problem being checking if some start position $$$\ i,\ j\ $$$ is okay in constant time. For each pair of string if they overlap we can check (using what we calculated in starting) if that overlap is fine.
I know My submission is not the cleanest way but still, happy to explain anything which is unclear.
There's editorial available for this task.
Yeah, but I can't read Japanese.
Oh, sorry, usually it's in English too.
Hey, I read the code from the editorial and explained what it does here: https://codeforces.net/blog/entry/74784?#comment-589657
and my submission which is the same strategy.