Problem link: http://www.spoj.com/problems/XXXXXXXX/
Solution Link: http://ideone.com/Myb8M6
Can someone help me debug my solution? I am trying to use segtree + treap in the code.
Thanks.
№ | Пользователь | Рейтинг |
---|---|---|
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 | 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 |
Problem link: http://www.spoj.com/problems/XXXXXXXX/
Solution Link: http://ideone.com/Myb8M6
Can someone help me debug my solution? I am trying to use segtree + treap in the code.
Thanks.
Название |
---|
Got the mistake. It was int -> long long mistake.
Can you please explain your approach.
I have used the approach explained in the comment http://codeforces.me/blog/entry/10508?#comment-158835
while updating i for A[i], I add the value A[i] to the point representing (i, left[i]) where left[i] denotes the greatest j s.t. A[j] == A[i] & j < i. If no such j exists, then left[i] = 0.
Now for query, I found the sum in (L,0) to (R,L-1) both included.
Updated code with int -> long long correction: http://ideone.com/sJMdlW
Thanks for the link.I guess instead of using treap we can also use square root decomposition with a bit in each block.
Yes, that should also work but I am not sure whether it will pass the time limit (Q * sqrtN * logN solution) as spoj is relatively more time-strict than any other sites I know.
Well -3 seems like downvoted to me...
It was 0 when I came and we all know that -3 is nothing compared to what a green coder would receive.
True.
Well, I did not personally ask you or anyone to debug the code.
I only posted it as a question. So, if someone will be available to debug it, he/she will and will tell me my mistake. You or Anyone for that matter had any obligation to see the code and try to find a bug.
Look at yourself before you start looking at others.
http://codeforces.me/blog/entry/16231
Hm I believe he was blue at that time. Also his question was not a direct saying "Please debug my code".