This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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"> |