It is running perfectly well on ideone, but is giving WA on codechef. Now, I always use C, and this is my first submission in C++. I tried submitting the answer both in C++ 4.3.2 and C++ 4.8.1, but got WA in both the cases. So, I checked some other solutions for this problem in C++, and most had included “stdio.h” and used “scanf” and “printf” instead of “cin” and “cout”. So, are there some guidelines which I need to follow while submitting my answers in C++?
Also, what is the difference between submitting an answer in C++ 4.3.2 and 4.8.1. Which one should I follow?
the problem with ur code is that u havent cleared the map after every test-case…which results in extra names in the map for the further cases…just add this statement before the end of ur while loop…
votes.clear();
this should solve ur problem…
EDIT:
For ur second ques…there are no such guidelines…all headers of C can be used in C++…also instead of writing “std::” before every cin count map, etc…u can just write “using namespace std;” just before writing ur code, outside the main fxn (ideally where all the header files are written). As it can be seen clearly 4.8.1 is an upgraded version of 4.3.2 it has many new features(C++11 features) which u can see here…!!!
scanf printf is preferred as it is faster than cin cout…also u can use ne of the 2 compilers…only thing i have noticed is that my c++4.3.2 code when submitted on c++4.8.1 takes a bit more time and memory…but the difference is not significant…!!!