meeting.cc

#include #include #include using namespace std; typedef long long dint; #define _l (long long int) struct Edge { int t; Edge* ne; }; const int maxn = 100003; dint f[maxn], g[maxn], ans; Edge epool[maxn * 2], *ebuf(epool), *head[maxn]; int n; inline void addEdge(int u, int v) { ebuf->t = v; ebuf->ne = head[u]; head[u] = ebuf++; } void DFS(int u, int fr) { f[u] = 1; g[u] = 0; for (Edge* e = head[u]; e; e = e->ne) { if (e->t !...

October 7, 2019 · 1 min · laekov

leetcode5129.py

class Solution: def longestWPI(self, hours: List[int]) -> int: for i, h in enumerate(hours): hours[i] = 1 if h > 8 else -1 s = [0] n = len(hours) values = [0] * (n * 2 + 2) for i, h in enumerate(hours): s.append(s[-1] + h) values[s[-1] + n] = i + 1 for i in range(n * 2 - 1, -1, -1): values[i] = max(values[i], values[i + 1]) answer = 0 for i in range(n): answer = max(answer, values[s[i] + n + 1] - i) return answer

July 16, 2019 · 1 min · laekov

leetocde5130.py

class Solution: def smallestSufficientTeam(self, req_skills: List[str], people: List[List[str]]) -> List[int]: m = len(req_skills) dp = [99999] * (1 « m) fr = [None] * (1 « m) dp[0] = 0 for pi, p in enumerate(people): skills = 0 for s in p: try: idx = req_skills.index(s) skills |= 1 « idx except Exception: continue for i in range(1 « m): if dp[i | skills] > dp[i] + 1: dp[i | skills] = dp[i] + 1 fr[i | skills] = (i, pi) result = [] stat = (1 « m) - 1 while stat > 0: result....

July 16, 2019 · 1 min · laekov

bzoj2118.cc

#include #include #include using namespace std; typedef long long qw; typedef pair <qw, int> dpair; #ifdef WIN32 #define lld “%I64d” #else #define lld “%lld” #endif const int maxn = 13; const int maxw = 400009; int n, w[maxn]; qw b0, b1, d[maxw]; dpair hp[maxn * maxw]; void dijkstra() { int th = 1; memset(d, -1, sizeof(d)); hp[0] = dpair(0, 0); while (th) { dpair g = hp[0]; pop_heap(hp, hp + (th –)); if (d[g....

April 29, 2017 · 1 min · laekov

pineapple.vim

" local syntax file - set colors on a per-machine basis: " vim: tw=0 ts=4 sw=4 " Vim color file " Maintainer: laekov laekov@163.com " Last Change: 2015 Feb " hi clear set background=dark syntax reset let g:colors_name=‘pineapple’ if has(‘gui’) hi Normal guibg=#000000 guifg=white hi SpecialKey term=bold ctermfg=4 guifg=Blue hi Directory term=bold ctermfg=4 guifg=Blue hi ErrorMsg term=standout cterm=bold ctermfg=7 ctermbg=1 gui=bold guifg=White guibg=Red hi IncSearch term=reverse cterm=reverse gui=reverse hi Search term=reverse guibg=Blue guifg=White hi MoreMsg term=bold ctermfg=2 gui=bold guifg=White hi ModeMsg term=bold cterm=bold gui=bold hi LineNr term=underline ctermfg=3 guifg=Pink guibg=#222222 hi Question term=standout ctermfg=2 gui=bold guifg=White hi StatusLine term=bold,reverse cterm=bold,reverse gui=bold guifg=White guibg=Grey35 hi StatusLineNC term=reverse cterm=reverse gui=bold guifg=Grey10 guibg=Gray85 hi VertSplit guibg=Pink guifg=Black hi Title term=bold ctermfg=5 gui=bold guifg=DeepPink3 hi Visual term=reverse cterm=reverse gui=reverse guifg=Grey80 guibg=fg hi VisualNOS term=bold,underline cterm=bold,underline gui=bold,underline hi WarningMsg term=standout ctermfg=1 gui=bold guifg=Red hi WildMenu term=standout ctermfg=0 ctermbg=3 guifg=Black guibg=Yellow hi Folded term=standout ctermfg=4 ctermbg=7 guifg=Black guibg=#e3c1a5 hi FoldColumn term=standout ctermfg=4 ctermbg=7 guifg=DarkBlue guibg=Gray80 hi DiffAdd term=bold ctermbg=4 guibg=White hi DiffChange term=bold ctermbg=5 guibg=#edb5cd hi DiffDelete term=bold cterm=bold ctermfg=4 ctermbg=6 gui=bold guifg=LightBlue guibg=#f6e8d0 hi DiffText term=reverse cterm=bold ctermbg=1 gui=bold guibg=#ff8060 hi Cursor guifg=black guibg=white hi lCursor guifg=bg guibg=fg hi CursorLine guibg=#222222 hi CursorLineNr guibg=#222222 guifg=red hi NonText guifg=green guibg=#1a1a1a " Colors for syntax highlighting hi Comment term=bold ctermfg=4 guifg=Cyan hi Constant term=underline ctermfg=1 guifg=Yellow hi Special term=bold ctermfg=5 guifg=#ff9c3a hi Identifier term=underline ctermfg=6 guifg=#9999ff hi Statement term=bold ctermfg=3 gui=bold guifg=#09f93f hi PreProc term=underline ctermfg=5 guifg=#888888 hi Type term=underline ctermfg=2 gui=bold guifg=#598ff9 hi Ignore cterm=bold ctermfg=7 guifg=bg hi Error term=reverse cterm=bold ctermfg=7 ctermbg=1 gui=bold guifg=White guibg=Red hi Todo term=standout ctermfg=0 ctermbg=3 guifg=Blue guibg=Yellow else hi Normal ctermfg=white ctermbg=0 hi ErrorMsg cterm=standout cterm=bold ctermfg=7 ctermbg=1 hi IncSearch cterm=reverse ctermbg=1 ctermfg=7 hi Search cterm=reverse ctermbg=7 ctermfg=blue hi Visual cterm=reverse if $TERM == ‘xterm-256color’ " hi NonText cterm=bold ctermbg=232 ctermfg=2 " hi Type cterm=bold ctermfg=4 " hi Special cterm=bold ctermfg=172 hi NonText cterm=bold ctermbg=234 ctermfg=2 hi Type cterm=bold ctermfg=4 hi Special cterm=bold ctermfg=1 else hi NonText cterm=bold ctermbg=8 ctermfg=2 hi Type cterm=bold ctermfg=32 hi Special cterm=bold ctermfg=1 endif hi LineNr cterm=bold ctermfg=5 hi ModeMsg cterm=bold hi StatusLine cterm=bold ctermfg=7 ctermbg=8 hi StatusLineNC ctermfg=7 ctermbg=8 hi VertSplit ctermfg=0 ctermbg=5 hi Folded cterm=standout ctermfg=3 ctermbg=4 hi FoldedColumn cterm=standout ctermfg=3 ctermbg=4 “For syntax hilighter hi Comment cterm=bold ctermfg=6 hi Constant ctermfg=yellow hi Indentifier cterm=bold ctermfg=2 hi Statement cterm=bold ctermfg=2 hi PreProc cterm=bold ctermfg=darkgrey hi Ignore ctermfg=7 hi Error term=reverse cterm=bold ctermfg=7 ctermbg=1 hi Todo term=standout ctermbg=6 ctermfg=0 endif

September 28, 2016 · 2 min · laekov

cf703e.cc

#include #include #include using namespace std; typedef long long dint; #define _l (long long int) #ifdef WIN32 define lld “%I64d” #else define lld “%lld” #endif const int maxs = (1 « 22) + 1; const int maxf = 23; const int inf = 0x3f3f3f3f; const int maxn = 1003; typedef pair <dint, int> item; item a[maxn]; dint k, kf[maxf], fs[maxs]; int f[maxs], ff[maxs], cs[maxs], fv[maxs], n, m, t, cf[maxf], v[maxf], vn[maxf], c;...

August 7, 2016 · 3 min · laekov

noip2015_transport.cc

// Source code from laekov at noip 2015 day2 #define PRID “transport” #include #include #include #include using namespace std; const int maxn = 300003; const int maxl = 21; const int buf_len = 45678; 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), neg(0); while (!isdigit(*bufb)) { if (*bufb == ‘-’) neg = 1; readBuf(); } do { s = s * 10 + *bufb - 48; readBuf(); } while (isdigit(*bufb)); if (neg) x = -s; else x = s; }...

November 17, 2015 · 4 min · laekov

noip2015_substring.cc

// Source code from laekov at noip 2015 day2 #define PRID “substring” #include #include #include using namespace std; const int maxa = 2003; const int maxb = 203; const int mod = 1e9 + 7; int n, m, l, f[2][maxb][maxb][2]; char a[maxa], b[maxb]; #define mInc(a,b) { a += b; if (a >= mod) a -= mod; } int main() { freopen(PRID “.in”, “r”, stdin); freopen(PRID “.out”, “w”, stdout); scanf("%d%d%d", &n, &m, &l); scanf("%s%s", a, b); memset(f, 0, sizeof(f)); int cur(0), prv(1); f[cur][0][0][0] = 1; for (int i = 0; i < n; ++ i) { swap(cur, prv); memset(f[cur], 0, sizeof(f[cur])); for (int j = 0; j <= m; ++ j) { for (int k = 0; k <= j && k <= l; ++ k) { if (f[prv][j][k][0]) mInc(f[cur][j][k][0], f[prv][j][k][0]); if (f[prv][j][k][1]) mInc(f[cur][j][k][0], f[prv][j][k][1]); } if (j < m && a[i] == b[j]) { for (int k = 0; k <= j && k <= l; ++ k) { if (f[prv][j][k][0] && k < l) mInc(f[cur][j + 1][k + 1][1], f[prv][j][k][0]); if (f[prv][j][k][1]) { if (k < l) mInc(f[cur][j + 1][k + 1][1], f[prv][j][k][1]); mInc(f[cur][j + 1][k][1], f[prv][j][k][1]); } } } } } printf("%d\n", (f[cur][m][l][0] + f[cur][m][l][1])% mod); }

November 17, 2015 · 1 min · laekov

noip2015_stone.cc

// Source code from laekov at noip 2015 day2 #define PRID “stone” #include #include #include using namespace std; const int maxn = 50003; int n, m, l, a[maxn]; int checkStone(int lt) { int s(0), po(0); for (int i = 0; i < n; ++ i) if (a[i] - po >= lt) po = a[i]; else ++ s; if (l - po < lt) ++ s; return s; } int main() { freopen(PRID “....

November 17, 2015 · 1 min · laekov

noip2015_landlords.cc

// Source code from laekov at noip 2015 day1 #define PRID “landlords” #include #include #include using namespace std; const int maxn = 17; int t, n, a[maxn], ans, c; int readCard() { int x, y; scanf("%d%d", &x, &y); if (x == 0) return 12 + y; else if (x == 1) return 11; else if (x == 2) return 12; else return x - 3; } void checkCtn(int, int, int, int);...

November 17, 2015 · 4 min · laekov