Can anyone tell me , why I am getting runtime error on test 1 itself ?? Problem link->http://codeforces.net/problemset/problem/387/B Code link->http://pastebin.com/N3JKSVPj
№ | Пользователь | Рейтинг |
---|---|---|
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 | 166 |
2 | maomao90 | 163 |
2 | Um_nik | 163 |
4 | atcoder_official | 161 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | nor | 153 |
9 | Dominater069 | 153 |
Can anyone tell me , why I am getting runtime error on test 1 itself ?? Problem link->http://codeforces.net/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.net/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..