Could anyone please tell me how to solve Problem E . I have seen some codes which use a segment tree but i am not able to understand. Also there is no editorial for this round .Any help would be appreciated. Thanks in advance.
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3947 |
2 | jiangly | 3734 |
3 | Radewoosh | 3646 |
4 | jqdai0815 | 3620 |
4 | Benq | 3620 |
6 | orzdevinwang | 3612 |
7 | ecnerwala | 3581 |
8 | Geothermal | 3569 |
8 | cnnfls_csy | 3569 |
10 | ksun48 | 3479 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | awoo | 162 |
2 | maomao90 | 160 |
3 | nor | 156 |
3 | adamant | 156 |
5 | -is-this-fft- | 155 |
5 | atcoder_official | 155 |
7 | cry | 154 |
8 | maroonrk | 153 |
9 | SecondThread | 147 |
10 | Petr | 146 |
Could anyone please tell me how to solve Problem E . I have seen some codes which use a segment tree but i am not able to understand. Also there is no editorial for this round .Any help would be appreciated. Thanks in advance.
Название |
---|
Hi, I've just solve this problem and looking for the editorial I found your question, maybe you already solves this problem but anyways.
I use a Segment Tree with Lazy Propagation, I don't know if it is the best solution, that's why I was looking for the editorial. If this technique is not familiar to you I suggest you to search it on google. Basically it allows to made updates in O(log(N)) time.
First, what you have to notice is that after each modification, you have to reset all the values, no matter what modifications occurred before. So if you know which was the last modification that affects the position you are analyzing you could answer the query. I let this part to you.
I used the ST to know latest modification. My ST answer the query max element in a range (in this particular problem the range is always length 1). Using lazy propagation you update range [y,y+k-1] whit value cont (the ordinal of the modification). When you ask for the max value you will get the desire ordinal of the modification.
I let you my code. 20223882 Sorry for my english.
I used another technique that is similar to this problem: 555B - Дело о беглеце. It's one that is used quite often in data structures problems. Try solving that one then solving this. I think it might give you some good insights. If you're desperate for the solution of this problem: 19610583