摘要: 二维树状数组优化dp,复杂度又O(n maxa k) 变成 O(n log(maxa k)) #include #include #include using namespace std; int maxn,n,k,a[10010],ans,tmp; struct BIT { int c[6060][550]; inline int lowbit(int x) ... 阅读全文
posted @ 2016-05-08 18:41 invoid 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 树形dp,bfs。 dfs爆栈。 #include #include #include using namespace std; const int maxn = 1000000 + 10; const int maxm = 2000000 + 10; int g[maxn],v[maxm],next[maxm],c[maxm],eid; int q[maxn],f[maxn],t[max... 阅读全文
posted @ 2016-05-06 16:04 invoid 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 二分答案。 阅读全文
posted @ 2016-05-05 14:55 invoid 阅读(86) 评论(0) 推荐(0) 编辑
摘要: dp。状态转移方程在代码里 #include #include #include using namespace std; const int maxn = 100 + 10; int a[maxn][3]; int f[maxn][maxn][maxn]; int s[maxn],s2[maxn][3]; int n,m,k; int main() { scanf("%d%d... 阅读全文
posted @ 2016-05-01 21:22 invoid 阅读(119) 评论(0) 推荐(0) 编辑
摘要: dp。转移方程在代码里。。 阅读全文
posted @ 2016-05-01 21:21 invoid 阅读(90) 评论(0) 推荐(0) 编辑
摘要: dp。 状态转移方程题解稳。 #include #include #include using namespace std; const int maxn = 100 + 10; int a[maxn][3]; int f[maxn][maxn][maxn]; int s[maxn],s2[maxn][3]; int n,m,k; int main() { scanf("%d... 阅读全文
posted @ 2016-05-01 21:19 invoid 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 块状链表。维护一个点f[i]次能到达下一个块,和到哪个位置。 #include #include using namespace std; const int maxn = 400000 + 100; int k[maxn],jump[maxn],st[maxn],belong[maxn],f[maxn]; int n,m,tot=1; void build() { scanf("... 阅读全文
posted @ 2016-05-01 21:16 invoid 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 动态规划. 首先,如果一个强连通分量的一个点在子图里,这个强连通分量所有点都在子图。所以先用tarjan算法求出强连通分量,缩点,当成一个点来处理。然后进行俩次动态规划就行了,注意判重边。 #include #include #include #include using namespace std; set > edge; const int maxn = 100000 + 10; c... 阅读全文
posted @ 2016-05-01 15:05 invoid 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 容斥原理。 算出不限制硬币数量的方案,-限制1+限制2-限制3+限制4。 限制就是用d+1个硬币。 #include #include #include using namespace std; const int maxn = 100000+10; long long f[maxn],res; int t,c[5],d[5]; void dfs(int dep,int sum,in... 阅读全文
posted @ 2016-04-30 12:24 invoid 阅读(123) 评论(0) 推荐(0) 编辑
摘要: spaly. #include #include #include using namespace std; const int maxn = 100000 + 10; int n,m,q; char op[10]; struct Splay { int f[maxn],l[maxn],r[maxn],s[maxn],a[maxn],fa[maxn]; int root;... 阅读全文
posted @ 2016-04-30 11:08 invoid 阅读(158) 评论(0) 推荐(0) 编辑