Hi, can anyone help with this task http://www.spoj.com/problems/METEORS/ . First i thought about binary search and segment tree with lazy propagation but that wouldn't work. Can anyone give me hole perspective to this problem? Thanks.
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
Hi, can anyone help with this task http://www.spoj.com/problems/METEORS/ . First i thought about binary search and segment tree with lazy propagation but that wouldn't work. Can anyone give me hole perspective to this problem? Thanks.
Название |
---|
Solution for yet another Div2 A.
Ok, but you want the sum of a group of numbers to become X.
Wow! I thought I've seen this problem before, but it has been an easier one. I'm sorry :p
Is O(N * sqrt(N)) solution ok for you?
Yes, but how did you get sqrt(N)?
Of course there should be M somewhere, but since N ~ M I wrote it in that way.
Ok, but how did you get sqrt?
Let's divide our queries into O(sqrt(N)) groups. We can process all the queries from a single group in O(N) time. When we do it, we can check whether a particular group is filled now. If it does, then let's run all these updates from the last group and get the precise time when it got filled. We can do it point-by point, since every point will be affected by O(sqrt(N)) segments.
This got accepted with two times margin on main, but got TLE on SPOJ :(
Thanks very much. :-D
Something got TLE on SPOJ? That is unbelievable :P! (I got TLEs for optimal complexities algorithms in 3 out of 5 problems I submitted on SPOJ :P)
Their new cluster is ok, but those problems that are checked on the old one are sometimes hard to make them pass.
Btw, it's pretty strange that there is 35 sec TL on some tests on main, while maximum TL on SPOJ is 15 sec.
Got accepted on SPOJ O(N * sqrt(N))
Code
Think about doing binary searches parallel.
That is a really great problem. In Poland parallel binary searching is abbreviated as "Meteors" since that task appeared on finals :P. I was really proud that I have solved it on a contest, but even though I got 70 pts — beware of long long overflow :D.
By the way, if you don't like SPOJ, here is that task on a much better site :P http://main.edu.pl/en/archive/oi/18/met
Can you recommend some good editorial for parallel binary searching? It also would be great if you explain this technique on "Meteors" problem. Thanks in advance.
In binary searching you need to be able to answer questions of form "Is answer greater than x?", so that in log n questions we can find answer. In that problem we need to find values a_1, ..., a_n and trick is that we can answer all of the questions of form "Is a_i greater than x_i?", where x_i are chosen by us, simulating all of the rains just once (pretty easy how to do this). So it suffices to do log n of simulations in order to find all answers.
Sorry to bring up this old thread, but has anyone got an AC using segment tree? here is my implementation of parallel binary search : http://ideone.com/7l4nSx which gets TLE on SPOJ
Edit : NVM, got AC with BIT.