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
template <class ValueTy> struct Tree { | |
int L, R; | |
Tree *lc, *rc; | |
ValueTy Val; | |
Tree() = default; | |
Tree(int L, int R) : L(L), R(R), lc(nullptr), rc(nullptr), Val() {} | |
void pull() { | |
Val = 0; | |
if (lc) | |
Val += lc->Val; |
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 <bits/stdc++.h> | |
using namespace std; | |
namespace system_test { | |
const size_t KB = 1024; | |
const size_t MB = KB * 1024; | |
const size_t GB = MB * 1024; | |
size_t block_size, bound; |
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 <algorithm> | |
#include <stdexcept> | |
#include <vector> | |
template <typename T, typename Alloc = std::allocator<T>> | |
class Discretizer : private std::vector<T, Alloc> { | |
void build() { | |
std::sort(std::vector<T, Alloc>::begin(), std::vector<T, Alloc>::end()); | |
std::vector<T, Alloc>::erase(std::unique(std::vector<T, Alloc>::begin(), | |
std::vector<T, Alloc>::end()), | |
std::vector<T, Alloc>::end()); |
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
// https://en.wikipedia.org/wiki/Recursive_descent_parser | |
#include <bits/stdc++.h> | |
/// Conditional const | |
/// cond_const<true, Type>: const Type | |
/// cond_const<false, Type>: Type | |
template <bool Const, class Type> struct cond_const { | |
typedef const Type type; | |
typedef const Type *ptr; |
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
template <typename T> struct point { | |
T x, y; | |
point() {} | |
point(const T &x, const T &y) : x(x), y(y) {} | |
point operator+(const point &b) const { return point(x + b.x, y + b.y); } | |
point operator-(const point &b) const { return point(x - b.x, y - b.y); } | |
point operator*(const T &b) const { return point(x * b, y * b); } | |
bool operator==(const point &b) const { return x == b.x && y == b.y; } | |
T dot(const point &b) const { return x * b.x + y * b.y; } | |
T cross(const point &b) const { return x * b.y - y * b.x; } |
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
import copy | |
import pygame,sys,time,random | |
from pygame.locals import * | |
class Point: | |
def __init__(self, x, y): | |
self.x = x | |
self.y = y | |
def __eq__(self, other): | |
return self.x==other.x and self.y==other.y |
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
template<typename T> | |
class kruskal{ | |
static const int MAXN=100005; | |
int n; // 1-base | |
tuple<T,int,int> edge; | |
int pa[MAXN]; | |
int find(int x){ | |
if(x==pa[x]) return x; | |
return pa[x] = find(pa[x]); | |
} |
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<string> | |
#include<map> | |
using namespace std; | |
string decode(const vector<int> &v){ | |
map<int,string> inv_dict; | |
int dictSize = 256; | |
for(int i=0;i<dictSize;++i) | |
inv_dict[i] = string(1,i); | |
string s, entry, res; |
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
/*********************************************************************************** | |
From <<A Faster Approximation Algorithm for the Steiner Tree Problem in Graphs>> | |
Kurt MEHLHORN | |
O(N logN) 2-approximation | |
Implement: SunMoon Master(Jinkela SHENGDIYAGE) | |
************************************************************************************/ | |
#pragma once |
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
template<class T> | |
class Delaunay{ | |
struct PT:public point<T>{ | |
int g[2]; | |
PT(const point<T> &p): | |
point<T>(p){ g[0]=g[1]=-1; } | |
}; | |
static bool cmp(const PT &a,const PT &b){ | |
return a.x<b.x||(a.x==b.x&&a.y<b.y); | |
} |
NewerOlder