bzoj3509.cc

#include #include #include #include using namespace std; typedef long long dint; #ifdef WIN32 #define lld “%I64d” #else #define lld “%lld” #endif #define _l (long long int) struct cplx { double r, i; cplx() {} cplx(double rx, double ix) { r = rx, i = ix; } }; inline cplx operator +(const cplx& a, const cplx& b) { return cplx(a. r + b. r, a. i + b. i); } inline cplx operator -(const cplx& a, const cplx& b) { return cplx(a....

April 1, 2015 · 3 min · laekov

bzoj2395.cc

#include #include #include using namespace std; typedef long long dint; #define _l (long long int) struct edge { int a, b, va, vb; inline void read() { scanf("%d%d%d%d", &a, &b, &va, &vb); } }; struct sptree { int va, vb; sptree() {} sptree(int ao, int bo) { va = ao, vb = bo; } inline dint prd() const { return _l va * vb; } void disp(int x) { printf("(%d,%d)%c", va, vb, x); } }; inline bool operator <(const sptree& a, const sptree& b) { return a....

April 1, 2015 · 2 min · laekov

bzoj2820.cc

#include #include #include using namespace std; typedef long long dint; #ifdef WIN32 #define lld “%I64d” #else #define lld “%lld” #endif #define _l (long long int) const int maxn = 10000009; int tp, pn[maxn], mu[maxn], h[maxn]; dint sh[maxn]; bool pr[maxn]; void pre() { memset(pr, 0, sizeof(pr)); tp = 0; mu[1] = 1; sh[0] = sh[1] = 0; for (int i = 2; i < maxn; ++ i) { if (!pr[i]) { pn[tp ++] = i; mu[i] = -1; h[i] = 1; } for (int j = 0, v; j < tp && i * pn[j] < maxn; ++ j) { pr[v = i * pn[j]] = 1; if (i % pn[j] == 0) { mu[v] = 0; h[v] = mu[i]; break; } else { mu[v] = -mu[i]; h[v] = mu[i] - h[i]; } } sh[i] = sh[i - 1] + h[i]; } }...

March 31, 2015 · 2 min · laekov

bzoj3597.cc

#define PROC “coconut” #include #include #include using namespace std; struct edge { int t, v; edge *next; }; const int maxn = 509; const int maxe = 6009; const double bseps = 1e-4; const double finf = 1e20; int n, m, fp[maxn], st, vis[maxn], tvis; edge ebuf_arr[maxe], *ebuf(ebuf_arr), *head[maxn]; double d[maxn]; inline void addEdge(int u, int v, int w) { ebuf-> t = v; ebuf-> v = w; ebuf-> next = head[u]; head[u] = ebuf ++; // printf(“AE %d -> %d of %d\n”, u, v, w); }...

March 29, 2015 · 2 min · laekov

bzoj3922.cc

#include #include #include #include using namespace std; struct seg { int v, l, r; seg *ls, *rs; }; const int maxn = 70009; const int maxb = 23; const int maxseg = maxn * maxb * 3; int n, m, bv, a[maxn]; seg *br[maxb][maxb], sbuf_arr[maxseg], *sbuf(sbuf_arr); #define midp(p) ((p->l+p->r)»1) inline seg* sgtBuild(int l, int r) { seg* p(sbuf ++); p-> l = l; p-> r = r; p-> v = 0; if (l + 1 < r) { p-> ls = sgtBuild(l, midp(p)); p-> rs = sgtBuild(midp(p), r); } return p; } inline void sgtChg(seg* p, int po, int vo) { if (p-> l + 1 == p-> r) p-> v += vo; else { if (po < midp(p)) sgtChg(p-> ls, po, vo); else sgtChg(p-> rs, po, vo); p-> v = max(p-> ls-> v, p-> rs-> v); } }...

March 29, 2015 · 2 min · laekov

bzoj2289.cc

#include #include #include #include using namespace std; #define dir_l 2 #define dir_r 3 struct circle { double x, y, r; void read() { scanf("%lf%lf%lf", &x, &y, &r); } }; typedef pair <double, int> dpr; inline double sqr(double x) { return x * x; } const int maxn = 100009; const double finf = 1e23; const double eps = 1e-8; int n, t; dpr y[maxn * 2]; circle c[maxn]; int checkDir(double x) { int wl(0), wr(0); t = 0; for (int i = 1; i <= n; ++ i) if (c[i]....

March 28, 2015 · 2 min · laekov

bzoj3784.cc

#include #include #include using namespace std; struct edge { int t, v; edge *next; }; typedef pair <int, int> dpr; struct seg { dpr d; int l, r; seg *ls, *rs; }; struct ptrec { dpr d; int l, r, du; seg *rt; }; inline bool operator <(const ptrec& a, const ptrec& b) { return a. d. first < b. d. first; } const int maxn = 50009; const int maxl = 17; const int maxbuf = maxn * maxl;...

March 27, 2015 · 4 min · laekov

bzoj2698.cc

#include #include #include #include using namespace std; typedef long long dint; const int maxn = 1000009; int n, m, l, r; dint a[maxn], b[maxn], ss[maxn], sv[maxn], sa[maxn], sr[maxn], tot; double ans; int main() { #ifndef ONLINE_JUDGE freopen(“in.txt”, “r”, stdin); #endif scanf("%d%d%d%d", &n, &m, &l, &r); memset(sv, 0, sizeof(sv)); memset(sa, 0, sizeof(sa)); tot = 0; for (int i = 1; i + l - 1 <= n; ++ i) { int li(i + l - 1), ri(min(n, i + r - 1)); tot += ri - li + 1; sv[i] += ri - li + 1; sv[ri + 1] -= ri - li + 1; if (li < ri) { sa[li + 1] -= 1; sa[ri + 1] += 1; sr[ri + 1] += ri - li; } } a[0] = b[0] = 0; dint ad(0); for (int i = 1; i <= n; ++ i) { ad += sa[i]; a[i] = a[i - 1] + sv[i]; b[i] = b[i - 1] + ad + sr[i]; } for (int i = 1; i <= n; ++ i) a[i] += b[i]; ans = 0; for (int i = 1; i <= n; ++ i) ans += 1....

March 27, 2015 · 1 min · laekov

bzoj1095.cc

#include #include #include #include #include using namespace std; const int buf_len = 4567; char buf[buf_len], *bufb(buf), *bufe(buf + 1); #define readBuf() { if (++ bufb == bufe) bufe = (bufb = buf) + fread(buf, 1, sizeof(buf), stdin); } #define readInt(x) { register int s(0); do { readBuf(); } while (!isdigit(*bufb)); do { s = s * 10 + *bufb - 48; readBuf(); } while (isdigit(*bufb)); x = s; } #define readOpt(x) { do { readBuf(); } while (*bufb !...

March 26, 2015 · 5 min · laekov

bzoj2806.cc

#include #include #include using namespace std; #define _l (long long int) struct node { int l; node *pr, *t[3]; node() { l = 0; pr = 0; memset(t, 0, sizeof(t)); } }; const int maxn = 1100009; node nbuf_arr[maxn « 1], *nbuf(nbuf_arr), *srt, *scur; int n, m, f[maxn], ml[maxn]; char a[maxn]; void samIns(int w) { node *np(nbuf ++), *p; np-> l = scur-> l + 1; for (p = scur; p && !...

March 25, 2015 · 2 min · laekov