一种不知道对不对的exact cover solution.
这是个NPC问题先来看经典的Dancing Links先看中文翻译,直到Four-way-linked插图,然后请看英文版pdf,结合代码,在pdf上用画笔抹一抹,就明白了。粘链接中文DLXcn翻译、及英文pdf在这里https://github.com/sqybi/DLXcnjava代码看这里 http://blog.gssxgss.me/use-dlx-to-solve-sudoku-1...
Quick Sort 和 Quick Sort
序这是一个历史遗留问题下文有两个函数 qsort和qsort2,其中qsort是对的,而qsort2会tle/wa?。。。直到现在还不知道是哪里的事儿。。囧rzTemplate#include <iostream>
using namespace std;
int a[100]={1,2,3,8,6,3,1,4,2,9,9,9,1}, n=13;
void qsort2(int ...
博弈论与Nim游戏的SG函数
很有趣,看了许多资料,回忆起了好多。博弈论不妨想像成一个棋盘,只有一个人来玩。(但是必胜/必败还是指的两人交替)N-Position 当前state必胜。P-Position 当前state必败。因此,任意一种state只能是P/N两种局面。N-Position == It have a chance into P-Position state at the next step, any c...
Hungarian Algoritim Template.
For Bipartite Graph..We Named left Node by 0,1,2,3,4,5...And the Right Node's names are also 0,1,2,3,4,5...For each time we call dfs(), we always stand on the left side, to watch the right side.Tem...
Longest increasing subsequence
https://en.wikipedia.org/wiki/Longest_increasing_subsequenceProblemSelect some item in array, and keep them ascending.e.g.: 0 8 2 9 3 1 7ans ==> 0 2 3 7 len=4Method1Binary Indexed TreeO(nlogn)ht...