Skip to content

Instantly share code, notes, and snippets.

View yinyanghu's full-sized avatar
🎯
Focusing

Jian Li yinyanghu

🎯
Focusing
View GitHub Profile
@yinyanghu
yinyanghu / MaxWeightPerfectBipartiteMatching.cc
Created December 16, 2015 01:40
Minimum / Maximum weight perfect matching for bipartite graph - Hungarian Algorithm - O(n^3)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
const int MAXN = 100;
const int INF = 100000000;
@yinyanghu
yinyanghu / PrimAlgorithm.py
Created January 26, 2016 02:29
Prim Algorithm with Minimum Heap
import heapq
# min-heap
class PriorityQueue:
def __init__(self):
self._queue = []
self._index = 0
def push(self, item, priority):
heapq.heappush(self._queue, (priority, self._index, item)) # -priority if max-heap
@yinyanghu
yinyanghu / baiduyun.sh
Created January 9, 2017 16:52
Download from BaiduYun
#!/bin/bash
while :
do
bypy -v download todownload .
sleep 10
done
@yinyanghu
yinyanghu / BIT.cc
Created February 11, 2017 22:24
Binary Indexed Tree (a.k.a. Fenwick tree)
#define MAXBIT 1000000
#define lowbit(x) (x & -x)
struct BIT {
int bit[MAXBIT];
int M;
void clear(int M) {
memset(bit, 0, sizeof(bit));
this->M = M;
@yinyanghu
yinyanghu / wlcs.cc
Last active November 5, 2018 19:16
Weighted LCS
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdio>
#include <stack>
#include <vector>
#include <cmath>
#include <unordered_map>
#include <utility>