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.
# | User | Rating |
---|---|---|
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 |
# | 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 |
9 | nor | 153 |
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.
Name |
---|
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 - Case of Fugitive. 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