Sunday, November 23, 2014

SPOJ 5132. Hello Kitty (HELLOKIT)

 The constraints are very low which give us a good opportunity to get the task accepted with a simple brute force. Simple build the first string and every time remove the first letter and add it from the back and you will get the next string. Repeat the process until the new string gets equal to the initial string.


       FULL SOURCE CODE

SPOJ 5676. STONE GAME (RESN04)

Thing we have to notice here is that the game can't have different outcomes if played different way. Consider the pile i , which has A[i] elements, how many times a move can took place for pile i, as long as there are full i-s in A[i] which means A[i]/i times, we can calculate the total number of moves possible for all the piles and in the end if it is an odd number then Alice will win.


       FULL SOURCE CODE

Saturday, November 22, 2014

SPOJ 4301. Tables

It is obvious that the bigger the capacity of the boxes the less amount of boxes we will need to get enough nails. So we need to sort them out and start taking from the biggest until we get enough.


       FULL SOURCE CODE

Wednesday, November 12, 2014

ACM 2023. Donald is a postman / Дональд-почтальон

Basic implementation. We need to somehow keep the corresponding number of shelf of every name so that we can access it with the given names, the C++ map can help a lot here. Also one thing, for making a little easier you can easily notice that there are no 2 names that start with the same letter but belong to different shelfs which means that we can only consider the first letter of the names.


       FULL SOURCE CODE

Monday, November 10, 2014

ACM 1563. Bayan / Баяны

Yet another task which is being handled easily with C++ map because with map we can easily keep the names which we have already encountered before, and if we did increment the answer by 1.


       FULL SOURCE CODE

ACM 2012. About Grisha N./ Про Гришу Н.

 The simple calculation shows that in 4 hours he can manage to solve 240/45 = 5 full tasks which means that if he solves more than 6 before this he will make it.


        FULL SOURCE CODE

Tuesday, November 4, 2014

SPOJ 206. Bitmap

 A simple BFS but we need to be a little clever. Remember how we were doing it? we were starting form a certain node and our wave was passing over all the nodes and the node was the closest, and there is no other path which is shorter than the one we found on the current way, In our case instead of starting from each node all over again we can start from all the '1' nodes which will generate us the same answer. for more details look at the source code/


       FULL SOURCE CODE