Day2
Monty and Ravioli both are home and I am here in hostel with Pulku. We went to the library for some work rushed back to have dinner coz we had a contest on codeforces today. My first contest on codeforces. Yes I am yet unrated. It started at 8:05PM IST, I spent the entire 2 hours on the question A. just because of a silly mistake.
I did 1673A. on codeforces named "Subtle Substring Subtraction".
See I came up with the following three cases in a matter of 20 minutes:
1. Bob wins with string length 1.
2. Alice wins with even string length.
3. For odd string lengths Alice will remove (n-1) length of substring leaving the last or the first letter depending on the position of the letter with the max value in the string.
I implemented it, it worked on the given test cases but gave a wrong answer on the pretest2. And from here I was loitering to find the error. Which I couldn't.
I also figured out that Bob will win ONLY with length 1 of the string and in all the other cases Alice will win. But the only thing that I did not realize is that the Alice's SCORE was also supposed to be optimized not just the gameplay was to be optimized to make her win.
So technically the third case will change as follows.
1. Bob wins with string length 1.
2. Alice wins with even string length.
3. For odd string lengths Alice will remove (n-1) length of substring leaving the last or the first letter depending on the score that she will get on removing the substring. She will use a max operation on the score obtained from leaving the last and score form leaving the first letter and play accordingly.
MORAL: Check the optimization carefully.
Bye. Cheers!
Comments
Post a Comment