<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Ois on The Site of laekov</title>
    <link>/oi/</link>
    <description>Recent content in Ois on The Site of laekov</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <copyright>&amp;copy; laekov&lt;br/&gt;[蜀ICP备15008072号](http://beian.miit.gov.cn/)&lt;br/&gt;</copyright>
    <lastBuildDate>Tue, 13 Aug 2019 02:31:17 +0000</lastBuildDate><atom:link href="/oi/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Leetcode1152 用户行为分析</title>
      <link>/oi/461caf/</link>
      <pubDate>Tue, 13 Aug 2019 02:31:17 +0000</pubDate>
      
      <guid>/oi/461caf/</guid>
      <description>看上去很复杂的一个题. 然而数据范围 ( n \leq 50 )
基础知识0: python 里面 list 可以做 dict 的 key.
基础知识1: python 里面 list 可以直接比较大小, 比较方式就是元素的字典序.
做法是先按照 username 对记录进行归类 (dict of list).
然后把每个 username 对应的所有记录按 timestamp 进行排序. (sorted(&amp;hellip;, key=lambda &amp;hellip;))
然后枚举每个用户的所有访问页面三元组并扔进 list 里面. 因为要求一个用户只算一次, 所以要去除 list 里面重复的元素. 所以把 list 转换成 set (集合) 就好了. 也可以直接用 set.
然后把 set 里面的元素都用一个 dict 做一下记数.
最后从记数的 dict 里面挑出次数最多且字典序最小的就可以了.
代码链接</description>
    </item>
    
    <item>
      <title>Leetcode1130 叶值最小代价生成树</title>
      <link>/oi/967d6b/</link>
      <pubDate>Wed, 24 Jul 2019 05:04:14 +0000</pubDate>
      
      <guid>/oi/967d6b/</guid>
      <description>首先弄清楚中序遍历是什么意思.
中序遍历是一个序列 (list).
不存在的节点的中序遍历是空序 ([]).
以 u 为根的二叉树的中序遍历 = u 的左儿子的中序遍历 + u + u 的右儿子的中序遍历
其中加号就是连接两个序列的意思.
题目里说只考虑叶子节点的中序遍历, 就是把所有非叶子从中序里扔掉就好了.
然后考虑从随便一个序列构造一个满足条件的二叉树. 其实这个二叉树上的任意一个点会对应原序列中的连续一段, 而这个点的值就是这一段的所有数的最大值.
我们考虑自底向上的建树. 也就是说最开始是 n 个单独的点, 然后每次建一个新点, 它的两个儿子分别是原来的两个点. 然后用这个新点代替原来的两个点. 重复 &amp;ldquo;挑选, 替代&amp;rdquo; 的过程直到只剩一个点, 就建成了一棵完整的树.
每次挑选的两个点一定代表原数组上相邻的两个区间. 合并后建成这棵树的 最小 代价为 左儿子的最小代价 + 右儿子的最小代价 + 左边最大值 * 右边最大值. 而我们的最小化目标是根的 最小 代价.
自然想到用 f[l][i] 代表以 i 为第一个数的长度为 l 的区间所代表的点为根的树 的 最小 代价. 首先 f[1][i] == a[i], 而我们的目标是 f[n][0].
进一步想, 最小化 f[l][i] 就是在所有该点的左右儿子分配方式 (就是各有多长, 总之加起来是 l) 中挑一个最小的.</description>
    </item>
    
    <item>
      <title>Leetcode1129  颜色交替的最短路径</title>
      <link>/oi/0529db/</link>
      <pubDate>Wed, 24 Jul 2019 02:51:30 +0000</pubDate>
      
      <guid>/oi/0529db/</guid>
      <description>很基础的 BFS 题目.
BFS 和 DFS 是相对应的两种算法. 其区别在于对于新发现的可能性, BFS 将其放入队列末尾, 稍后进行探索, 而 DFS 立即探索这种新情况, 等探索完之后再回到之前的状态继续枚举.
对于这道题目来说, 具体来讲, 状况可以用 (位置, 距离, 颜色) 这么一个 tuple 来表示. 最开始的时候, 有 (0, 0, blue) 和 (0, 0, red) 这两种情况. 假设 0到1 有一条蓝边, 0到2 有一条红边, 那么新的情况是 (1, 1, red) 和 (2, 1, blue).
如果我们使用 DFS, 那么当新发现 (1, 1, red) 这个状态的时候, 我会立即以 (1, 1, red) 为起点, 继续探索 1 号点的邻居, 比如找到了 (3, 2, blue) &amp;hellip; 直到找完所有通过 (1, 1, red) 可以达到的状态之后, 再继续以 (2, 1, blue) 为基础进行枚举.</description>
    </item>
    
    <item>
      <title>Leetcode5129</title>
      <link>/oi/51d1b4/</link>
      <pubDate>Tue, 16 Jul 2019 12:16:25 +0000</pubDate>
      
      <guid>/oi/51d1b4/</guid>
      <description>先预处理一下, 把 &amp;gt;8h 的变成 +1, &amp;lt;=8h 的变成 -1
现在问题就变成了: 找最长的连续一段使其和 &amp;gt;0
使用前缀和数组, 要求 i~j 的和, 公式是 sum[j] - sum[i - 1].
枚举左端点 i. 对于某个确定的 i, 要找以 i 为左端点的最长一段符合要求的区间, 即找满足条件 sum[j] &amp;gt; sum[i - 1] 的最大的 j
注意到 sum 数组的取值为 [-n, n], 故使用值域数组 values. value[k] 表示 sum[j] == k 的最大的 j. 该数组可以在求 sum 数组时一并求出.
满足条件 sum[j] &amp;gt; sum[i - 1] 的最大 j 即求 values[sum[i - 1] + 1], values[sum[i - 1] + 2], values[sum[i - 1] + 3], &amp;hellip;, values[正无穷] 中的最大值.</description>
    </item>
    
    <item>
      <title>Leetcode5130</title>
      <link>/oi/63d337/</link>
      <pubDate>Tue, 16 Jul 2019 12:14:30 +0000</pubDate>
      
      <guid>/oi/63d337/</guid>
      <description>状压动态规划.
dp[x] 表示 x 状态下的最少人数. 其中 x 是二进制数, 第 i 位表示第 i 项技能是否有人已经拥有. 例如 ( x = (10010)_2 ) 从右往左第 1, 4 位是 1, 表示技能 1, 4 已有人掌握, 而 0, 2, 3 无人掌握.
假设一个人的技巧是 p, 现在的状态是 x, 则加入后的状态是 x|p. 其中 | 即 python/cpp 中的 | 运算符, 意义是取二进制或.
运算过程为最初时只有 dp[0] = 0. 对于每个人的技能集合 p, 可以更新 dp 数组 dp[x | p] = min(dp[x | p], dp[x] + 1)
最后的答案是 dp[((111\dots 1)_2)] 即 dp[(1 &amp;laquo; len(skills)) - 1]</description>
    </item>
    
    <item>
      <title>CST DS2017 PA3-3</title>
      <link>/oi/6ca708/</link>
      <pubDate>Wed, 06 Dec 2017 11:19:22 +0000</pubDate>
      
      <guid>/oi/6ca708/</guid>
      <description>PA3-3
题意
一堆字符串判循环相等
做法
最小表示法模板题
也可以直接 hash
不过最小表示了也得 hash.
PA &amp;lt;= 常数优化实习.
可能会在这里贴代码.</description>
    </item>
    
    <item>
      <title>CST DS2017 PA1</title>
      <link>/oi/440904/</link>
      <pubDate>Tue, 19 Sep 2017 19:59:11 +0000</pubDate>
      
      <guid>/oi/440904/</guid>
      <description>1 使用数论快速傅立叶变换进行多项式乘法.
要压三位才能过.
2 先把两维坐标分别快速排序
然后每个问题二分
然后建立两个向量, 看它们的夹角是劣的还是优的, 从而判断这个点在线段和坐标轴围成的三角形的内外
3 维护一个栈
如果右边所有数里的最大值都没有栈顶大, 就弹栈, 否则一直压栈到右边最大的数, 输出最大的数, 然后重复执行此操作.
4 在普通的队列里再维护一个单调队列, 对价格单调. 每次从单调队列里选择当前持有的股票, 用普通队列维护添加 / 删除.
5 替罪羊树维护序列.
至今 90 的数据有一个点 wa 掉不知为何. 可能满跑速度有点悬.
6 利用双向链表进行操作.
链表并不记录前后, 而是只记录两个端.
每个光标记录左右.
然而还是被卡常了.</description>
    </item>
    
    <item>
      <title>NOIP2016 DAY2 简要思路</title>
      <link>/oi/fc5d4b/</link>
      <pubDate>Sun, 20 Nov 2016 14:35:52 +0000</pubDate>
      
      <guid>/oi/fc5d4b/</guid>
      <description>组合数 求n和m都各在一个范围里的组合数里能被k整除的数的个数.
用熟悉的组合数的公式.
\( C_n^m = C_{n-1}^{m-1} + C_{n-1}^m \)
把组合数先处理出来.
对于多组询问, 求出上面那个数组的二维前缀和即可.
蚯蚓 你有n只蚯蚓. 每秒把最长的蚯蚓砍成同比例的两段, 且其它蚯蚓变长. 求m秒中每一秒被砍的蚯蚓和最后所有的蚯蚓.
\( n \leq 10^5, m \leq 7*10^6 \)
目测那个t只是为了输入输出不超时.
正常的暴力是用堆来维护蚯蚓长度.
发现一个性质, 下一次被砍的蚯蚓被砍之后两段肯定会分别短于本次被砍的蚯蚓的两段.
仔细想想没有低于\( O(m) \) 的做法.
所以我们把堆换成若干个队列, 每次只取队首的蚯蚓来比较, 砍, 然后塞回队尾. 保证队列中的元素单调.
这样时间复杂度就变成线性了.
小鸟 平面上有若干只猪. 你可以从原点发射一个抛物线并消灭抛物线上的所有猪. 求最小发射多少次.
\( n \leq 18 \)
我们知道两点确定一条过原点的抛物线. 所以枚举两只猪就能得到所有能消灭至少两只猪的消灭方式. 剩余的猪只能直接消灭.
可以使用状态压缩型动态规划来解决这个问题. 只需要记录下当前已经消灭了哪些猪, 就可以进行转移了.
ps 题目难度还是比去年高. 祝各位好运.
laekov版权所有, 未经允许不得转载. 侵权必究. </description>
    </item>
    
    <item>
      <title>NOIP2016 DAY1 简要思路</title>
      <link>/oi/5402cd/</link>
      <pubDate>Sat, 19 Nov 2016 13:51:22 +0000</pubDate>
      
      <guid>/oi/5402cd/</guid>
      <description>简单看了看NOIP2016的题. 口糊一下自己的想法吧.
玩具 描述好乱. 反正就是一群人围成圈, 若干次左走右走问最后到哪.
加加减减取模就好了.
水水水水过.
跑步 一棵n个点的树, m条路径, 问对于每个点, 经过本点且起点距离本点为本点点权的路径条数.
\( n, m \leq 3*10^5 \)
我感觉这个题有点难呀. 很有可能是我想复杂了.
把每条路径从lca处拆成两段.
考虑对于每个点的询问.
对于起点到lca这段, 询问就是询问子树里lca深度小于等于当前深度的深度刚好为某个值的路径起点个数.
对于lca到终点这段, 询问就是询问子树里lca深度小于等于当前深度的 (长度-深度) 刚好为某个值的路径终点个数.
然后就成了一个比较简明的数据结构问题.
一种思路是平衡树启发式合并, 但是时间可能会炸.
另一种思路是用dfs序式树链剖分, 每条路径会被拆分为不超过lg个dfs序上的子段. 在路径的每个子段的起点和终点处分别打上标记. 然后对dfs序进行一次扫描即可得出答案. 复杂度比较优.
换教室 n节课, v间教室. 每节课有两种教室位置选择, 其中一种是已定的. 你有m次机会申请换掉其中一节课的教室位置, 每个请求有独立的p的概率成功. 教室在一张图上, 求最小总奔波路期望.
\( n, m \leq 10^3, v \leq 3*10^2 \)
个人认为这题比上一题水.
先用floyd处理出任意两间教室间的最短路.
然后用dp.
\( f_{i,j,k} \) 表示前i间教室, 用了j次交换机会, k表示上一次有没有换. 存答案.
转移就是一个概率的算式, 较为简单. 略.
ps 八年来第一次没有在赛场上考noip. 今年题目描述好长好长好长.</description>
    </item>
    
    <item>
      <title>CF703E Mishka and Divisors</title>
      <link>/oi/7a9bc3/</link>
      <pubDate>Sun, 07 Aug 2016 09:46:02 +0000</pubDate>
      
      <guid>/oi/7a9bc3/</guid>
      <description>题意:
给你n个数和一个k. 求这n个数的一个最小子集, 使得元素乘积为k的倍数, 且元素之和最小.
要输出方案.
\( n \leq 10^3, k \leq 10^{12} \)
结局:
死在输出方案上了.
思路:
首先发现k的质因数不会很多, 最多有14个.
然后k的因数也不会很多.
所以就dp一下. \(f_i\)表示当前积与k的gcd为i的时候的元素个数.
然后就像个背包一样嘛. 输出方案? 记录从哪里转移来的不就好了.
然后.
考虑这个例子.
3 9 3 24 21 你会先拿24从3更新到9.
然后21就会把3和9的转移都更新.
然后就炸了.
因为3应该是从原来的状态更新的. 但是现在被覆盖了.
然后发现状态是棵树. 可以把状态可持久化记下来.
更新一个状态的时候, 不是直接覆盖, 而是新建一个状态来保证从原来的状态转移出去的情况不会出错.
这样空间复杂度应该和转移次数有关?
然后怎么就糊过去了.
另一个细节是k=1是答案不能是0. woc.
依然感觉很鬼蓄.
代码</description>
    </item>
    
    <item>
      <title>ovoo solution</title>
      <link>/oi/dbimport_270/</link>
      <pubDate>Mon, 21 Dec 2015 17:32:29 +0000</pubDate>
      
      <guid>/oi/dbimport_270/</guid>
      <description>一点闲话 感觉这题好弱啊.应该有一堆神犇能秒吧.
取模是为了避免输出long long的问题.不知道有没有人中间就取模了2333.
这题的idea源于wc2015的k小割.考场上写了良久最后mle.
于是我决定这题既不卡空间也不卡时间.
是不是感觉我的题比ioi和zyf的题都良心啊hhh
测试点1-6 这六个点的权值和非常小.于是可以树形dp.用fi,j表示以i为根的子树中权值和为j的方案总数.于是可以dp一下就得到答案.
测试点7-8 接下来的点都是大数据了,然而还是有一些部分分.
比如这个.
没有题的一条链情况比这个题更简单了吧ovo
测试点9-10 这是最简单的菊花图ovo似乎就是k小割的弱化版啊.做法比较多喽.
介绍一个叫做学姐二分的方法.二分一个答案,然后强行dfs方案.如果总方案数大于k就直接结束.这样是可以保证复杂度的TAT
测试点11-12 一条链变成两条链了.一样的二分答案然后枚举一边二分另一边嘛.
剩下的测试点 这些点没办法用奇怪的方法了吧?有人用奇怪方法黑过去的和我说一声ovo
考虑当前如果已选的某个点集S,我们也把它叫做一个状态.
S可以向S中任意点的没有在S中的儿子扩展.设扩展后的状态叫S&amp;rsquo;.(它可能有很多个)
不难想到,已知前k小的状态S1 .. Sk后,第k+1小的状态一定是S&amp;rsquo;1 .. S&amp;rsquo;k中权值和最小的一个.
于是我们就是要维护当前所有状态的可扩展的状态.
对于每一个状态,用一个可持久化堆来记录它能扩展到的所有点,然后取其中最小的一个加上它本身的权值和扔进外层的堆里.
那么每次外层堆里的最小值就是第k+1小的状态.
那么找到k+1小状态后,就要将这条边从原状态中删除.然后对于新扩展出来的状态,把新扩展出来的原树上的点的所有儿子也扔到这个状态的堆里就好了.注意有的点的度数会很大,所以每个点的儿子本身就要用可合并堆来存.
然后直接找下去直到扩展出第k小的状态就行了.
以上所有操作的时间复杂度都是O(log(n))的,所以总复杂度是O(k*log(n))的.
另一种思路 上面提到过的&amp;quot;学姐二分&amp;quot;也可以应用到这里.因为我也没写过所以不作重点介绍了.大家可以自行思考一下.
劼司机的思路 (苣蒻的出题人并不能理解这种做法,你可以去找劼司机本人讨论ovo)
就是把树画到平面上。。
然后建个对偶图
对偶图里每条边的边权为他子树里边权和
也就是。。
在对偶图里走过一条边，等于把这条边下面的子树砍掉。。
然后就没了。。。
吉利就是这么虐人的！
松爷好强!</description>
    </item>
    
    <item>
      <title>noip2015 transport</title>
      <link>/oi/dbimport_267/</link>
      <pubDate>Tue, 17 Nov 2015 22:34:39 +0000</pubDate>
      
      <guid>/oi/dbimport_267/</guid>
      <description>唯一一道有点麻烦的题.似乎是Picks出的?orz.于是窝就90辣.
据说可以链剖然而退役的laekov已经搞忘了那是啥.
laekov思考了五分钟.
把所有链按长度排序.答案必定是这个路径序列的某个前缀的并集上的最长边.
然后并集只会减小不会增大.于是暴力判断当前并集端点是否在下一条路径上就可以了.
于是会被卡常数ovo窝也不知道怎么破.在uoj上加了个读入优化炸糊过去了.
然后窝程序在最长路径长度为0的时候会因为数据结构写丑而死循环ovo
反正还是挺水的啊.noip的压轴题怎么能这么水.</description>
    </item>
    
    <item>
      <title>noip2015 substring</title>
      <link>/oi/dbimport_266/</link>
      <pubDate>Tue, 17 Nov 2015 22:30:52 +0000</pubDate>
      
      <guid>/oi/dbimport_266/</guid>
      <description>水水的dp.压一维状态表示上一个字母到底有没有被用就可以算出子串数了.
然后会mle就滚一维呗.有高一小朋友不知道2333.
似乎会卡常数23333.</description>
    </item>
    
    <item>
      <title>noip2015 stone</title>
      <link>/oi/dbimport_265/</link>
      <pubDate>Tue, 17 Nov 2015 22:29:14 +0000</pubDate>
      
      <guid>/oi/dbimport_265/</guid>
      <description>水水的二分答案.
想四年前classroom还属于思考题.现在就已经沦落到开场题的地步了.oi界发展迅速啊.
然而真的不是3分钟搞定?</description>
    </item>
    
    <item>
      <title>noip2015 landlords</title>
      <link>/oi/dbimport_262/</link>
      <pubDate>Tue, 17 Nov 2015 22:27:41 +0000</pubDate>
      
      <guid>/oi/dbimport_262/</guid>
      <description>day1考的农业题.据说可以状压然而退役的laekov已经不会写状压了(雾.
于是直接dfs就好了啊23333
每次搜索的时候强制把当前点数最小的牌出掉至少一张.这样时间复杂度/=答案!.然后就完辣.</description>
    </item>
    
    <item>
      <title>noip2015 message</title>
      <link>/oi/dbimport_264/</link>
      <pubDate>Tue, 17 Nov 2015 22:25:20 +0000</pubDate>
      
      <guid>/oi/dbimport_264/</guid>
      <description>依然是水水的题.
基环内向树.从任意点开走要么是o型环要么是ρ型环.
那些写bfs的是啥心态.非要展示代码能力么.
以及谁说没考数论的?这题不就是&amp;quot;泼辣的肉&amp;quot;的推广(雾.</description>
    </item>
    
    <item>
      <title>noip2015 magic</title>
      <link>/oi/dbimport_263/</link>
      <pubDate>Tue, 17 Nov 2015 22:21:43 +0000</pubDate>
      
      <guid>/oi/dbimport_263/</guid>
      <description>noip成绩终于出来辣可以水水地写个题解辣.假装窝还是在更新窝的网站嘛.
&amp;ldquo;这么水的题还要写题解?&amp;rdquo;
&amp;ldquo;对不起嘛,laekov是noi才ag弱渣嘛.&amp;rdquo;
3分钟题ovo.</description>
    </item>
    
    <item>
      <title>Something for JXFLSers</title>
      <link>/oi/dbimport_112/</link>
      <pubDate>Tue, 10 Nov 2015 22:56:29 +0000</pubDate>
      
      <guid>/oi/dbimport_112/</guid>
      <description>这东西是写给jxfls的学弟学妹们的.cdqz众好好听毛教授的话就行了不要管窝.
写这个的目的是窝作为一个过来人对于泥萌进省队或者拿noi的Au给一点建议.(然而窝也没有noi的Au,所以泥也可以当窝是在口糊)
首先要明确一下这有什么好处.如果进了省队且noi至少拿了Cu(70%诶,sc算是中强省所以会有不少人垫背的),那么会有学校和泥签约.比如考上一本就可以被某校录取.某校嘛好点的比如pku,thu,sjtu,fdu,再有uestc,zju之类的.然后如果拿了Au(即前50),就可以被点招,高考0分上thu(或者泥愿意去pku啥的也行).
毕竟是jxfls出来的.在jxfls若干年也没有见过进省队的.窝想如果jxfls出现至少一个省队,那oi在学校里的地位也许就不一样了.说不定就能进入某种良性循环.如果能出noi的Au,规律是有一就有二,然后有三.毕竟Au爷可以不用高考,而是可以把精力放在冲国家队和提携后辈身上.如此往复.也许这要等很多届.也许永远也不能成功.不过这也算是窝曾经的心愿了吧.这篇文就算是窝尽一点绵薄之力了吧.
其实这件事在jxfls这种难以停课的地方并不容易.cdqz众多半从高二开学就不上文化课了.经过若干个月全力以赴的oi学习,水平自然是不同的.所以泥萌更要抓紧时间.
首先泥要意识到泥有多弱.noip在省选中占30%.泥可以把noip里高三的刨开之后看一看泥在能进省队的人里排在什么位置.也许很多人曾经以为noip一等就是终点.其实它是起点.所以说不要认为自己很厉害.省内,在cdqz,在南山,在绵中&amp;hellip;在省外&amp;hellip;有很多比泥萌厉害得多的人.他们中也有一部分很乐于与泥萌交流.要把握这样的机会,去和强者交流.
另外泥萌也要明白一点,教练不考noi.所以自己的路还得自己走.仅仅跟着教练是得不到好成绩的.个人经验,oi就是靠题目堆出来的.在不停地想题写题中找到不会的算法和数据结构,然后不断完善.
针对省选和noi做题推荐bzoj,又称lydsy.虽然分类什么的比较乱但是题目质量和数量都比较好.而且刷的人多.窝在高二省选时似乎有700道.窝认为如果泥能刷400+道非水题的话省选就能比较有底气了.至于不会的题也不一定要去硬纠结.去网上搜一搜别人博客里的题解,提高一下知识水平,再去敲敲练练代码能力也是极好的.至于哪些题可做的话可以每页按通过人数排序,或者找个前辈的记录跟着做.有些题的确是没法做的.至于bestcoder啊codeforces啊这样的在线比赛如果有时间也可以多参加一下,很能培养参加比赛的感觉.反正自己要努力就好了.
顺便提一下建议多使用linux.我指的是命令行.在bash里完成一切操作,用vim(或者emacs,nano啥的,反正我是vim党)写代码,用g++编译.虽然看上去没啥不同也许最初还会很不适应,但是这对养成好的编程习惯和未来参加noi有好处.
然后考试的时候也别太关注别人在干什么(比如窝在泥旁边打扫雷),干好自己的事就行了.
以上.总之祝你们好运.
再另外虽然窝是一只高三党,窝还是很乐于与泥萌交流的.</description>
    </item>
    
    <item>
      <title>bzoj2850 巧克力王国</title>
      <link>/oi/dbimport_165/</link>
      <pubDate>Wed, 01 Jul 2015 20:50:29 +0000</pubDate>
      
      <guid>/oi/dbimport_165/</guid>
      <description>rausen大爷太强辣!
嗯看到这个东西,咦,直线某一边的点的权值和?kd-tree上上上.
于是就开敲kd-tree.敲到一半弃emacs换vim.
然后就wa了.然后发现double的精度太高了ovoovo
于是rausen跑得好快啊.</description>
    </item>
    
    <item>
      <title>bzoj4134 ljw和lzr的hack比赛</title>
      <link>/oi/dbimport_246/</link>
      <pubDate>Sat, 27 Jun 2015 21:39:47 +0000</pubDate>
      
      <guid>/oi/dbimport_246/</guid>
      <description>之前感觉是sg函数.不过不会.在wulala神犇的指点下找来题解看了一下.太神辣.自己肯定想不出来&amp;hellip;
设以点u为根的子树的局面的sg值为sgu.设以u为根的子树中先手先hack掉v后的sg函数为gu,v.
那么gu,v = f[v] xor ∑ fu到v路径上所有点的非主干儿子.
然后fu = mex{gu,v}
这个转移得转移是O(n2)的样子吧.
然后发现某棵子树的g其实每次都是异或了一个相同的值.而且会合并.
咦可以用trie来优化一下.打下标记啥的.然后根据主席的论文这个东西是O(log n)的?虽然感觉复杂度证明没有说清楚啊ovoovo
然后就在trie树标记上卡了好久啊火冒三丈ing</description>
    </item>
    
    <item>
      <title>bzoj2781 机器人走步</title>
      <link>/oi/dbimport_159/</link>
      <pubDate>Fri, 26 Jun 2015 21:44:36 +0000</pubDate>
      
      <guid>/oi/dbimport_159/</guid>
      <description>上课题.之前只有5个人过5个人交.我成功地拉低了这题的通过率yeah.
其实就是考虑Si序列走完之后对x和y的贡献以及对方向的改变就好了.
比较烦的是中间那一个东西是哪个方向.然后发现如果在上一层的左边就是1否则是0.和更上层没有关系不能直接异或往下传.
代码越写越丑了TAT</description>
    </item>
    
    <item>
      <title>bzoj3329 Xorequ</title>
      <link>/oi/dbimport_192/</link>
      <pubDate>Tue, 23 Jun 2015 15:52:12 +0000</pubDate>
      
      <guid>/oi/dbimport_192/</guid>
      <description>还不错的题ovoovo
发现其实要求x的二进制表示中没有相邻的1就行了.
第一问水水的数位dp.从未写得如此愉快.
第二问就是前面的g.然后发现是fib数列.矩阵快速幂搞定.</description>
    </item>
    
    <item>
      <title>bzoj4145 [AMPPZ2014]The Prices</title>
      <link>/oi/dbimport_248/</link>
      <pubDate>Mon, 22 Jun 2015 10:55:59 +0000</pubDate>
      
      <guid>/oi/dbimport_248/</guid>
      <description>最近总是被一些水题虐智商啊&amp;hellip;怎么回事Ovo
无脑地状压dp一下就好了.
每个物品分开dp,这样可以降到O(2m * n * m)级别.
我还是太弱了.</description>
    </item>
    
    <item>
      <title>bzoj4152 [AMPPZ2014]The Captain</title>
      <link>/oi/dbimport_250/</link>
      <pubDate>Sun, 21 Jun 2015 11:13:29 +0000</pubDate>
      
      <guid>/oi/dbimport_250/</guid>
      <description>naive之laekov系列.这么水的题还想了几天ovoovo
这个距离,咦,不是传统的距离啊.等距线是十字形的.
思考一下.发现,分别按x和y排序,把相邻的两点之间连边,dijkstra,完了.
为啥啊?因为这样建图可以保证任意两点的最短路一定能在图上跑出来.
毕竟我太弱,ovoovo</description>
    </item>
    
    <item>
      <title>bzoj3451 tyvj1953 Normal</title>
      <link>/oi/dbimport_194/</link>
      <pubDate>Wed, 17 Jun 2015 20:55:30 +0000</pubDate>
      
      <guid>/oi/dbimport_194/</guid>
      <description>mhy大爷多久之前开的坑啊ovo
这题的思路比较神.点分+fft.两个点会产生的贡献是1/(dist + 1).于是要知道长度为多少的链有多少条.
利用树分可以将∑深度降到O(n*log n)的级别.原因很明显啊.
然后就用fft来求就好喽.反正是double也懒得用数论了.然后找了wyf的程序随便就拍出一组末位不等,也没用long double.居然能过太神奇了.
总复杂度O(n*log2n).然后莫名其妙就拿了rank1好开心啊.</description>
    </item>
    
    <item>
      <title>bzoj3265 志愿者招募加强版</title>
      <link>/oi/dbimport_186/</link>
      <pubDate>Tue, 16 Jun 2015 20:58:17 +0000</pubDate>
      
      <guid>/oi/dbimport_186/</guid>
      <description>simplex第一题.这玩意是不是拖得太久了啊ovo记得初中买算导的时候就想学它&amp;hellip;
simplex的思路其实比较简单.先找标号最小的目标函数中系数为正的变量.选择约束最紧的限制条件.通过这个条件来换元.直到消光.
感觉好神奇啊然而为啥啊ovoovo
然而线性规划的条件是≤而求的是目标函数的max.和这题的式子刚好相反啊.
然后神奇的东西是,对偶.强行把矩阵转制,然后把大小于符号取反,求出来的目标式max就是原问题的min.为啥啊Ovo算导上的证明也能看?
然后就是一个类似于高消的东西.据说跑得比较快.
另一个神奇的事情是在这道题里面因为奇怪的系数所以所有变量的系数都是+-1或者0.于是可以不用double强行写.开心.
然后网上的某份代码似乎会把无解的情况搞错hah
然而第一遍自己也有地方写丑&amp;hellip;
这种东西还要再练练.</description>
    </item>
    
    <item>
      <title>bzoj2589 Spoj 10707 Count on a tree II</title>
      <link>/oi/dbimport_149/</link>
      <pubDate>Fri, 12 Jun 2015 13:39:12 +0000</pubDate>
      
      <guid>/oi/dbimport_149/</guid>
      <description>mhy写此题写了良久啊然后T啊T,T啊T.然后我去翻了一下seter的博客.结合他的东西yy出一种比较优越的做法.
如果我是出数据的,我会出两种数据,菊花图和链.
如果是菊花图,直接朴素ovoovo如果是链,可以以每个叶子节点为根建一次可持久化线段树.
如果是链上长出了一团菊花&amp;hellip;
how to 结合?
不停地删叶子.如果删到某层时叶子足够少了,那就建可持久化线段树去.
对于询问,有若干种情况.
标记每个根里离得很近的点.
如果两个中有一个被标记过,那么直接以这个根求另一个的答案,然后朴素查找近的这个点到根的答案.
如果两个点都没有被删 ,那一定有至少一个根可以使得这条链的两个端点有祖先关系.这样的话直接用可持久化线段树求解.
好像完了?然后wa了ovoovo
还有一种情况是某个点被删了,但是删之后它是接在树枝上的!
于是它离根很远,还不一定有能搞出祖先关系的解.
于是先爬行到没被删的地方,看两个端点是否在同一棵被删的叶子树上.
如果是就朴素了.
如果不是的话,先求没被删的这一段,再朴素被删的一段.
终于完辣.
从来没写过这种代码.感觉自己萌萌哒.</description>
    </item>
    
    <item>
      <title>弱省互测Round5 Count</title>
      <link>/oi/dbimport_275/</link>
      <pubDate>Thu, 11 Jun 2015 20:03:25 +0000</pubDate>
      
      <guid>/oi/dbimport_275/</guid>
      <description>这题我的做法不太一样.所以mark一下.首先我把题里的n和m看反了,所以下面的m和n都与原题里的m和n相反.
首先考虑一行的方案.在不考虑顺序(即只考虑题中要求􏰍􏱫􏴈􏴉􏰕􏱫􏰍􏱫􏴈􏴉􏰕􏱫􏲙每个颜色个数这个条件一定时)的方案数.
n是50,刚好可以正整数拆分,把n拆成不超过k个正整数时,可行的方案数为n! / c1! / c2! / &amp;hellip; / s1! / s2! / &amp;hellip;这个样子.其中cx表示正整数拆分中的第x个数(后面补0可以不管),s1表示第一种相同的cx的个数.
其实就是说怎么把k个颜色分配到我拆分出的这些整数里.
然后对于一种这样的方案的排列数也比较好求.
然后就是求m行的情况.我的思考方法是先按上面固定顺序,再乘m!.其实这样有问题虽然我没出事.也有可以补救的方法.
上面拆出来的一种拆分,设它有t个不同的颜色分配方案,一种方案有c种排列.这里用一个类似于背包的转移,f[i] = f[j] + 一坨东西.
这坨东西就是把(i - j)个方案按顺序排列的答案.(都叫方案啊好晕ovo)当然这里排列的话会用到判断t是否大于等于(i - j),但是t被模过ovoovo.我偷了个懒假设t如果被模过不会正好小到影响统计.果然也没有.
其实也可以不去除,而是乘组合数吧.不过写起来好麻烦.
咦写了这么多了.然而感觉还是没说清楚啊.ovoovo结合代码理解吧.</description>
    </item>
    
    <item>
      <title>bzoj1228 [SDOI2009]E&amp;D</title>
      <link>/oi/dbimport_124/</link>
      <pubDate>Thu, 11 Jun 2015 14:48:49 +0000</pubDate>
      
      <guid>/oi/dbimport_124/</guid>
      <description>mhy开了道找规律oovovo
打表找规律良久.最后还是没有O(1)的规律.倒是发现有点像分形,有个log级别的递推式.
怎么来的啊好神奇啊ovoovo</description>
    </item>
    
    <item>
      <title>bzoj4127 Abs</title>
      <link>/oi/dbimport_244/</link>
      <pubDate>Wed, 10 Jun 2015 21:19:45 +0000</pubDate>
      
      <guid>/oi/dbimport_244/</guid>
      <description>最近都在做梦的感觉啊.这道题倒是mhy的博客一语点醒梦中人.
只会加正数,所以每个数只有至多一次会从负变非负.
链剖是肯定的.然后记录一下当前最大的负数是谁.如果大于等于0就改掉.所以还是O(n*log2n).
所以我还是太弱了.于是读入优化大法抢了一个rank1.</description>
    </item>
    
    <item>
      <title>bzoj4004 [JLOI2015]装备购买</title>
      <link>/oi/dbimport_226/</link>
      <pubDate>Tue, 09 Jun 2015 21:05:32 +0000</pubDate>
      
      <guid>/oi/dbimport_226/</guid>
      <description>比较郁闷的题ovo拍了老久.最后还是找Po神要来了数据.
首先这个矩阵的基就是一个拟阵,所以可以贪心.
然后发现就是要O(n^2)判断是否线性无关.
其他人的做法是强行顺序.我觉得没辣么麻烦啊.先把原来消出来的东西备份一下.如果发现不行再备份回来就好了啊ovoovo
那么直接高消会有非常严重的精度问题(似乎是).
于是我想直接用整数搞.然后发现会有变成负数的问题和越界的问题,强行re+wa.非常不开心.
于是直接取模yeah.然后由于用了辗转相除之类的东西所以常数巨大.而且bzoj上开了O2比本机没开O2竟然慢了6倍.ovoovo</description>
    </item>
    
    <item>
      <title>hdu5267 pog loves szh IV</title>
      <link>/oi/dbimport_254/</link>
      <pubDate>Sun, 07 Jun 2015 21:24:11 +0000</pubDate>
      
      <guid>/oi/dbimport_254/</guid>
      <description>bc fst爽翻.然后这题差二十分钟没调出来不然我就是rank1.还是应该直接敲而不是去和队友商量.
静态做的话直接按位树分就好了.然后资瓷修改的时候也是一样.只是把之前求的信息在树分后的dfs序上用线段树记下来.也就是要随时知道某个分治层里的某个子树上有多少个0或者1.
然后就是讨论某个修改对当前答案的贡献.要注意分治根的值,以及有贡献的是哪些位置.中间打错了外层的dfs序范围,导致调试了很久.明明想清楚了但是打错了,不应该的.
只有完了之后交了然后怒虐标程好开心啊.</description>
    </item>
    
    <item>
      <title>bzoj4123 [Baltic2015]Hacker</title>
      <link>/oi/dbimport_242/</link>
      <pubDate>Thu, 04 Jun 2015 22:31:15 +0000</pubDate>
      
      <guid>/oi/dbimport_242/</guid>
      <description>还比较有意思的一题.
考虑如果Alice选了某一个位置,那么Bob的策略一定是选使得Alice的和最小的一段.也就是对于所有位置,求包含它的所有区间中和最小的一个,再求个max.
这个东西先要展开一倍,然后可以比较方便地用单调队列搞定.</description>
    </item>
    
    <item>
      <title>bzoj2877 [Noi2012]魔幻棋盘</title>
      <link>/oi/dbimport_167/</link>
      <pubDate>Thu, 28 May 2015 19:39:13 +0000</pubDate>
      
      <guid>/oi/dbimport_167/</guid>
      <description>其实是一道没多大意思思的码农题TT然而这是我的第800题所以要mark一下.
gcd序列可以用插分序列+第一个数来支持区间加.二维那就二维差分喽.
然后发现第一个数似乎没有办法维护啊.不能做了?!
询问的方式比较奇怪,有一个中心.那就建4个方向吧.这样似乎可做了yeah.
所以我还是太naive了啊.
是时候屯一波题了.</description>
    </item>
    
    <item>
      <title>bzoj3864 Hero meet devil</title>
      <link>/oi/dbimport_210/</link>
      <pubDate>Sun, 24 May 2015 10:01:57 +0000</pubDate>
      
      <guid>/oi/dbimport_210/</guid>
      <description>立杰的dp套dp.之前在hwadee培训的时候讲过的题啊.
考虑求lcs时候的f数组的一列,发现相邻两个数要么差1要么不差.于是15就是拿来状压这个东西的.
然后很愉快地写了一个然后很愉快地tle了.妈妈,剧本里没这一节啊.
仔细思考了一下发现每次在计数dp转移的时候去找lcs dp非常慢.而且只要给定状态和转移,目标是确定的.跑1000次浪费了.于是改成预处理转移.就好了.</description>
    </item>
    
    <item>
      <title>bzoj3542 DZY Loves March</title>
      <link>/oi/dbimport_198/</link>
      <pubDate>Thu, 21 May 2015 19:33:30 +0000</pubDate>
      
      <guid>/oi/dbimport_198/</guid>
      <description>业界毒瘤ioi开的坑.然后被强行看了一下于教授的代码.然后觉得也不太难嘛.
看了一下条件.只和同行或者同列有关?那就拿map套动态建树的线段树好了辣.
然后距离是欧式距离?那就把完全平方式展开,发现只需要在线段树里记录一下个数,和,平方和,搞定了辣!
然后alloc的时候&amp;ndash;写成了++,查错良久,囧.</description>
    </item>
    
    <item>
      <title>bzoj2961 共点圆</title>
      <link>/oi/dbimport_171/</link>
      <pubDate>Thu, 21 May 2015 16:04:54 +0000</pubDate>
      
      <guid>/oi/dbimport_171/</guid>
      <description>之前觉得不可做的一道题.然后昨天听mhy一句话瞬间懂:几何反演.然后mhy说这题用cdq?骗我读书少呢?
html写公式好郁闷.把设圆心是(p,q),点是(x,y),那么点在圆内的条件是
(p-x)2+(q-y)2 ≤ p2+q2
转化一下变成
q ≥ -(x/y) * p + (x2+y2) / (y*2)
然后就可以把(p,q)看作一个点,每个询问就是询问之前的所有点是否都在这条直线的上方.
那么直接归并排序喽.处理出左边的凸壳再单调扫一遍右边的所有直线.这样复杂度是O(n*logn),又短又快yeah.
然后还听说有精度误差?我全程double没用eps也没出事啊hhh</description>
    </item>
    
    <item>
      <title>bzoj2962 序列操作</title>
      <link>/oi/dbimport_173/</link>
      <pubDate>Mon, 18 May 2015 21:09:13 +0000</pubDate>
      
      <guid>/oi/dbimport_173/</guid>
      <description>最近整个人都被Sone1搞得头昏脑胀。不爽ing。
这个题其实就是线段树+维护的题。考虑给一个区间里每个数加C的时候的式子会变成什么样就好了。
然后要注意标记得随时下传，不能永久化。
然后感觉时间有点慢不过跑起来还将就。
然后我太弱了。</description>
    </item>
    
    <item>
      <title>bzoj1225 [HNOI2001] 求正整数</title>
      <link>/oi/dbimport_121/</link>
      <pubDate>Thu, 14 May 2015 09:43:59 +0000</pubDate>
      
      <guid>/oi/dbimport_121/</guid>
      <description>ioi好神啊,居然写搜索.我显然是不想写高精的啦于是用java于是花费了整整两节课TT
我的想法是dp.设答案为f[m],那么f[m]只与fd有关.设f[i][j]表示i为m的第i小的约数,且已经用了前j个素数的答案.然后就可以转移辣.
然后得二分一下用多大的素数可以卡过.毕竟java自带大常数.而且bzoj坑爹在不管有多少组数据都只多给2秒总时限ovo</description>
    </item>
    
    <item>
      <title>bzoj4071 [Apio2015]巴邻旁之桥</title>
      <link>/oi/dbimport_240/</link>
      <pubDate>Wed, 13 May 2015 18:37:18 +0000</pubDate>
      
      <guid>/oi/dbimport_240/</guid>
      <description>这是apio里我最自豪的一道题了.让三分党去&amp;hellip;吧.
k=1直接在所有坐标的中位数处建桥就行了不要问我为什么.
首先感受一下发现可以按(a+b)把序列分成两半,然后两半就是k=1的情况嘛.那直接处理一下每个前缀和后缀的答案就完了辣.</description>
    </item>
    
    <item>
      <title>bzoj4070 [Apio2015]雅加达的摩天楼</title>
      <link>/oi/dbimport_238/</link>
      <pubDate>Wed, 13 May 2015 18:34:41 +0000</pubDate>
      
      <guid>/oi/dbimport_238/</guid>
      <description>apio的第二题.其实是我做题顺序里的最后一道.
我的方法比较奇怪.对于p分开讨论.如果p&amp;gt;c那么直接建边,否则在图的旁边再建若干条链,把这个点连到链上去.然后再跑一下最短路.
卡一卡常数就过去啦.</description>
    </item>
    
    <item>
      <title>bzoj4069 [Apio2015]巴厘岛的雕塑</title>
      <link>/oi/dbimport_236/</link>
      <pubDate>Wed, 13 May 2015 18:32:07 +0000</pubDate>
      
      <guid>/oi/dbimport_236/</guid>
      <description>看上去apio的成绩都出来了,那我就可以写题解喽.
这题比较水啊,尤其是在考试的时候允许多次提交,服务器还跑得飞快.强行bitset压位就好了.
按位从高向低贪心.
对于l=1的情况直接求最少的覆盖区间就好了.
对于剩下的情况,用f[i][j]表示前i个数能否用j个区间覆盖.
完了辣</description>
    </item>
    
    <item>
      <title>bzoj2111 [ZJOI2010]Perm 排列计数</title>
      <link>/oi/dbimport_126/</link>
      <pubDate>Wed, 13 May 2015 17:36:12 +0000</pubDate>
      
      <guid>/oi/dbimport_126/</guid>
      <description>之前觉得好神的题根本没有思路.刚才才发现ovo
发现这玩意其实就是一个堆而且堆里没有相同的元素.那么对于一个点它的方案数就是左右儿子的方案数的积再乘两边大小的组合数ovo
然后被坑了直到看到zyf的题解才想起有可能mod&amp;lt;n.然后得用一个pair来代替原来的数.
无语喽ovo</description>
    </item>
    
    <item>
      <title>bzoj4031 [HEOI2015]小Z的房间</title>
      <link>/oi/dbimport_232/</link>
      <pubDate>Thu, 30 Apr 2015 15:57:53 +0000</pubDate>
      
      <guid>/oi/dbimport_232/</guid>
      <description>看上去像是插头dp啊.然后基尔霍夫矩阵也能做.
关键是模数不是质数,所以不能逆元,所以要用mhy的黑科技,碾转相除来做.
mhy太强了ovo</description>
    </item>
    
    <item>
      <title>bzoj3996 [TJOI2015]线性代数</title>
      <link>/oi/dbimport_222/</link>
      <pubDate>Wed, 29 Apr 2015 19:04:27 +0000</pubDate>
      
      <guid>/oi/dbimport_222/</guid>
      <description>最开始看了一下这是什么gui啊.然后仔细一看发现有玄机.
管aa[1][i]叫a[i]好了.那么b[i]j对答案产生贡献当且仅当a[i]=a[j]=1.b[i][i]对答案产生贡献当且仅当a[i]=1.c[i]对答案产生影响当且仅当a[i]=1.
然后看上去好玄妙啊.其实就是要决定哪些a[i]要选.那不是最大权闭合子图嘛?
数据范围有点大?实测一下飞快啊.</description>
    </item>
    
    <item>
      <title>bzoj4011 [HNOI2015]落忆枫音</title>
      <link>/oi/dbimport_230/</link>
      <pubDate>Wed, 29 Apr 2015 09:24:11 +0000</pubDate>
      
      <guid>/oi/dbimport_230/</guid>
      <description>题目好长啊,像个阅读题一样.还是比较有意思的一道题.有点像gorgeous和我说的那个原创题的感觉啊.
首先如果没有加边的话那么答案就是∏indegreeu.
如果加了边之后还是dag那么无影响.
如果加了边之后存在一个scc,那么答案就要减去∑(环*∏其它点的indegree).这个东西可以用随随便便的dp来解决.</description>
    </item>
    
    <item>
      <title>bzoj4001 [TJOI2015]概率论</title>
      <link>/oi/dbimport_223/</link>
      <pubDate>Tue, 28 Apr 2015 15:55:58 +0000</pubDate>
      
      <guid>/oi/dbimport_223/</guid>
      <description>无语的智商题啊.居然没人写题解.
首先dp打个表.cnt[i]表示大小为i的二叉树的总个数.当然这个就是catlan数.然后son[i]表示大小为i的所有不同构的二叉树的叶子数的和.
然后经过找规律(翻oeis)发现son[i] = C(2n-2,n-1).
于是就没有于是了.推一下组合数发现answer=n2(n+1) / (n2) / (n*2-1).
代码好无语.</description>
    </item>
    
    <item>
      <title>bzoj3270 博物馆</title>
      <link>/oi/dbimport_188/</link>
      <pubDate>Sun, 26 Apr 2015 13:40:49 +0000</pubDate>
      
      <guid>/oi/dbimport_188/</guid>
      <description>比较基础的期望+高消的题.为了说明一下高消是what,我决定写一发题解.
首先题意是有个n个点m条边的无向图.有两个人初始位置是a和b.每个时刻每个人在一个点有p_i的概率不动,否则等概率移动到相邻的点.只有在同一时刻在同一个顶点上才算相遇.相遇了他俩就玩去了.求在第i号点相遇的概率.
首先方程很好列.定义一个状态f[i][j]表示第一个人在i,第二个人在j的概率.那么f[i][j] = ∑ f[k][l] * ptrans(k,i) * ptrans(j, l),其中ptrans(a,b)表示从a移动到b的概率.
然后这个东西就用高消嘛.(upd:才发现它叫gauss而不是guess.捂脸ing)
高消就是说每次把剩下的方程里的第一个系数不为0的未知数的系数全部通过减某一个方程来把这个系数都消成0.当然被减的方程得留下系数过会再用于推答案.然后就可以不管这个被留下的方程了.
换句话说,如果把方程组看成t*(t+1)的矩阵的话,其实就是消成一个右上三角.
然后再倒着推出每个未知数的值.
这个直接算比例就完了嘛.然后有一种情况是当前a[i][i]已经为0了,那么减不掉?反正所有方程的顺序没有关系啊.你就随便找一个不是0的到前面来消就好了啊.如果剩下方程的这一个系数都是0,那这个未知数取啥就无关了.也无所谓啦.
详见代码.</description>
    </item>
    
    <item>
      <title>bzoj1178 [Apio2009]CONVENTION会议中心</title>
      <link>/oi/dbimport_116/</link>
      <pubDate>Thu, 23 Apr 2015 10:08:48 +0000</pubDate>
      
      <guid>/oi/dbimport_116/</guid>
      <description>apio的题也是比较有质量的.听说这题很难写但是我感觉难点在想上啊.
首先直接两遍Lis强行判断能不能扔进去是错的.至于为啥我也不造啊.
于是就是区间询问答案最大.然后每次看把当前询问加进去后会不会对最大答案产生影响.
然后发现有点像今年sctsc那个倍增?居然还真是倍增.先去掉包含有其它区间的区间.然后找每个点向右跨过的最近的一个区间.然后再倍增一发.
好神的做法啊ovo
btw为啥bzoj第一页上充满了黑坨坨.不爽Ing.</description>
    </item>
    
    <item>
      <title>bzoj2438 [中山市选2011]杀人游戏</title>
      <link>/oi/dbimport_142/</link>
      <pubDate>Tue, 21 Apr 2015 20:59:49 +0000</pubDate>
      
      <guid>/oi/dbimport_142/</guid>
      <description>之前在哪里听过的题啊.于是卡了一晚上.
就是缩个点然后看看哪些点必需自己去点第一把火就好了.
然后有一种情况是把剩下的都查完之后只剩下一个了.那么看存不存在这种情况.那就是某个第一把火的地方的scc大小为1,且它连出去的都不必需用它查.
然后我就卡在ans&amp;gt;1上了.我傻了ovo
然后非递归tarjan还是写得不熟啊.还要再加深一下对自己想出来的算法的印象.</description>
    </item>
    
    <item>
      <title>bzoj4010 [HNOI2015]菜肴制作</title>
      <link>/oi/dbimport_228/</link>
      <pubDate>Tue, 21 Apr 2015 11:52:05 +0000</pubDate>
      
      <guid>/oi/dbimport_228/</guid>
      <description>bzoj都3k道题了ovo
hnoi的题好强.
这个题就建反图然后跑topsort就行了.每次选能选的里最大的扔进去.最后倒过来输出.
我也是猜的然后交上去居然是对的.
为什么呢?好神奇?</description>
    </item>
    
    <item>
      <title>bzoj1209 [HNOI2004]最佳包裹</title>
      <link>/oi/dbimport_118/</link>
      <pubDate>Tue, 21 Apr 2015 09:37:44 +0000</pubDate>
      
      <guid>/oi/dbimport_118/</guid>
      <description>三维算几ovo给mhy和idy跪烂.
三维凸包算是一种比较简单的三维算几吧.首先有一些基本的公式比如算四个点的体积就是一个底*高.不过变成了一个面的法向量点乘另一个向量.
然后就用随机增量法每次替掉一些面就好了.
然后有一种可能是所有点都共面.这种时候就随机把一些点乱移动一下让它们形成一个高度和纸一样薄的凸包再来算就行了.
感觉也不是特别恶心啊ovo</description>
    </item>
    
    <item>
      <title>bzoj2671 Calc</title>
      <link>/oi/dbimport_151/</link>
      <pubDate>Mon, 20 Apr 2015 21:17:44 +0000</pubDate>
      
      <guid>/oi/dbimport_151/</guid>
      <description>在颓废了一天之后决定写一个题解.因为我觉得这题挺有意思.
我们需要转化一下式子.把原来的a,b改成A,B.设d=gcd(A,B),A=ad,B=bd.
那么(a+b)d | abd2,即(a+b)|ab*d.
又因为gcd(a,b)=1,所以(a+b)一定与a,b都互质.于是(a+b)|d.
设t*(a+b)=d.那么因为bd≤n,所以t(a+b)*b≤n.那么b是sqrt(n)级别的.且我们只需要统计三元组(a,b,t)的个数就行了.
answer=∑b∑a(n/b)/(a+b)(gcd(a,b)=1)然后这个玩意看上去好像是个长得怪异一点的狄利克雷卷积啊.
于是就是要求[l, r]中与b互质的数的个数?这个玩意等于∑i|bu(i)*(r/i).然后发现可以把b分解质因数.而且只留下u不为0的.于是就能出奇迹辣好厉害ovo</description>
    </item>
    
    <item>
      <title>bzoj3992 [Sdoi2015]序列统计</title>
      <link>/oi/dbimport_220/</link>
      <pubDate>Thu, 16 Apr 2015 17:25:12 +0000</pubDate>
      
      <guid>/oi/dbimport_220/</guid>
      <description>好玩的数论题。想想发现可以像快速幂一样跑。然后就是思考如何转移优化。
发现模数比较奇怪。居然是fnt的模数ovo那就要用fft喽？可是这里是乘啊。木有关系喽，因为m是素数，所以它一定有原根。于是可以取原根的幂次，就变成加辣。
这种东西我自己当然想不出来ovo
同余系下的东西真有趣ovo</description>
    </item>
    
    <item>
      <title>bzoj2466 [中山市选2009]树</title>
      <link>/oi/dbimport_144/</link>
      <pubDate>Wed, 15 Apr 2015 20:30:02 +0000</pubDate>
      
      <guid>/oi/dbimport_144/</guid>
      <description>之前听说是异或高消？好神的感觉。
然后可以树形dp嘛！为啥网上题解这么误导ovo
就是f[u][i][j]表示u这个点有没有亮，有没有被按开关。完了嘛。
无语了辣。</description>
    </item>
    
    <item>
      <title>bzoj3944 sum</title>
      <link>/oi/dbimport_218/</link>
      <pubDate>Mon, 13 Apr 2015 23:41:20 +0000</pubDate>
      
      <guid>/oi/dbimport_218/</guid>
      <description>比较神奇的数学题.首先你得听说过一个东西叫Mertens函数.于是你可以找到一篇论文.然后你发现它是英文的.试图理解了很久没有成功.
然后终于有人良心贴出了一个blog.这回懂辣开心ovo
其实就是那一个公式:F(n) = ∑一堆约数 + ∑k=2nF([n/k])
然后发现mu和phi的左边一堆都是可以O(1)算的辣.右边强行记搜可以做到O(n2/3)的辣.
然后手写个hash啥的就能跑得飞快的辣.</description>
    </item>
    
    <item>
      <title>spoj235 Very Fast Multiplication</title>
      <link>/oi/dbimport_277/</link>
      <pubDate>Mon, 13 Apr 2015 20:46:02 +0000</pubDate>
      
      <guid>/oi/dbimport_277/</guid>
      <description>水水的fft啦.主要是来mark一下数论版fft.
有一个奇妙的东西叫原根.这个玩意要乘(p-1)次才能乘回自己.然后如果(p-1)含有很多很多个2的话,就可以拿来做fft辣.其实就是解决了fft的单位根,不用complex.剩下的照搬好辣.
水ovo.在这个前不着村后不着店的四星酒店里好无语ovo</description>
    </item>
    
    <item>
      <title>bzoj3549 [ONTAK2010]Tower</title>
      <link>/oi/dbimport_200/</link>
      <pubDate>Sat, 11 Apr 2015 15:08:19 +0000</pubDate>
      
      <guid>/oi/dbimport_200/</guid>
      <description>比较神奇的dp题.其实也不能算dp辣ovo
有一个神奇的事情是,塔的高度与底层的宽度是负相关的.
所以就变成了问塔底最窄的时候塔有多高.
用f[i]来表示用从第i个砖块到第n个砖块搭起来的塔的最窄底层宽度.用s[i]来表示宽度的前缀和,然后得到一个式子:
f[i] = min(s[j-1]) - s[i - 1] (f[j] ≤ s[j - 1] - s[i - 1], j &amp;gt; i)
s是单调的.看上去很像是dp呢.
然后就变成了求s[j - 1] - f[j] ≥ s[i - 1]时的最大的s[j - 1].于是开单调队列搞吧ovo</description>
    </item>
    
    <item>
      <title>bzoj3940 [Usaco2015 Feb]Censoring</title>
      <link>/oi/dbimport_216/</link>
      <pubDate>Fri, 10 Apr 2015 22:50:06 +0000</pubDate>
      
      <guid>/oi/dbimport_216/</guid>
      <description>自从会了sam,似乎已经不知道acam该怎么写了ovo
这个题就是强行用ac自动机记录匹配到某个位置的时候的状态.然后如果走到一个终态的话就可以强行删掉一段,然后把当前状态变为上一个状态.
最初没有想到有可能会连续删除,于是挂了很久.最后用官网上的数据还是过不了第9个点,然后交bzoj居然过了.好神奇.我猜想是迅雷挂了hhh毕竟usaco的数据用wget根本搞不下来好伤心.
所以我还是太弱ovo</description>
    </item>
    
    <item>
      <title>bzoj2216 [Poi2011]Lightning Conductor</title>
      <link>/oi/dbimport_130/</link>
      <pubDate>Thu, 09 Apr 2015 07:40:46 +0000</pubDate>
      
      <guid>/oi/dbimport_130/</guid>
      <description>idy居然会开1d-1d这个坑ovo之前听讲的时候也只是觉得很神奇,没有真正手写过,所以不明觉厉.
这个东西需要实际问题实际分析.总的思路就是利用决策的单调性.
对于这题,设f(x)=sqrt(x-j)+a[j].那么显然它是凸的.然后若干个它还可以拼成一个奇怪的凸壳状的分段函数.然后我们要取每段的极值.怎么有种半平面交的变形的感觉.
然后发现每次插入的函数的j单增,既x单增.于是只需要开一个双端出的队列就好了.然后每次二分一下两个函数的交的x坐标.其它时候可以完全单调性搞定.
然后算的时候用double会方便很多.
似乎很有意思啊hhh</description>
    </item>
    
    <item>
      <title>bzoj3887 [Usaco2015 Jan]Grass Cownoisseur</title>
      <link>/oi/dbimport_212/</link>
      <pubDate>Wed, 08 Apr 2015 20:03:05 +0000</pubDate>
      
      <guid>/oi/dbimport_212/</guid>
      <description>明明就是usaco的水题嘛有啥好写的ovo只是想mark一下刚自己想出来的非递归的正常版的tarjan.
这题思路灰常简单.就tarjan缩scc然后在dag上找一下最长路就完了.
然后就是非递归的tarjan.考虑平时用栈建树的dfs序的方法,既把一个点的所有儿子扔进栈再递归.然而这个方法不能直接套进tarjan的dfs.因为它的一个儿子可能会对另一个儿子造成影响,有可能甚至直接改变dfs的顺序.
所以如果更新的时候一个点连出去的点还没有被访问,那么不管它是否已经在栈里,都再把它扔进去一次.这样就保证了访问的顺序.而在再次访问的时候只要判断一下是否已经访问就行了.
然后对于两个更新,首先如果直接low[p]=dfn[p]的话是不需要专门去用dfn来取min的.然后考虑倒着更新.每个点被退visit栈的时候去更新它的父亲就好.因为它的父亲一定还没有出栈.然后如果是只更新不递归那就直接访问.
这样的话空间复杂度会变成O(n+m),不过妈妈再也不用担心我暴栈了.而这个方法也比强行模拟系统栈要方便一些.
开心ovo</description>
    </item>
    
    <item>
      <title>bzoj1211 [HNOI2004]树的计数</title>
      <link>/oi/dbimport_119/</link>
      <pubDate>Mon, 06 Apr 2015 22:20:35 +0000</pubDate>
      
      <guid>/oi/dbimport_119/</guid>
      <description>网没救啦.然后发现看电影居然看得无聊了.于是去愉快地刷题了ovo
来复习一下一个叫prufer序列的东西.它是用来做生成树计数的.考虑一棵有标号的树,每次把叶子中编号最大的一个节点的唯一一条边的另一边扔进序列尾部,然后把它扯了,直到只剩俩点.然后发现这个序列对于一棵树是唯一的,且一个序列对应唯一的树.且这个序列的取值全都是1到n的数,无相互限制.这也是为啥完全图的生成树个数是nn-2.
然后这个题是给定度数嘛,于是就是对于每个点要求在prufer序列中出现次数一定.那也很好做的啦.
然后要注意的是有一堆无解的情况要先判断一下.然后听说写c++要小心暴long long.我强行python无压力啦ovo</description>
    </item>
    
    <item>
      <title>bzoj3163 [Heoi2013]Eden的新背包问题</title>
      <link>/oi/dbimport_178/</link>
      <pubDate>Mon, 06 Apr 2015 21:08:25 +0000</pubDate>
      
      <guid>/oi/dbimport_178/</guid>
      <description>似乎是去年省选集训的时候见过啊ovo还记得当年因为把背包写错了所以被唱歌了ovo
比较有意思的题.这个题询问数是骗人的ovo其实是预处理然后O(1)询问.
把如果强行预处理的话时间是O(n3)的.于是考虑一些奇怪的黑暗.把物品强行分块.对于每一个块,可以知道它左边的总答案,右边的总答案.这个是可以O(n2)的.(二进制背包的log就忽略了)然后把左边和右边合并一下,这个是平方的.然后对于块内的每个物品,把其它的物品拿来强行跑一遍背包,这个对于一个物品的复杂度是O(n1.5)的.于是就奇妙地少了O(n0.5)的复杂度.然后就可过了ovo
我当年是怎么想到的ovo还是我当年黑暗过去了ovo</description>
    </item>
    
    <item>
      <title>bzoj2251 [2010Beijing Wc]外星联络</title>
      <link>/oi/dbimport_132/</link>
      <pubDate>Mon, 06 Apr 2015 13:51:17 +0000</pubDate>
      
      <guid>/oi/dbimport_132/</guid>
      <description>后缀数组的基础题ovo好久没写sa了还自己yy了半天ovo
为啥感觉每次写sa写得都不一样ovo
求出height数组之后,如果一个位置的height大于上一个位置的,那么高出来的这一截都是新的一个答案.那么直接朴素地去找它出现了多少次就好了.我相信出题人没有办法构造数据把我卡到三方.
所以各种题都要再复习一下ovo</description>
    </item>
    
    <item>
      <title>bzoj3611 [Heoi2014]大工程</title>
      <link>/oi/dbimport_204/</link>
      <pubDate>Mon, 06 Apr 2015 11:17:41 +0000</pubDate>
      
      <guid>/oi/dbimport_204/</guid>
      <description>继续填idy的坑ovo
这个题就是比sdoi那个题要麻烦一些.于是我决定把虚树建成真正的树来跑dp.然后这个树形dp似乎没啥麻烦的东西.就是给你一棵有关键点的树求所有点对的距离和,距离min和max.
常数又被吊打ovo无语喽.</description>
    </item>
    
    <item>
      <title>bzoj2286 [Sdoi2011]消耗战</title>
      <link>/oi/dbimport_134/</link>
      <pubDate>Mon, 06 Apr 2015 10:11:26 +0000</pubDate>
      
      <guid>/oi/dbimport_134/</guid>
      <description>idy又开坑辣.居然开的是虚树.
然后发现我好像还是不会ovo我太弱了ovo而且idy自带常数优化+代码长度优化根本打不过ovo
这个题算是相对比较容易的虚树吧.强行模拟一遍缩掉所有没有用的边之后的dfs就好了.中间要讨论一下几个点的祖先关系.yy起来还比较清晰.
然后似乎就没有啥要说的了ovo
Upd:早上起来脑洞一开发现似乎不需要讨论当前的点已经在栈里的情况啊ovo</description>
    </item>
    
    <item>
      <title>bzoj3218 a &#43; b problem</title>
      <link>/oi/dbimport_180/</link>
      <pubDate>Sun, 05 Apr 2015 22:08:21 +0000</pubDate>
      
      <guid>/oi/dbimport_180/</guid>
      <description>gui vfk.
在hdsdfz听讲过的题.
可持久化seg tree优化建边.好像一句话就能说清楚啊.
然后证明了我的网络流的姿势严重不科学ovo
然后bzoj上样例居然是图片ovo于是附上手打的样例ovo
10 0 1 7 3 9 2 7 4 0 9 10 5 1 0 4 2 10 2 7 9 1 5 7 2 6 3 5 3 6 2 6 6 4 1 8 1 6 1 6 0 6 5 2 2 5 0 9 3 5 1 3 0 2 5 5 6 7 1 1 2 </description>
    </item>
    
    <item>
      <title>bzoj2896 桥</title>
      <link>/oi/dbimport_169/</link>
      <pubDate>Sun, 05 Apr 2015 14:16:04 +0000</pubDate>
      
      <guid>/oi/dbimport_169/</guid>
      <description>有点像xyz在wc的时候讲的动态图连通性问题.不过这个看上去要水些啊.
考虑建一棵生成树,那么所有剩余的边覆盖了的边就不是桥.如果没有被覆盖就是桥.
于是这个题可以倒过来,支持加边和查询两点间没有被覆盖的边数.
似乎挺水.
完了.</description>
    </item>
    
    <item>
      <title>bzoj2182 [Spoj1479]The GbAaY Kingdom最小直径生成树</title>
      <link>/oi/dbimport_128/</link>
      <pubDate>Fri, 03 Apr 2015 20:34:55 +0000</pubDate>
      
      <guid>/oi/dbimport_128/</guid>
      <description>下午写的东西被奇妙地吞掉了ovo
最小直径生成树,一定不要用sort,否则会tle.
首先考虑一个绝对中心的概念.既在生成树上它是所有直径的严格中心.它有可能在点上,也有可能在边上.
于是我们枚举边,试图让这个绝对中心在这条边上.那么每个点都选择到这条边的最短路树来生成.如果两个端点的最长链的差距不是很大,那么就有可能在这条边上找到最小直径生成树的绝对中心.
考虑绝对中心对一个端点的距离,会对每个点形成一个峰形的函数.要找的答案就在相邻两个峰之间.于是可以利用两边直线k相同,把b排序之后直接做.总复杂度O(n3).
然后如果每个边强行排序只会多个log,但是会tle.</description>
    </item>
    
    <item>
      <title>bzoj3238 [Ahoi2013]差异</title>
      <link>/oi/dbimport_184/</link>
      <pubDate>Fri, 03 Apr 2015 10:39:33 +0000</pubDate>
      
      <guid>/oi/dbimport_184/</guid>
      <description>考试的时候do big die去刷bzoj.大概下午会hug zero.
sam的第二题.其实这个玩意是应该用sa做的,不过现在我觉得sa没有sam简单.虽然sam的构造和性质还是一团大雾.
这个题可以做出原串的后缀树,然后在上面dp一下.每个点对答案的贡献为任意两个不在同一子树的终态对数*深度.
然后倒过来建sam,它的parent树就是原串的后缀树.虽然我还没有成功理解这个东西.
然后坑了一会的一件事情是新建的nq节点的right集合为空.因为它只是一个扩展点,但是不是一个接受态ovo
我还是太弱啊怎么办.</description>
    </item>
    
    <item>
      <title>bzoj3772 精神污染</title>
      <link>/oi/dbimport_206/</link>
      <pubDate>Wed, 01 Apr 2015 21:50:09 +0000</pubDate>
      
      <guid>/oi/dbimport_206/</guid>
      <description>idy又开坑辣,虽然是个无聊的无聊题.
考虑每条路径会被哪些路径包含.那条路径的两个端点一定是在条路径的两个端点的子树上.(如果这两个点有祖先关系,那么需要重新makeroot一下)
当然我不是说要用Lct.直接用可持久化线段树在dfs序上把路径存下来就完了.</description>
    </item>
    
    <item>
      <title>bzoj3509 [CodeChef] COUNTARI</title>
      <link>/oi/dbimport_196/</link>
      <pubDate>Wed, 01 Apr 2015 20:01:08 +0000</pubDate>
      
      <guid>/oi/dbimport_196/</guid>
      <description>好难得自己去开坑hhhhh
其实之前看过做法,觉得有点麻烦.于是拖到现在.然后荣登最慢yeah.不知道那些又短又快的东西是怎么来的.肯定和我不是一个写法的啦.
我的做法是把序列每b个分成一块.对于同一块,直接b2求内部有三个点或者两个点的等差三元组的数量.
对于分别在3块的,对每块把两边的所有东西卷积一次来统计.
其实也没啥技术含量ovo</description>
    </item>
    
    <item>
      <title>bzoj2395 [Balkan 2011]Timeismoney</title>
      <link>/oi/dbimport_138/</link>
      <pubDate>Wed, 01 Apr 2015 16:03:54 +0000</pubDate>
      
      <guid>/oi/dbimport_138/</guid>
      <description>谁说最小乘积生成树是取log了ovo题意都不一样好么.
首先这个东西一定在一个像是下凸壳一样的东西上.其实是一个反比例函数的k的最小值.
把x和y的和看作坐标,求在(x0,y0)与(x1,y1)中间的一个点,为了平均分配,要取那个三角形最大,于是可以用叉积弄出一个式子来当作x和y的系数,这样就可以直接kruskal求最小生成树了.
如果求出来的点在这个线段上,那这个区间就不用再找了.否则还得去两边继续递归.
然后最初的左端点和右端点就取x的最小生成树和y的最小生成树就好了.
这个时间复杂度似乎还是没有保证啊.有点像自适应simpson的感觉,虽然这个肯定是精确的.然后跑起来也比较快.有意思.
这个玩意还是比较好写的.虽然中间kruskal把0打成1,看了半天ovo</description>
    </item>
    
    <item>
      <title>bzoj2986 Non-Squarefree Numbers</title>
      <link>/oi/dbimport_175/</link>
      <pubDate>Tue, 31 Mar 2015 19:42:17 +0000</pubDate>
      
      <guid>/oi/dbimport_175/</guid>
      <description>比较好想的dfs容斥，然后二分答案。
就只用dfs不超过sqrt(n)的素数的平方和。</description>
    </item>
    
    <item>
      <title>bzoj2820 yy的gcd</title>
      <link>/oi/dbimport_163/</link>
      <pubDate>Tue, 31 Mar 2015 10:41:02 +0000</pubDate>
      
      <guid>/oi/dbimport_163/</guid>
      <description>idy又开坑辣。
mobius反演题么么哒。强行sqrt(n)的询问。
于是推一下式子。
answer = ∑i∑j1 (gcd(i, j) = 1)
= ∑&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;∑&amp;lt;sub&amp;gt;g&amp;lt;/sub&amp;gt;u(g) * (n/(p*g)) * (m/(p*g)) 然后把p和g合起来设为v。
h(v) = ∑ u(v) (v = x/p)
然后发现h(v)函数是很好推的。
h(px) = (x % p == 0) ? (u(x)) : (u(x) - h(x))
然后就搞定啦orz.</description>
    </item>
    
    <item>
      <title>bzoj3597 [Scoi2014]方伯伯运椰子</title>
      <link>/oi/dbimport_202/</link>
      <pubDate>Sun, 29 Mar 2015 21:19:17 +0000</pubDate>
      
      <guid>/oi/dbimport_202/</guid>
      <description>去年的省选题.之前知道了是找负环.不过一直感觉好迷是个坑.最近又想了想发现也不是很麻烦.
当年省选的时候完全对比例题无感啊.经过一年之后终于觉悟了一点东西.
考虑一个网络流,每条边的流量上限是inf,只有从源出来的边不是.然后如果进行一次正向增广会使代价增加b+d,如果进行一次逆向增广的话代价会增加a-d,前提是有流量.于是只要二分一个答案,看下存不存在一个负环来增广就好了.
然后一个spfa就迷之拿了bzoj的rank1.好开心.</description>
    </item>
    
    <item>
      <title>bzoj3922 Karin的弹幕</title>
      <link>/oi/dbimport_214/</link>
      <pubDate>Sun, 29 Mar 2015 20:31:45 +0000</pubDate>
      
      <guid>/oi/dbimport_214/</guid>
      <description>迷之数据结构.我的想法比较简单,确定一个值b,对所有小于b的k建线段树维护,对大于b的k直接朴素找.
于是时间复杂度算起来比较迷.
试了一下发现b取20的时候能过.虽然还是跑得最慢的一个.无语喽.大概我不是正解.</description>
    </item>
    
    <item>
      <title>bzoj2289 POJ Challenge圆，圆，圆</title>
      <link>/oi/dbimport_136/</link>
      <pubDate>Sat, 28 Mar 2015 21:48:13 +0000</pubDate>
      
      <guid>/oi/dbimport_136/</guid>
      <description>白天讲课讲到的题。感觉比较有意思于是就去写了。然后这也是我超过于教授的题。感觉还是挺有意义的。
之前遇到过这个题。不过没有想出比较靠谱的方法。然后就用黑暗水过了。这回算是来对地方了。
做法比较简单。二分一个xo，看x=xo这条直线上有没有一部分被所有圆覆盖。如果有就ok。没有的话，如果有圆完全在它左或者它右，那么可以确定二分往哪边走或者无解。否则去随便找两个不相交的圆。如果它们在不同侧那就没有解了。在同一侧也可以确定方向。虽然我觉得没解这个地方需要再想想严格的证明。
不过反正填了2个点分之后终于写了道有意思的题，开心ing。
Historical Comments Unknown friend at 2016-01-18T08:27:34 @bzoj2289: “否则去随便找两个不相交的圆。如果它们在不同侧那就没有解了。” QAQ这里是有反例的……！ &amp;mdash;- anonymous
Unknown friend at 2016-01-18T08:27:34 @bzoj2289: “否则去随便找两个不相交的圆。如果它们在不同侧那就没有解了。” QAQ这里是有反例的……！ &amp;mdash;- anonymous
Unknown friend at 2016-01-18T22:40:55 @bzoj2289: 也许是吧= =表示高考解析几何比这玩意好玩多了ovo还有啊匿名是几个意思ovo &amp;mdash;- laekov
Unknown friend at 2016-01-18T22:40:55 @bzoj2289: 也许是吧= =表示高考解析几何比这玩意好玩多了ovo还有啊匿名是几个意思ovo &amp;mdash;- laekov</description>
    </item>
    
    <item>
      <title>bzoj3784 树上的路径</title>
      <link>/oi/dbimport_208/</link>
      <pubDate>Fri, 27 Mar 2015 21:33:23 +0000</pubDate>
      
      <guid>/oi/dbimport_208/</guid>
      <description>又是idy开的坑。感觉回去要被他吊打致残。
树分治。最开始想用二分，然后直接去每个分治点上查询。这样的总复杂度是O(n*log3n)的。不过感觉常数比较小而且绝对省代码，只用二分不用数据结构。然后发现要输出所有的边。这个算法要用容斥一样的东西来减，根本搞不定。
于是向mhy学习。使用类似noi那个超级钢琴的思路，每次把最大的一条路径找出来，然后找它的替代品。树分治后，对于每一个树上的团，算出它的dfs序。默认一个点与dfs序在它前面的区间中最深的连边。这样就可以保证不重，也比较好写。然后用堆来维护。堆中一个点需要记录的信息是这个点的答案，线段树的根，左右端点，这个点到分治团的根的距离。然后每次找出一个最大的之后把它的区间再折成两半扔回堆里就好啦。
比较神的做法。感觉我自己是想不出来的。要是考场上遇到还真会出事呢。郁闷ing。</description>
    </item>
    
    <item>
      <title>bzoj2698 染色</title>
      <link>/oi/dbimport_155/</link>
      <pubDate>Fri, 27 Mar 2015 10:26:10 +0000</pubDate>
      
      <guid>/oi/dbimport_155/</guid>
      <description>没有五笔好烦。
无语的期望题。AC第一页最长。
首先用像借教室一样的做法去求每个位置被覆盖了多少次。然后一个下降的序列需要求导再积回来。然后发现要加回来，这个东西是不能积的。于是坑了我好久。
最后期望就是∑1-Pim。其中Pi表示第i个点被任意一个区间覆盖的概率。
水过去啦。</description>
    </item>
    
    <item>
      <title>bzoj1095 [ZJOI2007]Hide 捉迷藏</title>
      <link>/oi/dbimport_114/</link>
      <pubDate>Thu, 26 Mar 2015 23:36:27 +0000</pubDate>
      
      <guid>/oi/dbimport_114/</guid>
      <description>迷一样的欧拉序列的题。然后似乎只有岛君的题解能看啊233。
其实就是在欧拉序列上，两点u,v之间的距离=(dfb[u], dfe[v]]之间未匹配的括号数（左开右闭）。其中dfb表示左括号的位置，dfe表示右括号的位置。
然后就是写一个线段树去维护了。写得比较丑，把所有数对都记下来了。其实只用记和跟差就行了。然后要强制如果一端是空的那么这个点就不能作为端点。完了。
然后dfs这一步越写越短了，开心hhh。
于是代码巨长还巨丑还巨慢。</description>
    </item>
    
    <item>
      <title>bzoj2806 ctsc2012 Cheat</title>
      <link>/oi/dbimport_161/</link>
      <pubDate>Wed, 25 Mar 2015 20:13:37 +0000</pubDate>
      
      <guid>/oi/dbimport_161/</guid>
      <description>我的SAM第一题。按照惯例几乎是照着std抄的OVO。本来以为是要在SAM上DP，后来发现好像是并列的，于是比较开心。
SAM这个东西主要就是用来匹配子串用的。建法详见clj的课件，然后现在我还处于消化状态中。
SAM匹配多个串的话也比较好弄，直接在串末再加一个字符集里没有的元素就好了。
现在假设已经用SAM匹配出了第i个位置往左ml[i]个位置都是可以匹配的，那么可以二分一个答案，然后用单调队列来DP判断。写法比较简单，虽然我急着去写SAM所以这部分也是蒙过去的。
然后网上的2个std就有2种不同的答案还和我不一样。最后还是wd学长的代码靠谱orz。
现在我可以说我是写过SAM的人了哈哈。</description>
    </item>
    
    <item>
      <title>bzoj3221 Codechef FEB13 Obserbing the tree树上询问</title>
      <link>/oi/dbimport_182/</link>
      <pubDate>Mon, 23 Mar 2015 22:08:32 +0000</pubDate>
      
      <guid>/oi/dbimport_182/</guid>
      <description>很早之前就看过的题。一直被数据范围吓到，然后感觉也比较难写所以都没写。后来发现还是挺好的。
就重链dfs序维护一下每个位置的和，然后可持久化一下就完了。然后一个常数优化是如果这个点是在这次修改的时候建的，那么就直接覆盖而不是新建点。然后跑得就比较快了。</description>
    </item>
    
    <item>
      <title>bzoj3328 PYXFIB</title>
      <link>/oi/dbimport_190/</link>
      <pubDate>Sun, 22 Mar 2015 21:22:04 +0000</pubDate>
      
      <guid>/oi/dbimport_190/</guid>
      <description>上课讲的神题。构造公式。本来用HTML写了一堆公式的。然后天杀的网就断了要我重新开然后就没了。很想骂人。那就不写了呗，自行翻课件或者yy。</description>
    </item>
    
    <item>
      <title>bzoj2700 聚会</title>
      <link>/oi/dbimport_157/</link>
      <pubDate>Fri, 20 Mar 2015 22:40:35 +0000</pubDate>
      
      <guid>/oi/dbimport_157/</guid>
      <description>比较基础的dp。不过因为权限的原因好像做的人不多。
首先肯定先泡便宜的茶再泡贵的茶。
然后记一下上一种茶是啥，连续泡了几次。
于是用f[i][j][k][l]表示泡了i个红茶，j个绿茶，上一种茶是k，连续泡了l次的最小花费。转移是O(1)的。然后后两个反正都要手拆开，所以干脆压下来了。
似乎很水的样子。</description>
    </item>
    
    <item>
      <title>bzoj2683 简单题</title>
      <link>/oi/dbimport_153/</link>
      <pubDate>Fri, 20 Mar 2015 20:26:17 +0000</pubDate>
      
      <guid>/oi/dbimport_153/</guid>
      <description>水水的cdq。久了不写练一下手。然后发现犯了一堆逗错。幸好没过样例不然就do big die了。</description>
    </item>
    
    <item>
      <title>bzoj2400 Spoj839 Optimal Marks</title>
      <link>/oi/dbimport_140/</link>
      <pubDate>Thu, 19 Mar 2015 22:59:07 +0000</pubDate>
      
      <guid>/oi/dbimport_140/</guid>
      <description>多年之前讲过的最小割。
比较好想啦。
把每一位拆开。然后单独跑一遍最小割。各种连边。然后以答案为高位，数字和为低位跑就行了。
好像也没说清楚怎么建图啊。
对于原图中已经确定的点，如果它是1，就从源连过来，否则连向汇。对于每一个未知的点，把所有边建出来。然后再向汇连个1的边来表示它如果选1的话就要产生贡献。然后就差不多了吧。脑补一下。</description>
    </item>
    
    <item>
      <title>bzoj2482 Spoj1557 Can you answer these queries II</title>
      <link>/oi/dbimport_146/</link>
      <pubDate>Thu, 19 Mar 2015 22:58:43 +0000</pubDate>
      
      <guid>/oi/dbimport_146/</guid>
      <description>原来备案还没过。那之前是怎么成功访问的囧。
写了一晚上。教训还是之前那个，写之前要想清楚。写完再去改就很烦。自己yy了很久，虽然最初是听了mhy的一句提醒。好有危机感。
首先这个东西可以离线。之前一直在想在线怎么做然后也觉得没法做。
把询问按右端点排序之后问题就转化成了左端点在一个范围里的时候的最大子段。
然后用一个线段树表示从i到current right的时候的和，这个玩意可以直接区间加。然后再去维护这个东西的历史最大值。于是就变成了每个位置上接了一个add序列，要找它的前缀最大值。那么只需要存两个东西：当前的和以及当前的最大前缀和，就可以合并了。
然后线段树上维护两个add序列，分别是对整个线段的lazy tag of add和max value of son。就可写了。
然后好像跑得很慢啊TT。</description>
    </item>
    
    <item>
      <title>hdu5189 zhx&#39;s tree</title>
      <link>/oi/dbimport_252/</link>
      <pubDate>Mon, 16 Mar 2015 22:35:14 +0000</pubDate>
      
      <guid>/oi/dbimport_252/</guid>
      <description>自己出的题还要写题解。
就是化成可以二分的形式，然后发现是找凸壳上x=x0的时候的最大值的和，看它是否大于0。
于是就写呗。据说很难写。我觉得写起来还行啊。
其实主要是为了测试系统用的。</description>
    </item>
    
    <item>
      <title>BZOJ3598 [Scoi2014]方伯伯的商场之旅</title>
      <link>/oi/i11rimport_002/</link>
      <pubDate>Wed, 11 Mar 2015 19:16:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_002/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 题目名字好长。&amp;lt;/p&amp;gt; &amp;nbsp;
当年在考场上只会分块打表的题。
&amp;nbsp;
前几天有人讲之后觉得大概可做。而且好像那个方法很优秀。
&amp;nbsp;
于是我难得地去写了一回不用记搜且不记上界的数位dp。感觉这个玩意写出来很短，但是思考和调试的复杂度变高了。我觉得是状态定义变得不明确的原因。也许再补一些题就好了。
&amp;nbsp;
考虑先让所有都合并到最低位，一个基础数位dp。（然后写丑了好久）
&amp;nbsp;
然后考虑如果把一个数字的集合位置从p移动到p+1，设这个数字从低位到高位是a[0]..a[n-1]，那么贡献就是∑a[0..p]-∑a[p+1..n-1]。显然当p从右往左移动的时候它是会先负后正的。如果它负的话就减，否则就不玩了。可以发现它们互相不影响。于是对于每一个p单独计算一遍贡献就行了。
&amp;nbsp;
然后还是没有原版跑得快。OTL。
&amp;nbsp;
#define PROC &#34;shop&#34; #include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
typedef long long dint; #ifdef WIN32 #define lld &amp;ldquo;%I64d&amp;rdquo; #else #define lld &amp;ldquo;%lld&amp;rdquo; #endif #define _l (long long int)
const int maxn = 53; const int maxm = 509; const int mb = 253;
dint l, r; int n, m, bs, a[maxn];</description>
    </item>
    
    <item>
      <title>BZOJ1604 [Usaco2008 Open]Cow Neighborhoods 奶牛的邻居</title>
      <link>/oi/i11rimport_003/</link>
      <pubDate>Wed, 11 Mar 2015 14:47:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_003/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 在一道usaco的题上wa了三次。我也是厉害。&amp;lt;/p&amp;gt; &amp;nbsp;
其实好像有简单做法的。不过我是要脑补一下曼哈顿最小生成树。
&amp;nbsp;
对于一个平面图上的点的曼哈顿最小生成树，一定存在一种方案，使得每个点的度数至多为8。也就是说以斜率为0,inf,1,-1的四条直线分出来的八个区域里各有一个点就行了。然后是可以保证的。
&amp;nbsp;
于是就是拿俩树状数组扫四遍就行了。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstdlib&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
const int inf = 0x3f3f3f3f;
struct point { int x, y, i; point() { x = -inf, y = -1; } point(int xo, int yo) { x = xo, y = yo; } inline void init(int ix) { scanf(&amp;quot;%d%d&amp;quot;, &amp;amp;x, &amp;amp;y); i = ix; } };
inline bool operator &amp;lt;(const point&amp;amp; a, const point&amp;amp; b) { return (a.</description>
    </item>
    
    <item>
      <title>BZOJ1814 Ural 1519 Formula 1</title>
      <link>/oi/i11rimport_008/</link>
      <pubDate>Sat, 07 Mar 2015 17:02:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_008/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 插头dp的练手题么。虽然之前还没写过哈密顿回路的题。&amp;lt;/p&amp;gt; &amp;nbsp;
学习了一下广义括号法。发现状态数比之前记连通性的方法要少。仔细想想发现，两个连通的插头的顺序有关。不能存在1212这种东西。所以连通性的方法记了很多废状态。那把连通性方法改进一下会不会变得更快呢？可以研究一下。我觉得应该是等效了吧。
&amp;nbsp;
今天的debug时间明显缩短了。虽然还是debug了老半天。然后怎么代码还是那么长。想起我每次都觉得把东西挤到一起看起来很不雅观，于是去写一堆找转移的函数。晕。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
typedef long long dint; #ifdef WIN32 #define lld &amp;ldquo;%I64d&amp;rdquo; #else #define lld &amp;ldquo;%lld&amp;rdquo; #endif #define _l (long long int)
const int maxn = 15; const int maxst = 50009;
#define mbit(x,y) ((x)&amp;lt;&amp;lt;((y)&amp;lt;&amp;lt;1)) #define gbit(x,y) (((x)&amp;gt;&amp;gt;((y)&amp;lt;&amp;lt;1))&amp;amp;3) #define cbit(x,y) ((x)&amp;amp;(~(3&amp;lt;&amp;lt;((y)&amp;lt;&amp;lt;1))))
int n, m, tots, slst[maxst]; bool mp[maxn][maxn]; dint f[2][maxst];
void dfsState(int l, int c, int z) { if (l == m + 1) { if (!</description>
    </item>
    
    <item>
      <title>BZOJ2402 陶陶的难题II</title>
      <link>/oi/i11rimport_009/</link>
      <pubDate>Sat, 07 Mar 2015 13:39:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_009/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; orz mhy。看mhy的刷题记录成为了我成天的刷题方向了。&amp;lt;/p&amp;gt; &amp;nbsp;
其实最初也没有想清楚。然后看了一眼mhy写的题解写了凸壳，秒懂。
&amp;nbsp;
二分一个答案，设它是ans。如果ans≥realAns的话，那么就会存在yi-ans*xi+qj-ans*pj≥0。然后i和j就分开了。于是变成了求一条路径上yi-ans*xi的最大值。把xi看作k，把yi看作b，就变成半平面交了。于是开归并式线段树把凸壳给记录下来就好了。然后复杂度大约是单次询问O(lg3(n))的？链剖后每棵树单独建树，然后复杂度我就不会算了TT。
&amp;nbsp;
于是就硬着头皮写了，然后发现跑得还挺快。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cmath&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
const int maxn = 30009; const int maxl = 15; const int max_buf = maxn * maxl * 2; const double eps = 1e-6; const double finf = 1e10;
int ibuf_arr[max_buf], *ibuf(ibuf_arr); double fbuf_arr[max_buf], *fbuf(fbuf_arr);
struct edge { int t; edge *next; };
struct line { double k, b; inline double xCross(const line&amp;amp; a) { return (a.</description>
    </item>
    
    <item>
      <title>BZOJ1513 [POI2006]Tet-Tetris 3D</title>
      <link>/oi/i11rimport_010/</link>
      <pubDate>Fri, 06 Mar 2015 22:25:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_010/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 这么水的题居然还要写题解。要不要说我写了半个下午+半个晚上。&amp;lt;/p&amp;gt; &amp;nbsp;
丧心病狂想写一发zkw去抢速度rank。然后发现zkw怎么支持区间修改查询TT。课件根本没讲懂。而且max怎么区间加。
&amp;nbsp;
想了很久终于想出了来了。然后交上去发现常数巨大比普通线段树还要慢TT。到头来想想如果我直接写普通线段树说不定十多分钟就能过，而且代码量还会小一些。因为那个是可以直接通用的，但是这个比较麻烦。
&amp;nbsp;
其实写这个就题解就是想记录一下我yy出来的zkw区间修改区间查询的方法。
&amp;nbsp;
这道题是区间查询最大值+区间修改。如果是写一般的线段树，需要记录两个值a和v（至于为啥我用了这俩神奇的字母我也不知道），分别表示当前区间被完整覆盖的修改的最大值（又称lazy标记）和当前区间的最大值。然后所以zkw也要记这两个东西。
&amp;nbsp;
如果我们把zkw看作一棵树，那么每次修改和询问操作的时候都是对一些线段的a和v进行操作。（废话）
&amp;nbsp;
首先考虑修改。zkw经典的变为开区间取中间能处理a值的改变，但是不能处理v值的改变。因为v值改变的线段不一定会被当前区间包含。然后仔细考虑发现a值没有变但是v值变了的点只可能存在于两个端点到根的路径上。那就直接强行更新一发就好了啊。然后更新的区域就变成了一个有点像倒置漏斗的形状。
&amp;nbsp;
再考虑询问。a要覆盖当前区间，v要被当前区间覆盖。那不就是修改把a和v的做法反一下么。
&amp;nbsp;
然后好像也不是很麻烦的样子哈。
&amp;nbsp;
然后常数很大哈。
&amp;nbsp;
那还拿zkw做何用。
&amp;nbsp;
晕。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cctype&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; 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 (!</description>
    </item>
    
    <item>
      <title>BZOJ2704 旅游</title>
      <link>/oi/i11rimport_011/</link>
      <pubDate>Fri, 06 Mar 2015 14:02:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_011/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 居然网上都没有找到程序来和我拍。好吧其实它是一道权限题而且过的人也不多。&amp;lt;/p&amp;gt; &amp;nbsp;
其实就是裸的插头DP。本来想学一下广义括号的然后被状态数吓到了于是只好还是写最小表示。连通性。
&amp;nbsp;
然后我发现最小表示连通性很容易写挂。而在findstate的时候检查一下是个不错的办法。至少这道题靠这个就可以直接debug出来问题了。
&amp;nbsp;
比上次写插头要好许多了。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
typedef long long dint; #define _l (long long int) #define mbit(x,y) ((_l x)&amp;lt;&amp;lt;((y)&amp;lt;&amp;lt;2)) #define gbit(x,y) (((x)&amp;gt;&amp;gt;((y)&amp;lt;&amp;lt;2))&amp;amp;0xf)
const int maxn = 13; const int maxst = 570009;
dint slst[maxst]; int n, m, v[maxn][maxn], tots, f[2][maxst], cnt[17]; bool av[2][maxst];
void dfsState(int l, int tot, dint z) { if (l == m) { for (int i = 1; i &amp;lt;= tot; ++ i) if (cnt[i] !</description>
    </item>
    
    <item>
      <title>BZOJ2178 圆的面积并</title>
      <link>/oi/i11rimport_012/</link>
      <pubDate>Fri, 06 Mar 2015 00:39:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_012/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 计算几何题。别人都用simpson搞。然后我决定不水一发，用hwd神犇在wc上讲的关键点法做。&amp;lt;/p&amp;gt; &amp;nbsp;
然后就搞到了12点半。发现坑数次。还专门用js写了个画圆的。当然我现在知道怎么画圆了。过两天去把oj7的统计图改一改。
&amp;nbsp;
思路是把所有圆的左右端点和所有圆的两两交的x提出来，unique一发（不然会tle显然的）。这样两个x之间的部分的圆弧是不会有交的。那么就可以视为一堆弓形和梯形了。然后扫描一下中位线的有效长度算梯形。每次新进入一个连通区域和出来的时候加相应弓形的面积。
&amp;nbsp;
需要注意按y排序的时候是按弓形与竖线的交点的y，而不是梯形的y，否则会有非常神奇的精度误差。另外算弓形面积必需要用反三角函数（至少我没研究出怎么不用）。如果用acos的话会暴精度暴得很惨。要用atan2来提高精度。
&amp;nbsp;
然后这样写连样例都会tle。仔细感受一下发现好像如果有一堆同心圆的话都会tle。然后考虑去掉包含的圆之后似乎就快了。然后就交了，然后居然跑过了。
&amp;nbsp;
然后来欣赏一下我的时间巨大，空间巨大，长度巨大。挤在一堆simpson里显得特别郁闷的代码。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cmath&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
const double eps = 1e-8; const double pi = acos(-1);
inline int sgn(double x) { return (x &amp;gt; eps) - (x &amp;lt; -eps); } inline double sqr(double x) { return x * x; }
typedef struct geo_obj { double x, y; geo_obj() {} geo_obj(double xo, double yo) { x = xo, y = yo; } inline void read() { scanf(&amp;quot;%lf%lf&amp;quot;, &amp;amp;x, &amp;amp;y); } inline geo_obj vertical() { return geo_obj(-y, x); } inline double len() { return sqrt(sqr(x) + sqr(y)); } } point, vect; inline geo_obj operator +(const geo_obj&amp;amp; a, const geo_obj&amp;amp; b) { return geo_obj(a.</description>
    </item>
    
    <item>
      <title>BZOJ1223 [HNOI2002]Kathy函数</title>
      <link>/oi/i11rimport_014/</link>
      <pubDate>Wed, 04 Mar 2015 18:36:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_014/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 比较神奇的数学题。首先你要知道这个函数的意思是把它的二进制flip。至于怎么来的我也是听说的。然后推一下发现的确是这么回事。&amp;lt;/p&amp;gt; &amp;nbsp;
于是就变成数位dp了。然后我发现数位dp常常可以用奇奇怪怪的方法水过去。然后又发现数组从0开始标号也会造成麻烦。+1-1啥的最讨厌了。
&amp;nbsp;
于是这题就变成高精度练习题了。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
const int maxn = 409;
struct BigInt { int l, a[maxn], base; BigInt(int b = 10) { l = 0; base = b; } void push() { for (int i = 0; i &amp;lt; l - 1; ++ i) { a[i + 1] += a[i] / base; a[i] %= base; } for (; a[l - 1] &amp;gt;= base; ++ l) { a[l] = a[l - 1] / base; a[l - 1] %= base; } } void pull() { for (; l &amp;amp;&amp;amp; !</description>
    </item>
    
    <item>
      <title>BZOJ1023 [SHOI2008]cactus仙人掌图</title>
      <link>/oi/i11rimport_015/</link>
      <pubDate>Wed, 04 Mar 2015 15:40:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_015/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 第六百道题一定要不水！虽然离第一页还有几十道题的距离。&amp;lt;/p&amp;gt; &amp;nbsp;
很早之前见过的题吧。然后一直觉得特别难写所以都没写。以前写点不重复的仙人掌都觉得挺痛苦，更不要说这个了。
&amp;nbsp;
现在想想还行，因为我yy出了化简的方法。先搞出dfs树。然后一个顶点如果是一个环里深度最浅的，那么称它为这个环的头。可以证明一个顶点最多在一个不以它为头的环上。把这个环记下来，其它的环都从这个顶点去找边来找就行了。这样的话可以比较节省代码量，写起来也比较明了。虽然还是比mhy长。
&amp;nbsp;
然后因为我在最后一步dp的时候写了一个static的f数组，所以光荣了。debug了好久。晕。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
struct edge { int t, av; edge *next, *rv; }; struct ball { int l, *a, h; };
const int maxn = 50009; const int maxm = 200009; const int maxarr = 400009;
int n, m, cb, fb[maxn], d[maxn]; int f[maxn], ans, fd[maxn], fe[maxn]; int stc[maxn], tst; int ibuf_arr[maxarr], *ibuf(ibuf_arr); bool vis[maxn]; edge elst[maxm], *ep(elst), *head[maxn]; ball b[maxm];</description>
    </item>
    
    <item>
      <title>BZOJ2734 [HNOI2012]集合选数</title>
      <link>/oi/i11rimport_016/</link>
      <pubDate>Wed, 04 Mar 2015 09:00:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_016/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 最初感觉好多状态怎么做。&amp;lt;/p&amp;gt; &amp;nbsp;
然后发现（其实是瞟了一下题解）如果把一个数分成2a*3b*c，那么c只影响上界。2a*3b中a最大是16，b最大是10，列一张17*11的表出来，然后发现右下方还有很多空东西。于是直接像插头一样状压一下轮廓线呗。反正对一个数有影响的只有它的上面和左边。最近写插头写得有点疯啊。其实它的很多思想都是可以推广出来用的。比如最小表示啥的。
&amp;nbsp;
于是如果直接这样写的话大概要跑30000多次dp，还是比较悬。然后再想想发现只有表里能取的数的形状发生改变的时候才会改变dp的答案。表里面的数很少所以改变次数也应该很少。所以记一下上一次的形状是什么然后比较相不相同，相同就直接沿用。
&amp;nbsp;
然后跑得飞快。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
#define _l (long long int) #define pow2(x) (1&amp;lt;&amp;lt;(x))
const int maxn = 19; const int maxm = 15; const int maxv = 100000; const int maxst = pow2(11) + 9; const int mod = 1e9 + 1;
int f[2][maxst], vl[maxn][maxm], n, m, v; int dis[maxn], ldis[maxn], lans, ans;
void pre() { for (int i = 0; i &amp;lt; maxn; ++ i) { vl[i][0] = (1 &amp;lt;&amp;lt; i); if (vl[i][0] &amp;gt; maxv) vl[i][0] = -1; for (int j = 1; j &amp;lt; maxm; ++ j) if (vl[i][j - 1] &amp;gt; -1) { vl[i][j] = vl[i][j - 1] * 3; if (vl[i][j] &amp;gt; maxv) vl[i][j] = -1; } else vl[i][j] = -1; } }</description>
    </item>
    
    <item>
      <title>BZOJ3242 [Noi2013]快餐店</title>
      <link>/oi/i11rimport_017/</link>
      <pubDate>Tue, 03 Mar 2015 21:18:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_017/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 好吧我的本意是想学习一下dp的。然后发现了这道纠结了一年半还多的题。&amp;lt;/p&amp;gt; &amp;nbsp;
首先把环找出来。然后环上会长一些树。先把树的答案求了，因为它很好求。
&amp;nbsp;
然后考虑环，那么答案应该是随便断一条边之后答案的最小值（而不是最大值）。于是乎记录一下每个点按某个方向到起点的距离，记为d[i]。算一下每个点的树的深度，记为l[i]。于是每次要最大化l[i]+l[j]+|d[i]-d[j]|。反正是最大化所以顺序是没有关系的，但是不能自交。这是个比较容易错的地方。于是就去写个线段树来维护吧。只查询不修改让我总有能线性搞的想法，虽然没想清楚具体怎么实现。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; #include &amp;lt;set&amp;gt; using namespace std;
struct edge { int t, v; edge *next; };
typedef long long dint; #ifdef WIN32 #define lld &amp;ldquo;%I64d&amp;rdquo; #else #define lld &amp;ldquo;%lld&amp;rdquo; #endif #define _l (long long int)
const int maxn = 100009;
edge elst[maxn &amp;lt;&amp;lt; 1], *ep(elst), *head[maxn]; int n, fa[maxn], df[maxn], ol[maxn], d[maxn]; int tlp, lp[maxn &amp;lt;&amp;lt; 1]; dint lv[maxn &amp;lt;&amp;lt; 1], le[maxn &amp;lt;&amp;lt; 1], md[maxn], ans;</description>
    </item>
    
    <item>
      <title>BZOJ1079 [SCOI2008]着色方案</title>
      <link>/oi/i11rimport_019/</link>
      <pubDate>Mon, 02 Mar 2015 21:31:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_019/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 看上去比较不可做的DP。好像别人写的记搜跑得飞快。&amp;lt;/p&amp;gt; &amp;nbsp;
我看我是写最小表示写上瘾了。
&amp;nbsp;
压一下状态，有点像今天第二题。算每种值的有多少。然后直接跑。
&amp;nbsp;
感觉废状态比较多啊，跑得好慢。另外用memset清空高维数组会比较快。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
const int mod = 1e9 + 7; const int maxn = 17; const int maxst = 16009;
#define mbit(a,b) ((a)&amp;lt;&amp;lt;((b)&amp;lt;&amp;lt;2)) #define gbit(a,b) (((a)&amp;gt;&amp;gt;((b)&amp;lt;&amp;lt;2))&amp;amp;0xf) #define _l (long long int)
int m, c[maxn], n, mt, tots, slst[maxst]; int f[2][7][maxst];
void dfsState(int t, int l, int v) { if (l == mt + 1) { slst[tots ++] = v | t; } else { for (int i = 0; i &amp;lt;= t; ++ i) dfsState(t - i, l + 1, v | mbit(i, l)); } }</description>
    </item>
    
    <item>
      <title>BZOJ2770 YY的Treap</title>
      <link>/oi/i11rimport_021/</link>
      <pubDate>Mon, 02 Mar 2015 16:13:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_021/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 今天考试题的弱化版。只用求LCA是谁，不用求它的深度。所以直接用线段树找下区间最值就搞定了。然后long的范围有负数坑了一发。&amp;lt;/p&amp;gt; &amp;nbsp;
好像在不平衡的平衡树上的题也比较热啊。而且我还做得比较少。是要补一补。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
typedef pair &amp;lt;int, int&amp;gt; vpr; typedef pair &amp;lt;bool, vpr&amp;gt; dpr; struct seg { int l, r; dpr d; seg *ls, *rs; }; struct query { int t, a, b; };
const int maxn = 400009;
int n, m, vl[maxn], tv; vpr a[maxn]; query q[maxn]; seg slst[maxn * 3], *sp(slst), *rt;
inline int gpos(int x) { return lower_bound(vl, vl + tv, x) - vl; }</description>
    </item>
    
    <item>
      <title>BZOJ1187 [HNOI2007]神奇游乐园</title>
      <link>/oi/i11rimport_023/</link>
      <pubDate>Sun, 01 Mar 2015 23:22:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_023/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 我的第二道插头DP。差不多纠结了一天。&amp;lt;/p&amp;gt; &amp;nbsp;
这道题网上的题解都讲的好简略啊。最后还得自己yy。没有用括号序列法让我觉得自己比较厉害。
&amp;nbsp;
考虑轮廓线上的m个格子，有3种情况：没有插头，有且只能往一边走，有且要往两边走。对于第二种，要用最多3个不同的值来记录连通性。还要有两个不同的值来表示第一种情况和第三种情况。我比较懒，所以直接用一个八进制数去表示，然后每次二分找编号。
&amp;nbsp;
考虑转移，分一堆情况进行讨论。默认从左上朝右下走。
&amp;nbsp;
首先是要走当前格子的情况。
&amp;nbsp;
如果左边和上面都有插头，那么看它们是否连通。如果不连通则把它们连通，如果已经连通，看是否还有其它插头。没有就更新答案，否则忽略。
&amp;nbsp;
如果只有左边有插头，再分类。如果它是第二种，那么这个格子可以新建一个第三种插头，或者把左边格子的插头接过来。如果它是第三种那么它必需把左边格子接过来。
&amp;nbsp;
如果只有上面有插头，那么必需把上面的插头接上来。
&amp;nbsp;
如果左边和上面都没有插头，那么可以新建一个第三种插头。
&amp;nbsp;
然后如果不走这个格子的话，要求上面没有插头，且左边不是第三种插头。
&amp;nbsp;
按mhy的话说，插头dp就是写起来很麻烦。的确。不过写出来也还是挺高兴的。
&amp;nbsp;
然后代码丑到不能看了。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
const int maxn = 109; const int maxm = 9; const int maxst = 50009; const int inf = 0x3f3f3f3f;
#define pow8(x) (1&amp;lt;&amp;lt;(x)&amp;lt;&amp;lt;(x)&amp;lt;&amp;lt;(x)) #define mbit(x,y) ((x)&amp;lt;&amp;lt;(y)&amp;lt;&amp;lt;(y)&amp;lt;&amp;lt;(y)) #define gbit(x,y) (((x)&amp;gt;&amp;gt;(y)&amp;gt;&amp;gt;(y)&amp;gt;&amp;gt;(y))&amp;amp;7)
int f[2][maxst], n, m, a[maxn][maxm], ans; int slst[maxst], tots;</description>
    </item>
    
    <item>
      <title>BZOJ3438 小M的作物</title>
      <link>/oi/i11rimport_024/</link>
      <pubDate>Sun, 01 Mar 2015 10:46:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_024/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 我以为是最大权闭合子图来着。然后好像就直接最小割就行了吧。突然觉得我的网络流好弱。&amp;lt;/p&amp;gt; &amp;nbsp;
建源汇，分别连每个作物。对于每个组合建两个点分别边源汇，然后中间像源汇一样连它的成员。如果全在一边，那么会有一条边不用割。这也是一个集合都选对答案有贡献的建图方式。
&amp;nbsp;
然后就完了。建图和dinic都写得有些丑，所以调了半天。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
struct edge { int t, c; edge *next, *rv; };
const int maxn = 3009; const int inf = 0x3f3f3f3f;
int n, m, c, d[maxn], t, st, te; edge *head[maxn];
inline edge* newEdge(int u, int v, int c) { edge* e(new edge); e-&amp;gt; t = v; e-&amp;gt; c = c; e-&amp;gt; next = head[u]; return head[u] = e; } inline void addEdge(int u, int v, int c) { edge *a(newEdge(u, v, c)), *b(newEdge(v, u, 0)); a-&amp;gt; rv = b; b-&amp;gt; rv = a; }</description>
    </item>
    
    <item>
      <title>BZOJ3888 [Usaco2015 Jan]Stampede</title>
      <link>/oi/i11rimport_025/</link>
      <pubDate>Sun, 01 Mar 2015 08:35:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_025/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; usaco的银组都开始考这种题了么。其实还是挺水的，不过题号比较好。&amp;lt;/p&amp;gt; &amp;nbsp;
就按y排序，挨个把时间轴上的东西扔掉就完了。写离散可能还没有直接写smt快呢。
&amp;nbsp;
然后线段有一边要减1有点坑。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstdlib&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
typedef long long dint; #define _l (long long int)
struct cow { int y; int ta, tb; };
struct node { int l, r, w; node ls, rs; }; typedef pair &amp;lt;node, node &amp;gt; npr;
const int maxn = 50009;
inline bool operator &amp;lt;(const cow&amp;amp; a, const cow&amp;amp; b) { return a.</description>
    </item>
    
    <item>
      <title>BZOJ1455 罗马游戏</title>
      <link>/oi/i11rimport_029/</link>
      <pubDate>Thu, 26 Feb 2015 14:52:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_029/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 左偏树+并查集的一眼题嘛。然后合并的时候搞忘了如果两个人已经在同一个团里要跳过，于是左偏树自交去了。&amp;lt;/p&amp;gt; &amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
#define szof(p) ((p)?(p-&amp;gt;sz):0) struct node { int sz, vl, id; node *ls, rs; node() {} node(int v, int i) { vl = v; id = i; sz = 1; ls = rs = 0; } inline void update() { if (szof(ls) &amp;lt; szof(rs)) swap(ls, rs); } }; node merge(node p, node q) { if (!p) return q; else if (!</description>
    </item>
    
    <item>
      <title>BZOJ1295 [SCOI2009]最长距离</title>
      <link>/oi/i11rimport_030/</link>
      <pubDate>Wed, 25 Feb 2015 21:26:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_030/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 多老的省选题了。&amp;lt;/p&amp;gt; &amp;nbsp;
就处理一下任意两个格子之间最少要经过几个1，如果小于等于t就更新答案。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cmath&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
#define mkword(x,y) (((x)&amp;lt;&amp;lt;16)|(y)) #define hiword(x) ((x)&amp;gt;&amp;gt;16) #define loword(x) ((x)&amp;amp;0x0000ffff)
const int maxn = 33; const int maxnd = 909; const int movx[4] = {0, 0, 1, -1}; const int movy[4] = {1, -1, 0, 0};
typedef pair &amp;lt;int, int&amp;gt; dpr;
inline int sqr(int x) { return x * x; }
int n, m, t, d[maxn][maxn], ans; int mp[maxn][maxn]; dpr hp[maxnd &amp;lt;&amp;lt; 2];</description>
    </item>
    
    <item>
      <title>BZOJ3757 苹果树</title>
      <link>/oi/i11rimport_031/</link>
      <pubDate>Wed, 25 Feb 2015 21:10:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_031/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 今天晚上的效率比白天高啊。&amp;lt;/p&amp;gt; &amp;nbsp;
树上莫队的另一道题。比糖果公园好写到哪里去了。
&amp;nbsp;
然后手写链表丑掉了导致调试半天+RE了一发。我还是太年轻了。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cmath&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
typedef struct node { int t; node *next; } edge; const int maxn = 50009; const int maxm = 100009; const int maxl = 17; node nlst[maxn], *np(nlst); struct chain { int sz; node *hd, *tl; chain() { hd = tl = 0; sz = 0; } inline void clear() { hd = tl = 0; sz = 0; } inline void push(int x) { np-&amp;gt; t = x; np-&amp;gt; next = 0; if (sz) { tl-&amp;gt; next = np; tl = np; } else { hd = np; tl = np; } ++ np; ++ sz; } inline void merge(chain a) { if (a.</description>
    </item>
    
    <item>
      <title>BZOJ1415 [Noi2005]聪聪和可可</title>
      <link>/oi/i11rimport_032/</link>
      <pubDate>Wed, 25 Feb 2015 20:19:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_032/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 最近很颓啊。&amp;lt;/p&amp;gt; &amp;nbsp;
这题很久之前看过。当时以为是高消就没管。然后开坑之神idy做了之后仔细一想才知道不是。
&amp;nbsp;
这题的做法是dp。首先因为边数少所以不用floyd，直接bfs预处理出所有t[i][j]表狼在i，兔子在j的时候狼下一步去哪。然后有一个结论是每一步两个玩意的距离至少缩短1，所以状态是不会有环的，这也是为啥可以不用高消。然后坑点是不能直接开状态队列，因为那不是拓补序。要先把每个点的入度算出来再跑dp。结局是我的代码超长。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
struct edge { int t; edge *next; };
#define mkword(x,y) (((x)&amp;lt;&amp;lt;16)|(y)) #define hiword(x) ((x)&amp;gt;&amp;gt;16) #define loword(x) ((x)&amp;amp;0x0000ffff)
const int maxn = 1009; const int maxst = 1000009; const int inf = 0x3f3f3f3f;
int n, m, st, te, deg[maxn], d[maxn], t[maxn][maxn], ind[maxn][maxn]; edge elst[maxn &amp;lt;&amp;lt; 1], *ep(elst), *head[maxn]; double f[maxn][maxn], g[maxn][maxn], c[maxn], ans;</description>
    </item>
    
    <item>
      <title>BZOJ3052 [wc2013]糖果公园</title>
      <link>/oi/i11rimport_033/</link>
      <pubDate>Wed, 25 Feb 2015 18:49:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_033/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 盯idy发现的题，之前想学然后放弃了，于是今天几乎写了一天。有种紧迫感啊。然后发现好多认识的人都是最近过的。&amp;lt;/p&amp;gt; &amp;nbsp;
思路比较简单，树上莫队。因为要修改，所以要把块的大小变成n2/3，然后用1086的方法分块。好像也可以直接按dfs序分块。两个端点和时间为三个关键字跑莫队。复杂度可以感受一下反正我也不会证。
&amp;nbsp;
要注意千万要控制LCA的用量，必需只能是O(n)级别的。在爬树的时候必需O(1)。我就是在移动时间的时候不小心手贱每次用一遍LCA，然后去检查在移动端点花了好久的时间。
&amp;nbsp;
比较不开心的是发现mac没法改栈空间？有两个点始终暴栈。而且拿另一台电脑的openSUSE跑，结果发现它的cpu没有mac好，跑得还比mac快！我猜是操作系统在捣鬼。mac还是比较坑啊不开心。然后在bzoj上跑的时间几乎是本地的5倍也是比较厉害啊。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cmath&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
const int maxn = 100009; const int maxl = 19;
typedef struct node { int t; node *next; } edge; node nlst[maxn], *np(nlst); struct chain { int sz; node *hd, *tl; chain() { hd = tl = 0; sz = 0; } inline void clear() { hd = tl = 0; sz = 0; } inline void push(int x) { np-&amp;gt; t = x; np-&amp;gt; next = 0; if (sz) { tl-&amp;gt; next = np; tl = np; } else { hd = np; tl = np; } ++ np; ++ sz; } inline void merge(chain a) { sz += a.</description>
    </item>
    
    <item>
      <title>BZOJ2916 [Poi1997]Monochromatic Triangles</title>
      <link>/oi/i11rimport_034/</link>
      <pubDate>Wed, 25 Feb 2015 10:10:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_034/</guid>
      <description>	&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 每日一水。不过这题还比较有意思。最初没看清题，觉得没法数总三角形个数。&amp;lt;/p&amp;gt; &amp;nbsp;
同色=总-不同色。对于一个不同色，会有两个顶点的两边颜色不同。直接按照顶点统计一下不同色的边组数，然后减一下就完了。
&amp;nbsp;
说好的糖果呢。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
const int maxn = 1009;
int n, m, t, c, w[maxn];
int main() { #ifndef ONLINE_JUDGE //freopen(&amp;ldquo;in.txt&amp;rdquo;, &amp;ldquo;r&amp;rdquo;, stdin); #endif
scanf(&amp;quot;%d%d&amp;quot;, &amp;amp;amp;n, &amp;amp;amp;m); memset(w, 0, sizeof(w)); t = n * (n - 1) * (n - 2) / 6; for (int i = 0; i &amp;amp;lt; m; ++ i) { int u, v; scanf(&amp;quot;%d%d&amp;quot;, &amp;amp;amp;u, &amp;amp;amp;v); ++ w[u]; ++ w[v]; } c = 0; for (int i = 1; i &amp;amp;lt;= n; ++ i) c += w[i] * (n - w[i] - 1); c &amp;amp;gt;&amp;amp;gt;= 1; printf(&amp;quot;%d\n&amp;quot;, t - c); } </description>
    </item>
    
    <item>
      <title>BZOJ1180 [CROATIAN2009]OTOCI &amp;amp; BZOJ2843 极地旅行社</title>
      <link>/oi/i11rimport_035/</link>
      <pubDate>Tue, 24 Feb 2015 20:58:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_035/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 难得的水水的双倍题。&amp;lt;/p&amp;gt; &amp;nbsp;
看上去是想考lct然后忘强制在线了么？那就直接预处理出形态然后链剖呗。当然我还没有达到mhy这种认为lct比tcd好写的水平。
&amp;nbsp;
中间还把修改写挂了一次，然后1180的询问数是2843的3倍又re了一次。晕。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
struct edge { int t; edge *next; }; struct seg { int l, r, s[2]; seg *ls, *rs; }; struct query { char o; int a, b, s; };
const int maxn = 30009; const int maxm = 300009;
int n, m, r[maxn], d[maxn], v[maxn], u[maxn]; int fa[maxn], sz[maxn], tc, fc[maxn], ch[maxn], cl[maxn]; int qret[2]; seg slst[maxn &amp;lt;&amp;lt; 2], *sp(slst), *rt[maxn]; edge elst[maxn &amp;lt;&amp;lt; 1], *ep(elst), *head[maxn]; query q[maxm];</description>
    </item>
    
    <item>
      <title>BZOJ1822 [JSOI2010]Frozen Nova 冷冻波</title>
      <link>/oi/i11rimport_036/</link>
      <pubDate>Tue, 24 Feb 2015 16:08:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_036/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 简单的算几+网络流么。然后花了将近两天。最近总和算几过不去啊。&amp;lt;/p&amp;gt; &amp;nbsp;
判断线段和圆是否有交还是比较简单的。反正不要让我用解析。先找下垂线，然后找下垂足，然后点乘一下搞定。然后错得不知道怎么死的。搞了很久。
&amp;nbsp;
然后二分网络流水水水水水水水水。
&amp;nbsp;
感觉mac好卡啊，gdb巨卡，bash也非常卡。难道我又没有搞对打开方式？
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cmath&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
inline long double sqr(long double x) { return x * x; }
typedef struct geo_obj { double x, y; geo_obj() {} geo_obj(double x0, double y0) { x = x0, y = y0; } inline void read() { scanf(&amp;quot;%lf%lf&amp;quot;, &amp;amp;x, &amp;amp;y); } inline geo_obj rev() { return geo_obj(-y, x); } inline double len() { return sqrt(sqr(x) + sqr(y)); } inline double sqLen() { return sqr(x) + sqr(y); } } point, vect; inline geo_obj operator +(const geo_obj&amp;amp; a, const geo_obj&amp;amp; b) { return geo_obj(a.</description>
    </item>
    
    <item>
      <title>BZOJ2157 旅游</title>
      <link>/oi/i11rimport_037/</link>
      <pubDate>Tue, 24 Feb 2015 10:10:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_037/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 去找水题于是找到这么一道恶心的代码题。其实应该可以用函数指针来优化一下代码量，不过懒得了。虽然复制粘贴导致调试了老半天。&amp;lt;/p&amp;gt; &amp;nbsp;
水水的链剖+线段树。然后tag打一打就好了。
&amp;nbsp;
最近是装备了高超的开坑技巧啊。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
struct seg { int l, r, s, a, b, rv; seg *ls, *rs; inline void update() { if (l + 1 &amp;lt; r) { s = ls-&amp;gt; s + rs-&amp;gt; s; a = min(ls-&amp;gt; a, rs-&amp;gt; a); b = max(ls-&amp;gt; b, rs-&amp;gt; b); if (rv) { s = -s; swap(a, b); a = -a; b = -b; } } else a = b = s; } inline void chgTag() { s = -s; swap(a, b); a = -a; b = -b; rv ^= 1; } inline void downTag() { if (rv) { rv = 0; if (l + 1 &amp;lt; r) { ls-&amp;gt; chgTag(); rs-&amp;gt; chgTag(); } } } }; struct edge { int t, v; edge *next; };</description>
    </item>
    
    <item>
      <title>BZOJ1845 [Cqoi2005] 三角形面积并</title>
      <link>/oi/i11rimport_038/</link>
      <pubDate>Sun, 22 Feb 2015 21:48:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_038/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 比较基础的算几。当是hwd在wc的时候讲的东西拿来练练吧。（都过去多久了）&amp;lt;/p&amp;gt; &amp;nbsp;
算几的板比较长。然后记得还有道半平面交精度题至今没过！？什么效率。
&amp;nbsp;
这题的思路比较简单。找出所有的关键x，分段。每段内都是一堆边不相交的梯形，那么答案=∑(▵x*∑中位线并的长度)。总时间复杂度到了O(n3)。不过n才100显然可过。至于n等于1000的题暂时不会啊。我太弱了。
&amp;nbsp;
然后这题也有神奇的精度误差，答案要-1e-7才能过。
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
const double eps = 1e-7; inline int sgn(double x) { return (x &amp;gt; eps) - (x &amp;lt; -eps); } inline double sqr(double x) { return x * x; }
typedef struct geo_obj { double x, y; inline geo_obj() {} inline geo_obj(double x0, double y0) { x = x0, y = y0; } inline void read() { scanf(&amp;quot;%lf%lf&amp;quot;, &amp;amp;x, &amp;amp;y); } } point, vect; inline geo_obj operator +(const geo_obj&amp;amp; a, const geo_obj&amp;amp; b) { return geo_obj(a.</description>
    </item>
    
    <item>
      <title>BZOJ2342 [Shoi2011]双倍回文</title>
      <link>/oi/i11rimport_039/</link>
      <pubDate>Sun, 22 Feb 2015 16:52:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_039/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 久了不写manacher又手生了只好抄红书了。&amp;lt;/p&amp;gt; &amp;nbsp;
后面的过程就是对每个位置i找一个最远的位置j满足j在i为中心的回文子串的一半以内且j最小。然后直接拿个set就能搞定。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; #include &amp;lt;set&amp;gt; using namespace std;
const int maxn = 500009;
char a[maxn]; int d[maxn &amp;lt;&amp;lt; 1], n;
void manacher() { d[0] = 1; for (int i = 1, j = 0; i &amp;lt; (n &amp;lt;&amp;lt; 1) - 1; ++ i) { int p(i &amp;gt;&amp;gt; 1), q(i - p), r(((j + 1) &amp;gt;&amp;gt; 1) + d[j] - 1); if (r &amp;lt; q) d[i] = 0; else d[i] = min(r - q + 1, d[(j &amp;lt;&amp;lt; 1) - i]); while (p - d[i] &amp;gt;= 0 &amp;amp;&amp;amp; q + d[i] &amp;lt; n &amp;amp;&amp;amp; a[p - d[i]] == a[q + d[i]]) ++ d[i]; if (q + d[i] - 1 &amp;gt; r) j = i; } }</description>
    </item>
    
    <item>
      <title>BZOJ1040 [ZJOI2008]骑士</title>
      <link>/oi/i11rimport_040/</link>
      <pubDate>Sun, 22 Feb 2015 11:48:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_040/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 多少年前的坑了。&amp;lt;/p&amp;gt; &amp;nbsp;
用mac写的第一篇题解呢。
&amp;nbsp;
环套树DP。先把树上的情况处理了，然后枚举取不取环上的第一个。
&amp;nbsp;
要注意会有重边的情况，比较恶心。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cctype&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
const int buf_len = 4000; 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; }</description>
    </item>
    
    <item>
      <title>BZOJ1017 [JSOI2008]魔兽地图DotR</title>
      <link>/oi/i11rimport_041/</link>
      <pubDate>Sat, 21 Feb 2015 12:41:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_041/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 数据水。填坑。语文阅读题，看到都不想做。&amp;lt;/p&amp;gt; &amp;nbsp;
就一树形dp。f[i][j][k]表示第i个物品，上供j个，花k块钱的代价。背包转移是O(m2)的，因为是一棵树所以转移次数是O(n)的，但是还要考虑j最大为100。一个技巧是合并完所有的东西之后再考虑把上供的烧掉。虽然这样的复杂度还是有点高。
&amp;nbsp;
毕竟我还是太弱啊，居然又花了一个上午。（虽然睡到十点）
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
struct edge { int t, v; edge *next; };
const int maxm = 2009; const int maxn = 53; const int maxa = 103;
int n, m, f[maxn][maxa][maxm], ans[maxm], vl[maxn], vmax[maxn]; bool lf[maxn], ir[maxn]; edge elst[maxn], *ep(elst), *head[maxn];
inline void addEdge(int u, int v, int w) { ep-&amp;gt; t = v; ep-&amp;gt; v = w; ep-&amp;gt; next = head[u]; head[u] = ep ++; }</description>
    </item>
    
    <item>
      <title>BZOJ2331 [SCOI2011]地板</title>
      <link>/oi/i11rimport_042/</link>
      <pubDate>Fri, 20 Feb 2015 17:20:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_042/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 插头DP的基础题。想插头DP都是将军没走的时候给我讲的了，距今有大半年了吧。mhy已经写了无数道了，我才开始写。唉，还是效率太低。&amp;lt;/p&amp;gt; &amp;nbsp;
插头DP的意思是把已经处理的部分的轮廓线上对后面状态有影响的东西状压下来，然后挨着处理每个格子的状态（比如方向，或者这里的地板怎么铺之类的）。
&amp;nbsp;
具体到这道题来说，考虑一个相邻格子之前的边，那么它可能没有连接两个相同的磁砖，有可能连接了两个还没有拐过弯的磁砖，有可能连接了两个已经拐过弯的磁砖，一共是3种情况，所以用一个三进制数把它压下来。然后直接一路转移过去就行了。要注意的是每行都处理完了之后要把最边上的那一条从右移动到左，所以还需要把所有的状态都改一下。
&amp;nbsp;
今天效率比较低，心不在焉，然后在最后一个转移的地方wa了大半天。插头DP的调试也比较麻烦。所以我还是naive。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
const int maxn = 13; const int maxa = 109; const int maxs = 200009; const int mod = 20110520;
bool mp[maxa][maxa]; int n, m, a[maxn], b[maxn], f[2][maxs];
#define fc f[cur] #define fp f[prv] #define doNothing ; inline void mInc(int&amp;amp; a, int b) { a += b; if (a &amp;gt;= mod) a %= mod; }</description>
    </item>
    
    <item>
      <title>BZOJ3769 SPOJ8549 BST again</title>
      <link>/oi/i11rimport_044/</link>
      <pubDate>Mon, 16 Feb 2015 22:16:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_044/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 什么鬼。&amp;lt;/p&amp;gt; &amp;nbsp;
很好想的dp。f[i][j]表示深度不超过i且大小为j的二叉树的个数。转移是f[i][j] = ∑(f[i - 1][k] * f[i - 1][j - k - 1])。
&amp;nbsp;
然后直接暴力是O(n3)的。在spoj上能过在bzoj上不能过。在bzoj上得用记忆化搜索来减掉一些无用的东西。虽然我觉得很烦。
&amp;nbsp;
然后试图用fft，发现fft比暴力还慢。然后试图用fnt，然后发现fnt好像不能对1e9+7这种质数用。因为1e9+6只有来一个2。真悲伤。我还是太弱啊。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;cmath&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
const int maxn = 609; const int mod = 1000000007;
#define _l (long long int)
int f[maxn][maxn];
int getf(int i, int j) { if (i == 0) return j &amp;lt;= 1; else if (j == 0) return 1; else if (f[i][j] == -1) { f[i][j] = 0; for (int k = 0; k &amp;lt; j; ++ k) f[i][j] = (f[i][j] + _l getf(i - 1, k) * getf(i - 1, j - k - 1)) % mod; } return f[i][j]; }</description>
    </item>
    
    <item>
      <title>BZOJ3105 [cqoi2013]新Nim游戏</title>
      <link>/oi/i11rimport_050/</link>
      <pubDate>Mon, 09 Feb 2015 21:57:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_050/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 今天wc讲的题。主要其实是用拟阵来证明贪心的正确性。就构造一下就好了。不选的集合构成一个拟阵的基，如果基不能异或出0就是线性无关的。然后按照拟阵的贪心方法挨个加。&amp;lt;/p&amp;gt; &amp;nbsp;
策略是从大到小排个序能不选就不选，用异或消元来判断一下就好了。许久没有写了，还好没有搞忘。
&amp;nbsp;
代码还是比较短的，开心ing。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
typedef long long dint; #ifdef WIN32 #define lld &amp;ldquo;%I64d&amp;rdquo; #else #define lld &amp;ldquo;%lld&amp;rdquo; #endif #define _l (long long int)
const int maxn = 109;
int n, a[maxn], b[maxn], c[maxn], t; dint s;
bool hasZero() { for (int i = 0; i &amp;lt; t; ++ i) b[i] = c[i]; for (int i = 31, j = 0; i &amp;gt;= 0 &amp;amp;&amp;amp; j &amp;lt; t; &amp;ndash; i) { for (int k = j; k &amp;lt; n; ++ k) if ((b[k] &amp;gt;&amp;gt; i) &amp;amp; 1) { swap(b[k], b[j]); break; } if ((b[j] &amp;gt;&amp;gt; i) &amp;amp; 1) { for (int k = j + 1; k &amp;lt; n; ++ k) if ((b[k] &amp;gt;&amp;gt; i) &amp;amp; 1) { b[k] ^= b[j]; if (!</description>
    </item>
    
    <item>
      <title>BZOJ1453 [Wc]Dface双面棋盘</title>
      <link>/oi/i11rimport_052/</link>
      <pubDate>Sat, 07 Feb 2015 15:07:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_052/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 有离线镜像还是能省不少流量。开心。不过流量还是用得飞快啊。&amp;lt;/p&amp;gt; &amp;nbsp;
这就是个cdq重构的题。学习了前几天xyz大爷讲的扔线段树的做法，省了不少代码。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
struct node { int v, c; node *next; }; struct seg { int l, r; node *head; seg *ls, *rs; };
const int maxa = 209; const int maxn = 40009; const int maxm = 10009; const int maxnd = maxn * 23; const int mov[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};</description>
    </item>
    
    <item>
      <title>HDU5173 GTY&#39;s game II</title>
      <link>/oi/i11rimport_054/</link>
      <pubDate>Fri, 06 Feb 2015 23:10:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_054/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; bc的题。今天bc又挂了。这题没有写完，然后b题fst了。伤心啊。&amp;lt;/p&amp;gt; &amp;nbsp;
其实思路比较简单。直接链剖dfs序上把所有区间找出来swap就好了。不过代码实现起来还是比较麻烦的，很容易绕晕。加上smt久了没写手生了，于是就调了一晚上。唉，我还是太年轻了。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstdlib&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
struct node { int v, s, sz, w, rv; node ls, rs; inline void update() { sz = 1; s = v; if (ls) { sz += ls-&amp;gt; sz; s += ls-&amp;gt; s; } if (rs) { sz += rs-&amp;gt; sz; s += rs-&amp;gt; s; } } inline void fix() { if (rv) { swap(ls, rs); if (ls) ls-&amp;gt; rv ^= 1; if (rs) rs-&amp;gt; rv ^= 1; rv = 0; } } }; typedef pair &amp;lt;node, node&amp;gt; npr;</description>
    </item>
    
    <item>
      <title>BZOJ2642 Pku3968 Jungle Outpost</title>
      <link>/oi/i11rimport_056/</link>
      <pubDate>Wed, 04 Feb 2015 21:28:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_056/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 看mhy写了好几天了啊。然后研究了一下，居然过得比他早。&amp;lt;/p&amp;gt; &amp;nbsp;
首先敌人一定可以炸连续的一段。然后就是要看炸掉任意连续一段之后还有没有剩下的公共部分，既半平面交。
&amp;nbsp;
然后我yy出了一个半平面交的做法。找出一条基准直线，按方向顺时针方向排序。然后按照正常半平面交的方法根据栈顶两个元素和当前直线的位置关系判断是否需要退栈。然后当找到一条与基准直线的角度大于等于π的直线（直线是有向的，也可以说是成负角）且它把栈里退到只剩基准直线一条的时候，这些半平面没有交。否则这些半平面有交。
&amp;nbsp;
至于证明嘛，我也不会（挠头），毕竟是感受出来的。然后感觉这次代码写得比较漂亮，开心。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cmath&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
inline double sqr(double x) { return x * x; }
struct point { double x, y; inline point() {} inline point(double x0, double y0) { x = x0, y = y0; } inline void read() { scanf(&amp;quot;%lf%lf&amp;quot;, &amp;amp;x, &amp;amp;y); } }; struct vect { double x, y; inline vect() {} inline vect(double x0, double y0) { x = x0, y = y0; } inline vect(point a, point b) { x = b.</description>
    </item>
    
    <item>
      <title>BZOJ1815 [Shoi2006]color 有色图</title>
      <link>/oi/i11rimport_057/</link>
      <pubDate>Wed, 04 Feb 2015 17:46:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_057/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 一道burnside，做了几次之后感觉比较经典了。然后发现网上居然没有题解。&amp;lt;/p&amp;gt; &amp;nbsp;
枚举正整数拆分，既每个质换的长度。然后枚举gcd算每类置换的贡献。再用错排公式来算每类置换的数量。然后求和。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
#define _l (long long int)
const int maxn = 63;
int n, m, mod, ans, g[maxn][maxn]; int sq[maxn], tq, fac[maxn], finv[maxn], vinv[maxn];
int modPow(int a, int x) { int s(1); for (; x; x &amp;gt;&amp;gt;= 1, a = _l a * a % mod) if (x &amp;amp; 1) s = _l s * a % mod; return s; }</description>
    </item>
    
    <item>
      <title>BZOJ2401 陶陶的难题I</title>
      <link>/oi/i11rimport_061/</link>
      <pubDate>Sun, 01 Feb 2015 21:18:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_061/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 推了半天，发现还是得sqrt，过不到啊。&amp;lt;/p&amp;gt; &amp;nbsp;
然后发现与经典的问题相比，就是n=n。然后这不是做过的那个LCM sum的前缀和就完了嘛。傻了。
&amp;nbsp;
然后第一次MLE是因为明明压了8位，还是开了30长的数组。第二次WA是因为高精输出的时候%08d写成了%8d。是不是明天又要逗极而死了。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
typedef long long dint;
#define _l (long long int)
const int maxlen = 7; const dint base = 1e8; struct BigInt { dint dig[maxlen], len; BigInt() { len = 0; } void set(dint x) { dig[0] = x; len = 1; while (dig[len - 1] &amp;gt;= base) { dig[len] = dig[len - 1] / base; dig[len - 1] %= base; ++ len; } } void copy(const BigInt&amp;amp; x) { len = x.</description>
    </item>
    
    <item>
      <title>BZOJ3435 [Wc2014]紫荆花之恋</title>
      <link>/oi/i11rimport_062/</link>
      <pubDate>Sun, 01 Feb 2015 20:07:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_062/</guid>
      <description>想起去年在考场上完全没有思路不想写数据结构于是骗了30分。现在想想当初还是naive。
&amp;nbsp;
这题看上去就是点分治。因为要动态加点所以要动态。然后利用替罪羊树的方法重构树上的一团东西（不能叫团，否则命名重复了）。
&amp;nbsp;
本来以为要写很久，结果也没写多久。奇怪的是，把maintain展开到insert里面之后就跑得飞快了，否则过不到而且根本跑不下来9和10。又丑了郁闷。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cctype&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
const int buf_len = 4000; const size_t buf_size = buf_len * sizeof(char); char buf[buf_len], *bufb(buf), *bufe(buf + 1); #define readBuf() { if (++ bufb == bufe) bufe = (bufb = buf) + fread(buf, 1, buf_size, 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; }</description>
    </item>
    
    <item>
      <title>POJ2154 Color</title>
      <link>/oi/i11rimport_064/</link>
      <pubDate>Sat, 31 Jan 2015 23:18:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_064/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 首先是burnside，对于旋转x下都要当作一个置换，所以总共有n个。然后第i个的不动点数量等于n&amp;lt;sup&amp;gt;gcd(n,i)&amp;lt;/sup&amp;gt;，然后统计一下个数是phi(gcd(n,i))个。&amp;lt;/p&amp;gt; &amp;nbsp;
然后发现要用奇奇怪怪的东西来求phi。我用的方法是分解质因数然后DFS，跑得飞快。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
#define _l (long long int)
const int maxn = 50009;
int n, mod; int tp, pn[maxn], phi[maxn]; bool pr[maxn];
void pre() { memset(pr, 0, sizeof(pr)); tp = 0; phi[1] = 1; for (int i = 2; i &amp;lt; maxn; ++ i) { if (!pr[i]) { pn[tp ++] = i; phi[i] = i - 1; } for (int j = 0; j &amp;lt; tp &amp;amp;&amp;amp; i * pn[j] &amp;lt; maxn; ++ j) { pr[i * pn[j]] = 1; if (i % pn[j] == 0) { phi[i * pn[j]] = phi[i] * pn[j]; break; } else phi[i * pn[j]] = phi[i] * phi[pn[j]]; } } }</description>
    </item>
    
    <item>
      <title>BZOJ2653 middle</title>
      <link>/oi/i11rimport_067/</link>
      <pubDate>Thu, 29 Jan 2015 20:50:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_067/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 老久之前就看到过的题，不过不会做。今天晚上也是花了差不多俩小时才调过，虽然大概一个半小时都在纠结二分怎么写的问题。我没救了。&amp;lt;/p&amp;gt; &amp;nbsp;
考虑经典的中位数二分，是把≤x的数字取-1，&amp;gt;x的数取1，然后算最大子串看是否大于-1或1中的某一个，具体要看题目要求偶数是取上整还是下整什么的。
&amp;nbsp;
然后这题就把所有东西排序之后拿可持久化线段树把这个序列搞出来，然后照着之前的思路二分就好了。线段树用来维护最大和最小前缀和。
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
struct dat { int sm, s; }; struct seg { int l, r; dat v[2]; seg *ls, *rs; };
#define _l (long long int)
typedef pair &amp;lt;int, int&amp;gt; vpr; typedef dat(*dat_mf)(const dat&amp;amp;, const dat&amp;amp;);
const int maxn = 20009; const int maxnd = maxn * 19; const dat null_str = {0, 0}; const dat neg_str0 = {-1, -1}; const dat neg_str1 = {-1, -1}; const dat pos_str0 = {1, 1}; const dat pos_str1 = {1, 1};</description>
    </item>
    
    <item>
      <title>BZOJ3351 [ioi2009]Regions</title>
      <link>/oi/i11rimport_068/</link>
      <pubDate>Wed, 28 Jan 2015 18:44:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_068/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; ioi的数据结构题，果然还是比较BT的。&amp;lt;/p&amp;gt; &amp;nbsp;
做法是对颜色分开，大的颜色预处理，小的颜色直接暴力。
&amp;nbsp;
然后一个小错又坑了好久。我真的没救了。
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstdlib&amp;gt; #include &amp;lt;cctype&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
const int buf_len = 4000; const size_t buf_size = buf_len * sizeof(char); char buf[buf_len], *bufb(buf), *bufe(buf + 1); #define readBuf() { if (++ bufb == bufe) bufe = (bufb = buf) + fread(buf, 1, buf_size, 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; }</description>
    </item>
    
    <item>
      <title>BZOJ1502 [NOI2005]月下柠檬树</title>
      <link>/oi/i11rimport_071/</link>
      <pubDate>Tue, 27 Jan 2015 20:55:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_071/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 今天几乎讲了一天的算几。或者说能听的只有算几。然后就去做了一道基础题。&amp;lt;/p&amp;gt; &amp;nbsp;
刚开始的时候比较naive，把相交的情况想简单了，打算直接上数学，然后悲剧地发现还有其它的不好算交点的情况，于是就去写simpson了。
&amp;nbsp;
simpson就是一个估计用的，s = (4 * f(mid) + f(l) + f(r))*(r-l)/6。至于为啥是对的就不知道了。反正比较能用。然后每次直接去扫一遍所有能交的地方，取max就行了，比挨个算交点方便许多。
&amp;nbsp;
然后第一次写，代码也比较乱。
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;cmath&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
const int maxn = 509; const double pi = asin(1) * 2; const double eps = 1e-6;
#define x1 x1 #define x2 x2 #define y1 y1 #define y2 y2
int n; double tht, x[maxn], h[maxn], r[maxn]; double crd[maxn]; double x1[maxn], x2[maxn], y1[maxn], y2[maxn]; bool c[maxn];</description>
    </item>
    
    <item>
      <title>BZOJ2816 [ZJOI2012]网络</title>
      <link>/oi/i11rimport_072/</link>
      <pubDate>Tue, 27 Jan 2015 20:51:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_072/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 听说是水水的splay，果然是。&amp;lt;/p&amp;gt; &amp;nbsp;
乍一看要用lct，然后因为度数只有2，所以肯定是一条链。然后就直接用splay来维护。然后因为少写了句splay(v)导致多调了至少一节课的时间。我没救了。
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; #include &amp;lt;map&amp;gt; using namespace std;
#define upmax(a,b) { if (a &amp;lt; b) a = b; }
struct splay_node { int vl, vm, rv; splay_node *pt, *ls, *rs; inline void update() { vm = vl; if (ls) upmax(vm, ls-&amp;gt; vm); if (rs) upmax(vm, rs-&amp;gt; vm); } inline void fix() { if (rv) { swap(ls, rs); if (ls) ls-&amp;gt; rv ^= 1; if (rs) rs-&amp;gt; rv ^= 1; rv = 0; } } };</description>
    </item>
    
    <item>
      <title>BZOJ3870 Our happy ending</title>
      <link>/oi/i11rimport_073/</link>
      <pubDate>Tue, 27 Jan 2015 20:48:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_073/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 立杰出的题，orz。&amp;lt;/p&amp;gt; &amp;nbsp;
一个时间比较微妙的状压DP。用一个二进制状态表示0~k中哪些数已经可以被表示出来了，然后大于k的数直接乘，因为对状态不产生影响。
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
#define pow2(x) (1&amp;lt;&amp;lt;(x)) #define _l (long long int)
const int maxn = 21; const int maxb = pow2(maxn) + 9; const int mod = 1e9 + 7;
int n, k, l, f[2][maxb], zu, va;
#define incm(a,b) { a += b; if (a &amp;gt;= mod) a %= mod; }
int sov() { int prv(0), cur(1); memset(f, 0, sizeof(f)); va = max(0, l - k) + 1; zu = pow2(k + 1) - 1; f[cur][1] = 1; for (int ti = 0; ti &amp;lt; n; ++ ti) { swap(cur, prv); for (int i = zu; i; &amp;ndash; i) f[cur][i] = 0; for (int i = zu; i; &amp;ndash; i) if (f[prv][i]) { for (int j = 1; j &amp;lt;= k; ++ j) { int zn((i | (i &amp;lt;&amp;lt; j)) &amp;amp; zu); incm(f[cur][zn], f[prv][i]); } incm(f[cur][i], _l f[prv][i] * va % mod); } } int ans(0); for (int i = zu, e = pow2(k); i &amp;gt;= e; &amp;ndash; i) incm(ans, f[cur][i]); return ans; }</description>
    </item>
    
    <item>
      <title>BZOJ2815 [ZJOI2012]灾难</title>
      <link>/oi/i11rimport_074/</link>
      <pubDate>Tue, 27 Jan 2015 20:45:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_074/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 灭绝树的模板题么。之前不知道这题，差点当原创题出出去了。&amp;lt;/p&amp;gt; &amp;nbsp;
好像有不少人不知道这东西的样子？orz zhx。
&amp;nbsp;
灭绝树只有一句口诀：一个东西的父亲是所有入边的另一端的点的LCA。
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
struct edge { int t; edge *next; };
const int maxn = 70009; const int maxl = 19; const int maxe = 2000009;
int n, ind[maxn], oud[maxn], tpo[maxn], ath[maxn][maxl], sz[maxn], d[maxn]; edge *ha[maxn], *hr[maxn], *ht[maxn];
inline void addEdge(edge** head, int u, int v) { edge* ep = new edge; ep-&amp;gt; t = v; ep-&amp;gt; next = head[u]; head[u] = ep; }</description>
    </item>
    
    <item>
      <title>BZOJ3251 树上三角形</title>
      <link>/oi/i11rimport_075/</link>
      <pubDate>Mon, 26 Jan 2015 23:00:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_075/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 原来在win下也有敲回车的bug。开心。&amp;lt;/p&amp;gt; &amp;nbsp;
这题坑啊。暴力还是很好想的，如果个数超过几十个的话就肯定有解了。比较坑的是两边之和大于第三边，边权231-1然后加起来就超过int的范围了。连WA若干次再见。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
struct edge { int t; edge *next; };
const int maxn = 100009; const int maxc = 88;
int n, m, v[maxn], d[maxn], fa[maxn], c[maxc]; edge *head[maxn], elst[maxn &amp;lt;&amp;lt; 1], *ep(elst);
void bfs() { static int q[maxn]; int hd(0), tl(1); q[0] = 1; memset(d, 0, sizeof(d)); d[1] = 1; while (hd &amp;lt; tl) { int p(q[hd ++]); for (edge* e = head[p]; e; e = e-&amp;gt; next) if (!</description>
    </item>
    
    <item>
      <title>BZOJ2419 电阻</title>
      <link>/oi/i11rimport_078/</link>
      <pubDate>Sun, 25 Jan 2015 21:33:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_078/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 记得这是高一的时候ty同学和我说的东西了。然后现在才解决，可以打败上帝造题的七分钟，荣登解决时间最长的题目了。&amp;lt;/p&amp;gt; &amp;nbsp;
其实也就是一个高斯消元，用电势来列方程。不过高斯消元写得不熟，平时有空都写ds的题去了。以后不能再这样了。
&amp;nbsp;
用自己的代码高亮脚本了，虽然还不完善不过还是很开心的。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;cmath&amp;gt; #include &amp;lt;cstdlib&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
const int maxn = 109; const double inf = 1e100; const double eps = 1e-8;
double x[maxn], a[maxn][maxn], b[maxn][maxn]; int n, m, perm[maxn];
int main() { #ifndef ONLINE_JUDGE freopen(&amp;ldquo;in.txt&amp;rdquo;, &amp;ldquo;r&amp;rdquo;, stdin); #endif
srand(19970911); while (scanf(&amp;quot;%d%d&amp;quot;, &amp;amp;amp;n, &amp;amp;amp;m) != EOF) { for (int i = 1; i &amp;amp;lt;= n; ++ i) perm[i] = i; if (n &amp;amp;gt; 2) random_shuffle(perm + 2, perm + n); for (int i = 1; i &amp;amp;lt;= n; ++ i) for (int j = 1; j &amp;amp;lt;= n; ++ j) if (i == j) a[i][j] = 0; else a[i][j] = inf; while (m --) { int u, v; double p; scanf(&amp;quot;%d%d%lf&amp;quot;, &amp;amp;amp;u, &amp;amp;amp;v, &amp;amp;amp;p); u = perm[u]; v = perm[v]; if (u == v) continue; a[u][v] = 1.</description>
    </item>
    
    <item>
      <title>BZOJ3136 [Baltic2013]brunhilda</title>
      <link>/oi/i11rimport_080/</link>
      <pubDate>Fri, 23 Jan 2015 21:32:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_080/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 决心写一道usaco之外的题，于是就挑中了这道。&amp;lt;/p&amp;gt; &amp;nbsp;
为啥这编辑器有BUG，每次按回车要向下跳？
&amp;nbsp;
发现可以预处理DP。f_i表示第i个数被砍完需要最少多少刀。对于每一个i，设p_i是它的质因子里最大的一个在给定集合里的，那么它可以转移到(i+1,i+p_i)这个范围。然后f_i显然不减，所以用单调队列之类的玩意。
&amp;nbsp;
然后卡着时间限制过了。不知道前面那些秒跑的人是怎么搞的。
&amp;nbsp;
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;cstring&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std;
const int maxn = 10000009; const int maxm = 100009;
int k[maxn], f[maxn], n, m, q, p[maxm], v[maxm];
void pre(int n) { sort(p, p + m); memset(k, 0, sizeof(k)); for (int i = 0; i &amp;lt; m; ++ i) if (!i || p[i] != p[i - 1]) for (int j = 0; j &amp;lt;= n; j += p[i]) k[j] = p[i];</description>
    </item>
    
    <item>
      <title>BZOJ3314 [Usaco2013 Nov]Crowded Cows</title>
      <link>/oi/i11rimport_082/</link>
      <pubDate>Fri, 23 Jan 2015 10:51:41 +0000</pubDate>
      
      <guid>/oi/i11rimport_082/</guid>
      <description>&amp;lt;div class=&amp;quot;post_brief&amp;quot;&amp;gt;&amp;lt;p&amp;gt; 又搬blog。发现这里可以自定义css之后就果断了。&amp;lt;/p&amp;gt; &amp;nbsp;
写道水题试试。set的应用。然后还写丑WA了两次，我没救了。
&amp;nbsp;
代码高亮是坏了吗？不要吓我。
&amp;nbsp;
决定直接用oj7的代码版了，没有高亮就算了。
#include &amp;lt;cstdio&amp;gt; #include &amp;lt;algorithm&amp;gt; #include &amp;lt;set&amp;gt; using namespace std;
typedef multiset &amp;lt;int&amp;gt; rb_tree; typedef rb_tree :: iterator rb_node; typedef pair &amp;lt;int, int&amp;gt; cow;
const int maxn = 50009;
int n, d, x[maxn], a[maxn], r[maxn]; cow c[maxn]; rb_tree t;
int main() { #ifndef ONLINE_JUDGE freopen(&amp;ldquo;in.txt&amp;rdquo;, &amp;ldquo;r&amp;rdquo;, stdin); #endif
scanf(&amp;quot;%d%d&amp;quot;, &amp;amp;amp;n, &amp;amp;amp;d); for (int i = 1; i &amp;amp;lt;= n; ++ i) { scanf(&amp;quot;%d%d&amp;quot;, x + i, a + i); c[i] = cow(x[i], a[i]); r[i] = 0; } sort(c + 1, c + n + 1); for (int i = 1; i &amp;amp;lt;= n; ++ i) { x[i] = c[i].</description>
    </item>
    
    <item>
      <title>BZOJ2693 jzptab</title>
      <link>/oi/lofterimport_000/</link>
      <pubDate>Sat, 17 Jan 2015 18:36:19 +0000</pubDate>
      
      <guid>/oi/lofterimport_000/</guid>
      <description>多组询问，硬根号。yy了一下午，在去80MSWC的时候的病历上打了若干草稿，最后硬yy出来了。
其实拿LaTeX来当公式编辑器蛮好的。
然后d(a)函数可以线性筛，讨论一下是不是倍数就行了。
发现数论真的好神奇。
lofter的html源码好讨厌啊。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
&amp;nbsp;
using namespace std;
&amp;nbsp;
#define _l (long long int)
&amp;nbsp;
const int maxn = 10000009;
const int maxq = 10009;
const int mod = 1e8 + 9;
&amp;nbsp;
int pn[maxn], tp, d[maxn];
bool pr[maxn];
int q, m[maxq], n[maxq], t;
&amp;nbsp;
#define incm(_a_,_b_)&amp;nbsp;{&amp;nbsp;\
&amp;nbsp;&amp;nbsp;&amp;nbsp; _a_+=_b_;&amp;nbsp;\
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (_a_&amp;gt;=mod||_a_&amp;lt;=-mod)&amp;nbsp;\
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _a_%=mod;&amp;nbsp;\
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (_a_&amp;lt;0)&amp;nbsp;\
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _a_+=mod;&amp;nbsp;\
}
&amp;nbsp;
void pre(int n)&amp;nbsp;{</description>
    </item>
    
    <item>
      <title>BZOJ2709 [Violet 1]迷宫花园</title>
      <link>/oi/lofterimport_001/</link>
      <pubDate>Sat, 17 Jan 2015 12:17:59 +0000</pubDate>
      
      <guid>/oi/lofterimport_001/</guid>
      <description>水水的二分+最短路么？
然后读入坑死了检查了好久的最短路。
没救了。
然后发现我好像进前100了，小小地开心一下。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
typedef pair &amp;lt;double, int&amp;gt; dpr;
struct edge {
int v, t;
edge *next;
};
#define nid(_x_,_y_)&amp;nbsp;((_x_-1)*m+(_y_))
const int maxn = 10009;
const int maxa = 109;
const int maxe = 80009;
const int mov[4][2]&amp;nbsp;=&amp;nbsp;{{1, 0},&amp;nbsp;{-1, 0},&amp;nbsp;{0, 1},&amp;nbsp;{0,&amp;nbsp;-1}};
const double eps = 1e-8;
int n, m, st, te, c[maxn];
char mp[maxa][maxa];
double d[maxn], tg;
edge *head[maxn],&amp;nbsp;*ep, elst[maxe];
dpr hp[maxe];</description>
    </item>
    
    <item>
      <title>BZOJ1273 [BeiJingWc2008]序列</title>
      <link>/oi/lofterimport_002/</link>
      <pubDate>Fri, 16 Jan 2015 17:13:02 +0000</pubDate>
      
      <guid>/oi/lofterimport_002/</guid>
      <description>逃掉数学考试。感觉解几纯粹不给人希望。
这题还是比较有意思。做法是把每位分开预处当总共加了多少的时候这一位上是1的数字有多少个。然后每一层是线性的。询问是O(1)的。
然后发现自己的代码能力已经没救了。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#define pow2(x)&amp;nbsp;(1&amp;lt;&amp;lt;(x))
typedef long long dint;
#ifdef WIN32
#define lld &amp;quot;%I64d&amp;quot;
#else
#define lld &amp;quot;%lld&amp;quot;
#endif
const int maxn = 100009;
const int maxl = 16;
const int maxv = pow2(maxl)&amp;nbsp;- 1;
int n, m, c[maxv + 3],&amp;nbsp;*t[maxl], b;
dint s;
void pre()&amp;nbsp;{
for (int i = 0; i &amp;lt; maxl;&amp;nbsp;++ i)&amp;nbsp;{
int len(pow2(i));
t[i]&amp;nbsp;= new int[(len &amp;lt;&amp;lt; 1)&amp;nbsp;+ 3];
t[i][0]&amp;nbsp;= 0;
for (int j = 0; j &amp;lt;= maxv;&amp;nbsp;++ j)</description>
    </item>
    
    <item>
      <title>20150116</title>
      <link>/oi/lofterimport_003/</link>
      <pubDate>Fri, 16 Jan 2015 13:56:04 +0000</pubDate>
      
      <guid>/oi/lofterimport_003/</guid>
      <description>感觉自己坚持不下去了。
现在真不知道为什么要回去上课。好多次想跑掉然后还是没有跑。毕竟还是，唉。
物理十分钟够我想一道选择题还多半是错的。化学生物英语啥的基本就是不会。zhx告诉我回去可以拿数学RANK1然后发现解析根本做不了。想起初中的时候很自豪地认为我的解析几何很厉害。现在才学会做人。
上课还是那种走神的样子。也没有想OI的题，也不想听课。不知不觉就跑掉了。最后只有利用上课的时间做作业。然后，不会，不开心，担惊受怕。
每天唯一的娱乐就是晚上去码一下OJ。然后发现我的东西写得太丑，如果数据量一大根本就handle不了。当初做的时候也是边做边改，好多东西根本就不科学。但是也不想重新来写。于是乱七八糟的东西越堆越多。
发现自己好像很少认真想过如果滚掉了会怎样。每次都推说去学校对面电脑城修电脑好了。但是世界真的允许我这样做吗？也许如果真的那样的话会过一个很痛苦的高三然后再上一个很痛苦的大学然后痛苦一辈子？不知道。只能说不上一个好的大学也不一定就没有好的前途吧。但是好的前途是什么？我发现我连这样简单的问题都没有想清楚。所以说造成恐惧的不是对现实的无力，而是对未来的迷惑？
不知道。
看到昨天的情系母校，最大的感慨是大学也不是天堂。大学有更多更麻烦的事情要去做。去上大学也不过是换个坑而已。要找到自己真正喜欢的事情？依然难。而再以后呢？工作？我只能推断它是一个更大的火坑。怎么办？
还没想清楚。
魏总说过的一句话很有道理，noi金牌这条路至少在这里是不会断的。我想这也是我现在唯一能抓住的东西了吧。不管怎样，下周就期末考试了。在我退役之前大概是不会再有这样的苦日子了。但是也是时候去学会成熟了。
期末需要加油，未来更要加油。
Historical Comments Unknown friend at 2015-01-16T23:02:27 找到适合自己的路才是最重要的 想走就走吧
Unknown friend at 2015-01-17T12:18:11 谢谢</description>
    </item>
    
    <item>
      <title>BZOJ2393 Cirno的完美算数教室</title>
      <link>/oi/lofterimport_004/</link>
      <pubDate>Sun, 11 Jan 2015 11:12:49 +0000</pubDate>
      
      <guid>/oi/lofterimport_004/</guid>
      <description>充分证明我已经学傻了。把ONLINE_JUDGE打成ONLINE_JUGE还WA了若干次。然后开了个10^10的数组直接CE还想了好久是怎么回事。
10^10大概会TLE，真正的数据大概只有10^9。
做法比较简单直接容斥+剪枝，反正凑起来的几个数不会很多。
#ifndef ONLINE_JUGE
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
typedef long long dint;
#ifdef WIN32
#define lld &amp;quot;%I64d&amp;quot;
#else
#define lld &amp;quot;%lld&amp;quot;
#endif
const int maxa = 2048;
const dint maxn = 10000000000LL;
//const dint maxn = 100000LL;
int e, t;
dint l, r, s, a[maxa], ans;
bool g[maxa];
void pre()&amp;nbsp;{
t = 0;
for (int l = 1; l &amp;lt;= 10;&amp;nbsp;++ l)
for (int j = 0; j &amp;lt;&amp;nbsp;(1&amp;nbsp;&amp;lt;&amp;lt; l);&amp;nbsp;++ j)&amp;nbsp;{</description>
    </item>
    
    <item>
      <title>BZOJ2813 奇妙的Fibonacci</title>
      <link>/oi/lofterimport_005/</link>
      <pubDate>Thu, 08 Jan 2015 20:46:03 +0000</pubDate>
      
      <guid>/oi/lofterimport_005/</guid>
      <description>的确比较奇妙。
有一个奇妙的玩意是fib[gcd(i, j)]&amp;nbsp;== gcd(fib[i], fib[j])。(fib[1]&amp;nbsp;= fib[2]&amp;nbsp;= 1)
然后就比较可搞了。
线性筛处理每个数的因子个数和因子和。开一点变量然后推一下就出来了。
然后要注意fib[2]也可以整除所有奇数，包括1。表示在这上面坑了2次提交。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
#define _l (long long int)
const int maxn = 10000009;
const int mod = 1000000007;
int tp, pn[maxn], sa[maxn], sb[maxn], b[maxn], c[maxn];
bool pr[maxn];
void pre(int n)&amp;nbsp;{
memset(pr, 0, sizeof(pr));
tp = 0;
sa[1]&amp;nbsp;= 1;
sb[1]&amp;nbsp;= 1;
b[1]&amp;nbsp;= 1;
c[1]&amp;nbsp;= 0;
for (int i = 2; i &amp;lt;= n;&amp;nbsp;++ i)&amp;nbsp;{
if (!</description>
    </item>
    
    <item>
      <title>BZOJ3522 [Poi2014]Hotel</title>
      <link>/oi/lofterimport_006/</link>
      <pubDate>Thu, 08 Jan 2015 19:14:45 +0000</pubDate>
      
      <guid>/oi/lofterimport_006/</guid>
      <description>水水的dp。拿pascal玩玩边表。然后莫名其妙地发现在main上先是ce然后全wa。下到数据一测就过了，交bzoj还是过了。不开心。
必定是一个中间点然后连三条出去。所以直接枚举中间点然后bfs就好了。相当于每条边被转移了两次所以还是O(n^2)的。最初想错了想成三方了把自己吓了一跳。
pascal啊。
type
edge =&amp;nbsp;^edger;
edger = record
t: longint;
next: edge;
end;
const
maxn = 5009;
//ONLINE_JUDGE = false;
ONLINE_JUDGE = true;
var
n, i, j, u, v: longint;
ans: int64;
d, cd, sd, td: array [0&amp;nbsp;.. maxn] of longint;
head: array [0&amp;nbsp;.. maxn] of edge;
ei: edge;
procedure addEdge(u, v: longint);
var
ep: edge;
begin
new(ep);
ep^. t := v;
ep^. next := head[u];
head[u]&amp;nbsp;:= ep;
end;</description>
    </item>
    
    <item>
      <title>BZOJ3851 2048</title>
      <link>/oi/lofterimport_007/</link>
      <pubDate>Thu, 08 Jan 2015 15:00:21 +0000</pubDate>
      
      <guid>/oi/lofterimport_007/</guid>
      <description>题号是3851，题目名称是2048。
比较厉害的DP。最初没有想到怎么表示状态。其实就是一个≤2048的自然数就可以表示状态了。
然后转移不能一个一个来，每个值要一起来，&amp;nbsp;然后拿组合数来算。然后就行了。
虽然hdu上还是过不到。好慢的说。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
#define _l (long long int)
const int maxn = 100009;
const int mod = 998244353;
int n, f[2][2051], c[2051];
int fac[maxn], finv[maxn], p2[maxn];
int modPow(int a, int x)&amp;nbsp;{
int s(1);
for (; x; x &amp;gt;&amp;gt;= 1, a = _l a * a % mod)
if (x&amp;nbsp;&amp;amp; 1)
s = _l s * a % mod;
return s;</description>
    </item>
    
    <item>
      <title>BZOJ2527 [Poi2011]Meteors</title>
      <link>/oi/lofterimport_008/</link>
      <pubDate>Thu, 08 Jan 2015 11:46:07 +0000</pubDate>
      
      <guid>/oi/lofterimport_008/</guid>
      <description>全局二分+树状数组，其实还是比较水。
比较坑的一点是直接求和会暴long long。如果≥Pi了要直接break掉。好坑啊。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;&amp;nbsp;
int _d_;
#define readInt(_x_)&amp;nbsp;{&amp;nbsp;\
int&amp;amp; _s_ =&amp;nbsp;(_x_&amp;nbsp;= 0);&amp;nbsp;\
while (!isdigit(_d_&amp;nbsp;= getchar()));&amp;nbsp;\
while (_s_&amp;nbsp;=&amp;nbsp;(_s_&amp;nbsp;&amp;lt;&amp;lt; 3)&amp;nbsp;+&amp;nbsp;(_s_ &amp;lt;&amp;lt; 1)&amp;nbsp;+ _d_ - 48, isdigit(_d_ = getchar()));&amp;nbsp;\
}
typedef long long dint;
const int maxn = 300009;
struct node {
int v;
node *next;
};
struct rain {
int l, r, a;
};
struct bintree {
dint t[maxn];
int n;
bintree()&amp;nbsp;{</description>
    </item>
    
    <item>
      <title>BZOJ1112 [POI2008]砖块</title>
      <link>/oi/lofterimport_009/</link>
      <pubDate>Wed, 07 Jan 2015 22:26:51 +0000</pubDate>
      
      <guid>/oi/lofterimport_009/</guid>
      <description>水一发。
本来可以直接拿主席树找中位数的，但是因为main上只有32MB，所以只好写了个splay。感觉现在是爱上指针了。然后kth的时候少打个等号又wa又re好爽。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
typedef long long dint;
#ifdef WIN32
#define lld &amp;quot;%I64d&amp;quot;
#else
#define lld &amp;quot;%lld&amp;quot;
#endif
#define _l (long long int)
const int maxn = 100009;
#define nsz(p)&amp;nbsp;((p)?(p-&amp;gt;sz):0)
#define sof(p)&amp;nbsp;((p)?(p-&amp;gt;s):0)
struct splay_node {
&amp;nbsp;&amp;nbsp; int v, sz;
&amp;nbsp;&amp;nbsp; dint s;
&amp;nbsp;&amp;nbsp; splay_node *ls,&amp;nbsp;*rs,&amp;nbsp;*pt;
&amp;nbsp;&amp;nbsp; inline void init(int v0)&amp;nbsp;{
&amp;nbsp;&amp;nbsp; v = v0;
&amp;nbsp;&amp;nbsp; sz = 1;
&amp;nbsp;&amp;nbsp; s = v0;
&amp;nbsp;&amp;nbsp; pt = ls = rs = 0;</description>
    </item>
    
    <item>
      <title>BZOJ1097 [POI2007]旅游景点</title>
      <link>/oi/lofterimport_010/</link>
      <pubDate>Wed, 07 Jan 2015 21:30:50 +0000</pubDate>
      
      <guid>/oi/lofterimport_010/</guid>
      <description>比较简单易懂的状压。
最初想懒一下把起点和终点也压进来然后发现刚好会超一点空间。然后不压进来的话就是100MB左右，很好奇MAIN上面64MB的内存应该怎么做。拿MAP么？
代码各种难看啊郁闷。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
struct edge {
int t, v;
edge *next;
};
#define pow2(x)&amp;nbsp;(1&amp;lt;&amp;lt;(x))
typedef pair &amp;lt;int, int&amp;gt; dspr;
const int maxn = 20009;
const int maxe = 400009;
const int maxk = 20;
const int maxz = pow2(20)&amp;nbsp;+ 3;
int n, m, k, d[maxn];
int f[maxz][maxk], ds[maxk], dt[maxk], dk[maxk][maxk], ans;
int g, pr[maxk];
edge *ep,&amp;nbsp;*head[maxn];
dspr hp[maxe];
inline void addEdge(int u, int v, int w)&amp;nbsp;{</description>
    </item>
    
    <item>
      <title>BZOJ3858 Number Transformation</title>
      <link>/oi/lofterimport_011/</link>
      <pubDate>Tue, 06 Jan 2015 21:10:22 +0000</pubDate>
      
      <guid>/oi/lofterimport_011/</guid>
      <description>yy了一个sqrt的玩意，不过因为n在变所以没有保障啊。
肯定不是正解了。
1s的题跑了1.3s居然AC，好厉害。
#include &amp;lt;cstdio&amp;gt;
typedef long long dint;
#ifdef WIN32
#define lld &amp;quot;%I64d&amp;quot;
#else
#define lld &amp;quot;%lld&amp;quot;
#endif
dint calc(dint n, dint k)&amp;nbsp;{
if (n&amp;nbsp;&amp;lt;= 1)
return k;
for (dint i = 1, j; i &amp;lt;= k; i = j + 1)&amp;nbsp;{
if (n&amp;nbsp;&amp;lt;= i)
return k;
j =&amp;nbsp;(n&amp;nbsp;- 1)&amp;nbsp;/&amp;nbsp;((n - 1)&amp;nbsp;/ i);
if (j&amp;nbsp;&amp;gt; k)
j = k;
n =&amp;nbsp;((n&amp;nbsp;- 1)&amp;nbsp;/ i + 1)&amp;nbsp;* j;
}
return n;</description>
    </item>
    
    <item>
      <title>BZOJ2870 最长道路</title>
      <link>/oi/lofterimport_012/</link>
      <pubDate>Mon, 05 Jan 2015 20:14:31 +0000</pubDate>
      
      <guid>/oi/lofterimport_012/</guid>
      <description>最初觉得挺麻烦的一道题没思路。有点像并查集直接搞但是不好维护直径。
然后发现树上到任意一点的最远点一定是直径的两个端点之一。于是直接把直径是哪俩点记下来就好了。然后按点权从大到小往树里插。
然后莫名其妙地抢到了第二快。这么老的题也是蛮欣慰的。大概是读入优化2333
#include &amp;lt;bits/stdc++.h&amp;gt;
using namespace std;
void setRand()&amp;nbsp;{
FILE* pf = fopen(&amp;quot;.rs&amp;quot;,&amp;nbsp;&amp;quot;r&amp;quot;);
int hsv;
if (pf)&amp;nbsp;{
fscanf(pf,&amp;nbsp;&amp;quot;%d&amp;quot;,&amp;nbsp;&amp;amp;hsv);
fclose(pf);
}
srand(hsv);
printf(&amp;quot;Seed =&amp;nbsp;%d\n&amp;quot;, hsv);
pf = fopen(&amp;quot;.rs&amp;quot;,&amp;nbsp;&amp;quot;w&amp;quot;);
fprintf(pf,&amp;nbsp;&amp;quot;%d&amp;quot;,&amp;nbsp;(hsv &amp;lt;&amp;lt; 1)&amp;nbsp;|&amp;nbsp;(rand()&amp;nbsp;&amp;amp; 1));
fclose(pf);
}
#define readArg(a,b)&amp;nbsp;{ if (argc&amp;nbsp;&amp;gt; a) sscanf(args[a],&amp;nbsp;&amp;quot;%d&amp;quot;,&amp;nbsp;&amp;amp;b);&amp;nbsp;}
void mklr(int m, char s)&amp;nbsp;{
int l, r;
do
l = rand()&amp;nbsp;% m + 1, r = rand()&amp;nbsp;% m + 1;
while (l&amp;nbsp;&amp;gt; r);
printf(&amp;quot;%d %d%c&amp;quot;, l, r, s);
}</description>
    </item>
    
    <item>
      <title>BZOJ3834 [Poi2014]Solar Panels</title>
      <link>/oi/lofterimport_013/</link>
      <pubDate>Mon, 05 Jan 2015 12:04:52 +0000</pubDate>
      
      <guid>/oi/lofterimport_013/</guid>
      <description>orz jason_yu提醒了我一句“最简单的优化”，才想起来。
如果d合法的话那么b/d-(a-1)/d&amp;gt;0。然后用整除优化到sqrt就可过。虽然比较慢。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
int main()&amp;nbsp;{
int t, a, b, c, d, s, e;
scanf(&amp;quot;%d&amp;quot;,&amp;nbsp;&amp;amp;t);
while (t&amp;nbsp;--)&amp;nbsp;{
scanf(&amp;quot;%d%d%d%d&amp;quot;,&amp;nbsp;&amp;amp;a,&amp;nbsp;&amp;amp;b,&amp;nbsp;&amp;amp;c,&amp;nbsp;&amp;amp;d);
-- a;
-- c;
s = 1;
e = min(b, d);
for (int i = 1, j; i &amp;lt;= e; i = j + 1)&amp;nbsp;{
j = min(b /&amp;nbsp;(b&amp;nbsp;/ i), d /&amp;nbsp;(d&amp;nbsp;/ i));
if (a&amp;nbsp;/ i)
j = min(j, a /&amp;nbsp;(a&amp;nbsp;/ i));
if (c&amp;nbsp;/ i)</description>
    </item>
    
    <item>
      <title>BZOJ3829 [Poi2014]FarmCraft</title>
      <link>/oi/lofterimport_014/</link>
      <pubDate>Sun, 04 Jan 2015 23:05:42 +0000</pubDate>
      
      <guid>/oi/lofterimport_014/</guid>
      <description>树型贪心orz
写丑了。调了半个晚上，然后发现是起点最耗时的时候的情况搞错了，只用走n-1条路而不是n条。晕。
对于每个节点贪心按f[p]-2*sz[p]排序或者用原式也行。不过巨慢。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
int _d_;&amp;nbsp;
#define readInt(_x_)&amp;nbsp;{&amp;nbsp;\
int&amp;amp; _s_ =&amp;nbsp;(_x_&amp;nbsp;= 0);&amp;nbsp;\
while (!isdigit(_d_&amp;nbsp;= getchar()));&amp;nbsp;\
while (_s_&amp;nbsp;= _s_ * 10 + _d_ - 48, isdigit(_d_ = getchar()));&amp;nbsp;\
}
struct edge {
int t;
edge *next;
};
const int maxn = 500009;
int n, v[maxn], t, f[maxn], sz[maxn], dfo[maxn], st[maxn];
edge *ep,&amp;nbsp;*head[maxn];
inline void addEdge(int u, int v)&amp;nbsp;{
ep-&amp;gt; t = v;</description>
    </item>
    
    <item>
      <title>BZOJ3831 [Poi2014]Little Bird</title>
      <link>/oi/lofterimport_015/</link>
      <pubDate>Sun, 04 Jan 2015 13:37:14 +0000</pubDate>
      
      <guid>/oi/lofterimport_015/</guid>
      <description>一血yeah yeah。
第一眼觉得是比较麻烦的单调队列。
然后发现转移的时候只会加1或者不加。
那么取的时候只用取队首，队里首先fi单不降然后hi单减。那么一定没有方案比取队首差。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
int _d_;&amp;nbsp;
#define readInt(_x_)&amp;nbsp;{&amp;nbsp;\
int&amp;amp; _s_ =&amp;nbsp;(_x_&amp;nbsp;= 0);&amp;nbsp;\
while (!isdigit(_d_&amp;nbsp;= getchar()));&amp;nbsp;\
while (_s_&amp;nbsp;= _s_ * 10 + _d_ - 48, isdigit(_d_ = getchar()));&amp;nbsp;\
}
const int maxn = 1000009;
int n, m, a[maxn], f[maxn], q[maxn];
int getTrans(int l, int r)&amp;nbsp;{
int v0 = f[q[l]];
while (l&amp;nbsp;&amp;lt; r)&amp;nbsp;{
int mid =&amp;nbsp;(l&amp;nbsp;+ r + 1)&amp;nbsp;&amp;gt;&amp;gt; 1;</description>
    </item>
    
    <item>
      <title>BZOJ3401 [Usaco2009 Mar]Look Up 仰望</title>
      <link>/oi/lofterimport_016/</link>
      <pubDate>Fri, 02 Jan 2015 21:46:13 +0000</pubDate>
      
      <guid>/oi/lofterimport_016/</guid>
      <description>签到题。表示今天虽然废了一天但是还是坚持写了题的。
单调栈搞定。
因为打球把小指头打残了所以不想敲include所以写了pascal，然后发现include不用小指。
const
maxn = 100009;
var
n, i, t: longint;
a, st, ans: array[0 .. maxn] of longint;
begin
readln(n);
for i := 1 to n do
readln(a[i]);
t := 0;
for i := n downto 1 do begin
while (t&amp;nbsp;&amp;gt; 0) and (a[i]&amp;nbsp;&amp;gt;= a[st[t]]) do
dec(t);
if t = 0 then
ans[i]&amp;nbsp;:= 0
else
ans[i]&amp;nbsp;:= st[t];
inc(t);
st[t]&amp;nbsp;:= i;
end;
for i := 1 to n do</description>
    </item>
    
    <item>
      <title>BZOJ3825 [Usaco2014 Nov]Marathon</title>
      <link>/oi/lofterimport_017/</link>
      <pubDate>Thu, 01 Jan 2015 16:08:54 +0000</pubDate>
      
      <guid>/oi/lofterimport_017/</guid>
      <description>英语阅读题。做完去翻译题面然后写英语作业了。
就维护一下区间里的距离和and忽略一个点的收益的最大值。完了。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
struct seg {
int l, r;
int s, v;
seg *ls,&amp;nbsp;*rs;
};
const int maxn = 100009;
int n, m, x[maxn], y[maxn], d[maxn], v[maxn];
seg *rt,&amp;nbsp;*sp;
inline void upDis(int i)&amp;nbsp;{
if (i&amp;nbsp;&amp;lt; n)
d[i]&amp;nbsp;= abs(x[i + 1]&amp;nbsp;- x[i])&amp;nbsp;+ abs(y[i + 1]&amp;nbsp;- y[i]);
else
d[i]&amp;nbsp;= 0;
}
inline void upVal(int i)&amp;nbsp;{
if (i&amp;nbsp;&amp;gt; 1 &amp;amp;&amp;amp; i &amp;lt; n)
v[i]&amp;nbsp;= d[i - 1]&amp;nbsp;+ d[i]&amp;nbsp;- abs(x[i + 1]&amp;nbsp;- x[i - 1])&amp;nbsp;- abs(y[i + 1]&amp;nbsp;- y[i - 1]);</description>
    </item>
    
    <item>
      <title>BZOJ3826 [Usaco2014 Nov]Cow Jog</title>
      <link>/oi/lofterimport_018/</link>
      <pubDate>Thu, 01 Jan 2015 15:30:07 +0000</pubDate>
      
      <guid>/oi/lofterimport_018/</guid>
      <description>新题么。略水。
就一个序列，如果起点单增的话只要终点单增就不会冲突。
然后最少单增子序列覆盖=最长不降子序。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
typedef long long dint;
#define _l (long long int)
const int maxn = 100009;
int n, m, a[maxn], t[maxn], s;
dint v[maxn], v0[maxn];
int btQry(int p)&amp;nbsp;{
int s = 0;
for (; p; p -=&amp;nbsp;(p&amp;nbsp;&amp;amp;&amp;nbsp;-p))
s = max(s, t[p]);
return s;
}
void btChg(int p, int v)&amp;nbsp;{
for (; p &amp;lt;= n; p +=&amp;nbsp;(p&amp;nbsp;&amp;amp;&amp;nbsp;-p))
t[p]&amp;nbsp;= max(t[p], v);
}</description>
    </item>
    
    <item>
      <title>20150101</title>
      <link>/oi/lofterimport_019/</link>
      <pubDate>Thu, 01 Jan 2015 00:20:32 +0000</pubDate>
      
      <guid>/oi/lofterimport_019/</guid>
      <description>2015，嗯，还习惯性地敲2014。一年就过去了，好快。
2014年1月1号已经是一年前的事情了，略恐怖。
感觉不只过了一年啊。
这一年我都在干啥？
寒假的时候去wc打个酱油，骗分的结果还不错。然后感觉讲课完全像在冬眠。好多课根本听不懂没法听。是我太弱吧。
开学之后就一直在教室和机房两边跑。对省队还怀有一丝幻想。直到，见到省选题。然后就以能拿的分没拿到不能拿的分也没拿到的分再见了。当时安慰自己太年轻，现在想来，也真是。
然后看到学长们填thu的自招表，也去跟着填了一个表。然后，当然肯定被毫无疑问地打了回来。令人触目惊心的是要填各次大考的成绩。半期缺考+垫底的我心中一惊啊。
然后期末的调研考试考得不好但是也比半期进步了不少。毕竟半期是停课裸考还没考完。
然后暑假很荣幸地去参观noi。结果自己再次犯傻把最简单第一题写错然后抱着AG哭。记得第一天估分的时候信心满满地报了个200+然后看到第一题60的时候。唉。
暑假回来感觉愉快不少，毕竟终于可以不上课了。
然后就全力准备noip，虽然常常刷题不小心就打开了bzoj。
然后就去了noip。然后再次犯傻的bird。于是没拿到省rank1。
然后半期经过三天“认真”复习之后真的垫底了。文化课看来是废了。
然后就又去学习thu集训的题了。然后跟着去了bj80ms。然后发现在诸如jiry和dzy大神的眼里我也只是根草而已，连菜都算不上。
然后回来了，然后被告愉快的停课生涯结束了。然后愉快地直接在月考中勇夺rank1还是倒数的。
老师问一年里收获是啥？学会了放弃吧。有多少付出才会有多少回报。然后当你面对你付出后血淋淋的伤口的时候，你会是怎样一种心情？也不见得能用愉快来形容吧。
管他去死。
既然都这样了，也只能继续了。人在矮桅下，不得不低头。等哪天离开矮檐了，再考虑去把让我低头的人的头给砍下来当夜壶。然后再深情地表达尊敬，还能写出一篇不错的议论文。
虽然也不是没有道理。有些事情总是要面对的。
不要忘了本，然后该干啥干啥吧。</description>
    </item>
    
    <item>
      <title>BZOJ3301 [USACO2011 Feb] Cow Line</title>
      <link>/oi/lofterimport_020/</link>
      <pubDate>Thu, 01 Jan 2015 00:00:03 +0000</pubDate>
      
      <guid>/oi/lofterimport_020/</guid>
      <description>新年第一题哈哈。虽然没有成功拿到fb。
所谓阶乘进制数么。略水。只不过加一减一啥的得小心些。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
typedef long long dint;
#define pow2(x)&amp;nbsp;(1&amp;lt;&amp;lt;(x))
#ifdef WIN32
#define lld &amp;quot;%I64d&amp;quot;
#else
#define lld &amp;quot;%lld&amp;quot;
#endif
const int maxn = 21;
dint fac[maxn];
int n, k, t, x[maxn];
dint a;
void sovPerm()&amp;nbsp;{
t = 0;
for (int i = n; i;&amp;nbsp;-- i)&amp;nbsp;{
int r =&amp;nbsp;(a&amp;nbsp;- 1)&amp;nbsp;/ fac[i - 1]&amp;nbsp;+ 1, c = 0;
a -=&amp;nbsp;(r&amp;nbsp;- 1)&amp;nbsp;* fac[i - 1];</description>
    </item>
    
    <item>
      <title>BZOJ3823 定情信物</title>
      <link>/oi/lofterimport_021/</link>
      <pubDate>Sun, 28 Dec 2014 01:38:08 +0000</pubDate>
      
      <guid>/oi/lofterimport_021/</guid>
      <description>解锁成就：半夜过题。（其实是因为在搞bsd）
仔细看下题推一下发现第n维中m维元素的个数为2^(n-m)*C(n,m)。
然后组合数好像得nlogn用逆元？恭喜tle。
然后yy了一个用线性筛的办法，只是素数用快速幂，这样大约可以降低复杂度，然后就能过了。好神奇。
代码好长TT。
#include &amp;lt;cstdio&amp;gt;
#include&amp;nbsp;&amp;lt;cstring&amp;gt;
#define _l (long long int)
const int maxn = 10000009;
int tp, pn[maxn], inv[maxn];
bool pr[maxn];
int n, mod, s, c, p;
int modPow(int a, int x)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp; int s = 1;
&amp;nbsp;&amp;nbsp;&amp;nbsp; for (; x; x &amp;gt;&amp;gt;= 1, a = _l a * a % mod)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (x&amp;nbsp;&amp;amp; 1)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s = _l s * a % mod;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return s;</description>
    </item>
    
    <item>
      <title>BZOJ1367 [Baltic2004]sequence</title>
      <link>/oi/lofterimport_022/</link>
      <pubDate>Sat, 27 Dec 2014 21:01:20 +0000</pubDate>
      
      <guid>/oi/lofterimport_022/</guid>
      <description>退役了之后智商下降严重啊。今天bc死惨了。这比较水的题也是去看了题解才反应过来的。
先把序列改成不降。
然后把原来的序列分成一些段，每段的中位数递增。
&amp;nbsp;&amp;nbsp;考虑新加入一个ai，如果它比前一段的中位数小，那么就把它和前一段合并，再拿合并之后的段去和再前一段比较一下。其实我也不能证明为啥是这样，只是感觉比较有道理。我肯定是没救了。
中位数的话用可合并的堆来维护比较方便。orz各种神级堆，然后我还是用的左偏树。
以后树要拿指针写所以代码巨长。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
int _d_;
#define readInt(_x_)&amp;nbsp;{&amp;nbsp;\
int&amp;amp; _s_ = _x_;&amp;nbsp;\
while (!isdigit(_d_&amp;nbsp;= getchar()));&amp;nbsp;\
_s_ = 0;&amp;nbsp;\
while ((_s_&amp;nbsp;= _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar()));&amp;nbsp;\
}
#define sof(p)&amp;nbsp;((p)?(p-&amp;gt;s):0)
struct node {
int v, s;
node *ls,&amp;nbsp;*rs;
inline void init(int x)&amp;nbsp;{
v = x;
s = 1;
ls = 0;
rs = 0;</description>
    </item>
    
    <item>
      <title>BZOJ1171 大sz的游戏</title>
      <link>/oi/lofterimport_023/</link>
      <pubDate>Sat, 27 Dec 2014 10:00:25 +0000</pubDate>
      
      <guid>/oi/lofterimport_023/</guid>
      <description>大概是今天不宜刷题来着。应该好好做作业。
用线段树套单调队列可以把复杂度降到O(nlogn)。然后deque严重不靠谱，得用list才行。
然后还是跑得巨慢。前面的人是排序搞定的么？表示不明觉厉。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;deque&amp;gt;
#include &amp;lt;list&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
int _d_;
#define readInt(_x_)&amp;nbsp;{&amp;nbsp;\
int&amp;amp; _s_ = _x_;&amp;nbsp;\
while (!isdigit(_d_&amp;nbsp;= getchar()));&amp;nbsp;\
_s_ = 0;&amp;nbsp;\
while ((_s_&amp;nbsp;= _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar()));&amp;nbsp;\
}
//typedef deque &amp;lt;int&amp;gt; dque_i;
typedef list &amp;lt;int&amp;gt; dque_i;
struct seg {
int l, r;
dque_i u, d;
seg *ls,&amp;nbsp;*rs;
};
const int maxn = 250009;</description>
    </item>
    
    <item>
      <title>BZOJ3821 玄学</title>
      <link>/oi/lofterimport_024/</link>
      <pubDate>Fri, 26 Dec 2014 21:32:24 +0000</pubDate>
      
      <guid>/oi/lofterimport_024/</guid>
      <description>zhx+主席出的题，恐怖至极。
写此题需要极高的常数优化技巧+耐心。
本地跑到50s才在bzoj上压80s跑过。
其实思路就是拿线段树套AVL把询问的时间复杂度优化到O(logn)。
然后首先用treap会t爽+mle爽。
然后avl需要各种常数优化。
然后要在xxxxx地方优化。
加上zhx牌读入优化+块状内存+抄std的AVL+.....终于在81s过了。
orz比我快一倍的wangyisong神犇。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstdlib&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
const int BUF_SIZE = 300;
char buf[BUF_SIZE],&amp;nbsp;*buf_s = buf,&amp;nbsp;*buf_t = buf + 1;
#define PTR_NEXT()&amp;nbsp;\
{&amp;nbsp;\
buf_s ++;&amp;nbsp;\
if (buf_s&amp;nbsp;== buf_t)&amp;nbsp;\
{&amp;nbsp;\
buf_s = buf;&amp;nbsp;\
buf_t = buf + fread(buf, 1, BUF_SIZE, stdin);&amp;nbsp;\
}&amp;nbsp;\
}
#define readInt(_n_)&amp;nbsp;\
{&amp;nbsp;\
while (*buf_s&amp;nbsp;!=&amp;nbsp;&#39;-&#39;&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;!isdigit(*buf_s))&amp;nbsp;\
PTR_NEXT();&amp;nbsp;\
bool register _nega_ = false;&amp;nbsp;\
if (*buf_s&amp;nbsp;==&amp;nbsp;&#39;-&#39;)&amp;nbsp;\</description>
    </item>
    
    <item>
      <title>BZOJ2738 矩阵乘法</title>
      <link>/oi/lofterimport_025/</link>
      <pubDate>Fri, 26 Dec 2014 17:45:06 +0000</pubDate>
      
      <guid>/oi/lofterimport_025/</guid>
      <description>全局二分的经典题。
最初试图用持久化线段树和分块，然后欢快地tle+mle了。看到jason_yu和mhy过了，只能说自己的常数优化还不过关啊。
第一次写这种二分。就是把所有东西扔进来快速排序，顺便考虑每个询问应该被扔到哪边。然后加树状数组来统计就好了。
代码巨丑。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
struct query {
int x1, y1, x2, y2, k, n;
};
int _d_;
#define readInt(_x_)&amp;nbsp;{&amp;nbsp;\
int&amp;amp; _s_ = _x_;&amp;nbsp;\
while (!isdigit(_d_&amp;nbsp;= getchar()));&amp;nbsp;\
_s_ = 0;&amp;nbsp;\
while ((_s_&amp;nbsp;= _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar()));&amp;nbsp;\
}
const int maxn = 509;
const int maxq = 310009;
int n, m, t, maxa, a[maxn][maxn], b[maxn][maxn], ttm;</description>
    </item>
    
    <item>
      <title>BZOJ1633 [Usaco2007 Feb]The Cow Lexicon 牛的词典</title>
      <link>/oi/lofterimport_026/</link>
      <pubDate>Wed, 24 Dec 2014 21:27:43 +0000</pubDate>
      
      <guid>/oi/lofterimport_026/</guid>
      <description>本来想做点英语作业的。想10分钟把这题搞定的。结果傻了去写trie树dp又傻了没有考虑终点也可以有子结点。
我真是无药可救了。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
int tcnt;
struct trie_node {
int d, e, t[26];
inline trie_node(int d0 = 0)&amp;nbsp;{
e = 0;
d = d0 + 1;
memset(t, 0, sizeof(t));
}
inline int ins(char c)&amp;nbsp;{
if (!t[c&amp;nbsp;- 97])
t[c - 97]&amp;nbsp;=&amp;nbsp;++ tcnt;
return t[c - 97];
}
inline int trans(char c)&amp;nbsp;{
return t[c - 97];
}
};
const int inf = 0x3f3f3f3f;
const int maxs = 15009;</description>
    </item>
    
    <item>
      <title>BZOJ1933 [Shoi2007]Bookcase 书柜的尺寸</title>
      <link>/oi/lofterimport_027/</link>
      <pubDate>Mon, 22 Dec 2014 23:32:06 +0000</pubDate>
      
      <guid>/oi/lofterimport_027/</guid>
      <description>老早之前就听说过的题。好像讲过不只一遍。不过才从bzoj上翻出来。
记得是神奇的dp优化。为啥这年头卡常数的题这么多。
首先肯定这玩意多项式可解。六维状态肯定能搞定。然后会mle+tle。
首先考虑从高到低放书，那么后面的如果不新开一行的话对高度没有影响。瞬间少了3维状态。
然后发现只要知道两维的总宽度和当前是第几位，就能知道第三维的宽度。于是一维2100缩70，开滚动可过。
当然还是需要一些常数优化的技艺。比如用宽度直接判断这一行有没有书。这样可以省下不少时间，而且好像只能这样才存得下。64MB太紧了点。另外把函数里的int改成const int&amp;amp;会变慢，不知为何。
居然花了这么久才搞出来。我太年轻了。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
struct book {
int w, h;
};
inline bool cmpBook(const book&amp;amp; a, const book&amp;amp; b)&amp;nbsp;{
return a. h &amp;gt; b. h;
}
const int maxn = 71;
const int maxw = 2109;
const int inf = 0x3f3f3f3f;
int n, f[2][maxw][maxw], sw;
book a[maxn];
inline void upmin(int&amp;amp; _a_, int _b_)&amp;nbsp;{
if (_a_&amp;nbsp;&amp;gt; _b_)
_a_ = _b_;</description>
    </item>
    
    <item>
      <title>20141222</title>
      <link>/oi/lofterimport_028/</link>
      <pubDate>Mon, 22 Dec 2014 19:45:44 +0000</pubDate>
      
      <guid>/oi/lofterimport_028/</guid>
      <description>不久之后要会考了，再过不久要期末了。教育部在放风，大概以后如果noi拿不到金牌的话就得和别人一样地高考了。
一直在oi里面坚持也没有怎么想过高考的事，一直只是当作一个额外的好处。如果让我不上大学给我一次ioi的机会，我想我也不会犹豫的。
本来，上什么大学，也不是什么重要的事情。作为oier，我知道，只向上看，是个很好的品质，但是不是什么好的策略。如果你非要落魄到拿着期末成绩去让大学收你，那你该考虑换个差点的大学了。
因为做过鸡头，所以对做凤尾产生了抵触吧。
当然，显然，学校，老师都不这么想。虽然我来这里的目的也完全不是因为高考，但是既然穿上这身校服，你也没有办法。
背起包走回教室的感觉真的很像退役了。
大本的崭新的练习册让人很压抑。如何在两周内补完一个学期的内容是一个很艰巨的问题。也许多看书多刷题是个不错的选择。
既然有人要来挑战，那就让他们看看。</description>
    </item>
    
    <item>
      <title>BZOJ3809 Gty的二逼妹子序列</title>
      <link>/oi/lofterimport_029/</link>
      <pubDate>Mon, 22 Dec 2014 19:38:16 +0000</pubDate>
      
      <guid>/oi/lofterimport_029/</guid>
      <description>好一道卡常数。不仅卡时间，还卡空间。堪称丧心病狂的极致。
首先因为空间小所以得用莫队。然后不知为何树状数组没有直接分块跑得快。
没有救啦。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;cmath&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
&amp;nbsp;
usingnamespacestd;
&amp;nbsp;
structqry {
&amp;nbsp;&amp;nbsp;&amp;nbsp; intl, r, a, b, n;
};
&amp;nbsp;
int_d_;
#define readInt(_x_)&amp;nbsp;{&amp;nbsp;\
&amp;nbsp;&amp;nbsp;&amp;nbsp; int&amp;amp; _s_ = _x_;&amp;nbsp;\
&amp;nbsp;&amp;nbsp;&amp;nbsp; while(!isdigit(_d_ = getchar()));&amp;nbsp;\
&amp;nbsp;&amp;nbsp;&amp;nbsp; _s_ = 0;&amp;nbsp;\
&amp;nbsp;&amp;nbsp;&amp;nbsp; while((_s_ = _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar()));&amp;nbsp;\
}
&amp;nbsp;
constintmaxn = 100009;
constintmaxm = 1000009;
&amp;nbsp;
intn, m, bsz, a[maxn], c[maxn], w[maxn], b[maxn], ans[maxm];</description>
    </item>
    
    <item>
      <title>BZOJ1875 [SDOI2009]HH去散步</title>
      <link>/oi/lofterimport_031/</link>
      <pubDate>Sun, 21 Dec 2014 14:55:35 +0000</pubDate>
      
      <guid>/oi/lofterimport_031/</guid>
      <description>乍一看矩阵水题，然后发现不能走回头路。
于是改一下把边当做点，把点当作转移，转移的时候就可以避免走过去就走回来的情况了。
说好的复习会考呢？
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
#define _l (long long int)
const int mod = 45989;
const int maxn = 123;
class matrix {
public:
int n, a[maxn][maxn];
inline matrix()&amp;nbsp;{
}
inline matrix(int n0, bool one = 0)&amp;nbsp;{
n = n0;
memset(a, 0, sizeof(a));
if (one)
for (int i = 0; i &amp;lt; n;&amp;nbsp;++ i)
a[i][i]&amp;nbsp;= 1;
}
void operator =(const matrix&amp;amp; x)&amp;nbsp;{
n = x.</description>
    </item>
    
    <item>
      <title>BZOJ3728 PA2014Final Zarowki</title>
      <link>/oi/lofterimport_032/</link>
      <pubDate>Sun, 21 Dec 2014 14:21:28 +0000</pubDate>
      
      <guid>/oi/lofterimport_032/</guid>
      <description>贪心。从小到大每个灯泡找个小于等于它的最接近的房间去照。
剩下的照不亮的房间直接换。
剩下的背包空间把已经匹配的差最大的换掉。
第一步要拿堆维护一下。剩下的直接排序。
然后把nie写成-1了，no save。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
typedef long long di;
#ifdef WIN32
#define difmt &amp;quot;%I64d&amp;quot;
#else
#define difmt &amp;quot;%lld&amp;quot;
#endif
const int maxn = 500009;
int _d_;
#define readInt(_x_)&amp;nbsp;{&amp;nbsp;\
int&amp;amp; _s_ = _x_;&amp;nbsp;\
while (!isdigit(_d_&amp;nbsp;= getchar()));&amp;nbsp;\
_s_ = 0;&amp;nbsp;\
while ((_s_&amp;nbsp;= _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar()));&amp;nbsp;\
}
int n, k, p[maxn], w[maxn], x[maxn], t;</description>
    </item>
    
    <item>
      <title>BZOJ2565 最长双回文串</title>
      <link>/oi/lofterimport_033/</link>
      <pubDate>Sat, 20 Dec 2014 23:09:18 +0000</pubDate>
      
      <guid>/oi/lofterimport_033/</guid>
      <description>以前觉得不会，仔细想想觉得还是挺水。
manacher找出所有中心回文串，然后用单调队列扫一下每个位置往左最长和往右最长就行。找位置比较烦不过还是比较好写的。
重点是写出了在windows下拿for循环对拍，虽然异常丑。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
const int maxn = 200009;
int n, l[maxn], q[maxn], vx[maxn], vy[maxn];
char a[maxn];
void manacher()&amp;nbsp;{
l[0]&amp;nbsp;= 1;
for (int i = 1, j = 0; i &amp;lt;&amp;nbsp;(n&amp;nbsp;&amp;lt;&amp;lt; 1)&amp;nbsp;- 1;&amp;nbsp;++ i)&amp;nbsp;{
int r =&amp;nbsp;((j&amp;nbsp;+ 1)&amp;nbsp;&amp;gt;&amp;gt; 1)&amp;nbsp;+ l[j]&amp;nbsp;- 1;
int p = i &amp;gt;&amp;gt; 1, q = i - p;
l[i]&amp;nbsp;=&amp;nbsp;(r &amp;gt;= q)&amp;nbsp;? min(r - q + 1, l[(j &amp;lt;&amp;lt; 1)&amp;nbsp;- i])&amp;nbsp;: 0;</description>
    </item>
    
    <item>
      <title>80MSWC diary 4.1</title>
      <link>/oi/lofterimport_035/</link>
      <pubDate>Thu, 18 Dec 2014 16:57:30 +0000</pubDate>
      
      <guid>/oi/lofterimport_035/</guid>
      <description>昨天就考完了不过今天还是讲了一天的课。
上午是罗翔宇的杂题。感觉好多题他上次都讲过不过就是记不得怎么做了。看来听课效率有待提高。
下午是讲icpc的题加各种神奇的玩意。感觉比较好玩，不过有点偏题啊。然后做表去了也没大听。
毕竟我还是太年轻对吧，七天就水过去了。还被学军的大爷们虐成狗了。</description>
    </item>
    
    <item>
      <title>BZOJ2105 增强型LCP</title>
      <link>/oi/lofterimport_037/</link>
      <pubDate>Wed, 17 Dec 2014 16:03:47 +0000</pubDate>
      
      <guid>/oi/lofterimport_037/</guid>
      <description>最初以为是splay维护Hash的简单题。顺手开心地敲了个splay还是指针版的。
然后发现tle了。
然后知道了可以暴力重新建串。
然后拿splay暴力重新建串。
然后又tle了。
然后不得已改成了随机线性存取表，过之。
我还是太naive了啊。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
typedef unsigned long long qw;
#define _l (long long int)
const int maxn = 200009;
const int base = 233;
struct str {
char a[maxn];
int len;
inline str()&amp;nbsp;{
len = 0;
}
inline void read()&amp;nbsp;{
scanf(&amp;quot;%s&amp;quot;, a + 1);
len = strlen(a + 1);
}
inline char operator [](const int&amp;amp; x) const {</description>
    </item>
    
    <item>
      <title>80MSWC diary 3.5</title>
      <link>/oi/lofterimport_038/</link>
      <pubDate>Tue, 16 Dec 2014 21:30:46 +0000</pubDate>
      
      <guid>/oi/lofterimport_038/</guid>
      <description>昨天是day3明天是day4所以今天是day3.5。
讲了一天课。
上午+晚上是图论。感觉图论的东西比较神。好像基本都是cf原题吧。好多东西要和其它的诸如数据结构和dp之类的东西结合，还有数学也比较重要。
下午是fft相关。先讲了一下fft的原理，虽然我觉得讲得除了好玩以外没什么特点，也没有用最好理解的方式来讲。然后期待的例题好像也不杂。然后怎么就扯到牛顿迭代上去了。不过这玩意以前没用过感觉还挺神奇的，改天找道题试试。
晚上无聊的时候写了个后缀数组，这种东西还是要不时写写不然都要忘了。然后后缀自动机的构建依然不太能理解。看来我还是太弱了WUW
然后明天是最后一天了。我虽然年轻，但是还是要努力一点的。</description>
    </item>
    
    <item>
      <title>BZOJ1692 [Usaco2007 Dec]队列变换</title>
      <link>/oi/lofterimport_039/</link>
      <pubDate>Tue, 16 Dec 2014 19:34:28 +0000</pubDate>
      
      <guid>/oi/lofterimport_039/</guid>
      <description>最初以为是水题，直接写个dq交上去不对。
看了下题解才知道是后缀数组。好久不写都快不会写了。
把原串倒过来扔一起排一下就行了。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
const int maxn = 60009;
int n;
int sa[maxn], rk[maxn], ro[maxn], w[maxn], o[maxn];
char a[maxn];
void sufixArray(int n)&amp;nbsp;{
memset(w, 0, sizeof(w));
for (int i = 0; i &amp;lt; n;&amp;nbsp;++ i)
++ w[(int)a[i]];
for (int i = 1; i &amp;lt; 123;&amp;nbsp;++ i)
w[i]&amp;nbsp;+= w[i - 1];
for (int i = 0; i &amp;lt; n;&amp;nbsp;++ i)
sa[-- w[(int)a[i]]]&amp;nbsp;= i;</description>
    </item>
    
    <item>
      <title>80MSWC diary 1.5</title>
      <link>/oi/lofterimport_042/</link>
      <pubDate>Sat, 13 Dec 2014 20:45:38 +0000</pubDate>
      
      <guid>/oi/lofterimport_042/</guid>
      <description>既然明天考试是day2，那么今天就叫day1.5好了。
上午下午都在听讲。
上午讲构造。题都比较神奇。我觉得比较重要的是思想吧。以后看到这类题可以稍微有些套路，不过更多的还是要靠智商了。
下午讲字符串。后缀树和后缀自动机前几天就在看，虽然一直不太理解怎么构造出来的。讲得我也有点晕。还是要自己努力消化了。然后在bzoj上看到好多例题都有jiry的不久前的ac记录，orz。
晚上bc做了a和c之后就不想做了。b没想出来，d知道是分块+主席树，不过也懒得敲了。晚上大概吃得有点多。
所以我啊，还是太年轻了。</description>
    </item>
    
    <item>
      <title>BZOJ2795 A Horrible Poem</title>
      <link>/oi/lofterimport_043/</link>
      <pubDate>Sat, 13 Dec 2014 20:41:53 +0000</pubDate>
      
      <guid>/oi/lofterimport_043/</guid>
      <description>今天上课讲的题。
做法就直接枚举约数，或者说分解质因数。后者可以预处理到log。
判循环也比较开心。直接用一些奇奇怪怪的字符串的性质就好了。
看来字符串很博大精深啊。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
typedef unsigned long long qw;
typedef pair &amp;lt;int, qw&amp;gt; hstrv;
#define _l (long long int)
int _d_;
#define readInt(_x_)&amp;nbsp;{&amp;nbsp;\
int&amp;amp; _s_ = _x_;&amp;nbsp;\
while (!isdigit(_d_&amp;nbsp;= getchar()));&amp;nbsp;\
_s_ = 0;&amp;nbsp;\
while ((_s_&amp;nbsp;= _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar()));&amp;nbsp;\
}
const int maxn = 500009;
const int base = 257;
const int hmod = 1000000093;</description>
    </item>
    
    <item>
      <title>80MSWC diary 0</title>
      <link>/oi/lofterimport_045/</link>
      <pubDate>Fri, 12 Dec 2014 18:24:55 +0000</pubDate>
      
      <guid>/oi/lofterimport_045/</guid>
      <description>昨天晚上被那道usaco的题玩坏了于是没写日记。
来到了帝都。第二次去80ms了。好像没啥好写啊。
这回没下雪不过风吹上去还是挺冷。
晚上去家乐福吃汉堡，然后走回去。外面好冷。（这绝对不是伏笔）
想到明天要考试也是比较开心。和zhx聊了聊人生，然后写了道usaco发现把题看错了不会。然后就弃疗了。</description>
    </item>
    
    <item>
      <title>BZOJ1037 生日聚会</title>
      <link>/oi/lofterimport_046/</link>
      <pubDate>Mon, 08 Dec 2014 15:04:52 +0000</pubDate>
      
      <guid>/oi/lofterimport_046/</guid>
      <description>好久没做过数据范围这么小的题了。
看来我是有点偏科了。
这么前面的题居然都不做。
dp就好。状态是前面男-女的最大值和最小值还有现在有多少男。然后滚动。
我毕竟太年轻。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
const int maxn = 159;
const int maxk = 49;
const int kbase = 23;
const int mod = 12345678;
int n, m, c, f[2][maxn][maxk][maxk];
#define incm(_x_,_b_)&amp;nbsp;{&amp;nbsp;\
int&amp;amp; _a_ = _x_;&amp;nbsp;\
_a_ += _b_;&amp;nbsp;\
if (_a_&amp;nbsp;&amp;gt;= mod)&amp;nbsp;\
_a_ %= mod;&amp;nbsp;\
}
int main()&amp;nbsp;{
#ifndef ONLINE_JUDGE
freopen(&amp;quot;in.txt&amp;quot;,&amp;nbsp;&amp;quot;r&amp;quot;, stdin);
#endif
scanf(&amp;quot;%d%d%d&amp;quot;,&amp;nbsp;&amp;amp;n,&amp;nbsp;&amp;amp;m,&amp;nbsp;&amp;amp;c);
if (c&amp;nbsp;== 0)&amp;nbsp;{
puts(&amp;quot;0&amp;quot;);
}
else {</description>
    </item>
    
    <item>
      <title>BZOJ3786 星系探索</title>
      <link>/oi/lofterimport_053/</link>
      <pubDate>Tue, 02 Dec 2014 17:16:23 +0000</pubDate>
      
      <guid>/oi/lofterimport_053/</guid>
      <description>前两天还在YY动态DFS序呢，这就冒了一个出来。
动态DFS序的郁闷之处在于不好维护dfs序上的end。而把反括号建出来正好能解决这个问题。
然后就splay写得飞慢不知道怎么回事。
用两个栈就可以迭代做出括号序列，自己YY出来的给自己赞一个。
然后是目前最长的代码和倒数第二慢的时间。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
int _d_;
#define readInt(_x_)&amp;nbsp;{&amp;nbsp;\
int &amp;amp;_s_&amp;nbsp;= _x_;&amp;nbsp;\
while (!isdigit(_d_&amp;nbsp;= getchar()));&amp;nbsp;\
_s_ = 0;&amp;nbsp;\
while ((_s_&amp;nbsp;= _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar()));&amp;nbsp;\
}
#define readOpt(_x_)&amp;nbsp;{&amp;nbsp;\
while (!isupper(_d_&amp;nbsp;= getchar()));&amp;nbsp;\
_x_ = _d_;&amp;nbsp;\
}
typedef long long qw;
#ifdef WIN32
#define lld &amp;quot;%I64d&amp;quot;
#else
#define lld &amp;quot;%lld&amp;quot;
#endif
struct edge {
int t;</description>
    </item>
    
    <item>
      <title>BZOJ2154 Crash的数字表格</title>
      <link>/oi/lofterimport_055/</link>
      <pubDate>Mon, 01 Dec 2014 21:27:34 +0000</pubDate>
      
      <guid>/oi/lofterimport_055/</guid>
      <description>优化方法暑假的时候zhx讲过，我居然还记得好感动。
Mobius反演加些奇异的东西。（不会用公式编辑器是不是已经落伍了）
两个优化-&amp;gt; sqrt(n)^2 == n。
跑得飞慢&amp;nbsp;。而且中间那坨又长又丑。
久了不写都快忘了。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
typedef long long qw;
#define _l (qw)
const int maxn = 10000009;
const int mod = 20101009;
int pn[maxn], mu[maxn], smu[maxn], tp;
bool pr[maxn];
void pre(int maxn)&amp;nbsp;{
memset(pr, 0, sizeof(pr));
tp = 0;
mu[1]&amp;nbsp;= 1;
for (int i = 2; i &amp;lt;= maxn;&amp;nbsp;++ i)&amp;nbsp;{
if (!pr[i])&amp;nbsp;{
pn[tp ++]&amp;nbsp;= i;
mu[i]&amp;nbsp;=&amp;nbsp;-1;
}
for (int j = 0; j &amp;lt; tp &amp;amp;&amp;amp; i * pn[j]&amp;nbsp;&amp;lt;= maxn;&amp;nbsp;++ j)&amp;nbsp;{</description>
    </item>
    
    <item>
      <title>BZOJ3000 Big Number</title>
      <link>/oi/lofterimport_058/</link>
      <pubDate>Sun, 30 Nov 2014 11:28:01 +0000</pubDate>
      
      <guid>/oi/lofterimport_058/</guid>
      <description>题意：求n!在b进制下的位数（n&amp;lt;=2^31）。
好像要高精！？好像会TLE！？根本不会做！
然后想到answer=∑log(k,i)
然后积分？∫ln(x) dx = xln(x)&amp;nbsp;- x
小数据直接跑，过之。试个极限数据，差了3！？
仔细一想，对数函数是凹的，这样算答案当然会偏小。
百度了一下，发现有个公式：n!≈√(2*π*n)*(n/e)^n。
拆开之后发现就是比原来的积分多了个ln(2*π*n)
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cmath&amp;gt;
const double pi = asin(1)&amp;nbsp;* 2.0;
double calc(double n, double k)&amp;nbsp;{
double ans = 0;
if (n&amp;nbsp;&amp;lt; 100000)&amp;nbsp;{
for (int i = 1; i &amp;lt;= n;&amp;nbsp;++ i)
ans += log(i);
ans /= log(k);
}
else {
ans =&amp;nbsp;(0.5&amp;nbsp;* log(pi * n * 2)&amp;nbsp;+ log(n)&amp;nbsp;* n - n)&amp;nbsp;/ log(k);
}
return ans + 0.5;
}</description>
    </item>
    
    <item>
      <title>BZOJ1951 [Sdoi2010]古代猪文</title>
      <link>/oi/lofterimport_061/</link>
      <pubDate>Sat, 29 Nov 2014 17:04:43 +0000</pubDate>
      
      <guid>/oi/lofterimport_061/</guid>
      <description>好像数学都退化了。
其实一直没有用过中国剩余定理。虽然好像也不是太麻烦，不过要记住。
然后这题也比较裸吧。把C(n,m)中的阶乘分解成t*p^k的样子就好了。ORZ JASON_YU
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
typedef long long qw;
#define _l (qw)
const int mod = 999911659;
const int pn[4]&amp;nbsp;=&amp;nbsp;{2, 3, 4679, 35617};
const int maxb = 50009;
int n, g, fac[maxb], tf, s[4];
int t[maxb];
int modPow(int a, int x, int mod)&amp;nbsp;{
int s = 1;
for (a&amp;nbsp;%= mod; x; x &amp;gt;&amp;gt;= 1, a = _l a * a % mod)</description>
    </item>
    
    <item>
      <title>BZOJ3319 黑白树</title>
      <link>/oi/lofterimport_062/</link>
      <pubDate>Fri, 28 Nov 2014 09:46:11 +0000</pubDate>
      
      <guid>/oi/lofterimport_062/</guid>
      <description>异常欢乐的并查集。馒头染色法。均摊O(n)的时间。
离线，先把每个染色操作会染黑哪些边算出来，把黑色子节点并到白色父节点里。
然后倒着处理，询问就直接用并查集问白色子节点顶上的黑色父节点最近是谁。染色操作再染回来。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
struct edge {
int t, i;
edge *next;
};
struct query {
int t, v, ans;
int *b;
};
int _d_;
#define readInt(_x_)&amp;nbsp;{&amp;nbsp;\
int&amp;amp; _s_ = _x_;&amp;nbsp;\
_s_ = 0;&amp;nbsp;\
while (!isdigit(_d_&amp;nbsp;= getchar()));&amp;nbsp;\
while ((_s_&amp;nbsp;= _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar()));&amp;nbsp;\
}
const int maxn = 1000009;
int n, m, d[maxn], fa[maxn], v[maxn], c[maxn], r[maxn];</description>
    </item>
    
    <item>
      <title>BZOJ1954 Pku3764 The xor-longest Path</title>
      <link>/oi/lofterimport_063/</link>
      <pubDate>Fri, 28 Nov 2014 08:52:14 +0000</pubDate>
      
      <guid>/oi/lofterimport_063/</guid>
      <description>The input contains several test cases.
虽然我没看到这句话但也A了，什么情况。
a到b的路径xor=(a到根xor b到根)&amp;nbsp;水
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
struct edge {
int t, v;
edge *next;
};
const int maxn = 100009;
const int maxl = 33;
int n, v[maxn], fa[maxn], tr[maxn * maxl][2], tn;
edge *head[maxn],&amp;nbsp;*ep;
inline void addEdge(int u, int v, int w)&amp;nbsp;{
ep-&amp;gt; t = v;
ep-&amp;gt; v = w;
ep-&amp;gt; next = head[u];
head[u]&amp;nbsp;= ep ++;</description>
    </item>
    
    <item>
      <title>Scoi2013多项式的运算</title>
      <link>/oi/lofterimport_065/</link>
      <pubDate>Wed, 26 Nov 2014 16:04:09 +0000</pubDate>
      
      <guid>/oi/lofterimport_065/</guid>
      <description>平衡树维护序列的老题。之前用SMT写过，不过在bzoj上就tle了。splay大法好。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
int _d_;
#define readInt(_x_)&amp;nbsp;{&amp;nbsp;\
int&amp;amp; _s_ = _x_;&amp;nbsp;\
while (!isdigit(_d_&amp;nbsp;= getchar()));&amp;nbsp;\
_s_ = 0;&amp;nbsp;\
while ((_s_&amp;nbsp;= _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar()));&amp;nbsp;\
}
#define readStr(_s_)&amp;nbsp;{&amp;nbsp;\
char* _i_ = _s_;&amp;nbsp;\
while (!islower(_d_&amp;nbsp;= getchar()));&amp;nbsp;\
while ((*(_i_&amp;nbsp;++)&amp;nbsp;= _d_), islower(_d_ = getchar()));&amp;nbsp;\
*(_i_)&amp;nbsp;= 0;&amp;nbsp;\
}
#define _l (long long int)
const int maxn = 300009;
const int mod = 20130426;</description>
    </item>
    
    <item>
      <title>BZOJ3237 [Ahoi2013]连通图</title>
      <link>/oi/lofterimport_066/</link>
      <pubDate>Wed, 26 Nov 2014 11:32:53 +0000</pubDate>
      
      <guid>/oi/lofterimport_066/</guid>
      <description>CDQ重构图。听上去比CDQ还高档的样子。
就是每层重新标号，把没有询问到的边拿来跑并查集。
最初是分开考虑然后可修复的并查集就T傻了。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;set&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
int _d_;
#define readInt(_x_)&amp;nbsp;{&amp;nbsp;\
int&amp;amp; _s_ = _x_;&amp;nbsp;\
while (!isdigit(_d_&amp;nbsp;= getchar()));&amp;nbsp;\
_s_ = 0;&amp;nbsp;\
while ((_s_&amp;nbsp;= _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar()));&amp;nbsp;\
}
const int maxn = 100009;
const int maxm = 200009;
const int maxl = 19;
struct edge {
int a, b, i;
};
struct dset {
int r[maxn], hp[maxn * 5], hv[maxn * 5], cnt;</description>
    </item>
    
    <item>
      <title>BZOJ3289 Mato的文件管理</title>
      <link>/oi/lofterimport_067/</link>
      <pubDate>Mon, 24 Nov 2014 20:52:44 +0000</pubDate>
      
      <guid>/oi/lofterimport_067/</guid>
      <description>离散，然后树状数组+莫队。
最初用的是直接粘过来的1488的sbt，然后极限随机数据要跑14s。好郁闷。
然后改用数状数组就变1s了。是我再次把sbt写丑了还是它常数够厉害TT
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
struct query {
int i, l, r, pl, pr;
};
typedef unsigned int uint;
const int maxn = 50009;
#define update(_p_)&amp;nbsp;(sz[_p_]=sz[ls[_p_]]+sz[rs[_p_]]+1)
inline bool cmpQry(const query&amp;amp; a, const query&amp;amp; b)&amp;nbsp;{
return a. pl &amp;lt; b. pl ||&amp;nbsp;(a. pl == b. pl &amp;amp;&amp;amp; a. pr &amp;gt; b. pr);
}
inline bool cmpP(int* a, int* b)&amp;nbsp;{
return *a&amp;nbsp;&amp;lt;&amp;nbsp;*b;
}
int n, m, bsz, a[maxn],&amp;nbsp;*r[maxn], maxa, t[maxn];</description>
    </item>
    
    <item>
      <title>BZOJ1488 || POJ1741 Tree</title>
      <link>/oi/lofterimport_068/</link>
      <pubDate>Mon, 24 Nov 2014 19:53:03 +0000</pubDate>
      
      <guid>/oi/lofterimport_068/</guid>
      <description>据说是男人八题。
状态太差调了一节宝贵的晚自习，严重不开心。
异常裸的点分治。然后里面还是套的sbt。
卡空间比较丧病，不能开nlogn，要想办法开到n。其实就是找重心分治完再bfs一遍。最初没有写，所以mle爽，在poj上还显示的是re。
然后各种逗的错误调啊调。把代码调得怪丑。我还是naive啊。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
struct edge {
int t, v;
edge *next;
};
const int maxn = 40009;
int n, k, ans;
int d[maxn], tvis, vis[maxn], vd[maxn], sz[maxn], qu[maxn];
edge *ep,&amp;nbsp;*head[maxn], elst[maxn * 2];
#define update(_p_)&amp;nbsp;(sz[_p_]=sz[ls[_p_]]+sz[rs[_p_]]+1)
namespace sbt {
const int maxnd = maxn * 2;
const int balc = 5;
int nst[maxnd], tn;
int ls[maxnd], rs[maxnd], vl[maxnd], sz[maxnd];
inline void lRot(int&amp;amp; p)&amp;nbsp;{</description>
    </item>
    
    <item>
      <title>BZOJ2626 JZPFAR</title>
      <link>/oi/lofterimport_069/</link>
      <pubDate>Mon, 24 Nov 2014 16:04:27 +0000</pubDate>
      
      <guid>/oi/lofterimport_069/</guid>
      <description>jason_yu表示是kd-tree的裸题。
拿个堆维护一下答案，然后剪剪枝啥的，写起来轻松愉快还比lct短。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
typedef long long qw;
typedef pair &amp;lt;qw, int&amp;gt; hele;
#define _l (qw)
int _d_;
bool _nag_;
#define readInt(_x_)&amp;nbsp;{&amp;nbsp;\
int &amp;amp;_s_&amp;nbsp;= _x_;&amp;nbsp;\
_s_ = 0;&amp;nbsp;\
_nag_ = 0;&amp;nbsp;\
while (!isdigit(_d_&amp;nbsp;= getchar()))&amp;nbsp;\
if (_d_&amp;nbsp;==&amp;nbsp;&#39;-&#39;)&amp;nbsp;\
_nag_ = 1;&amp;nbsp;\
while ((_s_&amp;nbsp;= _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar()));&amp;nbsp;\
if (_nag_)&amp;nbsp;\
_s_ =&amp;nbsp;- _s_;\
}
const int maxn = 100009;</description>
    </item>
    
    <item>
      <title>BZOJ1227 [SDOI2009]虔诚的墓主人</title>
      <link>/oi/lofterimport_070/</link>
      <pubDate>Mon, 24 Nov 2014 10:59:07 +0000</pubDate>
      
      <guid>/oi/lofterimport_070/</guid>
      <description>写完Kdtree感觉整个人都要离散了。
这题比较神，之前连题都没看懂。每个位置的方案数就是上下左右的数量的组合数的乘积。把x离散之后维护区间中左&amp;times;右的和，上下y相同的扫一遍搞定。（感觉说了像没说）
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
struct point {
int x, y;
};
const int maxn = 100009;
const int maxk = 13;
inline bool cmpP(int* a, int* b)&amp;nbsp;{
return *a&amp;nbsp;&amp;lt;&amp;nbsp;*b;
}
inline bool cmpy(const point&amp;amp; a, const point&amp;amp; b)&amp;nbsp;{
return (a. y &amp;lt; b. y)&amp;nbsp;||&amp;nbsp;(a. y == b. y &amp;amp;&amp;amp; a. x &amp;lt; b. x);
}
point a[maxn];
int n, m, c[maxn][maxk], cx[maxn], tx[maxn], t[maxn], maxx, ans;</description>
    </item>
    
    <item>
      <title>BZOJ2648 SJY摆棋子</title>
      <link>/oi/lofterimport_071/</link>
      <pubDate>Mon, 24 Nov 2014 10:23:51 +0000</pubDate>
      
      <guid>/oi/lofterimport_071/</guid>
      <description>Log^2的cdq分治怎么也跑不过。优化常数优化到底了也不行。所以kd大法好。
怎么都觉得kd树就一暴力+剪枝=log。
思想就是先按x二分，然后再按y二分，然后再按x二分。然后这玩意比较像平衡树，中间那个点是要代表一个真实的结点的而不是一个值。然后insert的时候感觉复杂度完全没有保证啊。如果要保证可能要替罪羊一类的东西吧。虽然这题好像不用保证。
询问的时候就更迷了，就是估计一个离哪边近，然后先搜。然后另一边如果估计值还小于答案就再搜一遍。好诡异，时间复杂度是怎么来的。
然后代码略丑，加了zhx式读入优化后长度xxxxx。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
#define READ_OPTIMIZE
#ifdef READ_OPTIMIZE
/*int _d_;
#define readInt(_s_)&amp;nbsp;{\
_s_ = 0;\
while (!isdigit(_d_&amp;nbsp;= getchar()));\
while ((_s_&amp;nbsp;= _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar()));\
}*/
const int BUF_SIZE = 30;
char buf[BUF_SIZE],&amp;nbsp;*buf_s = buf,&amp;nbsp;*buf_t = buf + 1;
&amp;nbsp;&amp;nbsp;
#define PTR_NEXT()&amp;nbsp;\
{&amp;nbsp;\
buf_s ++;&amp;nbsp;\
if (buf_s&amp;nbsp;== buf_t)&amp;nbsp;\
{&amp;nbsp;\
buf_s = buf;&amp;nbsp;\
buf_t = buf + fread(buf, 1, BUF_SIZE, stdin);&amp;nbsp;\</description>
    </item>
    
    <item>
      <title>BZOJ2716 [Violet 3]天使玩偶</title>
      <link>/oi/lofterimport_073/</link>
      <pubDate>Mon, 24 Nov 2014 08:43:28 +0000</pubDate>
      
      <guid>/oi/lofterimport_073/</guid>
      <description>看时间比较宽么，写一个log^2的cdq+树状数组么。
然后被2648卡了。学kd-tree吧。
naive。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
int _d_;
#define readInt(_s_)&amp;nbsp;{\
_s_ = 0;\
while (!isdigit(_d_&amp;nbsp;= getchar()));\
while ((_s_&amp;nbsp;= _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar()));\
}
struct point {
int x, y, t, i;
};
const int maxn = 500009;
const int maxz = 1000009;
const int inf = 0x3f3f3f3f;
inline bool cmpPoint(const point&amp;amp; a, const point&amp;amp; b)&amp;nbsp;{
return a.</description>
    </item>
    
    <item>
      <title>BZOJ2506 calc</title>
      <link>/oi/lofterimport_074/</link>
      <pubDate>Sun, 23 Nov 2014 17:32:59 +0000</pubDate>
      
      <guid>/oi/lofterimport_074/</guid>
      <description>看到取模瞬间想到了昨天的bc。
应该这是取模然后求啥玩意的时候的比较通用的解法吧。p&amp;lt;=sqrt(maxv)的预处理，剩下的直接暴力。结果预处理又写丑了一回。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
const int maxn = 100009;
const int maxv = 10000;
const int bsz = 100;
const int maxb = 103;
int n, m;
int a[maxn], vb[maxb][maxb], ve[maxb][maxb];
int xb[maxn], xe[maxn];
int i_buf[maxn * maxb * 2], tib;
void pre()&amp;nbsp;{
memset(ve, 0, sizeof(ve));
memset(xe, 0, sizeof(xe));
for (int i = 1; i &amp;lt;= n;&amp;nbsp;++ i)
++ xe[a[i]];
for (int i = 0; i &amp;lt;= maxv;&amp;nbsp;++ i)&amp;nbsp;{</description>
    </item>
    
    <item>
      <title>BZOJ1833 [ZJOI2010]count 数字计数</title>
      <link>/oi/lofterimport_075/</link>
      <pubDate>Sun, 23 Nov 2014 16:45:32 +0000</pubDate>
      
      <guid>/oi/lofterimport_075/</guid>
      <description>数位DP好麻烦啊不想写啊怎么办啊。
利用trie树思想直接做好了。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
typedef long long qw;
#ifdef WIN32
#define lld &amp;quot;%I64d&amp;quot;
#else
#define lld &amp;quot;%lld&amp;quot;
#endif
const int maxn = 15;
qw p10[maxn];
qw x, y, ans[10], c[10];
int n;
char a[maxn];
void calc(qw val, int sgn)&amp;nbsp;{
if (!val)
return;
sprintf(a + 1, lld, val);
int n = strlen(a + 1);
memset(c, 0, sizeof(c));
qw cz, cm, cr;
cz = 1;</description>
    </item>
    
    <item>
      <title>BZOJ3489 A simple rmq problem</title>
      <link>/oi/lofterimport_076/</link>
      <pubDate>Sun, 23 Nov 2014 16:15:05 +0000</pubDate>
      
      <guid>/oi/lofterimport_076/</guid>
      <description>乍一看不会。
想了想，求出每一个数的前一个相同的数的位置和后一个相同的数的位置，然后询问就是L&amp;lt;=i&amp;lt;=R &amp;amp;&amp;amp; next[i]&amp;gt;=R &amp;amp;&amp;amp; last[i]&amp;nbsp;&amp;lt;= L的最大的a[i]。这三层树套树啊！？
好像不带修改，那可以把一个Log的树优化成1的前缀和。
然后最值不满足减法，所以就把L&amp;lt;=i&amp;lt;=R拿动态建的线段树套里面好了。
卡空间400+MB过了，我对拍的大数据把网上的某人的程序干掉了哈哈。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
struct seg {
int v, ls, rs;
};
const int maxn = 100009;
const int maxnd = maxn * 409;
int n, m, a[maxn], v[maxn], ls[maxn], nx[maxn], o[maxn];
int t[maxn], sp;
seg sl[maxnd];
inline bool cmpO(const int&amp;amp; a, const int&amp;amp; b)&amp;nbsp;{
return ls[a]&amp;nbsp;&amp;lt; ls[b];
}
int getLa(int l0)&amp;nbsp;{
int l = 1, r = n;</description>
    </item>
    
    <item>
      <title>BZOJ3282 Tree</title>
      <link>/oi/lofterimport_077/</link>
      <pubDate>Sun, 23 Nov 2014 14:40:47 +0000</pubDate>
      
      <guid>/oi/lofterimport_077/</guid>
      <description>LCT的简单题。好久不写都手生了，还把rotate写错了一点点，导致找了半天错。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
int _d_;
#define readInt(_s_)&amp;nbsp;{\
_s_ = 0;\
while (!isdigit(_d_&amp;nbsp;= getchar()));\
while ((_s_&amp;nbsp;= _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar()));\
}
const int maxn = 300009;
int n, m;
int ls[maxn], rs[maxn], pt[maxn], rv[maxn], vl[maxn], vs[maxn];
inline void update(const int&amp;amp; p)&amp;nbsp;{
vs[p]&amp;nbsp;= vs[ls[p]]&amp;nbsp;^ vl[p]&amp;nbsp;^ vs[rs[p]];
}
inline void fix(int p)&amp;nbsp;{
if (rv[p])&amp;nbsp;{
swap(ls[p], rs[p]);
if (ls[p])</description>
    </item>
    
    <item>
      <title>BZOJ1492 [NOI2007]货币兑换Cash</title>
      <link>/oi/lofterimport_078/</link>
      <pubDate>Sun, 23 Nov 2014 13:51:36 +0000</pubDate>
      
      <guid>/oi/lofterimport_078/</guid>
      <description>cdq分治第二题。
最初没看清题所以一直不会做。晕。
cdq教程里的模板题。
显然所有卖都是卖完，买都是把钱买光。
f[i]表示第i天结束后最多持有b卷的数量，ans表示当前最多能赚到的rmb。
方程是：
f[i]&amp;nbsp;= max(ans, f[j]&amp;nbsp;* r[j]&amp;nbsp;* a[i]&amp;nbsp;+ f[j]&amp;nbsp;* b[i])&amp;nbsp;/&amp;nbsp;(a[i]&amp;nbsp;* r[i]&amp;nbsp;+ b[i])。
移项得：
f[j]&amp;nbsp;=&amp;nbsp;-(a[i]/b[i])&amp;nbsp;*&amp;nbsp;(r[j]&amp;nbsp;* f[j])&amp;nbsp;+&amp;nbsp;(r[i]&amp;nbsp;* a[i]&amp;nbsp;+ b[i])&amp;nbsp;/ b[i]&amp;nbsp;* f[j]。
把r[j]*f[j]看作x，把f[j]看作y，好像可以斜率优化了。
&amp;nbsp;不急，f[j]好像没有单调性吧？不对，好像a[i]/b[i]也没有单调性！？
平衡树维护凸壳？想起了上回那道hnoi的作业，调了一晚上，怎么能这样。
然后，其实可以cdq。
每次对右边有影响的是左边的凸壳，所以先跑左边，计算左边对右边的影响，再跑右边。这回是中序遍历，而不是Mokia那题的后序。
原来cdq可以这么神奇。
然后又把凸壳写丑了TT。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
const int maxn = 100009;
double ans, s, f[maxn], a[maxn], b[maxn], r[maxn];
int n, h[maxn], tmp[maxn], t;
inline double getx(const int&amp;amp; i)&amp;nbsp;{
return f[i]&amp;nbsp;* r[i];
}
inline double gety(const int&amp;amp; i)&amp;nbsp;{
return f[i];</description>
    </item>
    
    <item>
      <title>BZOJ2351/2462 [BeiJing2011]Matrix</title>
      <link>/oi/lofterimport_079/</link>
      <pubDate>Sat, 22 Nov 2014 22:58:45 +0000</pubDate>
      
      <guid>/oi/lofterimport_079/</guid>
      <description>好像要用二维AC自动机的样子！？不对，还要优化不然还会MLE！？
naive。
哈希水过之。
中途某处忘强转导致调了良久。
2462丧心病狂卡stl常数，差点写平衡树了，然后想了想二分水之。
#include &amp;lt;cstdio&amp;gt;
#include&amp;nbsp;&amp;lt;cstring&amp;gt;
#include&amp;nbsp;&amp;lt;set&amp;gt;
#include&amp;nbsp;&amp;lt;algorithm&amp;gt;
using namespace std;
typedef long long qw;
typedef unsigned long long uqw;
#define _l (qw)
const int rmod = 345379;
const int b1 = 3;
const int b2 = 3153131;
const int maxn = 1009;
int pb1[maxn];
int n, m, x, y, q, hr[maxn][maxn], t;
uqw hl[maxn][maxn], pb2[maxn];
char g[maxn];
uqw th[maxn * maxn];
void pre()&amp;nbsp;{
pb1[0]&amp;nbsp;= 1;
pb2[0]&amp;nbsp;= 1;</description>
    </item>
    
    <item>
      <title>BZOJ1176 [Balkan2007]Mokia</title>
      <link>/oi/lofterimport_081/</link>
      <pubDate>Fri, 21 Nov 2014 21:42:33 +0000</pubDate>
      
      <guid>/oi/lofterimport_081/</guid>
      <description>cdq分治第一题。
最近的主题是数据结构，这玩意应该也算一种和莫队一样厉害的黑暗大法吧。有些需要你把在线写得足够厉害的题可以用这玩意来水。
写起来很像归并排序，按时间分治，然后再按某个坐标之类的玩意归并一下，归并的时候像求逆序对一样做，计算一边对另一边的贡献，顺便用点啥数据结构维护一下之类的。
这题有点像上帝造题七分钟。不过w的范围显然不是让你写二维树状数组。感觉那题可以用cdq水过，不过cdq好像不能用简单的二维树状数组，至少要动态一下啥的，然后空间就bye了。
这题就是按x排序查询y。课件上的原题。
另外依然不会迗代，还是写的递归。（找到了fft的感觉）
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
typedef long long qw;
#ifdef WIN32
#define lld &amp;quot;%I64d&amp;quot;
#else
#define lld &amp;quot;%lld&amp;quot;
#endif
struct query {
int t, x, y, v;
inline query(int t0 = 0, int x0 = 0, int y0 = 0, int v0 = 0)&amp;nbsp;{
t = t0, x = x0, y = y0, v = v0;
}
};</description>
    </item>
    
    <item>
      <title>BZOJ3262 陌上花开</title>
      <link>/oi/lofterimport_082/</link>
      <pubDate>Fri, 21 Nov 2014 14:50:45 +0000</pubDate>
      
      <guid>/oi/lofterimport_082/</guid>
      <description>出题人应该才是真正的机房语文竞赛冠军。
好厉害的数据结构。cdq的不会。
树状数组套平衡树跑得飞快。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
struct flower {
int a, b, c;
};
const int maxn = 100009;
const int maxv = 200009;
const int maxl = 17;
#define update(p)&amp;nbsp;(sz[p]=sz[ls[p]]+sz[rs[p]]+1)
namespace sbt {
const int maxnd = maxn * maxl;
const int balc = 10;
int tn, ls[maxnd], rs[maxnd], sz[maxnd], vl[maxnd];
void init()&amp;nbsp;{
tn = 0;
sz[0]&amp;nbsp;= 0;
}
inline void lRot(int&amp;amp; p)&amp;nbsp;{</description>
    </item>
    
    <item>
      <title>BZOJ3751 [NOIP2014]解方程</title>
      <link>/oi/lofterimport_083/</link>
      <pubDate>Fri, 21 Nov 2014 09:11:40 +0000</pubDate>
      
      <guid>/oi/lofterimport_083/</guid>
      <description>BZOJ里的第二道noip题，今年防ak题，OTZ。
最初直接用大素数取模的方法要TLE，虽然本机不会。
用几个小质数pni，算出在模pni的同余系里0~pni-1的答案。如果x为原方程的解的话x%pni在模pni意义下也应该为0。
然后还是会TLE，最后发现小质数乘的时候不用取模了。bzoj上这题纯粹是丧心病狂卡常数啊。
ORZMHY
#define PROC &amp;quot;equation&amp;quot;
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
typedef unsigned long long uqw;
typedef long long qw;
const int maxn = 109;
const int maxl = 10009;
const int maxm = 1000009;
const int cp = 5;
//const int pn[cp]&amp;nbsp;=&amp;nbsp;{111119, 23333, 11113, 23251, 33329};
const int pn[]&amp;nbsp;=&amp;nbsp;{22861, 22871, 22877, 22901, 22907, 22921};
const int p10[]&amp;nbsp;=&amp;nbsp;{1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000};</description>
    </item>
    
    <item>
      <title>BZOJ1486 [HNOI2009]最小圈</title>
      <link>/oi/lofterimport_084/</link>
      <pubDate>Thu, 20 Nov 2014 17:14:47 +0000</pubDate>
      
      <guid>/oi/lofterimport_084/</guid>
      <description>做过。但是不对。
迷之找负环。
初值直接赋为0，这样可以节省找没用的最短路的时间。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
struct edge {
int t;
double v;
edge *next;
};
const int maxn = 3009;
const int maxm = 10009;
const double eps = 1e-9;
const double finf = 1e20;&amp;nbsp;
int n, m;
bool iq[maxn];
double d[maxn], ave;
edge *ep,&amp;nbsp;*head[maxn], elst[maxm];
bool dfs(int p)&amp;nbsp;{
iq[p]&amp;nbsp;= 1;
for (edge* e = head[p]; e; e = e-&amp;gt; next)
if (d[e-&amp;gt; t]&amp;nbsp;-&amp;nbsp;(d[p]&amp;nbsp;+ e-&amp;gt; v)&amp;nbsp;&amp;gt; eps)&amp;nbsp;{</description>
    </item>
    
    <item>
      <title>BZOJ3123 [Sdoi2013]森林</title>
      <link>/oi/lofterimport_085/</link>
      <pubDate>Thu, 20 Nov 2014 15:49:34 +0000</pubDate>
      
      <guid>/oi/lofterimport_085/</guid>
      <description>数据结构题神马的最开心了。
乍一看动态树，其实不然。复杂度可以再乘一个log的。
启发式合并。然后合并的时候直接暴力重构整棵子树，建主席树只和父亲节点有关，所以还是能搞定。
写了一个机智的垃圾回收把log^2的空间变成了log。然后发现空间有512MB。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
struct edge {
int t;
edge* next;
};
struct seg {
int v, c;
seg *ls,&amp;nbsp;*rs;
};
#define readInt(_s_)&amp;nbsp;{\
int _d_;\
_s_ = 0;\
while (!isdigit(_d_&amp;nbsp;= getchar()));\
while ((_s_&amp;nbsp;= _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar()));\
}
const int maxn = 80009;
const int maxl = 33;
const int maxnd = maxn * maxl;</description>
    </item>
    
    <item>
      <title>11月下旬计划</title>
      <link>/oi/lofterimport_086/</link>
      <pubDate>Wed, 19 Nov 2014 08:01:09 +0000</pubDate>
      
      <guid>/oi/lofterimport_086/</guid>
      <description>只有两个星期。
第一个星期（也就是现在）先在bzoj上写些水题来找找感觉。
根据卷子再看一遍半期之前的知识点。然后看一看历史书。
第二个星期去学习kd-tree，然后写题。顺便可以研究一下高维树套树的问题。
开始做文化课的作业。数理化生跟着进度，自己选择性多做一些作业。</description>
    </item>
    
    <item>
      <title>BZOJ2209 [Jsoi2011]括号序列</title>
      <link>/oi/lofterimport_087/</link>
      <pubDate>Tue, 18 Nov 2014 18:50:06 +0000</pubDate>
      
      <guid>/oi/lofterimport_087/</guid>
      <description>好恶心的数据结构题。
考虑单个询问。把(视作1，把)视作-1，设minprefix为最小前缀和，设cp=(minprefix+1)/2，那么答案为(sum/2+cp*2)，使劲想想想得出来。
所以就是用个splay或者smt来维护一下一段的最小前缀和以及总和。因为有两种操作所以写起来比较麻烦。要注意不要把操作看反了，还要注意标记的优先级和更新的问题。
恶心了一下午。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
struct dat {
int sm, t[2][2];
inline void operator =(const dat&amp;amp; a)&amp;nbsp;{
sm = a. sm;
t[0][0]&amp;nbsp;= a. t[0][0];
t[0][1]&amp;nbsp;= a. t[0][1];
t[1][0]&amp;nbsp;= a. t[1][0];
t[1][1]&amp;nbsp;= a. t[1][1];
}
};
const int maxn = 100009;
int n, m, cr, a[maxn], sz[maxn], ls[maxn], rs[maxn], pt[maxn], vl[maxn];
bool flip[maxn], rev[maxn];
dat d[maxn];
dat sgd(int v)&amp;nbsp;{
dat r;
r. sm = v;</description>
    </item>
    
    <item>
      <title>BZOJ3236 作业</title>
      <link>/oi/lofterimport_088/</link>
      <pubDate>Tue, 18 Nov 2014 11:26:38 +0000</pubDate>
      
      <guid>/oi/lofterimport_088/</guid>
      <description>好厉害的数据结构题，时限太吓人了。
最初想写莫队的，但是在数据范围下屈服了。
用可持久化线段树套可持久化线段树来维护可过。虽然跑了97s。本机跑得快得多，虽然有两个点被卡到了18s。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
struct seg {
int v, ls, rs;
};
#define readInt(_s_)&amp;nbsp;{\
_s_ = 0;\
int _d_ = 0;\
while (!isdigit(_d_&amp;nbsp;= getchar()));\
while ((_s_&amp;nbsp;= _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar()));\
}
const int maxn = 100009;
const int maxl = 20;
const int maxnd = maxn * maxl * maxl;
seg s[maxnd];
int n, m, t, a[maxn], d[maxn], c[maxn],&amp;nbsp;*r[maxn], sp, rt[maxn];</description>
    </item>
    
    <item>
      <title>HDOJ5107 K-short Problem</title>
      <link>/oi/lofterimport_090/</link>
      <pubDate>Mon, 17 Nov 2014 11:20:21 +0000</pubDate>
      
      <guid>/oi/lofterimport_090/</guid>
      <description>前天晚上的best coder的题。
数据太弱暴力都放过去了，而且还是错的。当然我也太naive了TT。
我没管k&amp;lt;=10，直接硬上树状数组套平衡树，用二分搞的。然后数组开小了不开心啊。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cmath&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;algorithm&amp;gt;
#include &amp;lt;set&amp;gt;
#include &amp;lt;memory.h&amp;gt;
using namespace std;
struct query {
int x, y, k, n;
};
struct tower {
int x, y, h;
};
inline bool cmpTower(const tower&amp;amp; a, const tower&amp;amp; b)&amp;nbsp;{
return a. x &amp;lt; b. x;
}
inline bool cmpQuery(const query&amp;amp; a, const query&amp;amp; b)&amp;nbsp;{
return a. x &amp;lt; b. x;
}
inline bool cmpP(int* a, int* b)&amp;nbsp;{</description>
    </item>
    
    <item>
      <title>省选前长期计划</title>
      <link>/oi/lofterimport_091/</link>
      <pubDate>Mon, 17 Nov 2014 09:52:54 +0000</pubDate>
      
      <guid>/oi/lofterimport_091/</guid>
      <description>做事总得有点计划性。
省选是第二步。noip这步逗了，所以后面要加油。
十一月和十二月重点搞数据结构。毕竟天冷不适合思考太复杂的数学问题TT比如kd-tree之类的东西拿来看一看，bzoj上以前wc的数据结构也不少。争取多刷些题。
一月份大概会有会考，就乱刷些题当休闲了。
二月有wc。然后到时候大神应该也比较多，可以多学习一下数学题和dp。还要把计算几何认真学习一下。
三月大概会开始集训了。图论题比较重要。很多题就是看你记不记得那些结论。当然也有不少的烧脑题。需要多刷题来弥补智商的不足。
四月么，加油！</description>
    </item>
    
    <item>
      <title>高二上半期总结</title>
      <link>/oi/lofterimport_092/</link>
      <pubDate>Sun, 16 Nov 2014 22:52:16 +0000</pubDate>
      
      <guid>/oi/lofterimport_092/</guid>
      <description>想起有这么一个总结，但是忘了带本子了，只好这样写了。
半个学期在学习文化课的时间也不超过20天。大概是没有多少好总结的。
半期的时候考懞了。虽然也花了三天的时间预习，不过那也只是简单地补补知识点，完全不能挽回任何东西。毕竟在高中的文化课里，书本和考试的差距还是有那么一些大的。感觉数学英语的差距要稍微小一些，另外四科就比较惨淡了。下半学期没有noip那么要紧的事情了，虽然还要停课，但是每天晚上也还是要做下作业，补一补知识点。数学物理和英语争取能跟上进度，这样压力应该会小一些。然后前半期的知识，每天做完作业之后也按顺序去前面把相应的作业做一做。班上有不少人批判刷题，但是现在血淋淋的事实就是，不刷题根本没有办法应付考试。
另外就是竞赛吧。其实这半期也没有写多少议论文，题解和总结倒写了不少。noip考得应该还将就，明天出正式成绩。反正第一步是迈出去了，后面的路会更艰险，不过我有信心和决心去实现自己的愿望。选择了便认定这一条路走下去，剩者为王！
好像虽然在停课，也参与了一些活动。比如运动会啥的，然后成绩也不错以至于被rp攻击了好几天。长跑教会了我不只是长跑。也许有许多人会和你在路上相遇，但是只有你自己坚持下来去冲击终点的红线。也许有人会跑得很快，但是你也不要怕，也许他们过会就会体力不支。也许有人会跑得很慢，但是也不要骄傲，他们也许是在保存实力。至于总有些人会战胜你，要保持一颗平和的心，因为有很多人也在以同样的视角看你。总之，你要做的就是不断地努力。即使是在你累得不能呼吸的时候，只要终点还在前方，你就得跑下去。长跑如是，竞赛如是，人生亦如是。当然长跑这个项目也不能停。好的身体在后面的学习中还是很重要的。
另外在停课搞竞赛的时候也还是学到了很多其它的东西。比如如何去协助老师管理同学，如何组织大家做事，以及如何应对各种突发情况等等。这些也是人生宝贵的财富吧。管理人是比管理程序更麻烦也更有挑战性的一件事情，也是必需要学会的一件事情。
下半学期的任务更加复杂。没有像noip一样的重大事件了，但是这半个学期将会深远地影响到高中结业以及省选，所以也要抓紧时间，提高效率。
最后希望明天++ rp，也希望我不会再写一篇同样题目的总结。
Historical Comments Unknown friend at 2014-11-16T22:56:11 OTL OTL OTL OTL OTL Unknown friend at 2014-11-16T22:57:13 现在还在赶……</description>
    </item>
    
    <item>
      <title>BZOJ3744 Gty的妹子序列</title>
      <link>/oi/lofterimport_095/</link>
      <pubDate>Fri, 14 Nov 2014 21:14:19 +0000</pubDate>
      
      <guid>/oi/lofterimport_095/</guid>
      <description>这题就是考你怎么把能优化常数的地方都优化一下。
做法比较清晰，分块加持久化值域线段树。大块预处理，小块暴力算。虽然最初不想写持久化数据结构就试图用平衡树去做，结果发现做法是错的，单次复杂度是O(n*lgn)的。看来我太年轻了。后来改了但是常数巨大也没法跑。
本来是一次询问里有若干次在持久化线段树上查询的。然后首先发现可以预处理出从开头到一块末尾这一段里有多少个比后面任意一个位置大的数的个数。还有一个数前面比它大的数的个数。这俩加起来常数差不多就小到能过了。
丧心病狂！
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
const int maxn = 50009;
const int maxb = 259;
const int maxnd = maxn * 30;
struct seg {
int v;
seg *ls,&amp;nbsp;*rs;
};
inline bool cmpP(const int* a, const int* b)&amp;nbsp;{
return *a&amp;nbsp;&amp;lt;&amp;nbsp;*b;
}
#define readInt(_s_)&amp;nbsp;{\
int _d_;\
_s_ = 0;\
while (!isdigit(_d_&amp;nbsp;= getchar()));\
while ((_s_&amp;nbsp;= _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar()));\</description>
    </item>
    
    <item>
      <title>BZOJ3333 排队计划</title>
      <link>/oi/lofterimport_096/</link>
      <pubDate>Thu, 13 Nov 2014 22:01:17 +0000</pubDate>
      
      <guid>/oi/lofterimport_096/</guid>
      <description>暑假的时候就听zhx讲过这题，不过好像当时讲复杂了。
很容易知道答案就是每次减去被出列的人里面没有出过列的人在原序列里右边的比她矮的人的个数。
所以每个人只会被算一次，均摊下来是O(n)的。然后就是怎么很快地找到这些人。我觉得用线段树比较方便，时间可以做到log。不知道是不是能用并查集。
好写好调。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstdlib&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;memory.h&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
#define readInt(_s_)&amp;nbsp;{\
int _d_;\
while (!isdigit(_d_&amp;nbsp;= getchar()));\
_s_ = 0;\
while ((_s_&amp;nbsp;= _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar()));\
}
typedef long long qw;
#ifdef WIN32
#define lld &amp;quot;%I64d&amp;quot;
#else
#define lld &amp;quot;%lld&amp;quot;
#endif
struct seg {
int l, r, v, p;
seg *ls,&amp;nbsp;*rs;
};
const int maxn = 500009;</description>
    </item>
    
    <item>
      <title>BZOJ2141 排队</title>
      <link>/oi/lofterimport_097/</link>
      <pubDate>Thu, 13 Nov 2014 13:34:28 +0000</pubDate>
      
      <guid>/oi/lofterimport_097/</guid>
      <description>连yjq都会做，简直是水暴了。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;algorithm&amp;gt;
&amp;nbsp;
usingnamespacestd;
&amp;nbsp;
constintmaxn = 20009;
&amp;nbsp;
intn, m, a[maxn], t[maxn],&amp;nbsp;*r[maxn], s;
&amp;nbsp;
intbtQry(int* t, intp)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp; ints = 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp; while(p)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s += t[p], p -=&amp;nbsp;(p&amp;nbsp;&amp;amp;&amp;nbsp;-p);
&amp;nbsp;&amp;nbsp;&amp;nbsp; returns;
}
&amp;nbsp;
voidbtChg(int* t, intp, intv)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp; while(p &amp;lt; maxn)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t[p]&amp;nbsp;+= v, p +=&amp;nbsp;(p&amp;nbsp;&amp;amp;&amp;nbsp;-p);
}
&amp;nbsp;
inlineboolcmpP(constint* a, constint* b)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp; return*a &amp;lt;&amp;nbsp;*b;
}
&amp;nbsp;
intmain()&amp;nbsp;{
#ifndef ONLINE_JUDGE
&amp;nbsp;&amp;nbsp;&amp;nbsp; freopen(&amp;quot;in.txt&amp;quot;,&amp;nbsp;&amp;quot;r&amp;quot;, stdin);
#endif</description>
    </item>
    
    <item>
      <title>NOIP2014 DIARY2</title>
      <link>/oi/lofterimport_099/</link>
      <pubDate>Sun, 09 Nov 2014 13:08:09 +0000</pubDate>
      
      <guid>/oi/lofterimport_099/</guid>
      <description>居然感冒了，嗓子痛死了。
8:00 进考场了，不准动机器，那还怎么配vim啊TT
8:30 这密码。看了下题好像也不是特别麻烦啊，除了最后一题有个10^10000。
8:35 第一题敲完了？
8:45 第二题敲完了？
8:50 第三题想不出其它的做法啊。哈希吧。
9:10 花了四十分钟就做完了？点开扫雷的时候看到了身旁某兄怨念的眼神。
10:00 第三题极限数据居然会tle。想打数据分治但是觉得不好的。发现可以先用自然溢出，如果没有暴再用模质数检查。这样好像0.5s能跑完。希望评测机不要比这个机子慢太多。
11:00 第一题居然把++ x写scanf上面了，作死。
12:00 终于交卷了。又老了一岁的感觉。
12:15 照相，讨论。jason_yu好像第三题写得不太一样，其他人基本都想得一样。看谁长得帅了。
然后某人的第六次noip就结束了。</description>
    </item>
    
    <item>
      <title>NOIP2014 DIARY1</title>
      <link>/oi/lofterimport_100/</link>
      <pubDate>Sat, 08 Nov 2014 15:40:01 +0000</pubDate>
      
      <guid>/oi/lofterimport_100/</guid>
      <description>记得noi的时候写了日记，那么noip也那么写一写。
听说今天的题很水，虽然我心里总有种不确定的感觉。
6:00 醒了。好像下雨了，有点冷。再睡会。
6:30 起床。
7:40 到考场了。因为下雨所以外面的广场上都没站什么人。倒是看到了徐老和初中的小伙伴。
8:10 开始配vim。好像我的键盘和旁边的同学不太一样，敲起来手感比较不错。
8:25?&amp;nbsp;发密码了。很淡定地输入，打开。好像之前已经重复做这个动作做了很多遍了，异常淡定。
8:30 第一题n才200？直接模拟？打表，写。
8:40 原来第二题是树。写。
8:55 第三题n*m^2会tle?难道不应该是f[i]-i=max(f[j]-j)?写！
9:10 写完好晕，怎么过不了样例啊。打印中间变量发现如果上升的话就不会下降了，囧。
9:40 好像写完了，对拍吧。
10:xx 第二题居然乘暴了。原来要取模。
11:xx 第三题拍出错了！？仔细一看暴力有bug。
12:00 终于交卷了，尿胀慌了。
出来看到小伙伴们也比较开心。心里还是那种很不确定的感觉。估分的时候扔了个300，大概是在向flag学说发出挑战。还好有mhy陪我挑战。
day1就这么过去了。原来我是如此之年轻。</description>
    </item>
    
    <item>
      <title>noip2014 计划</title>
      <link>/oi/lofterimport_101/</link>
      <pubDate>Fri, 07 Nov 2014 21:19:18 +0000</pubDate>
      
      <guid>/oi/lofterimport_101/</guid>
      <description>好奇怪的题目。
明天就要考noip了。第六年了，该成熟点了。
仿佛也在几个小时前有一些紧张。这么多年这么些路走过来了，这算是最后一博了吧？
更多的是一种成长的感觉吧。这一年，改变了太多太多了。从noip2013的惨败开始，有wc的奇奇怪怪的noip后遗症，然后是省选莫名其妙自己扔了一百多分，然后混进noi又疏忽地把au拿去喂狗了。没有什么好看的成绩，只有一双越来越快的敲键盘的手。
这两天的集训考得还是将就。但是也没有九月那么绝对了。也许是我的心态也没有经受住挑战，也许是大家都进步了吧。两者都有。总觉得过去的一切离我好遥远，好像去年的我和今年的我是老死不相识的两个人似的。这叫作成长？或者是太专注一件事情导致的沧桑？
oi就是那么玄妙。不见到ccf官网上的成绩，一切就是未知数。即使考前能场场ak，也说不准考场上会发生什么，何况我也没有那个实力去ak。换个角度说，noip，考的是细心。
只能说调整好自己的心态，&amp;nbsp;淡定地去战斗吧。
预祝所有人能成功，即使没有什么人会看到这句话。</description>
    </item>
    
    <item>
      <title>BZOJ3513 [MUTC2013]idiots</title>
      <link>/oi/lofterimport_110/</link>
      <pubDate>Thu, 30 Oct 2014 21:11:25 +0000</pubDate>
      
      <guid>/oi/lofterimport_110/</guid>
      <description>居然写了一半手贱就把所有东西都弄没了。严重地不开心。
既然这样那么简单说吧。
长度≤10^5这个条件在bzoj上没说。
用fft求出长度和为leni的组数。
枚举第三根火柴，可行的是（它作为最长的总组合数&amp;nbsp;-&amp;nbsp;（长度≤它的组合数））那么多组。
fft必需常数够小。不写蝴蝶会tle。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cmath&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;memory.h&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
typedef long long qw;
#define readInt(_s_)&amp;nbsp;{\
int _d_;\
_s_ = 0;\
while (!isdigit(_d_&amp;nbsp;= getchar()));\
while ((_s_&amp;nbsp;= _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar()));\
}
struct cplx {
double r, i;
inline cplx()&amp;nbsp;{
r = 0, i = 0;
}
inline cplx(double r0, double i0)&amp;nbsp;{
r = r0, i = i0;</description>
    </item>
    
    <item>
      <title>BZOJ3585 mex</title>
      <link>/oi/lofterimport_112/</link>
      <pubDate>Thu, 30 Oct 2014 15:58:58 +0000</pubDate>
      
      <guid>/oi/lofterimport_112/</guid>
      <description>很久之前就看过的题。不过一直没有勇气去做。爱真的需要勇气。
mex这个函数的性质比较奇妙。一端确定的话一定是单增的。两段和起来也一定是增加的。
可以很方便地求出从1到任何一个位置的mex。考虑把询问离线。按左端点排序。如果去掉一个数，那么对于右端点在（从这个数到下一个等于这个数的位置）这一段里的询问，它的值至多是这个数。
所以用线段树维护区修单查维护一下区间最小值就好了。注意如果没有下一个数了那么右端点是n。
据说要离散不过被我用map给水过去了。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;memory.h&amp;gt;
#include &amp;lt;map&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
#define readInt(_s_)&amp;nbsp;{\
int _d_;\
_s_ = 0;\
while (!isdigit(_d_&amp;nbsp;= getchar()));\
while ((_s_&amp;nbsp;= _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar()));\
}
struct seg {
int l, r, z;
seg *ls,&amp;nbsp;*rs;
};
struct query {
int l, r, n;
};
inline bool cmpQuery(const query&amp;amp; a, const query&amp;amp; b)&amp;nbsp;{
return a. l &amp;lt; b.</description>
    </item>
    
    <item>
      <title>BZOJ3626 LCA</title>
      <link>/oi/lofterimport_116/</link>
      <pubDate>Mon, 27 Oct 2014 20:52:07 +0000</pubDate>
      
      <guid>/oi/lofterimport_116/</guid>
      <description>比较神奇的一道树的题。
做法是离线。想了好久的在线啊。
把询问拆成0~l-1和0~r。挨个从0开始加点。加点就是把从根到这个点的所有点权+1，询问就是询问这个点到根的点权和。好机智的做法。
代码还比较舒服。dfs+树链剖分+树状数组。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;memory.h&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
struct edge {
int t;
edge *next;
};
struct query {
int p, v, n, c;
inline query(int p0 = 0, int v0 = 0, int n0 = 0, int c0 = 0)&amp;nbsp;{
p = p0, v = v0, n = n0, c = c0;
}
};
const int maxn = 50009;
const int mod = 201314;</description>
    </item>
    
    <item>
      <title>20141027-1107 计划</title>
      <link>/oi/lofterimport_118/</link>
      <pubDate>Sun, 26 Oct 2014 21:46:05 +0000</pubDate>
      
      <guid>/oi/lofterimport_118/</guid>
      <description>离noip只有12天了。这是我的倒数第二次noip中，正数第六次。
作为一个老人不需要太多的惊慌或者什么的。保持一颗平和与淡定的心是最重要的。
接下来都是连续的考试了。总共有10套题。这个时候也不是大规划地去补算法的时候。更多的是要调整好自己，学会怎样去应试。
oi中的一系列赛事里只有noip是三个半小时，而不是五个小时。当然它的难度与普及度决定了这一点。所以你没有更多的时间去思考和感受。更多需要的是准确的直觉和高效的代码。
任何一个小处的失误，都是致使的。唯一的办法是检查，检查，再检查。后面的考试里尽量要多坐一会，能对拍的都多拍一些数据。可能考试的时候还是会用windows，虽然这几天还是在noi-linux下练习。不过这也只是写bash脚本对拍和写bat对拍的小小区别而已。当然不要在这些小细节上浪费时间。不行用cpp就好。
noip的题目更多的在于思维难度，而不是代码难度。所以也要养成多动笔多打草稿多yy的习惯。
每天的安排也就是上午写题下午补题顺便刷题晚上刷题跑步散心睡觉。
嗯，哦，唉，&amp;times;，fighting。</description>
    </item>
    
    <item>
      <title>BZOJ1858 序列操作</title>
      <link>/oi/lofterimport_120/</link>
      <pubDate>Thu, 23 Oct 2014 16:18:13 +0000</pubDate>
      
      <guid>/oi/lofterimport_120/</guid>
      <description>一堆标记的线段树。
翻过的，没翻过的，都分开记下来。然后还要注意flip标记与set标记的优先级关系和互相之间的影响。然后就完了。
虽说在这个颓废的下午还是花了好一会才调通。&amp;nbsp;
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
struct dat {
int l, r, s, t, m;
};
struct seg {
int l, r, f, z;
dat d[2];
seg *ls,&amp;nbsp;*rs;
};
const int maxn = 100009;
seg *rt,&amp;nbsp;*sp;
int n, m, a[maxn];
inline dat sgd(int v, int s = 1)&amp;nbsp;{
dat r;
r. l = s * v;
r. r = s * v;
r. s = s * v;</description>
    </item>
    
    <item>
      <title>BZOJ1146 [CTSC2008]网络管理Network</title>
      <link>/oi/lofterimport_121/</link>
      <pubDate>Thu, 23 Oct 2014 12:09:56 +0000</pubDate>
      
      <guid>/oi/lofterimport_121/</guid>
      <description>数据结构题总是很令人开心的。
这题据说可以主席树？好麻烦的说。
树链剖分+线段树+treap就好了吧。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstdlib&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;memory.h&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
struct edge {
int t;
edge *next;
};
struct seg {
int l, r, v;
seg *ls,&amp;nbsp;*rs;
};
#define readInt(_s_)&amp;nbsp;{\
int _d_;\
_s_ = 0;\
while (!isdigit(_d_&amp;nbsp;= getchar()));\
while ((_s_&amp;nbsp;= _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar()));\
}
const int maxn = 80009;
const int maxv = 1e8;
namespace treap {</description>
    </item>
    
    <item>
      <title>BZOJ3589 动态树</title>
      <link>/oi/lofterimport_122/</link>
      <pubDate>Thu, 23 Oct 2014 10:50:38 +0000</pubDate>
      
      <guid>/oi/lofterimport_122/</guid>
      <description>啊啊看到动态树被吓尿了。
然后发现动的不是树的形态是点权。
树链剖分+dfs序么。
重点是我TLE了。
最初的写法是直接查询然后把访问过的点打个标记。一个询问做完再标记回去。然后，tle。
参考jason_yu的做法，找出所有dfs序上要询问的区间，合并之后询问，应该不会tle了吧？还是tle。
最后发现是线段树lazy标记的地方写成n^2了。开心啊。
事实证明第一种写法12秒左右，第二种写法3秒多。当然也要考虑我巨丑的常数。
所以我还是太naive了。
代码当然要粘快的。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;memory.h&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
struct edge {
int t;
edge *next;
};
struct seg {
int l, r, a, v;
seg *ls,&amp;nbsp;*rs;
};
struct rect {
int l, r;
inline rect(int l0 = 0, int r0 = 0)&amp;nbsp;{
l = l0, r = r0;
}
inline rect operator +(const rect&amp;amp; a) const {</description>
    </item>
    
    <item>
      <title>20141023 计划</title>
      <link>/oi/lofterimport_123/</link>
      <pubDate>Thu, 23 Oct 2014 08:05:19 +0000</pubDate>
      
      <guid>/oi/lofterimport_123/</guid>
      <description>最近都在认真写Noip难度题（虽然跑题有点严重）。
专题大概是差不多了。
今天换个口味写数据结构好了。
就这么愉快地决定了。&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</description>
    </item>
    
    <item>
      <title>20141022 总结</title>
      <link>/oi/lofterimport_124/</link>
      <pubDate>Wed, 22 Oct 2014 21:18:24 +0000</pubDate>
      
      <guid>/oi/lofterimport_124/</guid>
      <description>跑题了。
好像刷了几道水水的图论吧。估计也不会考到Msc或者极大团之类的玩意，所以也没写。
然后就刷了一天bzoj。第一次一天10道，好开心。
noip也不远了，感受到了各路大神的压力。
想要生存下去，唯一的出路是让自己不断变得更强。</description>
    </item>
    
    <item>
      <title>BZOJ2226 LCMSum</title>
      <link>/oi/lofterimport_125/</link>
      <pubDate>Wed, 22 Oct 2014 21:14:21 +0000</pubDate>
      
      <guid>/oi/lofterimport_125/</guid>
      <description>比较神奇的数学题。
重要的结论是&amp;lt;n且与n素质的数的和是phi(n)*n/2。
所以就枚举一下gcd就好了。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;memory.h&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
typedef long long qw;
#ifdef WIN32
#define lld &amp;quot;%I64d&amp;quot;
#else
#define lld &amp;quot;%lld&amp;quot;
#endif
#define _l (qw)
#define readInt(_s_)&amp;nbsp;{\
int _d_;\
_s_ = 0;\
while (!isdigit(_d_&amp;nbsp;= getchar()));\
while ((_s_&amp;nbsp;= _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar()));\
}
const int maxn = 1000009;
qw ans[maxn];
int tp, pn[maxn], phi[maxn];
bool pr[maxn];
void pre()&amp;nbsp;{
memset(pr, 0, sizeof(pr));</description>
    </item>
    
    <item>
      <title>BZOJ3428 [Usaco2014 Jan]Cow Curling</title>
      <link>/oi/lofterimport_126/</link>
      <pubDate>Wed, 22 Oct 2014 10:50:12 +0000</pubDate>
      
      <guid>/oi/lofterimport_126/</guid>
      <description>补昨天的题。
比较好想的计算几何。就看每个点在不在另一个颜色的点形成的上凸壳下面，下凸壳上面。这个用二分可以做到单次log。用单调应该也能O(n)。
但是写起来非常坑，要用long long，还有各种等号啥的。
写win32 app来显示点的代码比交上去的代码还长。开心。
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;algorithm&amp;gt;
&amp;nbsp;
usingnamespacestd;
&amp;nbsp;
typedeflonglongqw;
&amp;nbsp;
#define _l (qw)
&amp;nbsp;
structpoint {
&amp;nbsp;&amp;nbsp;&amp;nbsp; intx, y;
&amp;nbsp;&amp;nbsp;&amp;nbsp; point (intx0&amp;nbsp;= 0, inty0 = 0)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = x0, y = y0;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp; inlinevoidread()&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; scanf(&amp;quot;%d%d&amp;quot;,&amp;nbsp;&amp;amp;x,&amp;nbsp;&amp;amp;y);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
};
structvect {
&amp;nbsp;&amp;nbsp;&amp;nbsp; intx, y;
&amp;nbsp;&amp;nbsp;&amp;nbsp; vect(intx0 = 0, inty0 = 0)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = x0, y = y0;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp; vect(constpoint&amp;amp; a, constpoint&amp;amp; b)&amp;nbsp;{</description>
    </item>
    
    <item>
      <title>20141022 计划</title>
      <link>/oi/lofterimport_127/</link>
      <pubDate>Wed, 22 Oct 2014 08:10:36 +0000</pubDate>
      
      <guid>/oi/lofterimport_127/</guid>
      <description>因为运动会，好像时间又变少了。
早上本来想补觉来着，打开电脑就睡不着了。
上午先补题吧。
然后今天就去刷图论好了。最小生成树啊最短路啊还有各种神奇的东西都去写一写。
美好的一天。</description>
    </item>
    
    <item>
      <title>BZOJ2338 数矩形</title>
      <link>/oi/lofterimport_129/</link>
      <pubDate>Tue, 21 Oct 2014 15:47:05 +0000</pubDate>
      
      <guid>/oi/lofterimport_129/</guid>
      <description>本来以为是上回那道数正方形的原题的。结果发现不要求边与座标轴平行，于是我就naive了。然后数据结构变身计算几何一堆东西吼吼。
矩形的对角线相等且互相平分（来自初二数学书）。把所有点对的中点找出来，把所有相等且平分的放一起用单调性，有点像旋转卡(qia3)壳(qiao4)的做法。jason_yu说暴力枚举都能过，而且他跑得比我快！
计算几何也写得比较naive。调了半天啊。
毕竟我弱嘛。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cmath&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
typedef long long qw;
#ifdef WIN32
#define lld &amp;quot;%I64d&amp;quot;
#else
#define lld &amp;quot;%lld&amp;quot;
#endif
#define _l (qw)
const double eps = 1e-8;
const int maxn = 1509;
#define sqr(x)&amp;nbsp;((x)*(x))
#define dist(a,b)&amp;nbsp;(sqr(a.x-b.x)+sqr(a.y-b.y))
#define nextele(_x_)&amp;nbsp;((_x_+1==r)?(l):(_x_+1))
struct point {
qw x, y;
point(qw x0 = 0, qw y0 = 0)&amp;nbsp;{
x = x0, y = y0;
}
inline point operator =(const point&amp;amp; a)&amp;nbsp;{</description>
    </item>
    
    <item>
      <title>BZOJ2429 聪明的猴子</title>
      <link>/oi/lofterimport_130/</link>
      <pubDate>Tue, 21 Oct 2014 14:28:42 +0000</pubDate>
      
      <guid>/oi/lofterimport_130/</guid>
      <description>找到一道水题真是一件令人开心的事情。
最小生成树。完了。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cmath&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
#define sqr(x)&amp;nbsp;((x)*(x))
struct edge {
int a, b, v;
edge(int a0 = 0, int b0 = 0, int v0 = 0)&amp;nbsp;{
a = a0, b = b0, v = v0;
}
};
const int maxn = 1009;
int n, m, a[maxn], t, x[maxn], y[maxn], r[maxn];
edge e[maxn * maxn];
inline bool cmpE(const edge&amp;amp; a, const edge&amp;amp; b)&amp;nbsp;{
return a. v &amp;lt; b.</description>
    </item>
    
    <item>
      <title>20141021 计划</title>
      <link>/oi/lofterimport_131/</link>
      <pubDate>Tue, 21 Oct 2014 08:06:46 +0000</pubDate>
      
      <guid>/oi/lofterimport_131/</guid>
      <description>好端端的上午被体检腰斩了。
早上先花两节课继续复习数学吧。
然后去写图论。
下午爬梯子和bzoj。还有高一小朋友的图论基础（虽然多半听不到两分钟就受不了了）。
然后晚上还要考试好开心。</description>
    </item>
    
    <item>
      <title>BZOJ1597 [Usaco2008 Mar]土地购买</title>
      <link>/oi/lofterimport_133/</link>
      <pubDate>Mon, 20 Oct 2014 21:01:01 +0000</pubDate>
      
      <guid>/oi/lofterimport_133/</guid>
      <description>大概也不是很难。毕竟只有做水题的份。
就把原来的土地按x排个序，把能合并的合并，变成一个x单增y单减的序列。
然后就是dp。f[i]&amp;nbsp;= min(f[j]&amp;nbsp;+ y[j+1]*x[i])，可以单调的斜率优化。
符号比较郁闷还搞错了好几次。
所以说我太弱了啊怎么办啊。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
typedef long long qw;
typedef long double exf;
#ifdef WIN32
#define lld &amp;quot;%I64d&amp;quot;
#else
#define lld &amp;quot;%lld&amp;quot;
#endif
#define _l (qw)
#define _f (exf)
struct field {
int x, y;
};
inline bool cmpField(const field&amp;amp; a, const field&amp;amp; b)&amp;nbsp;{
return (a. x &amp;lt; b. x)&amp;nbsp;||&amp;nbsp;(a. x == b. x &amp;amp;&amp;amp; a. y &amp;lt; b. y);
}</description>
    </item>
    
    <item>
      <title>BZOJ3231 递归数列</title>
      <link>/oi/lofterimport_134/</link>
      <pubDate>Mon, 20 Oct 2014 19:06:02 +0000</pubDate>
      
      <guid>/oi/lofterimport_134/</guid>
      <description>感觉几百年没有刷bzoj了？虽然昨天才写了题，下午也还交了题的。
还是挺水的一道矩阵题。看到数列想得到矩阵，不知道没看到数列能不能想到矩阵。
关键是求和比较不好想。其实新加一行把和记下来就行了。重点就是构造对吧。
然后矩阵快速幂啥的还好。主要是要记得快速乘。（想起了zhx的babysit）
#include &amp;lt;iostream&amp;gt;
#ifndef ONLINE_JUDGE
#include &amp;lt;fstream&amp;gt;
#define cin _cin_
std :: ifstream cin(&amp;quot;in.txt&amp;quot;);
#endif
#include &amp;lt;algorithm&amp;gt;
using namespace std;
typedef long long qw;
const int maxn = 19;
qw n, b[maxn], c[maxn], x, y, mod;
qw modMul(qw a, qw b)&amp;nbsp;{
qw s = 0;
for (; b; b &amp;gt;&amp;gt;= 1, a =&amp;nbsp;(a&amp;nbsp;&amp;lt;&amp;lt; 1)&amp;nbsp;% mod)
if (b&amp;nbsp;&amp;amp; 1)
s =&amp;nbsp;(s&amp;nbsp;+ a)&amp;nbsp;% mod;
return s;
}
class matrix {</description>
    </item>
    
    <item>
      <title>20141020 计划</title>
      <link>/oi/lofterimport_135/</link>
      <pubDate>Mon, 20 Oct 2014 08:23:00 +0000</pubDate>
      
      <guid>/oi/lofterimport_135/</guid>
      <description>突然感到noip已经很近了。
恐怕只剩下一周自己刷题了。
现在还没补完的专题？数学和图论。
今天先搞点数学题吧。
上午下午都用来刷cv好了。
晚上么，bzoj。</description>
    </item>
    
    <item>
      <title>BZOJ1977 次小生成树</title>
      <link>/oi/lofterimport_136/</link>
      <pubDate>Sun, 19 Oct 2014 11:51:51 +0000</pubDate>
      
      <guid>/oi/lofterimport_136/</guid>
      <description>题意是严格次小生成树。
想了一下发现应该是一条不在最小生成树上的边构成的环上替换一条边就行了。感觉好想noi那道lct，哈。其实不用那么复杂的。
就用倍增就可以了。不过我还是比较倾向于用链剖。感觉链剖空间小而且写起来倍爽。不像倍增写挂了不只一次了。
要注意的是不仅要找最大值还要找严格次大值，因为要找严格次小。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;memory.h&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
typedef long long qw;
#ifdef WIN32
#define lld &amp;quot;%I64d&amp;quot;
#else
#define lld &amp;quot;%lld&amp;quot;
#endif
struct edge_g {
int a, b, v, mk;
};
struct edge_t {
int t, v;
edge_t *next;
};
struct dat {
int a, b;
dat(int v0 =&amp;nbsp;-1)&amp;nbsp;{
a = v0, b =&amp;nbsp;-1;
}
dat(int a0, int b0)&amp;nbsp;{
a = a0, b = b0;</description>
    </item>
    
    <item>
      <title>CodeVS3147 矩阵乘法2</title>
      <link>/oi/lofterimport_138/</link>
      <pubDate>Sat, 18 Oct 2014 17:06:28 +0000</pubDate>
      
      <guid>/oi/lofterimport_138/</guid>
      <description>居然继续沦落到写CV的题解的地步了。
这又是一道坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑题。
思路很简单。就是记a的列前缀和和b的行前缀和，每次询问的时候O(n)的扫一遍乘积累和。
但是，极限数据本地要跑3.2s。虽然我笔记本是慢，但是也不能这样玩我啊。交了好久都在tle。
最后想到一个常数优化的办法。因为每次是把一行或者一列的数都访问一遍，所以用一个指针把数组的那一行记下来。这样寻址会快一些。事实证明快了不只一些。
坑，哈哈。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;memory.h&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
typedef long long qw;
#ifdef WIN32
#define lld &amp;quot;%I64d&amp;quot;
#else
#define lld &amp;quot;%lld&amp;quot;
#endif
#define _l (qw)
#define readInt(_s_)&amp;nbsp;{\
int _d_;\
_s_ = 0;\
while (!isdigit(_d_&amp;nbsp;= getchar()));\
while ((_s_&amp;nbsp;= _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar()));\
}
const int maxn = 2001;
int a[maxn][maxn], b[maxn][maxn], n, m;
int main()&amp;nbsp;{
readInt(n);</description>
    </item>
    
    <item>
      <title>20141018 计划</title>
      <link>/oi/lofterimport_139/</link>
      <pubDate>Sat, 18 Oct 2014 08:18:05 +0000</pubDate>
      
      <guid>/oi/lofterimport_139/</guid>
      <description>早上adam发话说要好好准备noip。
不能再颓废下去了。
tyvj520了。所以先让它好看一点吧。那么今天去爬cv的天梯好了。好多恶心的代码题也可以写一写了。
下午的话继续。
晚上大概可以回家了。然后有bc吧。</description>
    </item>
    
    <item>
      <title>SPOJ4487 GSS6</title>
      <link>/oi/lofterimport_141/</link>
      <pubDate>Fri, 17 Oct 2014 19:48:32 +0000</pubDate>
      
      <guid>/oi/lofterimport_141/</guid>
      <description>看上去挺水水水水水水水水的一道平衡树维护序列的数据结构题啊。
先用split-merge tree写，tle。
然后改用splay，tle。
最后据说把splay的裸数组改到struct node里就能过。于是再写了一个程序来改代码。
不&amp;nbsp;带&amp;nbsp;这&amp;nbsp;么&amp;nbsp;坑&amp;nbsp;的&amp;nbsp;！
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstdlib&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;memory.h&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
/*#define readInt(_s_)&amp;nbsp;{\
int _d_;\
bool _nag_ = 0;\
_s_ = 0;\
while (!isdigit(_d_&amp;nbsp;= getchar()))\
if (_d_&amp;nbsp;==&amp;nbsp;&#39;-&#39;)\
_nag_ = 1;\
while ((_s_&amp;nbsp;= _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar()));\
if (_nag_)\
_s_ =&amp;nbsp;- _s_;\
}*/
#define readInt(_s_) scanf(&amp;quot;%d&amp;quot;,&amp;amp;_s_);
#define readOpt(_s_)&amp;nbsp;{\
do\
_s_ = getchar();\
while (_s_&amp;nbsp;!=&amp;nbsp;&#39;I&#39;&amp;nbsp;&amp;amp;&amp;amp; _s_ !=&amp;nbsp;&#39;D&#39;&amp;nbsp;&amp;amp;&amp;amp; _s_ !</description>
    </item>
    
    <item>
      <title>20141017 计划</title>
      <link>/oi/lofterimport_142/</link>
      <pubDate>Fri, 17 Oct 2014 08:01:41 +0000</pubDate>
      
      <guid>/oi/lofterimport_142/</guid>
      <description>上午要考试。
下午把昨天的题补了吧。然后也去打打球啥的。
晚上补一补文化课好了。好像已经欠了好多了。唉。不好好刷题就只有刷53，好好刷题也匆忘53。</description>
    </item>
    
    <item>
      <title>20141016 计划</title>
      <link>/oi/lofterimport_144/</link>
      <pubDate>Thu, 16 Oct 2014 08:10:55 +0000</pubDate>
      
      <guid>/oi/lofterimport_144/</guid>
      <description>早上来先修椅子，敲钉子*5min。yzy:修凳子哪家强？...
昨天晚上tyvj终于-- rank了，开心。
上午先补一补觉，然后去做模拟题好了。
下午到bzoj上去逛逛，找点数据结构来做吧。
晚上依稀记得要上课。好久没跑成步了怎么办啊。</description>
    </item>
    
    <item>
      <title>BZOJ1414 对称的正方形</title>
      <link>/oi/lofterimport_146/</link>
      <pubDate>Wed, 15 Oct 2014 20:11:35 +0000</pubDate>
      
      <guid>/oi/lofterimport_146/</guid>
      <description>OTL写manacher的mhy。
我没有那么高端去研究st怎么搞，所以就用了一个二维hash。从四个角各来一遍真是爽翻了。需要注意的是hash的时候行之间和列之间的值要不同才能区别，不然有数据随便可以卡掉。
代码么，巨丑无比。
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;memory.h&amp;gt;
#include &amp;lt;algorithm&amp;gt;
using namespace std;
#define uint _uint_
typedef unsigned long long int uint;
const int maxn = 1009;
const uint bh = 1e9 + 93;
const uint bv = 1e9 + 7;
#define readInt(_s_)&amp;nbsp;{\
int _d_;\
_s_ = 0;\
while (!isdigit(_d_&amp;nbsp;= getchar()));\
while ((_s_&amp;nbsp;= _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar()));\
}
int n, m, a[maxn][maxn];
uint h[4][maxn][maxn], ph[maxn * 2], pv[maxn * 2];</description>
    </item>
    
    <item>
      <title>tyvj1996 工作分配2</title>
      <link>/oi/lofterimport_147/</link>
      <pubDate>Wed, 15 Oct 2014 12:00:49 +0000</pubDate>
      
      <guid>/oi/lofterimport_147/</guid>
      <description>沦落到写tyvj的题解了。不过看在这题之前只有7人过的份上就写一下好了。
式子是容斥，比较好想。answer = sigma((-1)^i * m^(n-i)&amp;nbsp;* C(m, i))&amp;nbsp;(0 &amp;lt;= i &amp;lt;= m)
m^(n-i)这一块用快速幂就好了。
然后对于前一题因为m很小所以用m^2把组合数弄出来就行了。但是这里m^2就T到明天去了。
观察
C(m, i)&amp;nbsp;= m!/(i!&amp;nbsp;*&amp;nbsp;(m-i)!)&amp;nbsp;
=&amp;gt; C(m, i - 1)&amp;nbsp;= m!&amp;nbsp;/&amp;nbsp;((i-1)!&amp;nbsp;*&amp;nbsp;(m-i+1)!)&amp;nbsp;
=&amp;gt; C(m, i)&amp;nbsp;= C(m, i - 1)&amp;nbsp;/ i *&amp;nbsp;(m&amp;nbsp;- i + 1)
这样递推用逆元来做就是O(m * lgm)的时间了。
然后这题就这样了。代码很短。
#include &amp;lt;iostream&amp;gt;
#include &amp;lt;memory.h&amp;gt;
using namespace std;
#define _l (long long int)
typedef long long qw;
const int maxm = 1000009;
const int mod = 1e9 + 7;
int cm[maxm];</description>
    </item>
    
    <item>
      <title>20141015 计划</title>
      <link>/oi/lofterimport_148/</link>
      <pubDate>Wed, 15 Oct 2014 08:17:48 +0000</pubDate>
      
      <guid>/oi/lofterimport_148/</guid>
      <description>昨天晚上好像考试了？
好像noip只有20来天了。要抓紧了。
上午先把昨天的题补了，然后找点模拟啊字符串啊啥的题来做。
下午去搞bzoj上那道回文正方形。
晚上还是学一下鸟语和文化课啥的。然后再玩一玩八中。还能跑步。哈哈</description>
    </item>
    
    <item>
      <title>BZOJ3672 [NOI2014]购票</title>
      <link>/oi/lofterimport_150/</link>
      <pubDate>Tue, 14 Oct 2014 18:01:23 +0000</pubDate>
      
      <guid>/oi/lofterimport_150/</guid>
      <description>考场上只想到暴力。
如果只是一条链的话怎么乱搞一搞？
如果没有深度限制的话简单的斜率优化+链剖就行了。
有深度限制就把hull扔到线段树里用可持久化栈来维护一下。DFS的时候塞进线段树里，然后完了再扔出来。总的复杂度O(n*log^2(n))，
代码也不怎么复杂。
#include &amp;lt;cstdio&amp;gt;
#include&amp;nbsp;&amp;lt;cctype&amp;gt;
#include&amp;nbsp;&amp;lt;memory.h&amp;gt;
#include&amp;nbsp;&amp;lt;vector&amp;gt;
#include&amp;nbsp;&amp;lt;algorithm&amp;gt;
using namespace std;
struct edge {
int t;
edge* next;
};
typedef long long qw;
typedef long double exf;
#ifdef WIN32
#define lld &amp;quot;%I64d&amp;quot;
#else
#define lld &amp;quot;%lld&amp;quot;
#endif
#define _l (qw)
#define readInt(_s_)&amp;nbsp;{\
int _d_;\
_s_ = 0;\
while (!isdigit(_d_&amp;nbsp;= getchar()));\
while ((_s_&amp;nbsp;= _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar()));\
}
struct oper {
int p, v, t;</description>
    </item>
    
    <item>
      <title>20141014 计划</title>
      <link>/oi/lofterimport_151/</link>
      <pubDate>Tue, 14 Oct 2014 08:01:58 +0000</pubDate>
      
      <guid>/oi/lofterimport_151/</guid>
      <description>反正闲着时间比较多。每天写计划写总结好了。
早上复习字符串。重点是kmp和马拉车。当然其它题看到也做一做。
下午把NOI那题做了。数据结构+DP=ORZ
晚上还是要跑步。然后顺便刷下bzoj吧。
然后发现晚上要考试。又naive了啊。唉。</description>
    </item>
    
    <item>
      <title>#0</title>
      <link>/oi/lofterimport_153/</link>
      <pubDate>Mon, 13 Oct 2014 21:09:00 +0000</pubDate>
      
      <guid>/oi/lofterimport_153/</guid>
      <description>不知道这是啥，不过看上去很有趣的样子。
页面好像比百度空间好看，虽然没有看到专门插入代码的东西，不过好像也不用在百度空间上粘代码的说。
一级域名比较赞。
决定以后就拿它写总结了。希望不会过两天就RE了吧。</description>
    </item>
    
  </channel>
</rss>
