04 2018 档案

摘要:一开始死磕sam,发现根本没法做。。。。。。 后来想了想,反正匹配子串的大部分不是sam就是 二分+hash啊,,,于是就想了想二分+hash,发现好像可以做啊! 就是假设我们要让 s1[1] 映射到s2 中的位置是 s2[i] ,那么这种情况的答案就很好算了,就是求一次lcp之后把第一个不匹配的钦 阅读全文
posted @ 2018-04-30 18:30 蒟蒻JHY 阅读(174) 评论(0) 推荐(0)
摘要:1965: [Ahoi2005]SHUFFLE 洗牌 Description 为了表彰小联为Samuel星球的探险所做出的贡献,小联被邀请参加Samuel星球近距离载人探险活动。 由于Samuel星球相当遥远,科学家们要在飞船中度过相当长的一段时间,小联提议用扑克牌打发长途旅行中的无聊时间。玩了几局 阅读全文
posted @ 2018-04-30 12:02 蒟蒻JHY 阅读(264) 评论(0) 推荐(0)
摘要:可以很容易的发现,如果选了最高的房子,那么就不能再选了;否则在左边选一坨合法的,在右边选一坨合法的,拼起来还是合法的。 所以我们可以处理出,每个数的控制区间[L,R] (保证这个区间是其他数都小于它的极大区间),以及左边右边最大的比它小的数的位置(在区间里)。 这样我们就可以做到类似线段树的分割并合 阅读全文
posted @ 2018-04-30 10:03 蒟蒻JHY 阅读(283) 评论(0) 推荐(0)
摘要:做法超好想,细节调一辈子。 估计这句话最适合这个题了hhhh。 首先一个很显然的想法:把边设成未知数,对点列异或方程,最后的解的个数就是 2^自由元 。 不过如果某个联通分量里有奇数个黑点,那么问题无解。然后我来证明一下: 把一个联通分量里所有点代表的方程都异或起来,因为这个联通分量里的边恰好在其两 阅读全文
posted @ 2018-04-29 11:30 蒟蒻JHY 阅读(1077) 评论(1) 推荐(1)
摘要:套着dp外套的数论题hhhhh。 不难推出以下的几个性质: 1.第i种物品能表示的数 -> gcd(V[i] , P) 的倍数。 2.查询W[i] 其实就相当于查询 gcd(W[i] , P). 3.在%P同余系下 ,ax + by 可以表示的数 与 gcd(a,b) 的倍数 是相同的集合。 看起来 阅读全文
posted @ 2018-04-28 12:00 蒟蒻JHY 阅读(790) 评论(0) 推荐(0)
摘要:4017: 小Q的无敌异或 Description 背景 小Q学习位运算时发现了异或的秘密。 描述 小Q是一个热爱学习的人,他经常去维基百科(http://en.wikipedia.org/wiki/Main_Page)学习计算机科学。 就在刚才,小Q认真地学习了一系列位运算符(http://en. 阅读全文
posted @ 2018-04-27 20:56 蒟蒻JHY 阅读(546) 评论(0) 推荐(0)
摘要:非常好的一道思维性题目,想了很久才想出来qwq(我好笨啊) 考虑a[]数组有什么用,首先可以yy出一些性质 (设num[i]为原来第i个位置的数是什么 , 因为题目说至少有一个排列可以满足a[],所以我们就假设num[]没有相同的元素): 1. 当 a[i] == a[j] 且 i<j 的时候,我们 阅读全文
posted @ 2018-04-27 19:00 蒟蒻JHY 阅读(492) 评论(0) 推荐(0)
摘要:刚刚做的时候一看:这不是个傻逼题吗hhhhh。。。。然后发现写完了过不了样例,仔细一看题:同构的算一种。 这可咋办啊? 其实很简单,设f[i] 为 以a[i] 结尾的上升子序列个数,我们考虑当前如果算到 i 了,那么我们需要查询 a[j] < a[i] 且 j < i 的所有 的 f[j] 的和。 阅读全文
posted @ 2018-04-27 15:52 蒟蒻JHY 阅读(339) 评论(0) 推荐(0)
摘要:3261: 最大异或和 Time Limit: 10 Sec Memory Limit: 512 MBSubmit: 2637 Solved: 1078[Submit][Status][Discuss] Description 给定一个非负整数序列{a},初始长度为N。 有M个操作,有以下两种操作类 阅读全文
posted @ 2018-04-27 10:57 蒟蒻JHY 阅读(201) 评论(0) 推荐(0)
摘要:二元费用模型基本题hhhh,以前一直以为这个题和happiness是一个。。。 阅读全文
posted @ 2018-04-27 08:26 蒟蒻JHY 阅读(279) 评论(0) 推荐(0)
摘要:可以先将问题建模为 : 物品大小为1~inf 且每件物品数量无限 的背包选体积为1~n的方案数。 显然物品体积只有1~n有用,我们不妨把 体积1~sqrt(n) 的物品先暴力插入到背包中,设这一部分最后 体积i的方案数是 A[i] 。 考虑体积>sqrt(n)的物品怎么计算方案,可以发现这样的物品最 阅读全文
posted @ 2018-04-26 20:51 蒟蒻JHY 阅读(685) 评论(0) 推荐(0)
摘要:Discription As you know, the most intelligent beings on the Earth are, of course, cows. This conclusion was reached long ago by the Martian aliens, as 阅读全文
posted @ 2018-04-26 11:02 蒟蒻JHY 阅读(426) 评论(0) 推荐(0)
摘要:Discription As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be s 阅读全文
posted @ 2018-04-26 10:06 蒟蒻JHY 阅读(445) 评论(0) 推荐(0)
摘要:看样例猜结论hhhhhh,竟然蒙对了。。(正确性待证明) 阅读全文
posted @ 2018-04-26 09:10 蒟蒻JHY 阅读(382) 评论(0) 推荐(0)
摘要:可以很简单的推出每个数a[i]最后对答案的的贡献系数是 C(n-1,i-1) / 2^(n-1) ,但是不能直接照着这么算,,精度会爆炸。 我们取一下对数,就可以直接做了(注意因为负数不能取对数,所以加一个负数就相当于减它的相反数) 阅读全文
posted @ 2018-04-26 08:32 蒟蒻JHY 阅读(282) 评论(0) 推荐(0)
摘要:2889: Tree Conundrum Description 给定一棵N个节点的无根树,现要求有多少种合法的分块方案。 所谓合法的分块方案,就是将树分为若干个连通块,满足每个连通块内点数相同。 给定一棵N个节点的无根树,现要求有多少种合法的分块方案。 所谓合法的分块方案,就是将树分为若干个连通块 阅读全文
posted @ 2018-04-25 21:01 蒟蒻JHY 阅读(278) 评论(0) 推荐(0)
摘要:2839: 集合计数 Description 一个有N个元素的集合有2^N个不同子集(包含空集),现在要在这2^N个集合中取出若干集合(至少一个),使得 它们的交集的元素个数为K,求取法的方案数,答案模1000000007。(是质数喔~) 一个有N个元素的集合有2^N个不同子集(包含空集),现在要在 阅读全文
posted @ 2018-04-25 20:37 蒟蒻JHY 阅读(274) 评论(0) 推荐(0)
摘要:Discription Gargari got bored to play with the bishops and now, after solving the problem about them, he is trying to do math homework. In a math book 阅读全文
posted @ 2018-04-25 19:37 蒟蒻JHY 阅读(263) 评论(0) 推荐(0)
摘要:5092: [Lydsy1711月赛]分割序列 Description 对于一个长度为n的非负整数序列b_1,b_2,...,b_n,定义这个序列的能量为:f(b)=max{i=0,1,...,n}((b_1 xor b _2 xor...xor b_i)+(b_{i+1} xor b_{i+2} 阅读全文
posted @ 2018-04-25 16:17 蒟蒻JHY 阅读(254) 评论(0) 推荐(0)
摘要:Discription You are given an array of n integers a1... an. The cost of a subsegment is the number of unordered pairs of distinct indices within the su 阅读全文
posted @ 2018-04-25 11:22 蒟蒻JHY 阅读(329) 评论(0) 推荐(0)
摘要:新学了一波 决策单调性 dp 套路。。。。 这种dp一般是长这样的 => f[i][j] = max/min { f[i-1][k] + cost(k+1,j)} ,其中cost函数满足四边形不等式。 其实这就可以看成是个多阶段决策,每一个阶段的f都是单调的;但因为f[i-1][k] + cost( 阅读全文
posted @ 2018-04-25 10:26 蒟蒻JHY 阅读(403) 评论(0) 推荐(0)
摘要:设f[0/1][x]为区间[1,x]的根向下 不选(0)或者选(1) 的dp pair<最优值,方案数>。 可以很容易的发现总状态数就是log级别的,因为2*n 与 (2*n+1 或者 2*n-1) 向下有很多重叠,记忆化搜索即可。 初始化的话 f[0][1] = {0,1}, f[1][1] = 阅读全文
posted @ 2018-04-25 08:46 蒟蒻JHY 阅读(300) 评论(0) 推荐(0)
摘要:Discription HOHO,终于从Speakless手上赢走了所有的糖果,是Gardon吃糖果时有个特殊的癖好,就是不喜欢将一样的糖果放在一起吃,喜欢先吃一种,下一次吃另一种,这样;可是Gardon不知道是否存在一种吃糖果的顺序使得他能把所有糖果都吃完?请你写个程序帮忙计算一下。 Input 阅读全文
posted @ 2018-04-24 21:28 蒟蒻JHY 阅读(168) 评论(0) 推荐(0)
摘要:Discription Given a text s[1..n] of length n, we create its suffix array by taking all its suffixes: s[1..n], s[2..n],...., s[n..n] and sorting them l 阅读全文
posted @ 2018-04-24 21:05 蒟蒻JHY 阅读(182) 评论(0) 推荐(0)
摘要:Discription Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if and only if it is d 阅读全文
posted @ 2018-04-24 19:02 蒟蒻JHY 阅读(239) 评论(0) 推荐(0)
摘要:Discription 单身! 依然单身! 吉哥依然单身! DS级码农吉哥依然单身! 所以,他生平最恨情人节,不管是214还是77,他都讨厌! 吉哥观察了214和77这两个数,发现: 2+1+4=7 7+7=7*2 77=7*11 最终,他发现原来这一切归根到底都是因为和7有关!所以,他现在甚至讨厌 阅读全文
posted @ 2018-04-24 17:16 蒟蒻JHY 阅读(443) 评论(0) 推荐(0)
摘要:Discription 给定一棵n个节点的树,从1到n标号。选择k个点,你需要选择一些边使得这k个点通过选择的边联通,目标是使得选择的边数最少。 现需要计算对于所有选择k个点的情况最小选择边数的总和为多少。 样例解释: 一共有三种可能:(下列配图蓝色点表示选择的点,红色边表示最优方案中的边) 选择点 阅读全文
posted @ 2018-04-24 16:23 蒟蒻JHY 阅读(170) 评论(0) 推荐(0)
摘要:Discription You are given two multisets A and B. Each multiset has exactly n integers each between 1 and n inclusive. Multisets may contain multiple c 阅读全文
posted @ 2018-04-24 11:44 蒟蒻JHY 阅读(353) 评论(0) 推荐(0)
摘要:Discription A group of n cities is connected by a network of roads. There is an undirected road between every pair of cities, so there are roads in to 阅读全文
posted @ 2018-04-24 11:19 蒟蒻JHY 阅读(503) 评论(0) 推荐(0)
摘要:Problem Statement You are given an integer sequence of length N, a= {a1,a2,…,aN}, and an integer K. a has N(N+1)⁄2 non-empty contiguous subsequences, 阅读全文
posted @ 2018-04-23 21:22 蒟蒻JHY 阅读(266) 评论(0) 推荐(0)
摘要:Discription Altanie is a very large and strange country in Mars. People of Mars ages a lot. Some of them live for thousands of centuries! Your old fri 阅读全文
posted @ 2018-04-23 18:41 蒟蒻JHY 阅读(346) 评论(0) 推荐(0)
摘要:题目背景 08四川NOI省选 题目描述 你正在玩你最喜欢的电子游戏,并且刚刚进入一个奖励关。在这个奖励关里,系统将依次随机抛出k次宝物,每次你都可以选择吃或者不吃(必须在抛出下一个宝物之前做出选择,且现在决定不吃的宝物以后也不能再吃)。 宝物一共有n种,系统每次抛出这n种宝物的概率都相同且相互独立。 阅读全文
posted @ 2018-04-23 17:06 蒟蒻JHY 阅读(184) 评论(0) 推荐(0)
摘要:Discription Statements Whistle has bought a new car, which has an infinite fuel tank capacity. He discovered an irregular country since it has n citie 阅读全文
posted @ 2018-04-23 16:51 蒟蒻JHY 阅读(375) 评论(0) 推荐(0)
摘要:Discription Berland is a tourist country! At least, it can become such — the government of Berland is confident about this. There are n cities in Berl 阅读全文
posted @ 2018-04-23 10:48 蒟蒻JHY 阅读(431) 评论(0) 推荐(0)
摘要:建一下模,把行和列看成二分图的点,把车看成是二分图中的边,这样就变成了上一个博客的问题。 我们每次新加一条边,就把它加入一条 这条边两端点最小没有出现的颜色 交替出现的路径中去。 阅读全文
posted @ 2018-04-23 09:14 蒟蒻JHY 阅读(241) 评论(0) 推荐(0)
摘要:Discription You are given an undirected bipartite graph without multiple edges. You should paint the edges of graph to minimal number of colours, so t 阅读全文
posted @ 2018-04-23 08:52 蒟蒻JHY 阅读(464) 评论(0) 推荐(0)
摘要:一道特别好的题qwq。 题目大意就是给你一个无向图,让你把边定向之后再加一些边使得这个图强连通,求最少需要加多少边。 一开始毫无头绪23333,数据范围让人摸不着头脑。。。。。 然后开始画图,,,发现环上的边都顺时针或者逆时针是很优的,之后扩展到了 边双联通分量上(因为边双联通分量中的每个边都在至少 阅读全文
posted @ 2018-04-22 20:55 蒟蒻JHY 阅读(273) 评论(0) 推荐(0)
摘要:题目背景 当今社会,在社交网络上看朋友的消息已经成为许多人生活的一部分。通常,一个用户在社交网络上发布一条消息(例如微博、状态、Tweet等) 后,他的好友们也可以看见这条消息,并可能转发。转发的消息还可以继续被人转发,进而扩散到整个社交网络中。 题目描述 在一个实验性的小规模社交网络中我们发现,有 阅读全文
posted @ 2018-04-22 17:19 蒟蒻JHY 阅读(361) 评论(0) 推荐(0)
摘要:经典的根据题目描述yy连边的网络流hhhh,几乎可以说是模拟了 阅读全文
posted @ 2018-04-22 15:44 蒟蒻JHY 阅读(208) 评论(0) 推荐(0)
摘要:题目大意就是求一下 杨辉三角的第N行中不能被P整除的有多少个。 直接卢卡斯定理一下就行啦。 阅读全文
posted @ 2018-04-22 11:53 蒟蒻JHY 阅读(245) 评论(0) 推荐(0)
摘要:题目背景 Diffie-Hellman密钥交换协议是一种简单有效的密钥交换方法。它可以让通讯双方在没有事先约定密钥(密码) 的情况下,通过不安全的信道(可能被窃听) 建立一个安全的密钥K,用于加密之后的通讯内容。 题目描述 假定通讯双方名为Alice和Bob,协议的工作过程描述如下(其中 mod 表 阅读全文
posted @ 2018-04-22 10:43 蒟蒻JHY 阅读(412) 评论(0) 推荐(0)
摘要:题目背景 使用过Android 手机的同学一定对手势解锁屏幕不陌生。Android 的解锁屏幕由3X3 个点组成,手指在屏幕上画一条线,将其中一些点连接起来,即可构成一个解锁图案。如下面三个例子所示: 题目描述 画线时还需要遵循一些规则: 连接的点数不能少于4 个。也就是说只连接两个点或者三个点会提 阅读全文
posted @ 2018-04-22 10:12 蒟蒻JHY 阅读(387) 评论(0) 推荐(0)
摘要:Discription Given a permutation a1, a2, … aN of {1, 2, …, N}, we define its E-value as the amount of elements where ai > i. For example, the E-value o 阅读全文
posted @ 2018-04-20 21:33 蒟蒻JHY 阅读(221) 评论(0) 推荐(0)
摘要:Read problems statements in Mandarin Chinese and Russian. Rin is attending a university. She has M semesters to finish her program, and that program h 阅读全文
posted @ 2018-04-20 20:37 蒟蒻JHY 阅读(282) 评论(0) 推荐(0)
摘要:题面:https://www.luogu.org/problemnew/show/P4451 题解链接:https://www.luogu.org/blog/user31377/solution-p4451 题解见代码注释 (或者我回来会放我在洛谷上写的题解) 阅读全文
posted @ 2018-04-19 20:56 蒟蒻JHY 阅读(320) 评论(0) 推荐(0)
摘要:2718: [Violet 4]毕业旅行 Description Input Output 最多可选多少景点 最多可选多少景点 Sample Input 7 6 1 2 2 3 5 4 4 3 3 6 6 7 Sample Output 2 HINT 首先有一个结论是:最长反链大小 = 最小路径覆盖 阅读全文
posted @ 2018-04-19 20:19 蒟蒻JHY 阅读(279) 评论(0) 推荐(0)
摘要:Discription Consider a sequence F i that satisfies the following conditions: Discription Consider a sequence F i that satisfies the following conditio 阅读全文
posted @ 2018-04-19 16:02 蒟蒻JHY 阅读(245) 评论(0) 推荐(0)
摘要:Discription Input 第一行一个正整数,表示数据组数据 ,接下来T行每行三个正整数N,K,P Output T行,每行输出一个整数,表示结果 Sample Input Discription 第一行一个正整数,表示数据组数据 ,接下来T行每行三个正整数N,K,P T行,每行输出一个整数 阅读全文
posted @ 2018-04-19 11:42 蒟蒻JHY 阅读(363) 评论(0) 推荐(0)
摘要:考虑一下简单环覆盖这个图的意义,其实就是找出原序列的所有排列,满足所有<i,a[i]>都是原图中的一条有向边。 因为一个置换就是由很多简单环构成的。 于是我们可以设 f[i][S] 为考虑了前i个点的出边,且有入度的点集为S的方案数。 直接dp不难发现复杂度是 O(n^2 * 2^n),正好会T掉2 阅读全文
posted @ 2018-04-19 09:54 蒟蒻JHY 阅读(309) 评论(0) 推荐(0)
摘要:把第1个和第n个点加进来之后,设f[i][j]为到了第i个点,且经过的不合法的点的奇偶性是j的方案数。最后答案就是 f[n+2][0] - f[n+2][1] 。 考虑我们算的其实是至少经过枚举的点的方案数,所以 给奇数加上权 -1,偶数加上权 1之后,只有一个不合法点都没走的方案会贡献1,其他都被 阅读全文
posted @ 2018-04-18 21:14 蒟蒻JHY 阅读(321) 评论(0) 推荐(0)
摘要:Discription Given a sequence of integers a1, ..., an and q queries x1, ..., xq on it. For each query xi you have to count the number of pairs (l, r) s 阅读全文
posted @ 2018-04-18 20:40 蒟蒻JHY 阅读(338) 评论(0) 推荐(0)
摘要:1283: 序列 Description 给出一个长度为 的正整数序列Ci,求一个子序列,使得原序列中任意长度为M的子串中被选出的元素不超过K(K,M<=100) 个,并且选出的元素之和最大。 Input 第1行三个数N,m,k。 接下来N行,每行一个字符串表示Ci。 Output 最大和。 Sam 阅读全文
posted @ 2018-04-18 16:29 蒟蒻JHY 阅读(271) 评论(0) 推荐(0)
摘要:5298: [Cqoi2018]交错序列 Description 我们称一个仅由0、1构成的序列为"交错序列",当且仅当序列中没有相邻的1(可以有相邻的0)。例如,000,001 ,101,都是交错序列,而110则不是。对于一个长度为n的交错序列,统计其中0和1出现的次数,分别记为x和y。 给定参数 阅读全文
posted @ 2018-04-18 14:43 蒟蒻JHY 阅读(827) 评论(0) 推荐(0)
摘要:前缀异或和是可以讨论的,非常naive,然后这就是个水题了23333 阅读全文
posted @ 2018-04-18 11:01 蒟蒻JHY 阅读(176) 评论(0) 推荐(0)
摘要:显然是个二分图,直接求最大独立就行了。 阅读全文
posted @ 2018-04-18 10:15 蒟蒻JHY 阅读(175) 评论(0) 推荐(0)
摘要:Discription Hint: 对于 100% 的数据, n<=10^6。 阅读全文
posted @ 2018-04-17 21:26 蒟蒻JHY 阅读(233) 评论(0) 推荐(0)
摘要:Discription 阅读全文
posted @ 2018-04-17 21:20 蒟蒻JHY 阅读(155) 评论(0) 推荐(0)
摘要:Discription Everyone knows what the Fibonacci sequence is. This sequence can be defined by the recurrence relation: We'll define a new number sequence 阅读全文
posted @ 2018-04-17 20:15 蒟蒻JHY 阅读(258) 评论(0) 推荐(0)
摘要:发现一个区间[L,R]代表的2进制数是3的倍数,当且仅当从L开始的后缀二进制值 - 从R+1开始的后缀二进制值 是 3 的倍数 (具体证明因为太简单而被屏蔽)。 于是我们就可以在每个点维护从它开始的后缀二进制数的值,因为在%3同余系下只有3个数,所以我们可以很容易的用线段树进行区间维护,然后答案就是 阅读全文
posted @ 2018-04-17 17:19 蒟蒻JHY 阅读(370) 评论(0) 推荐(0)
摘要:显然答案具有单调性,可以二分。问题是 我们二分出一个 堆数,该怎么判定能否达到这个堆数呢? 我们可以很简单的用调整法证明,最底下的一层的冰淇淋肯定是最小的那些,往上叠加的话我们再贪心的让较少的放在较小的上面,答案总不会更劣。 于是就口胡完了2333 阅读全文
posted @ 2018-04-17 17:07 蒟蒻JHY 阅读(315) 评论(0) 推荐(0)
摘要:Discription Given a simple graph, output the number of simple cycles in it. A simple cycle is a cycle with no repeated vertices or edges. Input The fi 阅读全文
posted @ 2018-04-17 15:50 蒟蒻JHY 阅读(591) 评论(0) 推荐(0)
摘要:Problem Statement You are given a tree with N vertices. The vertices are numbered 0 through N−1, and the edges are numbered 1 through N−1. Edge i conn 阅读全文
posted @ 2018-04-17 08:55 蒟蒻JHY 阅读(439) 评论(0) 推荐(0)
摘要:首先与等于零 相当于要求 每一位 在选的数里都有至少一个在该位为 0。直接求这个不太好求,我们考虑容斥: 设F(s) 为 不合法的位的集合至少是s的方案数 ,某一位不合法当且仅当选的数在这一位都是1。 于是答案就是 Σ F(s) * (-1)^|s| ,因为在左边这个式子中,只有所有位都合法的选数集 阅读全文
posted @ 2018-04-16 21:45 蒟蒻JHY 阅读(232) 评论(0) 推荐(0)
摘要:我们知道一个数S会对所有它的子集S'产生1的贡献,但是我们直接枚举子集是 3^(log2 1000000)的,会炸掉;如果直接把每个有1的位变成0往下推也会凉掉,因为这样会有很多重复的。 但是我们发现 第二种方法其实算的是 有序的路径方案数, 我们尝试把它变成无序的,贡献就正好是1了。 具体的说,我 阅读全文
posted @ 2018-04-16 21:28 蒟蒻JHY 阅读(156) 评论(0) 推荐(0)
摘要:Discription John likes playing the game Permutation Jumping. First he writes down a permutation A of the first n numbers. Then, he chooses any cell to 阅读全文
posted @ 2018-04-16 20:04 蒟蒻JHY 阅读(242) 评论(0) 推荐(0)
摘要:设f[i]为i这个数的划分方案,则: 1.i是奇数的时候,最前面只能放1,所以f[i] = f[i-1] 2.i是偶数的时候,最前面可以放1也可以不放1,而不放1的时候数列都是偶数所以 f[i] = f[i-1] + f[i>>1]. 阅读全文
posted @ 2018-04-16 18:19 蒟蒻JHY 阅读(265) 评论(0) 推荐(0)
摘要:Discription 对于 100% 的数据, N<=50. solution: 发现N比较小,所以我们可以花O(N^2)的代价枚举两颗树的联通块的LCA分别是哪个点,然后现在问题就变成了:选一个点必须要选它在两个树上的祖先,问如何选点可以使收益最大。 这是一个裸的 最大权闭合子图 问题, 节点连 阅读全文
posted @ 2018-04-16 16:36 蒟蒻JHY 阅读(292) 评论(0) 推荐(0)
摘要:Discription Mahmoud and Ehab live in a country with n cities numbered from 1 to n and connected by n - 1 undirected roads. It's guaranteed that you ca 阅读全文
posted @ 2018-04-16 09:41 蒟蒻JHY 阅读(259) 评论(0) 推荐(0)
摘要:Read problems statements in Mandarin Chinese and Russian. Little Elephant from Zoo of Lviv likes to watch movies. There are N different movies (number 阅读全文
posted @ 2018-04-16 08:49 蒟蒻JHY 阅读(408) 评论(0) 推荐(0)
摘要:Read problems statements in Mandarin Chinese and Russian. A meteor fell on Andrew's house. That's why he decided to build a new home and chose a site 阅读全文
posted @ 2018-04-15 19:49 蒟蒻JHY 阅读(204) 评论(0) 推荐(0)
摘要:Discription Mahmoud has an array a consisting of n integers. He asked Ehab to find another arrayb of the same length such that: b is lexicographically 阅读全文
posted @ 2018-04-14 21:31 蒟蒻JHY 阅读(331) 评论(0) 推荐(0)
摘要:Discription Ehab has an array a of n integers. He likes the bitwise-xor operation and he likes to bother Mahmoud so he came up with a problem. He gave 阅读全文
posted @ 2018-04-14 20:39 蒟蒻JHY 阅读(452) 评论(0) 推荐(0)
摘要:Discription Ehab is interested in the bitwise-xor operation and the special graphs. Mahmoud gave him a problem that combines both. He has a complete g 阅读全文
posted @ 2018-04-14 20:20 蒟蒻JHY 阅读(844) 评论(4) 推荐(1)
摘要:Discription Sigma function is an interesting function in Number Theory. It is denoted by the Greek letter Sigma (σ). This function actually denotes th 阅读全文
posted @ 2018-04-13 21:14 蒟蒻JHY 阅读(256) 评论(0) 推荐(0)
摘要:设 g(x) = f(x) * x ,多项式 A = Σ g(i) * x^i , 多项式 B = Σ f(i) * x^i。 首先,g(x) = g(x-1) + g(x-2) + f(x-1) + 2f(x-2),所以我们可以得到: A = x * A + x^2 * A + x * B + 2 阅读全文
posted @ 2018-04-13 18:17 蒟蒻JHY 阅读(266) 评论(0) 推荐(0)
摘要:题目描述 对于一个给定的序列a1, …, an,我们对它进行一个操作reduce(i),该操作将数列中的元素ai和ai+1用一个元素max(ai,ai+1)替代,这样得到一个比原来序列短的新序列。这一操作的代价是max(ai,ai+1)。进行n-1次该操作后,可以得到一个长度为1的序列。 我们的任务 阅读全文
posted @ 2018-04-12 20:57 蒟蒻JHY 阅读(291) 评论(0) 推荐(0)
摘要:Discription 给出一个 N 行 M 列的矩阵A, 保证满足以下性质: 1.M>N。 2.矩阵中每个数都是 [0,N] 中的自然数。 3.每行中, [1,N] 中每个自然数都恰好出现一次。这意味着每行中 0 恰好出现 M−N 次。 4.每列中,[1,N] 中每个自然数至多出现一次。 现在我们 阅读全文
posted @ 2018-04-12 19:38 蒟蒻JHY 阅读(242) 评论(0) 推荐(0)
摘要:题目描述 摩尔瓦多的移动电话公司摩基亚(Mokia)设计出了一种新的用户定位系统。和其他的定位系统一样,它能够迅速回答任何形如“用户C的位置在哪?”的问题,精确到毫米。但其真正高科技之处在于,它能够回答形如“给定区域内有多少名用户?”的问题。 在定位系统中,世界被认为是一个W×W的正方形区域,由1× 阅读全文
posted @ 2018-04-12 19:04 蒟蒻JHY 阅读(196) 评论(0) 推荐(0)
摘要:Discription Problem statement is simple. Given A and B you need to calculate S(A,B) . Here, f(n)=n, if n is square free otherwise 0. Also f(1)=1. Inpu 阅读全文
posted @ 2018-04-12 16:45 蒟蒻JHY 阅读(238) 评论(0) 推荐(0)
摘要:Discription 有一棵以1为根的树,他有n个结点,用1到n编号。第i号点有一个值vi。 现在可以对树进行如下操作: 步骤1:在树中选一个连通块,这个连通块必须包含1这个结点。 步骤2:然后对这个连通块中所有结点的值加1或者减1。 问最少要经过几次操作才能把树中所有结点都变成0。 注意:步骤1 阅读全文
posted @ 2018-04-12 14:37 蒟蒻JHY 阅读(430) 评论(0) 推荐(0)
摘要:Discription Ilya got tired of sports programming, left university and got a job in the subway. He was given the task to determine the escalator load f 阅读全文
posted @ 2018-04-12 10:23 蒟蒻JHY 阅读(361) 评论(0) 推荐(0)
摘要:Discription Ostap already settled down in Rio de Janiero suburb and started to grow a tree in his garden. Recall that a tree is a connected undirected 阅读全文
posted @ 2018-04-12 09:28 蒟蒻JHY 阅读(353) 评论(0) 推荐(0)
摘要:题目描述 PDF 输入输出格式 输入格式: 输出格式: 输入输出样例 输入样例#1: 3 2 1 2 2 0 2 2 0 1 4 1 1 1 0 1 3 1 2 0 输出样例#1: Case 1: 3 Case 2: 2 子集dp经典题,, #include<bits/stdc++.h> #defi 阅读全文
posted @ 2018-04-11 21:11 蒟蒻JHY 阅读(181) 评论(0) 推荐(0)
摘要:题目描述 PDF 输入输出格式 输入格式: 输出格式: 输入输出样例 输入样例#1: 3 10 5 20 1 1 1 2 2 0 输出样例#1: 23.348371% 0.000000% 100.000000% 发现求的是一个和 反比例函数有关的积分,吓得我赶紧去学习了一波积分(之前一直不会还这么淡 阅读全文
posted @ 2018-04-11 20:50 蒟蒻JHY 阅读(272) 评论(0) 推荐(0)
摘要:Discription N ladies attend the ball in the King's palace. Every lady can be described with three values: beauty, intellect and richness. King's Maste 阅读全文
posted @ 2018-04-11 16:17 蒟蒻JHY 阅读(347) 评论(0) 推荐(0)
摘要:4766: 文艺计算姬 Description "奋战三星期,造台计算机"。小W响应号召,花了三星期造了台文艺计算姬。文艺计算姬比普通计算机有更多的艺 术细胞。普通计算机能计算一个带标号完全图的生成树个数,而文艺计算姬能计算一个带标号完全二分图的生成树 个数。更具体地,给定一个一边点数为n,另一边点 阅读全文
posted @ 2018-04-11 15:35 蒟蒻JHY 阅读(341) 评论(0) 推荐(0)
摘要:Discription It's the turn of the year, so Bash wants to send presents to his friends. There are n cities in the Himalayan region and they are connecte 阅读全文
posted @ 2018-04-11 13:58 蒟蒻JHY 阅读(364) 评论(0) 推荐(0)
摘要:题目描述 给n个人安排座位,先给每个人一个1~n的编号,设第i个人的编号为ai(不同人的编号可以相同),接着从第一个人开始,大家依次入座,第i个人来了以后尝试坐到ai,如果ai被占据了,就尝试ai+1,ai+1也被占据了的话就尝试ai+2,……,如果一直尝试到第n个都不行,该安排方案就不合法。然而有 阅读全文
posted @ 2018-04-11 10:05 蒟蒻JHY 阅读(293) 评论(0) 推荐(0)
摘要:Problem Statement You are given N integers A1, A2, ..., AN. Consider the sums of all non-empty subsequences of A. There are 2N−1 such sums, an odd num 阅读全文
posted @ 2018-04-10 21:03 蒟蒻JHY 阅读(292) 评论(0) 推荐(0)
摘要:题目描述 有N个工作,M种机器,每种机器你可以租或者买过来. 每个工作包括若干道工序,每道工序需要某种机器来完成,你可以通过购买或租用机器来完成。 现在给出这些参数,求最大利润 输入输出格式 输入格式: 第一行给出 N,M(1<=N<=1200,1<=M<=1200) 下面将有N组数据。 每组数据第 阅读全文
posted @ 2018-04-10 20:37 蒟蒻JHY 阅读(243) 评论(0) 推荐(0)
摘要:Problem Statement Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeati 阅读全文
posted @ 2018-04-10 19:02 蒟蒻JHY 阅读(255) 评论(0) 推荐(0)
摘要:2212: [Poi2011]Tree Rotations Description Byteasar the gardener is growing a rare tree called Rotatus Informatikus. It has some interesting features: 阅读全文
posted @ 2018-04-10 11:05 蒟蒻JHY 阅读(450) 评论(0) 推荐(0)
摘要:5216: [Lydsy2017省队十连测]公路建设 Description 在Byteland一共有n个城市,编号依次为1到n,它们之间计划修建m条双向道路,其中修建第i条道路的费用为ci。B yteasar作为Byteland公路建设项目的总工程师,他决定选定一个区间[l,r],仅使用编号在该区 阅读全文
posted @ 2018-04-09 19:51 蒟蒻JHY 阅读(254) 评论(0) 推荐(0)
摘要:5215: [Lydsy2017省队十连测]商店购物 Description 在 Byteland一共开着 n家商店,编号依次为 1到 n,其中编号为1到 m的商店有日消费量上限,第 i家商店的日消 费量上限为wi。Byteasar每次购物的过程是这样的:依次经过每家商店,然后购买非负整数价格的商品 阅读全文
posted @ 2018-04-09 19:04 蒟蒻JHY 阅读(575) 评论(0) 推荐(0)
摘要:Discription One day Polycarp decided to rewatch his absolute favourite episode of well-known TV series "Tufurama". He was pretty surprised when he got 阅读全文
posted @ 2018-04-09 18:29 蒟蒻JHY 阅读(421) 评论(0) 推荐(0)
摘要:题目背景 We could have had it all. . . . . . 我们本该,拥有一切 Counting on a tree. . . . . . 何至于此,数数树上 Counting on a Tree(CoaT)即是本题的英文名称。 题目描述 Access Globe 最近正在玩一 阅读全文
posted @ 2018-04-09 17:04 蒟蒻JHY 阅读(919) 评论(0) 推荐(1)
摘要:题目描述 You are given nn points on Cartesian plane. Every point is a lattice point (i. e. both of its coordinates are integers), and all points are disti 阅读全文
posted @ 2018-04-09 10:28 蒟蒻JHY 阅读(548) 评论(0) 推荐(0)
摘要:题目背景 一年一度的综艺节目《中国新代码》又开始了。Zayid 从小就梦想成为一名程序员,他觉得这是一个展示自己的舞台,于是他毫不犹豫地报名了。 题目描述 轻车熟路的Zayid 顺利地通过了海选,接下来的环节是导师盲选,这一阶段的规则是这样的: 总共n 名参赛选手(编号从1 至n)每人写出一份代码并 阅读全文
posted @ 2018-04-08 20:23 蒟蒻JHY 阅读(359) 评论(0) 推荐(0)
摘要:题目描述 菲菲和牛牛在一块n 行m 列的棋盘上下棋,菲菲执黑棋先手,牛牛执白棋后手。 棋局开始时,棋盘上没有任何棋子,两人轮流在格子上落子,直到填满棋盘时结束。 落子的规则是:一个格子可以落子当且仅当这个格子内没有棋子且这个格子的左侧及上方的所有格子内都有棋子。 棋盘的每个格子上,都写有两个非负整数 阅读全文
posted @ 2018-04-08 11:14 蒟蒻JHY 阅读(397) 评论(0) 推荐(0)
摘要:题目背景 在北纬 91° ,有一个神奇的国度,叫做企鹅国。这里的企鹅也有自己发达的文明,称为企鹅文明。因为企鹅只有黑白两种颜色,所以他们的数学也是以二进制为基础发展的。 比如早在 1110100111101001 年前,他们就有了异或这样一个数学概念。如果你不知道异或是什么,请出门过墙左转到这里。 阅读全文
posted @ 2018-04-06 21:18 蒟蒻JHY 阅读(539) 评论(0) 推荐(0)
摘要:前言: 作为一个SD的蒟蒻,我非常确信我就是来划水的2333,希望我能进二轮吧hhhh DAY0: 玩了一上午2k之后,又去打了一下午球,,,晚上和几个很好的朋友聊了聊天,收到了满满的鼓励qwq。 这一天就当调整心情了,毕竟考试的时候想太多就真的gg了。 DAY1: 早上来的有点晚,,,都开始入场了 阅读全文
posted @ 2018-04-06 18:48 蒟蒻JHY 阅读(1663) 评论(4) 推荐(0)
摘要:题目描述 随着iPig在P++语言上的造诣日益提升,他形成了自己一套完整的代码库。猪王国想参加POI的童鞋们都争先恐后问iPig索要代码库。iPig不想把代码库给所有想要的小猪,只想给其中的一部分既关系好又肯出钱的小猪,于是他决定举行了一个超大型拍卖会。 在拍卖会上,所有的N头小猪将会按照和iPig 阅读全文
posted @ 2018-04-02 21:58 蒟蒻JHY 阅读(344) 评论(0) 推荐(0)
摘要:题目背景 本题开O2优化,请注意常数 题目描述 博艾市除了有海底高铁连接中国大陆、台湾与日本,市区里也有很成熟的轨道交通系统。我们可以认为博艾地铁系统是一个无向连通图。博艾有N个地铁站,同时有M小段地铁连接两个不同的站。 地铁计价方式很简单。从A站到B站,每经过一小段铁路(连接直接相邻的两个点的一条 阅读全文
posted @ 2018-04-01 18:08 蒟蒻JHY 阅读(238) 评论(0) 推荐(0)
摘要:题目描述 English VietnameseGiven a sequence of n numbers a _{1}1​ , a _{2}2​ , ..., a _{n}n​ and a number of d-queries. A d-query is a pair (i, j) (1 ≤ i 阅读全文
posted @ 2018-04-01 14:44 蒟蒻JHY 阅读(354) 评论(0) 推荐(0)
摘要:让我先把微笑送给出题人 这个题最基础的一个想法:先找出一个度数和为总度数和的1/2的点集,然后判断这个点集和这个点集的补集能否形成二分图。但是就算我们把判断的复杂度看成O(1),这个算法的复杂度也是 O(T * 2^n),根本过不了。 下面我就来列举一下我这两个月做的优化: 1.把度数序列排序。 这 阅读全文
posted @ 2018-04-01 11:05 蒟蒻JHY 阅读(339) 评论(0) 推荐(0)