【Tricks】Hello World！

#define _________ }
#define ________ putchar
#define _______ main
#define _(a) ________(a);
#define ______ _______(){
#define __ ______ _(0x48)_(0x65)_(0x6C)_(0x6C)
#define ___ _(0x6F)_(0x2C)_(0x20)_(0x77)_(0x6F)
#define ____ _(0x72)_(0x6C)_(0x64)_(0x21)
#define _____ __ ___ ____ _________
#include<stdio.h>
_____


【日常小测】回转寿司

Code

#include<bits/stdc++.h>
#define LL long long
using namespace std;

const int N = 400009;
const int M = 25009;
const int S = 1000;
const int B = N / S + 10;

int n, sn, m, arr[N];
priority_queue<int> val[B];
vector<int> opr[B];

char c = getchar();
int ret = 0, f = 1;
while (c < '0' || c > '9') {
f = c == '-'? -1: 1;
c = getchar();
}
while ('0' <= c && c <= '9') {
ret = ret * 10 + c - '0';
c = getchar();
}
return ret * f;
}

inline void get_element(int w) {
if (opr[w].empty()) {
return;
}
priority_queue<int, vector<int>, greater<int> > heap(opr[w].begin(), opr[w].end());
for (int i = max(1, w * S), lim = min((w + 1) * S - 1, n); i <= lim; i++) {
if (arr[i] > heap.top()) {
heap.push(arr[i]);
arr[i] = heap.top();
heap.pop();
}
}
opr[w].clear();
}

inline int modify_element(int w, int s, int t, int v) {
get_element(w);
int tmp = -1;
for (int i = s; i <= t; i++) {
if (v < arr[i]) {
tmp = arr[i];
swap(v, arr[i]);
}
}
val[w] = priority_queue<int>(arr + max(1, w * S), arr + 1 + min(n, (w + 1) * S - 1));
return v;
}

inline int modify_block(int w, int v) {
val[w].push(v);
int ret = val[w].top();
val[w].pop();
if (v != ret) {
opr[w].push_back(v);
}
return ret;
}

inline int solve(int s, int t, int v) {
int ss = s / S, st = t / S;
v = modify_element(ss, s, min(t, (ss + 1) * S - 1), v);
if (ss != st) {
for (int i = ss + 1; i < st; i++) {
v = modify_block(i, v);
}
v = modify_element(st, st * S, t, v);
}
return v;
}

int main() {
sn = n / S;
for (int i = 1; i <= n; i++) {
}
for (int i = 0; i <= sn; i++) {
val[i] = priority_queue<int>(arr + max(1, i * S), arr + 1 + min(n, (i + 1) * S - 1));
}
for (int tt = 1; tt <= m; tt++) {
if (s <= t) {
v = solve(s, t, v);
} else {
v = solve(s, n, v);
v = solve(1, t, v);
}
printf("%d\n", v);
}
return 0;
}


【HDU 5716】带可选字符的多字符串匹配

Code

#include<bits/stdc++.h>
#define LL long long
using namespace std;

const int N = 2000009;
const int M = 600;
const int SGZ = 100;

char s[N], sgz[SGZ];
bitset<M> v, f[SGZ];

char c = getchar(); int ret = 0, f = 1;
for (; c < '0' || c > '9'; f = c == '-'? -1: 1, c = getchar());
for (; '0' <= c && c <= '9'; ret = ret * 10 + c - '0', c = getchar());
return ret * f;
}

inline int id(char c) {
if ('0' <= c && c <= '9') {
return c - '0' + 1;
} else if ('a' <= c && c <= 'z') {
return c - 'a' + 11;
} else if ('A' <= c && c <= 'Z'){
return c - 'A' + 37;
} else {
return 0;
}
}

int main() {
while (gets(s + 1)) {
int n = strlen(s + 1), m = read();
v.reset();
for (int i = 0; i < SGZ; i++) {
f[i].reset();
}
for (int i = 1; i <= m; i++) {
scanf("%s", sgz + 1);
for (int j = 1; j <= SGZ; j++) {
f[id(sgz[j])][i] = 1;
}
}
bool CantMatch = 1;
for (int i = 1; i <= n; i++) {
v = (v << 1) & f[id(s[i])];
v[1] = f[id(s[i])][1];
if (v[m]) {
printf("%d\n", i - m + 1);
CantMatch = 0;
}
}
if (CantMatch) {
puts("NULL");
}
getchar();
}
return 0;
}


—————————— UPD 2017.7.3 ———————————

【日常小测】异或与区间加

Code

#include<bits/stdc++.h>
#define LL long long
#define UI unsigned int
using namespace std;

const int N = 150009;
const int MOD = 1073741824;
const int blk_sz = 800;

int n, m, k, a[N];
UI a1[N], ans[N], blk_tag[N], tag[N];
vector<int> num, pos_list[N];
vector<pair<int, int> > left_list[N], right_list[N];
struct Query{
int l, r, w;
inline bool operator < (const Query &QQQ) const {
return r > QQQ.r;
}
}q[N];

char c = getchar();
int ret = 0, f = 1;
while (c < '0' || c > '9') {
f = c == '-'? -1: 1;
c = getchar();
}
while ('0' <= c && c <= '9') {
ret = ret * 10 + c - '0';
c = getchar();
}
return ret * f;
}

inline int find(int x) {
int l = 0, r = num.size() - 1, mid;
while (l <= r) {
mid = l + r >> 1;
if (num[mid] == x) {
return mid;
} else if (num[mid] < x) {
l = mid + 1;
} else {
r = mid - 1;
}
}
return -1;
}

inline void solve(int A, int B) {
static UI a2[N], cur;
memset(a2, 0, sizeof(a2));
for (int i = 1; i <= n; i++) {
a2[i] = a2[i - 1] + (a[i] == num[B]);
}
cur = 0;
for (int i = n; i; i--) {
if (a[i] == num[B]) {
cur += a1[i];
}
if (a[i - 1] == num[A]) {
ans[i] += cur;
}
for (int j = 0; j < (int)left_list[i].size(); ++j) {
cur -= (UI)left_list[i][j].second * (a2[left_list[i][j].first] - a2[i - 1]);
}
}
memset(a2, 0, sizeof(a2));
for (int i = 1; i <= n; ++i) {
a2[i] = a2[i - 1] + (a[i - 1] == num[A]);
}
cur = 0;
for (int i = 1; i <= n; i++) {
if (a[i - 1] == num[A]) {
cur -= a1[i];
}
if (a[i] == num[B]) {
ans[i + 1] += cur;
}
for (int j = 0; j < (int)right_list[i].size(); ++j) {
cur += (UI)right_list[i][j].second * (a2[i] - a2[right_list[i][j].first - 1]);
}
}
}

int main() {
freopen("xor.in", "r", stdin);
freopen("xor.out", "w", stdout);
num.push_back(0);
for (int i = 1; i <= n; ++i) {
a[i] = a[i - 1] ^ read();
num.push_back(a[i]);
}
sort(num.begin(), num.end());
num.resize(unique(num.begin(), num.end()) - num.begin());
for (int i = 0; i <= n; i++) {
int pp = find(a[i]);
pos_list[pp].push_back(i);
}
for (int i = 1, l, r, w; i <= m; ++i) {
left_list[l].push_back(make_pair(r, w));
right_list[r].push_back(make_pair(l, w));
a1[l] += w;
a1[r + 1] -= w;
}
sort(q + 1, q + 1 + m);
for (int i = 1; i <= n; ++i) {
a1[i] += a1[i - 1];
}
for (int i = 0; i < (int)num.size(); i++) {
int r = i, l = find(num[i] ^ k);
if (l != -1 && (int)pos_list[l].size() > blk_sz) {
solve(l, r);
}
}
for (int r = n, cur = 0; r; r--) {
while (cur < m && q[cur + 1].r >= r) {
++cur;
for (int i = q[cur].l, lim = min(q[cur].r, (q[cur].l / blk_sz + 1) * blk_sz - 1); i <= lim; ++i) {
tag[i] += q[cur].w;
}
for (int i = q[cur].l / blk_sz + 1, lim = q[cur].r / blk_sz - 1; i <= lim; ++i) {
blk_tag[i] += q[cur].w;
}
for (int i = max(q[cur].r / blk_sz, q[cur].l / blk_sz + 1) * blk_sz; i <= q[cur].r; ++i) {
tag[i] += q[cur].w;
}
}
int t = find(a[r] ^ k);
if (t != -1 && (int)pos_list[t].size() <= blk_sz) {
for (int tt = 0; tt < (int)pos_list[t].size(); ++tt) {
int l = pos_list[t][tt] + 1;
if (l <= r) {
ans[l] += tag[l] + blk_tag[l / blk_sz];
ans[r + 1] -= tag[l] + blk_tag[l / blk_sz];
} else {
break;
}
}
}
}
for (int i = 1; i <= n; i++) {
ans[i] += ans[i - 1];
printf("%d ", ans[i] % MOD);
}
return 0;
}


【日常小测】友好城市

Code

#include<bits/stdc++.h>
#define LL long long
#define UI unsigned int
#define lowbit(x) ((x)&-(x))
using namespace std;

const int N = 159;
const int M = 300009;
const int QQ = 50009;
const int BlockSize = 1200;
const UI ALL = (1ll << 32) - 1;

int n, m, q, U[M], V[M], ans[QQ];
struct Query{
int l, r, blk, id;
inline bool operator < (const Query &Q) const {
return blk < Q.blk || (blk == Q.blk && r < Q.r);
}
}qy[QQ];
struct Bitset{
UI v[5];
inline void flip(int x) {
v[x >> 5] ^= 1 << (x & 31);
}
inline void set(int x) {
v[x >> 5] |= 1 << (x & 31);
}
inline void reset() {
memset(v, 0, sizeof(v));
}
inline bool operator [](int x) {
return v[x >> 5] & (1 << (x & 31));
}
}g[N], rg[N], PreG[M / BlockSize + 9][N], PreRG[M / BlockSize + 9][N];

char c = getchar();
int ret = 0, f = 1;
while (c < '0' || c > '9') {
f = c == '-'? -1: 1;
c = getchar();
}
while ('0' <= c && c <= '9') {
ret = ret * 10 + c - '0';
c = getchar();
}
return ret * f;
}

inline void AddEdge(int u, int v, Bitset *a1, Bitset *a2) {
a1[u].set(v);
a2[v].set(u);
}

class Kosaraju{
vector<int> que;
Bitset vis;
public:
inline int solve() {
vis.reset();
que.clear();
for (int i = 1; i <= n; ++i) {
if (!vis[i]) {
dfs0(i);
}
}
vis.reset();
int ret = 0;
for (int j = n - 1; ~j; j--) {
int i = que[j];
if (!vis[i]) {
int cnt = dfs1(i);
ret += cnt * (cnt - 1) / 2;
}
}
return ret;
}
private:
inline void dfs0(int w) {
vis.flip(w);
for (int i = 0; i < 5; i++) {
for (UI j = g[w].v[i] & (ALL ^ vis.v[i]); j; j ^= lowbit(j)) {
int t = (__builtin_ffs(j) - 1) | (i << 5);
if (!vis[t]) {
dfs0(t);
}
}
}
que.push_back(w);
}
inline int dfs1(int w) {
vis.flip(w);
int ret = 1;
for (int i = 0; i < 5; i++) {
for (UI j = rg[w].v[i] & (ALL ^ vis.v[i]); j; j ^= lowbit(j)) {
int t = (__builtin_ffs(j) - 1) | (i << 5);
if (!vis[t]) {
ret += dfs1(t);
}
}
}
return ret;
}
}scc;

int main() {
freopen("friend.in", "r", stdin);
freopen("friend.out", "w", stdout);
for (int i = 1; i <= m; i++) {
AddEdge(U[i], V[i], PreG[i / BlockSize], PreRG[i / BlockSize]);
}
for (int i = 1; i <= q; i++) {
qy[i].blk = qy[i].l / BlockSize;
qy[i].id = i;
}
sort(qy + 1, qy + 1 + q);
Bitset CurG[N], CurRG[N];
for (int i = 1, L = 1, R = 0; i <= q; i++) {
if (qy[i].blk != qy[i - 1].blk || i == 1) {
L = qy[i].blk + 1;
R = L - 1;
for (int j = 1; j <= n; j++) {
CurG[j].reset();
CurRG[j].reset();
}
}
if (qy[i].r / BlockSize - 1 > R) {
for (int j = R + 1, lim = qy[i].r / BlockSize - 1; j <= lim; j++) {
for (int k = 1; k <= n; k++) {
for (int h = 0; h < 5; h++) {
CurG[k].v[h] ^= PreG[j][k].v[h];
CurRG[k].v[h] ^= PreRG[j][k].v[h];
}
}
}
R = qy[i].r / BlockSize - 1;
}
if (L <= R) {
for (int i = 1; i <= n; i++) {
g[i] = CurG[i];
rg[i] = CurRG[i];
}
for (int l = qy[i].l; l < L * BlockSize; l++) {
}
for (int r = (R + 1) * BlockSize; r <= qy[i].r; r++) {
}
ans[qy[i].id] = scc.solve();
} else {
for (int i = 1; i <= n; i++) {
g[i].reset();
rg[i].reset();
}
for (int j = qy[i].l; j <= qy[i].r; ++j) {
}
ans[qy[i].id] = scc.solve();
}
}
for (int i = 1; i <= q; i++) {
printf("%d\n", ans[i]);
}
return 0;
}


【BZOJ 3577】玩手机

Code

#include<bits/stdc++.h>
#define LL long long
using namespace std;

const int INF = 1e9;
const int N = 500000;
const int M = 2000000;

int S,T,E,tot,A,B,Y,X,n2[2][70][70][8];

char c=getchar(); int f=1,ret=0;
while (c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();}
while (c<='9'&&c>='0') {ret=ret*10+c-'0';c=getchar();}
return ret * f;
}

inline void AddEdge(int u, int v, int f) {
assert(u); assert(v);
to[++E] = v; nxt[E] = head[u]; head[u] = E; flow[E] = f;
to[++E] = u; nxt[E] = head[v]; head[v] = E; flow[E] = 0;
}

class NetworkFlow{
int dis[N],cur[N];
queue<int> que;
public:
inline int MaxFlow() {
int ret = 0;
while (BFS()) {
ret += DFS(S, INF);
}
return ret;
}
private:
inline bool BFS() {
memset(dis, 60, sizeof(dis));
dis[S] = 0;
for (que.push(S); !que.empty(); que.pop()) {
int w = que.front();
for (int i = head[w]; i; i = nxt[i]) {
if (flow[i] && dis[to[i]] > INF) {
dis[to[i]] = dis[w] + 1;
que.push(to[i]);
}
}
}
return dis[T] <= INF;
}
inline int DFS(int w, int f) {
if (w == T) {
return f;
} else {
int ret = 0;
for (int &i = cur[w]; i; i = nxt[i]) {
if (flow[i] && dis[to[i]] == dis[w] + 1) {
int tmp = DFS(to[i], min(f, flow[i]));
ret += tmp; f -= tmp;
flow[i] -= tmp; flow[i ^ 1] += tmp;
if (!f) {
break;
}
}
}
return ret;
}
}
}Dinic;

int main() {
#ifdef DBG
freopen("11input.in", "r", stdin);
#endif
S = ++tot; T = ++tot;
E = 1;
for (int i = 1; i <= X; ++i) {
for (int j = 1; j <= Y; ++j) {
n1[0][i][j] = ++tot;
n1[1][i][j] = ++tot;
}
}
for (int i = X; i; --i) {
for (int j = Y; j; --j) {
for (int a = 0, len = 1; i + len - 1 <= X && j + len - 1 <= Y; ++a, len <<= 1) {
n2[0][i][j][a] = ++tot;
n2[1][i][j][a] = ++tot;
if (!a) {
} else {
int llen = len >> 1;
AddEdge(n2[0][i][j][a], n2[0][i + llen][j][a - 1], INF);
AddEdge(n2[0][i][j][a], n2[0][i][j + llen][a - 1], INF);
AddEdge(n2[0][i][j][a], n2[0][i + llen][j + llen][a - 1], INF);

AddEdge(n2[1][i][j + llen][a - 1], n2[1][i][j][a], INF);
AddEdge(n2[1][i + llen][j][a - 1], n2[1][i][j][a], INF);
AddEdge(n2[1][i + llen][j + llen][a - 1], n2[1][i][j][a], INF);
}
}
}
}
for (int i = 1, w, x1, x2, y1, y2, p0, p1; i <= A; ++i) {
p0 = ++tot; p1 = ++tot;

int len = x2 - x1 + 1, lg = 0, d = 1;
for (; (d << 1) <= len; lg++, d <<= 1);
AddEdge(p1, n2[0][x1][y2 - d + 1][lg], INF);
AddEdge(p1, n2[0][x2 - d + 1][y1][lg], INF);
AddEdge(p1, n2[0][x2 - d + 1][y2 - d + 1][lg], INF);
}
for (int i = 1, w, x1, x2, y1, y2, p0, p1; i <= B; ++i) {
p0 = ++tot;	p1 = ++tot;

int len = x2 - x1 + 1, lg = 0, d = 1;
for (; (d << 1) <= len; lg++, d <<= 1);
AddEdge(n2[1][x1][y2 - d + 1][lg], p0, INF);
AddEdge(n2[1][x2 - d + 1][y1][lg], p0, INF);
AddEdge(n2[1][x2 - d + 1][y2 - d + 1][lg], p0, INF);
}
assert(tot < N);
assert(E < M);
printf("%d\n", Dinic.MaxFlow());
return 0;
}


Part 1. Gedit的配置

#!/bin/sh
fullname=$GEDIT_CURRENT_DOCUMENT_NAME name=echo$fullname | cut -d. -f1
suffix=echo $fullname | cut -d. -f2 g++$fullname -o $name  在拓展工具里创建新工具Run #!/bin/sh fullname=$GEDIT_CURRENT_DOCUMENT_NAME
name=echo $fullname | cut -d. -f1 suffix=echo$fullname | cut -d. -f2
dir=$GEDIT_CURRENT_DOCUMENT_DIR gnome-terminal --working-directory=$dir -x bash -c "$dir/$name; echo; echo 'press ENTER to continue'; read"


Part 2. 计算器

NOI Linux下似乎没有图形界面的计算器

—————————— UPD 2017.5.15 ——————————

—————————— UPD 2017.6.13 ——————————

【BZOJ 4861】[BeiJing2017] 魔法咒语

Code

#include<bits/stdc++.h>
#define LL long long
using namespace std;

const int MOD = 1000000007;

int n,m,L,len[109];
char s1[109][109],s2[109][109];

char c=getchar(); int f=1,ret=0;
while (c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();}
while (c<='9'&&c>='0') {ret=ret*10+c-'0';c=getchar();}
return ret * f;
}

class AC_Automaton{
int cnt,ch[109][26],vis[109],fail[109];
vector<int> G[109];
queue<int> que;
public:
inline AC_Automaton() {
cnt=1;
}
inline void insert(char *s) {
int l = strlen(s + 1), w = 1;
for (int i=1;i<=l;i++) {
int c = s[i] - 'a';
if (!ch[w]) ch[w] = ++cnt;
w = ch[w];
}
vis[w] = 1;
}
inline void build() {
for (int i=0;i<26;i++) {
if (!ch[1][i]) ch[1][i] = 1;
else fail[ch[1][i]] = 1, que.push(ch[1][i]);
}
while (!que.empty()) {
int w = que.front(); que.pop();
G[fail[w]].push_back(w);
for (int i=0;i<26;i++) {
if (ch[w][i] && ch[w][i] != 1) {
que.push(ch[w][i]);
fail[ch[w][i]] = ch[fail[w]][i];
} else {
ch[w][i] = ch[fail[w]][i];
}
}
}
DFS(1, 0);
}
inline int size() {
return cnt;
}
inline int MOVE(int w, int j) {
if (vis[j]) return -1;
for (int i=1;i<=len[w];i++) {
j = ch[j][s1[w][i]-'a'];
if (vis[j]) return -1;
}
return j;
}
private:
void DFS(int w, int t) {
t |= vis[w];
if (t) vis[w] = 1;
for (int i=G[w].size()-1;~i;i--) {
if (G[w][i] != i) {
DFS(G[w][i], t);
}
}
}
}ac;

int f[109][109],tot,ans;
int tra[109][109];

inline void solve() {
for (int i=1;i<=n;i++) {
scanf("%s",s1[i]+1);
len[i] = strlen(s1[i]+1);
}
for (int i=1;i<=m;i++) {
scanf("%s",s2[i]+1);
ac.insert(s2[i]);
}
ac.build();
for (int i=1;i<=n;i++) {
for (int j=1;j<=ac.size();j++) {
int tmp = ac.MOVE(i, j);
if (tmp != -1) tra[j][i] = tmp;
}
}
f[0][1] = 1;
for (int i=0;i<L;i++) {
for (int j=1;j<=ac.size();j++) {
if (f[i][j]) {
for (int k=1,t1,t2;k<=n;k++) {
if ((t1=tra[j][k]) != -1 && (t2=i + len[k]) <= L) {
f[t2][t1] = (f[t2][t1] + f[i][j]) % MOD;
}
}
}
}
}
for (int i=1;i<=ac.size();i++) {
ans = (ans + f[L][i]) % MOD;
}
printf("%d\n",ans);
}
};

int sz,tot,tra[109][109*109+109];
struct Matrix{
int a[209][209];
inline Matrix() {
memset(a,0,sizeof(a));
}
inline Matrix(int x) {
memset(a,0,sizeof(a));
for (int i=1;i<=sz;i++) a[i][i] = x;
}
inline Matrix operator * (const Matrix &M) {
Matrix ret;
for (int i=1;i<=sz;i++) {
for (int j=1;j<=sz;j++) {
for (int k=1;k<=sz;k++) {
ret.a[i][j] = (ret.a[i][j] + (LL)a[k][j] * M.a[i][k]) % MOD;
}
}
}
return ret;
}
inline Matrix operator ^ (int t) {
Matrix ret(1),tmp;
for (int i=1;i<=sz;i++) {
memcpy(tmp.a[i],a[i],sizeof(a[i]));
}
for (;t;t>>=1,tmp=tmp*tmp) {
if (t&1) ret = ret * tmp;
}
return ret;
}
inline void init() {
memset(a,0,sizeof(a));
}
}ans,trans;

inline void solve() {
for (int i=1;i<=n;i++) {
scanf("%s",s1[i]+1);
len[i] = strlen(s1[i]+1);
}
for (int i=1;i<=m;i++) {
scanf("%s",s2[i]+1);
ac.insert(s2[i]);
}
ac.build(); sz = ac.size();
for (int i=1;i<=n;i++) {
for (int j=1;j<=sz;j++) {
int tmp = ac.MOVE(i, j);
if (tmp != -1) tra[j][i] = tmp;
}
}
ans.a[1][1] = 1; int ori = sz;
for (int i=1;i<=ori;i++) trans.a[i][++sz]++;
for (int i=1;i<=ori;i++) {
for (int j=1;j<=n;j++) {
if (!tra[i][j]) continue;
if (len[j] == 1) ++trans.a[tra[i][j]][i];
else trans.a[tra[i][j]+ori][i]++;
}
}
trans = trans ^ L;
ans = ans * trans;
int vout = 0;
for (int i=1;i<=ori;i++) vout = (vout + ans.a[i][1]) % MOD;
cout<<vout<<endl;
}
};

int main() {
if (L <= 100) {
} else {
}
return 0;
}


【BZOJ 4008】[HNOI2015] 亚瑟王

Code

#include<bits/stdc++.h>
#define LL long long
using namespace std;

int n,r,d[250];
double f[250][150],p[250][150],ans[250];

char c=getchar(); int ret=0,f=1;
while (c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();}
while (c<='9'&&c>='0') {ret=ret*10+c-'0';c=getchar();}
return ret*f;
}

int main() {
memset(f,0,sizeof(f)); memset(ans,0,sizeof(ans));
for (int i=1;i<=n;i++) scanf("%lf%d",&p[i][0],&d[i]);
for (int i=1;i<=n;i++) {
p[i][1] = 1 - p[i][0];
for (int j=2;j<=r;j++) p[i][j] = p[i][j-1] * p[i][1];
}
f[1][r] = 1;
for (int i=1;i<=n;i++) {
for (int j=1;j<=r;j++) {
ans[i] += f[i][j] * (1 - p[i][j]);
f[i+1][j] += f[i][j] * p[i][j];
f[i+1][j-1] += f[i][j] * (1 - p[i][j]);
}
}
double vout = 0;
for (int i=1;i<=n;i++) vout += ans[i] * d[i];
printf("%.10lf\n",vout);
}
return 0;
}


CF水题必备（逃

3. Desmos

（虽然我自己不会用 QwQ

—————————— UPD 2017.3.23 ——————————

【Tricks】Linux下进行对拍

1. 每一次给数据生成程序传递随机种子（代替srand(time(0))
2. diff -q 代替 fc
3. linux下运行程序前面要加 ./

【Tricks】Voronoi Diagram

前言

https://en.wikipedia.org/wiki/Voronoi_diagram

正文

http://alexbeutel.com/webgl/voronoi.html

【Tricks】Lambda表达式

前言

sort(a+1, a+1+n, cmp)
bool cmp(const int a, cnost int b) {return a > b;}


解决方案

Lambda表达式如果叫做匿名函数的话可能更能凸显他的特性

static auto cmp = [](int a, int b) {return a > b;};
sort(a+1, a+1+n, cmp);


sort(a+1, a+1+n, [](int a, int b) {return a > b;});


兼容性

#pragma GCC diagnostic error "-std=c++11"