How to solve this?
https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_e
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 165 |
2 | maomao90 | 163 |
2 | Um_nik | 163 |
4 | atcoder_official | 161 |
5 | adamant | 160 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | nor | 153 |
9 | Dominater069 | 153 |
How to solve this?
https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_e
Название |
---|
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://mirror.codeforces.com/blog/entry/74784?#comment-589657
and my submission which is the same strategy.