原题地址:https://open.kattis.com/problems/aplusb FFT代码参考kuangbin的博客:http://www.cnblogs.com/kuangbin/archive/2013/07/24/3210565.html A+B Problem Given N integers in the range [−50000,50000], how many ways are there to pick three integers ai, aj, ak, such…
Let SS be a sequence of integers s_{1}s​1​​, s_{2}s​2​​, ......, s_{n}s​n​​Each integer is is associated with a weight by the following rules: (1) If is is negative, then its weight is 00. (2) If is is greater than or equal to 1000010000, then its we…
原题网址:https://open.kattis.com/problems/classrooms Classrooms The new semester is about to begin, and finding classrooms for orientation activities is always a headache. There are k classrooms on campus and n proposed activities that need to be assigne…
原题网址:https://open.kattis.com/problems/driver Crazy Driver In the Linear City, there are N gates arranged in a straight line. The gates are labelled from 1 to N. Between adjacent gates, there is a bidirectional road. Each road takes one hour to travel…
原题网址:https://open.kattis.com/problems/boxes Boxes There are N boxes, indexed by a number from 1 to N.Each box may (or not may not) be put into other boxes. These boxes together form a tree structure (or a forest structure, to be precise). You have to…
\(\mathcal{Description}\)   给定一个含 \(n\) 个点 \(m\) 条边的简单无向图,设图中最大点双的大小为 \(s\),则保证 \(s\le6\).你将要用 \(k\) 种颜色为结点染色,其中有些结点需要染成的颜色被确定,其余结点颜色任意.一次染色可以将一块全部无色的连通块染成某种颜色.求最少染色次数.   \(n\le10^5\),\(k\le20\),\(s\le6\). \(\mathcal{Solution}\)   提到点双,尝试建出广义圆方树,在其上…
\(\mathcal{Description}\)   给定 \(\{a_n\}\),求一个 \(\{b_{n-1}\}\),使得 \(\forall x\in\{a_n\},\exists i,j\in[1,n),b_i+b_j=x\).输出 \(\{b_{n-1}\}\) 以及对于每个 \(x\) 所应该取的 \(i,j\),或断言不可能.   \(n\le30\). \(\mathcal{Solution}\)   原来不是构造题啊.(悲   若 \(a\) 中有偶数 \(2k\),取一个…
主要是记录思路,不要被刚开始错误方向带偏了 www 「CF1110F」Nearest Leaf 特殊性质:先序遍历即为 \(1 \to n\),可得出:叶子节点编号递增或可在不改变树形态的基础上调整为递增. 这样就可找出区间 \([l, r]\) 中的叶子节点有哪些了,预处理深度,暴力 \(O(n ^ 2)\). 考虑柿子 \(\min \{\mathrm{d} (y) - \mathrm{d} (\mathrm{f} (x))\}\),其中 \(d(x)\) 表示深度,\(f(x)\) 表示父…
\(\mathcal{Description}\)   求出处 owo.   给定一个长度为 \(n\),仅包含小写字母的字符串 \(s\),问是否存在长度为 \(n\),仅包含小写字母的字符串 \(t\),使得 \(t<s\) 且 \(s,t\) 的后缀数组(\(\text{Suffix Array}\),sa[])相同.   \(n\le50\).(建议开到 \(n\le2\times10^5\). \(\mathcal{Solution}\) 奇怪的结论   若存在 \(t\),则存在一个…
\(\mathcal{Description}\)   link.   给定 \(n\) 个水果,每个结点可能有甜度 \(v_i\),或不甜(\(v_i=-1\)).现在把这些水果串成一棵无根树.称一个水果"真甜",当且仅当其本身和至少一个邻接水果是甜的.每个"真甜"水果对树的甜度产生 \(v_i\) 的贡献.求所有甜度不超过 \(maxv\) 的树.   \(n\le40\). \(\mathcal{Solution}\)   令无序地取恰好 \(i\) 个水果使…