bzoj1211.py

n = int(raw_input()); gl = raw_input().split(’ ‘); a = []; a.append(0); s = 0; iz = 0; for i in range(0, n): a.append(int(gl[i]) - 1); s = s + a[i + 1]; if (a[i + 1] < 0): iz = 1; if (n == 1): if (a[1] == -1): print 1; else: print 0; elif (s != n - 2 or iz): print 0; else: fac = []; fac.append(1); for i in range(1, n + 1): fac....

April 6, 2015 · 1 min · laekov

bzoj3163.cc

#include #include #include #include using namespace std; struct doll { int w, v, e; inline void read() { scanf("%d%d%d", &w, &v, &e); } }; const int maxn = 1009; const int tv = 1000; int n, q, bsz, fa[maxn][maxn], fr[maxn][maxn], f[maxn][maxn]; doll d[maxn]; void sglDP(int* f, doll d) { int e(d. e); for (int i = 1; i <= e; i «= 1) { e -= i; for (int j = tv; j >= i * d....

April 6, 2015 · 2 min · laekov

bzoj2251.cc

#include #include #include using namespace std; const int maxn = 3009; int n, a[maxn], sa[maxn], rk[maxn], hi[maxn], ho[maxn]; char g[maxn]; inline bool equStr(int a, int b, int l) { if (rk[a] > rk[b]) return 0; else if (a + l >= n && b + l >= n) return 1; else if (a + l >= n || b + l >= n) return 0; else return rk[a + l] == rk[b + l]; }...

April 6, 2015 · 2 min · laekov

bzoj3611.cc

#include #include #include #include using namespace std; const int buf_len = 4567; char buf[buf_len], *bufb(buf), *bufe(bufb + 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; } typedef long long dint; #ifdef WIN32 #define lld “%I64d” #else #define lld “%lld” #endif #define _l (long long int)...

April 6, 2015 · 5 min · laekov

bzoj2286.cc

#include #include #include using namespace std; struct edge { int t, v; edge *next; }; typedef long long dint; #ifdef WIN32 #define lld “%I64d” #else #define lld “%lld” #endif #define _l (long long int) const int maxn = 250009; const int maxl = 19; const int inf = 0x3f3f3f3f; const dint dinf = 0x3f3f3f3f3f3f3f3fll; int n, m; int d[maxn], dfb[maxn], dfe[maxn], dfo[maxn]; int ut[maxn][maxl], uv[maxn][maxl]; edge ebuf_arr[maxn « 1], *ebuf(ebuf_arr), *head[maxn];...

April 5, 2015 · 3 min · laekov

bzoj3218.cc

#include #include #include using namespace std; struct seg { int id; seg *ls, *rs; }; struct block { int b, w, p, l, r, a; int lid, rid, mid; inline void read() { scanf("%d%d%d%d%d%d", &a, &b, &w, &l, &r, &p); } }; struct edge { int t, c; edge *next, *rv; }; const int maxn = 5009; const int maxnd = 90009; const int maxe = 400009; const int inf = 0x3f3f3f3f;...

April 5, 2015 · 4 min · laekov

bzoj2896.cc

#include #include #include #include using namespace std; typedef pair <int, int> epr; typedef set erbt; struct seg { int s, z, l, r; seg *ls, *rs; }; struct edge { int t; edge *next; }; struct oper { int t, u, v, s; }; const int maxn = 30009; const int maxq = 40009; const int maxe = 100009; int n, m, q, r[maxn]; int fa[maxn], d[maxn], sz[maxn], tc, fc[maxn], ch[maxn], cl[maxn]; seg sbuf_arr[maxn « 2], *sbuf(sbuf_arr), *rt[maxn]; oper o[maxq]; erbt re; edge ebuf_arr[maxn « 1], *ebuf(ebuf_arr), *head[maxn];...

April 5, 2015 · 4 min · laekov

bzoj2182.cc

#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; } const int maxn = 209; const int inf = 0x3f3f3f3f;...

April 3, 2015 · 2 min · laekov

bzoj3238.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) struct node { int l, i, ri; node *tr[26], *pr; node() { ri = l = 0; memset(tr, 0, sizeof(tr)); } }; struct edge { int t; edge *next; }; const int maxn = 1000009; char a[maxn]; int n, ni, f[maxn], sz[maxn], d[maxn]; dint ans; edge ebuf_arr[maxn], *ebuf(ebuf_arr), *head[maxn]; node nbuf_arr[maxn], *nbuf(nbuf_arr), *l, *srt, *scur;...

April 3, 2015 · 2 min · laekov

bzoj3772.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) struct seg { int s; seg *ch[2]; }; struct edge { int t; edge *next; }; struct path { int u, v; inline void read() { scanf("%d%d", &u, &v); } }; const int maxn = 100009; const int maxl = 19; seg sbuf_arr[maxn * maxl], *sbuf(sbuf_arr), *rt[maxn]; dint su, sd; int n, m, ut[maxn][maxl]; int d[maxn], dfo[maxn], dfb[maxn], dfe[maxn]; edge ebuf_arr[maxn « 1], *ebuf(ebuf_arr), *head[maxn]; path q[maxn];...

April 1, 2015 · 4 min · laekov