
HDU
邵光亮
要为自己喜欢的事情不留余力
展开
-
2020HDU多校第二场
A - Total Eclipse题意:code:F - The Oculus题意:code:J - Lead of Wisdom题意:code:L - String Distance题意:code:原创 2020-10-24 21:39:51 · 144159 阅读 · 0 评论 -
2019HDU多校第七场
J Just Repeat题意:两个人玩游戏,每回合一方可以放另一方没有放过的卡,谁最后没卡放谁输每个人优先出的牌的颜色肯定是场上没出过的, 对方也持有的, 并且两个人手中持有数量最多的牌.对方持有的越多意味着可以封掉更多的牌, 而自己手里的越多意味着可以防止自己更多的牌被封掉.因此, 对所有两个人手里都持有的颜色的牌数进行统计, 从大到小依次分配给第一, 第二个玩家.如果此时第一个玩家手里的牌数 > 第二个玩家, 则第一个玩家胜利, 否则第二个玩家胜利.到此为止, 问题转换成另一个问题, 就是原创 2020-08-21 11:10:35 · 140826 阅读 · 0 评论 -
2019HDU多校第二场
E Everything Is Generated In Equal Probability题意;给出一个 nnn 然后在 1−n1-n1−n 中选择一个数 xxx,然后在 1−x1-x1−x 中选择 xxx 个互不相同的数组成一个全排列,然后统计他的逆序数的个数和他子序列的逆序数的个数,求最后逆序数的期望值。对于一个长度为 nnn 的随机排列,总共有 cn2c_n^2cn2 的数对,因为随机的缘故,所以期望的逆序对数就是cn22\frac{c_n^2}{2}2cn2 。然后其子序列也是同样的原创 2020-07-18 10:07:17 · 148237 阅读 · 0 评论 -
2019HDU多校第一场
D Vacation题意;给出 n+1n+1n+1 辆车的车长 lil_ili、车头到终点的距离 sis_isi、速度 viv_ivi,问离第一辆车到终点的时间是多少。如果有前车速度慢的情况,那么肯定是按照前车的速度行驶,枚举前车速度即可。AC代码:const int N = 5e5 + 50;int s[N], v[N], l[N];double ans;int main(){ int n; while (~sd(n)) { rep(i, 0, n) sd(l[i]原创 2020-07-17 09:22:53 · 147204 阅读 · 0 评论 -
POJ 2387 Til the Cows Come Home(dijkstra)
Til the Cows Come HomeBessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep...原创 2020-03-17 16:51:36 · 139596 阅读 · 0 评论 -
UCF Local Programming Contest 2012 C. Clean Up the Powers that Be(记住这个错误)
题意:题意很简单,写起来也不难,唯一需要注意的就是格式了。我是个憨憨,因为我数组开到 NNN,然后就到遍历直接写的到 NNN,所以就数组越界一直 wawawa,重写完过了找了好久才发现,以后这种低级错误绝不再犯。AC代码:const int N = 10009;int n, m;int res, ans, tmp;int x, y;int cnt[N];int getlen...原创 2020-03-04 18:41:23 · 141626 阅读 · 1 评论 -
2020 CCPC Wannafly Winter Camp Day7 L 图(状压)
题意:给定一个 nnn 个点 mmm 条边的有向图。每条边以 (x,y)\left(x,y\right)(x,y) 的形式给出,无重边无自环。开始时每个点都黑点或白点,初始状态为第 000 轮。之后每一轮,每个点的颜色都可能改变,规则如下:若在上一轮,有奇数个黑点连向当前点,则当前点在该轮为黑点。若在上一轮,有偶数个黑点连向当前点,则当前点在该轮为白点。给定 qqq 次询问,每次询问以...原创 2020-03-03 15:30:34 · 140906 阅读 · 0 评论 -
2020 CCPC Wannafly Winter Camp Day6 K 最大权值排列(构造)
题意:构造出一个长度为 nnn 的序列使得这个序列的全部区间和最小。其实光看样例也可以猜到。可以这样考虑:一个序列 AAA 中越靠近中间的数对 f(A)f\left(A\right)f(A) 的贡献越大。为了使 f(P)f\left(P\right)f(P) 最大,需要让越大的数尽可能靠近中间,亦即越小的数越靠近两侧。将奇数和偶数分开,分别从两侧往中间从小到大放置即可。AC代码:...原创 2020-02-28 16:10:21 · 139659 阅读 · 0 评论 -
2020 CCPC Wannafly Winter Camp Day6 N 合并!
题目描述有 n{n}n 个石子堆,第 i{i}i 个在一开始有 aia_iai个石子。每次你可以选择两堆相邻的石子 ai,ai+1a_i,a_{i+1}ai,ai+1 合并,合并完之后得到的收益为 aiai+1a_ia_{i+1}aiai+1,两堆石子变成一堆有 ai+aja_i+a_jai+aj 个石子的堆。你会一直进行合并操作,直到只剩下一堆石子为止。求你能得到的最大的收...原创 2020-02-28 14:53:37 · 139605 阅读 · 0 评论 -
2020 CCPC Wannafly Winter Camp Day5 E Matching Problem(枚举)
题意:称序列 KaTeX parse error: Expected group after '_' at position 2: x_̲ 和序列 yyy 匹配,当且仅当 p=qp=qp=q 且对 ∀i,j∈[1,p], xi=xj⇔yi=yj\forall i,j\in\left[1,p\right],\ x_i=x_j\Leftrightarrow y_i=y_j∀i,j∈[1,...原创 2020-02-26 16:52:28 · 139246 阅读 · 0 评论 -
2020 CCPC Wannafly Winter Camp Day5 A Alternative Accounts(二进制)
题意:有 nnn个账号,其中某些账号参加了比赛。比赛共 kkk 场,每场比赛都以整数 mmm 和一个长度为 mmm 的序列 xxx 描述。序列 xxx 的第 iii 个 xxx 表示参加了这场比赛的 mmm 个账号。参赛者不能使用不同账号参加同一场比赛。一个账号只能属于一个参赛者。在不违背前两条规则的前提下参加不同比赛的不同账号可属于同一个参赛者。求最少有多少人参加了比赛。注意到...原创 2020-02-26 16:24:47 · 139167 阅读 · 0 评论 -
2020 CCPC-Wannafly Winter Camp Day3 A 黑色气球
题目描述小D面前有 n{n}n 个黑色的气球。假设第 i{i}i 个黑色气球的高度是一个正整数 hih_ihi,现在小D知道了任意两个不同气球的高度之和,你能帮小D还原出每个黑色气球的具体高度嘛?输入描述:第一行一个整数 n{n}n 接下来 n{n}n 行,每行 n{n}n 个整数,其中第 iii 行第 jjj 个整数表示第 i{i}i 个气球和第 j{j}j 个气球的高度之和。(当 i...原创 2020-02-23 11:54:22 · 228 阅读 · 0 评论 -
CTU Open Contest 2019 B Beer Bill(模拟)
题意:计算字符串的价格。 给多个字符串, 每个串占一行。 字符串分两种, 一种字符串名为 RakedLineRakedLineRakedLine 只含有 CCC 个 ’∣’’|’’∣’ 字符,这种字符串的价格定义为 42∗C42*C42∗C。 另一种字符串名为 PricedLinePriced LinePricedLine, 格式是以数字 pricepriceprice 开头、 中间用两个...原创 2020-02-22 18:02:36 · 389 阅读 · 0 评论 -
2020 CCPC Wannafly Winter Camp Day2 E 阔力梯的树
题意:给定一棵 NNN个结点的有根树,结点编号为 1∼N1\sim N1∼N ,根结点编号为 111 .给定一个长度为 N−1N-1N−1 的序列 ppp ,第 iii 项 pip_ipi为结点 i+1i+1i+1 的父结点编号。若树上以某个结点为根的子树的大小为 kkk ,子树的结点编号排序后第 iii 个编号为 aia_iai定义该结点的价值为 ∑i=1k−1(ai−ai+1)2...原创 2020-02-22 16:42:54 · 318 阅读 · 1 评论 -
2019 icpc 上海 D Spanning Tree Removal (构造)
题意:给定一个 nnn 个点的完全图。从图中删去与 nnn 个点形成一棵树 n−1n-1n−1 条边为删去一棵树。求最多删去多少棵树,并输出删边的方案,每输出 n−1n-1n−1 条边表示删除一棵树。nnn 个点的完全图有 n(n−1)2\frac{n(n-1)}{2}2n(n−1) 条边,最多能删去 n2\frac{n}{2}2n 棵树。按编号从小到大逆时针排列在一个圆上。以...原创 2020-02-16 17:50:02 · 715 阅读 · 0 评论 -
HDU 4349 Xiao Ming's Hope (Lucas定理详解+推理过程)
Problem Description\quadXiao Ming likes counting numbers very much, especially he is fond of counting odd numbers. Maybe he thinks it is the best way to show he is alone without a girl friend. The da...原创 2019-12-06 22:07:34 · 307 阅读 · 0 评论 -
HDU 4471 Super Mario(主席树)
Problem Description\quadMario is world-famous plumber. His “burly” figure and amazing jumping ability reminded in our memory. Now the poor princess is in trouble again and Mario needs to save his lov...原创 2019-11-29 16:53:06 · 240 阅读 · 0 评论 -
HDU 4193 Non-negative Partial Sums(单调队列)
Description:You are given a sequence of n numbers a0,..., an-1. A cyclic shift by k positions (0<=k<=n-1) results in the following sequence: akak+1,..., an-1, a0, a1,..., ak-1. How m...原创 2019-11-06 19:29:16 · 277 阅读 · 0 评论 -
HDU6198 number number number(打表 矩阵快速幂)
题意就是找到用K个斐波那契数组不成的最小的数字是谁。先打表找规律1 4 2 12 3 33 4 88 5 232 6 609 可以发现递推规律:F[n]=4*(F[n-1]-F[n-2])+F[n-3]如果直接递推打表1e9是打不出来的,这时候就用矩阵快速幂来做。AC代码:#include<cstdio&...原创 2019-10-24 19:06:10 · 252 阅读 · 0 评论 -
HDU2825 Wireless Password (AC自动机+状态压缩DP)
Problem DescriptionLiyuan lives in a old apartment. One day, he suddenly found that there was a wireless network in the building. Liyuan did not know the password of the network, but he got some im...原创 2019-10-14 20:23:54 · 327 阅读 · 0 评论 -
HDU2457DNA repair(AC自动机+DP)
Problem DescriptionBiologists finally invent techniques of repairing DNA that contains segments causing kinds of inherited diseases. For the sake of simplicity, a DNA is represented as a string con...原创 2019-10-13 15:28:32 · 200 阅读 · 0 评论 -
HDU3065 病毒侵袭持续中(AC自动机)
Problem Description小t非常感谢大家帮忙解决了他的上一个问题。然而病毒侵袭持续中。在小t的不懈努力下,他发现了网路中的“万恶之源”。这是一个庞大的病毒网站,他有着好多好多的病毒,但是这个网站包含的病毒很奇怪,这些病毒的特征码很短,而且只包含“英文大写字符”。当然小t好想好想为民除害,但是小t从来不打没有准备的战争。知己知彼,百战不殆,小t首先要做的是知道这个病毒网站特征:包...原创 2019-10-12 16:54:55 · 241 阅读 · 0 评论 -
HDU2087 剪花布条(贪心+KMP)
Problem Description一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案。对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出几块小饰条来呢?Input输入中含有一些数据,分别是成对出现的花布条和小饰条,其布条都是用可见ASCII字符表示的,可见的ASCII字符有多少个,布条的花纹也有多少种花样。花纹条和小饰条不会超过1000个字符长。如果遇...原创 2019-10-04 18:12:22 · 286 阅读 · 0 评论 -
HDU 1867 A + B for you again (KMP两次匹配)
Problem DescriptionGenerally speaking, there are a lot of problems about strings processing. Now you encounter another such problem. If you get two strings, such as “asdf” and “sdfg”, the result o...原创 2019-10-04 17:27:29 · 279 阅读 · 0 评论 -
HDU 3336(扩展KMP)
Problem DescriptionIt is well known that AekdyCoin is good at string problems as well as number theory problems. When given a string s, we can write down all the non-empty prefixes of this string....原创 2019-10-04 16:26:29 · 252 阅读 · 0 评论 -
HDU 1542 Atlantis(线段树:扫描线)
Problem Description There are several ancient Greek texts that contain descriptions of the fabled island Atlantis. Some of these texts even include maps of parts of the island. But unfortunat...原创 2019-08-29 11:24:02 · 667 阅读 · 0 评论 -
HDU3746 Cyclic Nacklace (KMP)
Problem DescriptionCC always becomes very depressed at the end of this month, he has checked his credit card yesterday, without any surprise, there are only 99.9 yuan left. he is too distressed an...原创 2019-10-05 10:21:43 · 117 阅读 · 0 评论 -
HDU 3068 最长回文 (manacher模板)
Problem Description给出一个只由小写英文字符a,b,c…y,z组成的字符串S,求S中最长回文串的长度.回文就是正反读都是一样的字符串,如aba, abba等Input输入有多组case,不超过120组,每组输入为一行小写英文字符a,b,c…y,z组成的字符串S两组case之间由空行隔开(该空行不用处理)字符串长度len <= 110000Outp...原创 2019-10-05 16:13:00 · 157 阅读 · 0 评论 -
HDU 1251 统计难题 (字典树)
Problem DescriptionIgnatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀).Input输入数据的第一部分是一张单词表,每行一个单词,单词的长度不超过10,它们代表的是老师交给Ignatius统计的单词,一个空行代表单词表的结束.第二部分是一连串的提...原创 2019-10-09 18:51:19 · 277 阅读 · 0 评论 -
HDU2027单词数(字典树)
Problem Descriptionlily的好朋友xiaoou333最近很空,他想了一件没有什么意义的事情,就是统计一篇文章里不同单词的总数。下面你的任务是帮助xiaoou333解决这个问题。Input有多组数据,每组一行,每组就是一篇小文章。每篇小文章都是由小写字母和空格组成,没有标点符号,遇到#时表示输入结束。Output每组只输出一个整数,其单独成行,该...原创 2019-10-09 21:13:29 · 193 阅读 · 0 评论 -
HDU4825 Xor Sum (01字典树)
Problem DescriptionZeus 和 Prometheus 做了一个游戏,Prometheus 给 Zeus 一个集合,集合中包含了N个正整数,随后 Prometheus 将向 Zeus 发起M次询问,每次询问中包含一个正整数 S ,之后 Zeus 需要在集合当中找出一个正整数 K ,使得 K 与 S 的异或结果最大。Prometheus 为了让 Zeus 看到人类的伟大,随即...原创 2019-10-10 17:07:02 · 254 阅读 · 0 评论 -
HDU5536 Chip Factory(01字典树)
Problem DescriptionJohn is a manager of a CPU chip factory, the factory produces lots of chips everyday. To manage large amounts of products, every processor has a serial number. More specifically,...原创 2019-10-10 17:41:14 · 212 阅读 · 0 评论 -
HDU 3534 Tree(树的直径)
Problem DescriptionIn the Data structure class of HEU, the teacher asks one problem: How to find the longest path of one tree and the number of such longest path?InputThere are several test cas...原创 2019-09-29 18:17:07 · 290 阅读 · 0 评论 -
HDU - 1540 Tunnel Warfare (线段树维护区间最大连续值)
Description:During the War of Resistance Against Japan, tunnel warfare was carried out extensively in the vast areas of north China Plain. Generally speaking, villages connected by tunnels lay in a...原创 2019-09-29 17:09:28 · 244 阅读 · 0 评论 -
2019ccpc秦皇岛F(DFS判环)
Problem DescriptionZ 国近年来一直在考虑遏制国土沙漠化的方案。在 Z 国广阔的疆域上,有着许多的沙漠。沙漠上干旱少雨,荒无人烟,仅有仙人掌能在这种魔鬼环境中生存。经过 Z 国地质探测局的调查,他们得到了沙漠的实地情况。Z 国的地质探测局是一个热爱 CCPC 的机构,他们喜欢使用图论的方式来描述看到的景色。在得到的数据中,沙漠中的每一个连通块都是一棵仙人掌;一个连通块是一棵...原创 2019-09-29 11:11:54 · 437 阅读 · 0 评论 -
HDU 4489 The King’s Ups and Downs(递推)
DescriptionThe king has guards of all different heights. Rather than line them up in increasing or decreasing height order, he wants to line them up so each guard is either shorter than the guards n...原创 2019-04-09 23:49:19 · 824 阅读 · 6 评论 -
hdu 4745 Two Rabbits(最长回文子序列DP)
DescriptionLong long ago, there lived two rabbits Tom and Jerry in the forest. On a sunny afternoon, they planned to play a game with some stones. There were n stones on the ground and they were arr...原创 2019-04-11 22:25:22 · 715 阅读 · 0 评论 -
HDU - 1978 How many ways (DP)
Description这是一个简单的生存游戏,你控制一个机器人从一个棋盘的起始点(1,1)走到棋盘的终点(n,m)。游戏的规则描述如下:1.机器人一开始在棋盘的起始点并有起始点所标有的能量。2.机器人只能向右或者向下走,并且每走一步消耗一单位能量。3.机器人不能在原地停留。4.当机器人选择了一条可行路径后,当他走到这条路径的终点时,他将只有终点所标记的能量。如上图,机器人一开始在(1...原创 2019-03-25 16:52:02 · 795 阅读 · 0 评论 -
HDU2845 Beans
DescriptionBean-eating is an interesting game, everyone owns an M*N matrix, which is filled with different qualities beans. Meantime, there is only one bean in any 1*1 grid. Now you want to eat the ...原创 2019-03-28 22:43:44 · 692 阅读 · 0 评论 -
HDU1078 FatMouse and Cheese(记忆化搜索)
DescriptionFatMouse has stored some cheese in a city. The city can be considered as a square grid of dimension n: each grid location is labelled (p,q) where 0 <= p < n and 0 <= q < n. At...原创 2019-03-29 19:07:41 · 681 阅读 · 0 评论