G. Fake News (easy) time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output As it's the first of April, Heidi is suspecting that the news she reads today are fake, and she does not want to look sil…
Description Heidi's friend Jenny is asking Heidi to deliver an important letter to one of their common friends. Since Jenny is Irish, Heidi thinks that this might be a prank. More precisely, she suspects that the message she is asked to deliver state…
Description The marmots have prepared a very easy problem for this year's HC2 – this one. It involves numbers n, k and a sequence of n positive integersa1, a2, ..., an. They also came up with a beautiful and riveting story for the problem statement.…
Description Your search for Heidi is over – you finally found her at a library, dressed up as a human. In fact, she has spent so much time there that she now runs the place! Her job is to buy books and keep them at the library so that people can borr…
http://codeforces.com/contest/1184 A1 找一对整数,使x^x+2xy+x+1=r 变换成一个分式,保证整除 #include<iostream> #include<cstdio> #include<string> #include<cstring> #include<algorithm> #include<cmath> #include<queue> #include<vector…
题意:n个数字1-m,问取k个组成的set方案数 题解:假设某个数出现k次,那么生成函数为\(1+x+...+x^k\),那么假设第i个数出现ai次,结果就是\(\sum_{i=1}^m(1+x+...+x^{a_i})\),第k项即为答案,启发式合并fft即可 组合(即set):普通生成函数.排列:指数型生成函数 //#pragma GCC optimize(2) //#pragma GCC optimize(3) //#pragma GCC optimize(4) //#pragma GCC…
题目描述 Brain Network (hard) 这个问题就是给出一个不断加边的树,保证每一次加边之后都只有一个连通块(每一次连的点都是之前出现过的),问每一次加边之后树的直径. 算法 每一次增加一条边之后,树的直径长度要么不变,要么会增加1,并且如果树的直径长度增加1了,新的直径的端点其中一个必然是新增的点,而另一个是原来直径的某个端点.关于为什么可以这样做,在Quora上有个回答解释地不错,可以参考. 实现 所以这个问题其实就是要计算树上任意两个点的距离,LCA可以很轻松地处理. 可以一次…
来自FallDream的博客,未经允许,请勿转载,谢谢, 第一次在cf上打acm...和同校大佬组队打 总共15题,比较鬼畜,最后勉强过了10题. AB一样的题目,不同数据范围,一起讲吧 你有一个背包,最多装k本书,你在第i天需要拥有一本编号ai的书,但是你可以去商店购买并加入背包. 问你至少要买多少本书?n,k<=400000 显然可以贪心,留下下一次需要的时间最早的书就行了. #include<iostream> #include<cstdio> #include<…
第一次打ACM赛制的团队赛,感觉还行: 好吧主要是切水题: 开场先挑着做五道EASY,他们分给我D题,woc什么玩意,还泊松分布,我连题都读不懂好吗! 果断弃掉了,换了M和J,然后切掉了,看N题: loser大佬切了A,G: 然后翔哥在攻H题: N题好像是费用流,(看了一会才发现的我果断被同在机房打比赛的别的队的大佬D了233) 然后写出了之后,那个大佬说费用流T了,交都没交就弃掉了: (事后才知道大概是图建的不好) loser大佬B题写的差不多了,交上去WA... 翔哥在攻H题: 我开始看K题…
Description Tonight is brain dinner night and all zombies will gather together to scarf down some delicious brains. The artful Heidi plans to crash the party, incognito, disguised as one of them. Her objective is to get away with at least one brain,…
Description Heidi has finally found the mythical Tree of Life – a legendary combinatorial structure which is said to contain a prophecy crucially needed to defeat the undead armies. On the surface, the Tree of Life is just a regular undirected tree w…
Description The zombies are gathering in their secret lair! Heidi will strike hard to destroy them once and for all. But there is a little problem... Before she can strike, she needs to know where the lair is. And the intel she has is not very good.…
Description Further research on zombie thought processes yielded interesting results. As we know from the previous problem, the nervous system of a zombie consists of n brains and m brain connectors joining some pairs of brains together. It was obser…
Description "The zombies are lurking outside. Waiting. Moaning. And when they come..." "When they come?" "I hope the Wall is high enough." Zombie attacks have hit the Wall, our line of defense in the North. Its protection is…
Description One particularly well-known fact about zombies is that they move and think terribly slowly. While we still don't know why their movements are so sluggish, the problem of laggy thinking has been recently resolved. It turns out that the rea…
Helvetic Coding Contest 2019 A2 题意:给一个长度为 n 的01序列 y.认为 k 合法当且仅当存在一个长度为 n 的01序列 x,使得 x 异或 x 循环右移 k 位的 01 串得到 y .问合法的 k 的个数. \(n \le 2*10^5\) key:找规律 考虑如何check一个 k 是否合法.那么对于所有的 i 和 i-k 在模 n 的意义下,如果 y 的第 i 位为 0 则二者必须不同,否则必须相同.这样可以用并查集判断是否合法.实际上是把相同的缩起来后…
Description 传送门(翻译就别想了,本人英语太垃圾) Solution 设ans[i]为设置i个船时能控制的最多星球数(看到这你可能因为是dp,然而我可以很负责地告诉你是假的) 首先一个显然的结论,ans[1]=1,ans[2]=树的直径长 有由B1题的提示我们也可以得到一个显然的结论,要使控制数最多,其实只有叶子节点是有用的 如果这样,那就比较容易了. 我们可以先找出树的直径,然后从直径上的点向外扩展,记录每个节点的深度(叶子节点深度为一个常数,反正只要一样又不会爆类型就无所谓) 为…
题目链接:戳我 小注:其中部分(大括号不换行的)代码是BLUESKY007神仙写的. 咕 CF1184 A1 直接枚举,以根号的时间复杂度判断即可.注意x,y都是正整数. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #define MAXN 100010 #define ll long long using na…
题目链接: Coding Contest Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others) Problem Description A coding contest will be held in this university, in a huge playground. The whole playground would be divided into N blocks,…
Problem DescriptionA coding contest will be held in this university, in a huge playground. The whole playground would be divided into N blocks, and there would be M directed paths linking these blocks. The i-th path goes from the ui-th block to the v…
题目链接:https://www.nowcoder.com/acm/contest/207/G 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5988 时间限制:C/C++ 2秒,其他语言4秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述 A coding contest will be held in this university, in a huge playground. Th…
Coding Contest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1751    Accepted Submission(s): 374 Problem Description A coding contest will be held in this university, in a huge playground. The…
Coding Contest http://acm.hdu.edu.cn/showproblem.php?pid=5988 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 5337    Accepted Submission(s): 1256 Problem Description A coding contest will be he…
Coding Contest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 5968    Accepted Submission(s): 1413 Problem Description A coding contest will be held in this university, in a huge playground. Th…
Problem Description A coding contest will be held in this university, in a huge playground. The whole playground would be divided into N blocks, and there would be M directed paths linking these blocks. The i-th path goes from the u_i-th block to the…
NAIPC 2017 Yin and Yang Stones 75.39% 1000ms 262144K   A mysterious circular arrangement of black stones and white stones has appeared. Ming has been tasked with balancing the stones so that only one black and one white stone remain. Ming has two ope…
1065 Beihang Collegiate Pronunciation Contest 2017 思路 在字符串中不断做匹配 找到一个匹配就输出 时间复杂度\(O(n)\) ps.模式串是定长的,因此看做常数 代码 #include<string> #include<iostream> using namespace std; int main() { int n; cin >> n; string ch; cin >> ch; for (auto i…
ACM International Collegiate Programming Contest, Tishreen Collegiate Programming Contest (2017)- K. Poor Ramzi -dp+记忆化搜索 [Problem Description] 给你一串\(01\)字符串,将其划分,使得划分后,分别求出每组\(01\)之和后是回文的,求划分的方案数, [Solution] 定义\(dp[l][r]\)表示,区间\([l,r]\)中满足条件的方案数是多少.…
A. Numbers Joke time limit per test:2 seconds memory limit per test:64 megabytes input:standard input output:standard output   Input The input contains a single integer a (1 ≤ a ≤ 30). Output Output a single integer. Example Input 3 Output 27 题目链接:ht…
题目: Go Northwest! is a game usually played in the park main hall when occasional rainy weather discourages the visitors from enjoying outdoor attractions. The game is played by a pair of players and it is based entirely on luck, the players can hardl…