Showing posts with label UVAoj discussions. Show all posts
Showing posts with label UVAoj discussions. Show all posts

Saturday, January 16, 2016

UVA 10258 : Contest Scoreboard

This problem will always remind me how important it is to read the problem carefully. Very carefully. Most of the mistakes that I did could have been avoided, had I read the problem statement with patience.

Mistakes I did :
  1. I didn't read what was required in the output correctly. They asked for all those who have made a submission, I rather gave the output only for those contestants who made a correct submission.
  2. I didn't take care of the test case where the user will submit the correct output for the same problem more than once. I thought of it while starting to program, but then ignored it. Big mistake, indeed !

One mistake that I was going to do, was I didn't yet got what to do if user submits wrong answer after a correct submission. Guess what?! It was clearly mentioned what's needed to be done in the question itself. My first mistake saved me from this one.

I also learned a few new C++ features, namely, stable_sort, peek, get. I am yet to understand how to use stable_sort properly.

[5:57 PM] And yeah, I made another mistake just now. Foolish me!! Once again I have to say that I didn't read the problem properly because I missed the case that there is no penalty for unsolved problems. Damn it, it look a long time to correct this mistake.

I also got to know of stringstream, although I haven't used it yet.

Here is my solution for the same : https://github.com/ashwani-pandey/UVAoj-solutions/blob/master/10258.cpp

Sunday, January 3, 2016

UVA 11340 : Newspaper

 Ah, this question led me to learn new things, strangely.

It is pretty easy to implement this one, but I was getting WA. And then when I went on uDebug, I found this link : http://www.redgreencode.com/solving-uva-11340-in-java/  and I thought may be character encoding/decoding would be the reason I am stuck.

So, I read this article followed by another good article : http://www.joelonsoftware.com/articles/Unicode.html. I really enjoyed reading both of these articles. It's always great to learn something you don't know of, and I certainly didn't knew of unicode and all the stuff.

But alas, I still got a WA even after doing all the implementation corrections as mentioned in the articles. Later, I found out that the reason I am getting WA is because after finding the answer in cents, I was doing something as I have shown in the code uva11340-wrongway.cpp

You see the stupidity I was doing?! Well I was mixing up the strings with floating point values, and that's why all those WAs.

Simply the following has had to be done, as shown in the code uva11340-rightway.cpp!!


See if you have done some silly mistake like that, it was a big lesson that I learned today.