This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <list> | |
template<class T> | |
class union_find { | |
public: | |
struct node { | |
node *parent = nullptr; | |
T data; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <vector> | |
template<class T> | |
class BIT { | |
public: | |
explicit BIT(size_t N=1) : _bit(N) {} | |
void add(size_t i, T val) { | |
while (i < _bit.size()){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <algorithm> | |
#include <limits> | |
template<class T> | |
class segtree { | |
public: | |
explicit segtree(size_t N=1, T init=std::numeric_limits<T>::max()) | |
: _init(init), _N(N), _tree(4*N,init) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <iostream> | |
#ifdef DEBUG | |
#define debug std::cout | |
#else | |
#define debug true ? : std::cout | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <string> | |
#include <functional> | |
#include <vector> | |
#include <map> | |
class options { | |
public: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
template<class T> T gcd(T a, T b) { | |
T c; | |
while ( a != 0 ) { c = a; a = b%a; b = c; } | |
return b; | |
} | |
template<class T> T lcm(T a, T b) { | |
return a / gcd(a,b) * b; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <list> | |
template<class T> | |
class BST { | |
public: | |
struct Node { | |
T value; | |
Node *lhs, *rhs, *parent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <vector> | |
#include <algorithm> | |
template<class T> | |
class segtree { | |
public: | |
struct node { T all; T part; }; | |
explicit segtree(size_t N=1, T init=0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <vector> | |
#include <algorithm> | |
#include <limits> | |
template<class T> | |
class starrysky { | |
public: | |
struct node { T add; T min; }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
do_svm_install() { | |
svm_path=$HOME/.svm | |
if [[ ! -d "$svm_path" ]]; then | |
echo "Making directory $svm_path" | |
mkdir -p $svm_path | |
fi | |
if [[ ! -e "$svm_path/bin/.git" ]]; then |