Can anyone tell me , why I am getting runtime error on test 1 itself ?? Problem link->http://codeforces.me/problemset/problem/387/B Code link->http://pastebin.com/N3JKSVPj
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | djm03178 | 152 |
Can anyone tell me , why I am getting runtime error on test 1 itself ?? Problem link->http://codeforces.me/problemset/problem/387/B Code link->http://pastebin.com/N3JKSVPj
Название |
---|
Run it through valgrind and you'll see a bunch of invalid read errors. You need to advance the iterator before you erase the element from the set. You can use the return value from set.erase() like this.
http://codeforces.me/submissions/rakcode1998.
First of all , Thanks for helping .. Secondly, Above is the link of my recent submission as per your advice . I have corrected this as you said yuizy but i am not getting anything apart from runtime error.. And added to this IS , that my code is perfectly running on my PC..
You still have the same issue — you're advancing the iterator after erasing the corresponding element from the set. The reason it works on your PC is that it's undefined behavior, and would most likely cause a runtime error on your PC as well with bigger inputs. It seems you didn't perhaps understand my code, so here's a link with a few alternative solutions to the issue as one of them might be easier to understand: http://stackoverflow.com/questions/2874441/deleting-elements-from-stl-set-while-iterating.
Thanks yuizy ..and sorry for late reply..