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); | |
} |
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<cstring> | |
#include<algorithm> | |
const int MAXN=1505; | |
int h[MAXN][MAXN*2], v[MAXN][MAXN*2]; | |
char B[MAXN*2]; | |
int CLCS(const char *a, const char *b){ | |
int m = strlen(a), n = strlen(b); | |
strcpy(B,b); strcpy(B+n,b); | |
for(int j=0; j<n*2; ++j) h[0][j] = j+1; | |
for(int i=0; i<m; ++i){ |
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<map> | |
using std::map; | |
using std::pair; | |
#define x first | |
#define y second | |
template<typename T> | |
class convexBST : public map<T,T>{ | |
typedef const pair<T,T>& point; | |
static T cross(point a, point b, point c){ | |
return (a.x-c.x) * (b.y-c.y) - (b.x-c.x) * (a.y-c.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
#include<vector> | |
#include<algorithm> | |
using namespace std; | |
template<class VDB> | |
VDB simplex(int m,int n,vector<VDB> a){ | |
vector<int> left(m+1), up(n+1); | |
iota(left.begin(), left.end(), n); | |
iota(up.begin(), up.end(), 0); | |
auto pivot = [&](int x, int y){ | |
swap(left[x], up[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
<!DOCTYPE html> | |
<html dir="ltr" mozdisallowselectionprint> | |
<head> | |
<meta charset="utf-8"> | |
<title>PDF.js viewer</title> | |
<!-- pdf.js v2.0.332 --> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.0.332/pdf.min.js"></script> | |
</head> | |
<body tabindex="1" class="loadingInProgress"> |
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
#ifndef SUNMOON_SYMMETRIC_MIN_MAX_HEAP | |
#define SUNMOON_SYMMETRIC_MIN_MAX_HEAP | |
#include<vector> | |
#include<algorithm> | |
template<typename T,typename _Seq=std::vector<T>,typename _Compare=std::less<T> > | |
class symmetric_minmax_heap{ | |
_Seq s; | |
_Compare cmp; | |
void BubbleUp(size_t id){ | |
if(id%2&&cmp(s[id],s[id-1])){ |
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> | |
template<typename T> | |
class st_queue{ | |
std::vector<T> A,B; | |
public: | |
void swap(st_queue& stq){ | |
A.swap(stq.A); | |
B.swap(stq.B); | |
} | |
bool empty()const{ |
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 IT,typename CMP> | |
void SM_sort(IT first,IT last,CMP cmp){ // 幫他寫了一個sort做測試 | |
if(last-first<=1)return; | |
IT mid=kth(first,last,(last-first)/2,cmp); | |
SM_sort(first,mid,cmp); | |
SM_sort(mid+1,last,cmp); | |
} |