Skip to content

Instantly share code, notes, and snippets.

View Superty's full-sized avatar

Arjun P Superty

  • University of Edinburgh
View GitHub Profile
@Superty
Superty / findMaxFlow.cpp
Last active May 15, 2016 21:56
finding maximum flow (ford-fulkerson)
int findMaxFlow()
{
int totalFlow = 0;
while(true)
{
int flow[MAX_N] = { }, prev[MAX_N] = { };
bool seen[MAX_N] = { };
flow[S] = inf;
int maxFlow, maxLoc;
@Superty
Superty / findArticulationPoints.cpp
Last active May 15, 2016 21:56
finding articulation points (tarjan's)
#include <vector>
bool seen[MAX_N] = { };
int num[MAX_N], low[MAX_N], cnt = 1, rootcnt = 0;
vector<int> pts;
void findArticulationPoints(int v, int prev)
{
seen[v] = true;
num[v] = low[v] = cnt;
@Superty
Superty / findStronglyConnectedComponents.cpp
Last active May 15, 2016 21:55
finding strongly connected components (tarjan's)
int curComp = 1, curNum = 1;
int comp[MAX_N], num[MAX_N] = { };
int low[MAX_N], stack[MAX_N], front = 0;
void findStronglyConnectedComponents(int v)
{
num[v] = low[v] = curNum;
curNum++;
stack[front] = v;
front++;
@Superty
Superty / segmentTree.cpp
Last active May 15, 2016 21:55
segment tree
struct node
{
//data members
void split(node &l, node &r) { } //reset update members; update l and r
void merge(node &l, node &r) { } //update by merging l and r; reset update members
node() { }
} segTree[SIZE];
int h = 0;
@Superty
Superty / topologicalSort.cpp
Last active May 15, 2016 21:55
performing topological sort
int deg[maxn], rank[maxn];
void topologicalSort()
{
queue<int> q;
for(int i = 1; i <= n; i++)
{
if(deg[i] == 0)
{
rank[i] = 0;
@Superty
Superty / minHeap.cpp
Created January 14, 2015 09:09
min heap
int n = 0;
int heap[maxn];
const int inf = 1e9;
void update(int p, int x)
{
if(heap[p] < x)
{
heap[p] = x;
while(heap[p] > min(heap[2*p], heap[2*p + 1]))
{
long long gcd(long long a, long long b)
{
if(b == 0) return a;
else return gcd(b, a % b);
}
@Superty
Superty / rec.cpp
Last active September 11, 2016 20:29
dp[i][j] = no. of ways to get j in the first i slots
dp[0][j] = 0, dp[0][0] = 1
dp[i][j] = sum[i - 1][b] - sum[(k = a to b)
sum[i - 1][j] = sum dp[i - 1][k] k = 1 to j
dp[i]
dp[i][j] = no. of ways to partition i into j partitions
dp[i][j] = dp[i - 1][j - 1] + j*dp[i - 1][j]
The following methods of address collection are not considered 'opt-in' and are not recommended:
Setting a checkbox on a web form or within a piece of software to subscribe all users by default (requiring users to explicitly opt-out of mailings).
Add the following headers as described in RFC 8058:
List-Unsubscribe-Post: List-Unsubscribe=One-Click
List-Unsubscribe: <https://example.com/unsubscribe/opaquepart>
Automatically unsubscribe users whose addresses bounce multiple pieces of mail.
Explicitly indicate the email address subscribed to your list.
namespace hidden
open nat (zero succ)
def add : ℕ → ℕ → ℕ
| n zero := n
| n (succ m) := succ (add n m)
set_option trace.app_builder true