Skip to content

Instantly share code, notes, and snippets.

View louchenyao's full-sized avatar

Chenyao Lou louchenyao

View GitHub Profile
@louchenyao
louchenyao / arrow.cpp
Created March 9, 2018 13:57
proof of arrow's impossibility for n = 2, m = 3
#include <cstdio>
using namespace std;
bool gt[7][4][4];
bool unanimity[37][7];
char* profile_str[7];
@louchenyao
louchenyao / kruskal.cpp
Created October 6, 2017 14:00
The implementation of Kruskal’s algorithm.
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
struct Edge {
int u, v;
double weight;
bool operator < (const Edge & e) const {
@louchenyao
louchenyao / bzoj_3203.cpp
Created June 16, 2015 07:48
BZOJ 3203: [Sdoi2013]保护出题人
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef long double LD;
const int kN = 1e5+10;
int N;
LL D;
LL A[kN], X[kN], SUM[kN];
@louchenyao
louchenyao / bzoj_2525.cpp
Created June 15, 2015 16:05
BZOJ 2525: [Poi2011]Dynamite
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int kN = 300000+10;
int N, M;
vector<int> G[kN];
bool have_bomb[kN];
int T, need;
@louchenyao
louchenyao / bzoj_1117.cpp
Created June 15, 2015 15:57
BZOJ 1117: [POI2009]救火站Gas
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int kN = 1e5+10;
const int kK = 20+2;
int N, S, K;
vector<int> G[kN];
long long need[kN][kK], have[kN][kK];
int deep[kN], fa[kN];
@louchenyao
louchenyao / bzoj_2069.cpp
Last active August 29, 2015 14:23
BZOJ 2069
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef pair<int, int> PII;
const int kN = 5000+10;
const int INF = 1e9;
int N, M, first_dis[kN], last_dis[kN];
vector<PII> G[kN];