题目链接: http://codeforces.com/contest/575/problem/B 题解: 把链u,v拆成u,lca(u,v)和v,lca(u,v)(v,lca(u,v)是倒过来的).这样就只要考虑自下而上的线性结构了,可以用前缀和的思想来做成段更新. 代码: #include<cstdio> #include<vector> #include<cstring> #include<iostream> #include<algorithm…
H. Bots Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/575/problem/H Description Sasha and Ira are two best friends. But they aren’t just friends, they are software engineers and experts in artificial intelligence. They are…
D. Tablecity Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/575/problem/D Description There was a big bank robbery in Tablecity. In order to catch the thief, the President called none other than Albert – Tablecity’s Chief o…
F. Bulbo Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/575/problem/F Description Bananistan is a beautiful banana republic. Beautiful women in beautiful dresses. Beautiful statues of beautiful warlords. Beautiful stars in…
Bubble Cup 12 - Finals Online Mirror, unrated, Div. 1 C. Jumping Transformers 我会状压 DP! 用 \(dp[x][y][mask]\) 记录到达 \((x,y)\),之前清楚的排骨龙集合为 \(mask\) 的最小耗费. 如果到达 \((x,y)\) 时,本应遭遇的排骨龙没了,那么想想:这只排骨龙是何时遭到放逐? 很自然地设计出状态:\(dp[x][y][len][0/1]\) 表示当前在 \(x\) 行, \(y\…
Bubble Cup 11 - Finals [Online Mirror, Div. 1] 一场很好玩的题啊! I. Palindrome Pairs 枚举哪种字符出现奇数次. G. AI robots 对\(r\)从大到小排序,然后cdq分治. 注意要对\(q-k,q+k,q\)进行离散化 B. Space Isaac 对原序列做差分,b[i]=a[i]-a[i-1] 如果我们要凑出\(x\),那么集合A中小于\(x\)的数字,要关于\(x/2\)对称,大于\(x\)的数字要关于\((x+m…
传送门  Problem - 1600J - Codeforces 题目   题意 给定n行m列, 求每个连通块由多少格子组成,并将格子数从大到小排序输出 对于每个格子都有一个数(0~15),将其转化为二进制(四位数),比如1010 表示北为1,不可通:东为0,可通:南为1,不可通:西为0,可通. 即 1表示墙,不可通,四位数字依次表示为北东南西 [注意:比如样例9到14去,只需判断9东边是否可通即可,14不用管] 题解 差不多和dfs的板子一样~ AC代码 #include <iostream…
来自FallDream的博客,未经允许,请勿转载,谢谢. 组了个菜鸡队打cf上的ACM比赛 比较快做完了8题但是菜的抠脚罚时巨多,所以最后被顶到了19名(居然没出首页) 自己的号自从上次疯狂掉分就没动过了,感觉像是红名橙名大佬中的一股清流. A.奇怪的贪心,我写了一发结果挂了,题解见大爷博客 B.dp方程很容易列出来,然后写个矩阵乘法就行了. C.每个点的位置决定了两边的白色小三角形的面积,这个面积是关于位置的一次函数,所以排序之后贪心就行了. D.二分+网络流判定 E.dp方程容易列出,然后换…
B. Neural Network country time limit per test 2 seconds memory limit per test 256 megabytes Due to the recent popularity of the Deep learning new countries are starting to look like Neural Networks. That is, the countries are being built deep with ma…
题意略,题解生成函数练习题,1+(q-ai)x卷积即可,线段树优化(类似分治思想) //#pragma GCC optimize(2) //#pragma GCC optimize(3) //#pragma GCC optimize(4) //#pragma GCC optimize("unroll-loops") //#pragma comment(linker, "/stack:200000000") //#pragma GCC optimize("O…