bzoj4059.cc

#include #include #include #include using namespace std; typedef pair <int, int> ipr; typedef map <int, int> imap; typedef imap :: iterator imap_it; struct seg { int l, r, s, a; seg *ls, *rs; }; struct oper { int x, ya, yb, t; }; inline bool operator <(const oper& a, const oper& b) { return a. x < b. x; } const int maxn = 400009; int n, m, a[maxn], pr[maxn], su[maxn], t; oper o[maxn]; seg sbuf_arr[maxn * 2], *sbuf, *rt; imap ri;...

May 12, 2015 · 3 min · laekov

bzoj4031.cc

#include #include #include using namespace std; const int maxn = 89; const int mod = 1e9; const int movx[4] = {1, 0, -1, 0}; const int movy[4] = {0, 1, 0, -1}; int n, m, a[maxn][maxn], nid[11][11], t; char g[11][11]; #define _l (long long int) #define mInc(a,b) { a += b; if (a >= mod) a -= mod; } #define mDec(a,b) { a -= b; if (a < 0) a += mod; }...

April 30, 2015 · 2 min · laekov

bzoj3996.cc

#include #include #include using namespace std; struct edge { int t, c; edge *next, *rv; }; const int maxn = 255009; const int maxe = 2000009; const int maxa = 509; const int inf = 0x3f3f3f3f; int n, st, te, tnid, rid[maxa], ans; int tvis, vis[maxn], d[maxn]; edge ebuf_arr[maxe], *ebuf(ebuf_arr), *head[maxn]; inline edge* allocEdge(int u, int v, int c) { ebuf-> t = v; ebuf-> c = c; ebuf-> next = head[u]; return head[u] = ebuf ++; } inline void addEdge(int u, int v, int c) { edge* a(allocEdge(u, v, c)); edge* b(allocEdge(v, u, 0)); a-> rv = b; b-> rv = a; }...

April 29, 2015 · 2 min · laekov

bzoj4011.cc

#include #include #include using namespace std; struct edge { int t; edge* next; }; typedef long long dint; #define _l (long long int) const int maxn = 100009; const int maxe = 200009; const int mod = 1e9 + 7; int n, m, x, y, ans, ind[maxn], tpo[maxn], tpn[maxn], inv[maxn], f[maxn]; edge ebuf_arr[maxe], *ebuf(ebuf_arr), *head[maxn]; int modPow(int a, int x) { int s(1); for (; x; x »= 1, a = _l a * a % mod) if (x & 1) s = _l s * a % mod; return s; }...

April 29, 2015 · 2 min · laekov

bzoj4001.pas

var n: double; begin readln(n); writeln(nn(n+1)/(2n-1)/(2n):0:9); end.

April 28, 2015 · 1 min · laekov

bzoj3270.cc

#include #include #include #include using namespace std; const double eps = 1e-11; const int maxa = 23; const int maxn = 409; int n, m, t, pa, pb, mp[maxa][maxa], deg[maxn]; double p[maxa], a[maxn][maxn], s[maxn]; inline double transPsb(int a, int b) { if (a == b) return p[a]; else if (!mp[a][b]) return 0; else return (1.0 - p[a]) / deg[a]; } void guess() { for (int i = 0; i < t; ++ i) { int z; for (z = i; fabs(a[z][i]) < eps; ++ z); if (z > i) for (int k = i; k <= t; ++ k) swap(a[i][k], a[z][k]); for (int j = i + 1; j < t; ++ j) { double rat(a[j][i] / a[i][i]); for (int k = i; k <= t; ++ k) a[j][k] -= a[i][k] * rat; } } for (int i = t - 1; i >= 0; – i) { s[i] = - a[i][t]; for (int j = t - 1; j > i; – j) s[i] -= s[j] * a[i][j]; s[i] /= a[i][i]; } }...

April 26, 2015 · 2 min · laekov

bzoj2961.cc

#include #include #include using namespace std; inline double sqr(const double& x) { return x * x; } struct opt { int t, i; double x, y; inline double f(double xo) { return x * xo + y; } inline void read() { scanf("%d%lf%lf", &t, &x, &y); } }; inline bool operator <(const opt& a, const opt& b) { if (a. x == b. x) return a. y < b. y; else return a....

April 25, 2015 · 3 min · laekov

bzoj1178.cc

#include #include #include #include using namespace std; typedef set rbt; typedef set :: iterator rbt_it; struct cus { int l, r, i; }; inline bool rCmp(const cus& a, const cus& b) { if (a. r == b. r) return a. l > b. l; else return a. r < b. r; } inline bool iCmp(const cus& a, const cus& b) { return a. i < b. i; } const int maxn = 400009; const int maxl = 19;...

April 23, 2015 · 3 min · laekov

bzoj2438.cc

#include #include #include using namespace std; struct edge { int t; edge *next; }; const int maxn = 100009; const int maxe = 600009; const int maxst = 800009; int n, m, vis[maxn], dfn[maxn], low[maxn], tscc, fs[maxn], ssz[maxn], ind[maxn]; edge ebuf_arr[maxe], *ebuf(ebuf_arr), *head[maxn], *hg[maxn]; inline void addEdge(edge** head, int u, int v) { ebuf-> t = v; ebuf-> next = head[u]; head[u] = ebuf ++; } void tarjanDFS(int po) { static int stc[maxst], stv[maxn], stt[maxn], fr[maxn], d[maxn]; int tsc(1), tsv(0), tst(0), dfi(0); d[stc[tsc] = po] = 1; vis[po] = 1; while (tsc) { int p(stc[tsc –]); if (dfn[p]) continue; for (; tsv && d[p] <= d[stv[tsv]]; – tsv) { low[fr[stv[tsv]]] = min(low[fr[stv[tsv]]], low[stv[tsv]]); if (low[stv[tsv]] == dfn[stv[tsv]]) { ssz[++ tscc] = 0; do { vis[stt[tst]] = 2; ++ ssz[fs[stt[tst]] = tscc]; } while (stt[tst –] !...

April 21, 2015 · 2 min · laekov

bzoj4010.cc

#include #include #include using namespace std; struct edge { int t; edge *next; }; const int maxn = 100009; int n, m, ind[maxn], hp[maxn], q[maxn]; edge ebuf_arr[maxn], *ebuf, *head[maxn]; inline void addEdge(int u, int v) { ebuf-> t = v; ebuf-> next = head[u]; head[u] = ebuf ++; } void sov() { memset(ind, 0, sizeof(ind)); memset(head, 0, sizeof(head)); ebuf = ebuf_arr; scanf("%d%d", &n, &m); for (int i = 0; i < m; ++ i) { int u, v; scanf("%d%d", &u, &v); addEdge(v, u); ++ ind[u]; } int th(0), tq(0); for (int i = 1; i <= n; ++ i) if (!...

April 21, 2015 · 1 min · laekov