摘要:One sentence in the problem statement is crucial "your friend will also play optimally", if you interpret it correctly, you are very close to AC. What...
阅读全文
03 2015 档案
摘要:The code below is for:http://hihocoder.com/problemset/solution/237010With enough comments to understand:#include #include #include #include #include #...
阅读全文
摘要:Classic DP, and requires you to track optimal path.len1, len2 = map(int, raw_input().strip().split())a = map(int, raw_input().strip().split())b = map(...
阅读全文
摘要:Kinda similar with another palindrome DP from LeetCode. Feel it, it is a bottom-up DP - palindrome subsequence.str = input()slen = len(str)dp = [[0 fo...
阅读全文
摘要:Very good problem to learn knapsack (complete knapsack in this case).My brutal-force solution in Python got AC too, which surprised me a bit. Here is ...
阅读全文
摘要:"How many inverted pairs" - that usually ends up with MergeSort solution (of course there are other solutions out there)def mergeSort(arr): if len(...
阅读全文
摘要:Nothing special, just some corner casesn = int(input())arr = [int(i) for i in input().strip().split()]# Collect rec = []i = 0while i arr[i + 1]: ...
阅读全文
摘要:Longest Common Subsequence in disguise.Python impl. has TLE in one case. And C++ is fine.#include #include #include #include #include #include #includ...
阅读全文
摘要:This is a very smart observation:http://www.martinkysel.com/hackerrank-sherlock-and-gcd-solution/# http://www.martinkysel.com/hackerrank-sherlock-and-...
阅读全文
摘要:Counting number of enabled bits in uint32_t.. Here is a O(lg32) solution. Very smart, like bottom-up parallel tree post-order traversal.Solution from ...
阅读全文
摘要:http://www.cnblogs.com/grenet/p/3145800.htmlBest elaboration on dancing list I found. in Chinese.Traditional backtracing is a heuristic-like procedure...
阅读全文
摘要:Point: not necessarily contigous max sub array, at least one element should be selected:def maxSubarrCont(arr, n): ret = arr[0] curr = arr[0] ...
阅读全文
摘要:In Haskell. Two points: 1. pruning 2. Int suffers from overflow. Integer it is.getPowerSum :: Integer -> [Integer] -> Integer -> IntegergetPowerSum _ ...
阅读全文
摘要:Greedy beats DP this time...I tried several DP solutions first, but all failed with RE\TLE. If you 'feel' the problem, Greedy should be working:(A sol...
阅读全文