Tuesday, June 25, 2013

836 Largest Submatrix

The 2D range sum DP problem recurrence relation same as 836
only change is we have to consider submatrix wih max 1's and (not maxsum)
have a look at condition on line no 106

Saturday, June 15, 2013

11242 Tour de France


This is complete search problem only catch in this problem to fix and round the ouput note cout at the end

435 Block Voting


This is problem of Complete search.Though problem statement is not clear it can be understood with the test case.It states to find no of winning combination including particular party. Search all combinations

10360 Rat Attack



This is easy backtracking problem which can be solved in O(n*d^2) complexity.
But this could also solved in 1025^2 using dp using range sum.
take input and make entries in dp[1025][1025];
Preproccess the 1025x1025 array using :
        dp[i][j]=dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]+dp[i][j];
then, use recurrence relation to find max
        dp[i+d][j+d]-dp[i+d][j-d-1]-dp[i-d-1][j+d]+dp[i-d-1][j-d-1]; for all (i,j) between d+1 to 1025-d


Tuesday, June 11, 2013

990 Diving for Gold


This is same as Knapsack 0/1 (maximize profit with using time < given amount of time) This problem can be considered as little bit harder because reconstruction of solution is also required here for that purpose we are going to have 2-D(number of element as rows and time as column) boolean array which tells us that whether we have taken element with current row ndex.

Sunday, June 9, 2013

494 Kindergarten Counting Game


Very is problem simple use gets in while loop until end of file and any character other than alphabate is delimiter

Thursday, June 6, 2013

10363 Tic Tac Toe


This is easy problem but there is one catch multiple winning are allowed(as it is not mentioned in problem) , i tried both ways and got AC on commenting that condition (line : 121 in following code)

10812 Beat the Spread!



but note test case if sum=0 and differece = 0 so if d > s then continue ; (and not d>=s)

10420 List of Conquests


very easy problem
just note use of map,sort() and getchar()

573 The Snail


This is very simple problem but to avoid complications of floating point just multiply with the 100

Tuesday, June 4, 2013

105 - The Skyline Problem solution



Simple brute force solution.make array of all 10000 coordinates and for each coordinate store highest value and skip the x coordinates if there is no change in height