摘要:Typical Floyd-Walshall Algorithm.#include #include #include #include #include #include #include #include #include using namespace std;const long DIST_...
阅读全文
随笔分类 - HackerRank
摘要:No big difference with "Breadth First Search: Shortest Reach", but this statement is crucial:If there are edges between the same pair of nodes with di...
阅读全文
摘要:Typical Dijstra algorithm impl. one.#include #include #include #include #include #include #include #include #include using namespace std;const long DI...
阅读全文
摘要:A combination of different DP passes.https://www.hackerrank.com/challenges/lego-blocks/editorial#include #include #include using namespace std;typedef...
阅读全文
摘要:Classic.. just classic. It is a mix of Greedy and DP. The naive DP is, iterate over all [1..Bi] which is O(n^3). However, deeper thought into the prob...
阅读全文
摘要:Interesting one.. It is more about data structure design actually. After you figure out how to represent cells, the DP formula will be very intuitive ...
阅读全文
摘要:Actually I think it should belong to category of 'Bits Manipulation'.. but still, a really good one.My first reaction was, how to derive from a ^ (b #...
阅读全文
摘要:Brutal-force solution is not hard to think about. But linear space input usually indicates O(n) DP solution.State design: dp[i]: total sum until index...
阅读全文
摘要:My first thought made it unnecessarily difficult. Well, the correct solution falls into a typical pattern: use DP to calc cumulative results of each c...
阅读全文
摘要:A typical bucketing strategy, but it is probably the most complex one..Basically I refer tothissubmission.
阅读全文
摘要:First I was stuck at how to represent state of "add all except i".. but after checking editorial, it is simply inverted Coin Change problem..#include ...
阅读全文
摘要:1AC. 1D DP + Sieving#include #include #include #include #include #include #include #include #include #include #include using namespace std;int ways(in...
阅读全文
摘要:Good one.. marked as DP, so I was striking to work out a DP formula... well, not all DP have a formula - one type of DP is called memorized search: th...
阅读全文
摘要:First I thought it should be solved using DP, and I gave a standard O(n^2) solution:#include #include #include #include using namespace std;#define RE...
阅读全文
摘要:If coin order matters, that is, each sequence is unique, the DP function is simple enough to make it 1D DP. But key is that order DOESN'T matter, so w...
阅读全文
摘要:The Editorial provides a Fast Fourier Transformation solution O(nlgn)... which is too maths for me. In the leaderboard, I found a not-that-fast O(n^2)...
阅读全文
摘要:New techniques learnt: Trie can be used for some XOR problems. The basic idea: we build a MSB->LSB prefix Trie of all numbers; then query greedily: fi...
阅读全文
摘要:Yes just an implementation problem.. a lot of typing work.#include #include #include #include #include #include #include #include #include #include us...
阅读全文
摘要:1st Try: brutal-force solution failed 3 test cases with TLE2nd Try: uint32_t bucketing - AC:#include #include #include #include #include #include #inc...
阅读全文
摘要:This one is marked as "Advanced".. i don't tink so, not that hard if you can visualize all the bits from a to b. Two key points here:1. Say both a and...
阅读全文

浙公网安备 33010602011771号