随笔分类 - DP
摘要:N个不同的正整数,找出由这些数组成的最长的等差数列。 例如:1 3 5 6 8 9 10 12 13 14 等差子数列包括(仅包括两项的不列举) 1 3 5 1 5 9 13 3 6 9 12 3 8 13 5 9 13 例如:1 3 5 6 8 9 10 12 13 14 等差子数列包括(仅包括两
阅读全文
摘要:For the given sequence with n different elements find the number of increasing subsequences with k + 1 elements. It is guaranteed that the answer is n
阅读全文
摘要:You are given a directed graph with n nodes and m edges, with all edges having a certain weight. There might be multiple edges and self loops, and the
阅读全文
摘要:Red John has committed another murder. But this time, he doesn't leave a red smiley behind. What he leaves behind is a puzzle for Patrick Jane to solv
阅读全文
摘要:"Holiday is coming, holiday is coming, hurray hurray!" shouts Joke in the last day of his college. On this holiday, Joke plans to go to his grandmothe
阅读全文
摘要:Jonathan Irvin Gunawan is a very handsome living person. You have to admit it to live in this world. To become more handsome, Jonathan the Handsome ha
阅读全文
摘要:There is a robot on the 2D plane. Robot initially standing on the position (0, 0). Robot can make a 4 different moves: After moving N times Robot gets
阅读全文
摘要:Eagle (AKA Mohamed Ahmed) lives in a city consists of n intersections connected by n-1 roads, in a way that can go from any intersection to any other
阅读全文
摘要:ultmaster 男神和小迷妹们玩起了捉迷藏的游戏。 小迷妹们都希望自己被 ultmaster 男神发现,因此她们都把自己位置告诉了 ultmaster 男神,因此 ultmaster 男神知道了自己去找每个小迷妹所要花的时间。 已知发现第 i 小迷妹得到的分数为 ai⋅tr(tr 为游戏剩余时间
阅读全文
摘要:Rainbow 6 is a very popular game in colleges. There are 2 teams, each having some members and the 2 teams play some matches against each other. The te
阅读全文
摘要:ps:感觉比昨天晚上的华师题目质量高一点,至少emmm,题面没有那么多bug。 下面忽略了水题,只给出我觉得有价值的几个题目的题解和代码: 【C:神山神石】: 题意: 每一天,Wells可以喂神山一个神石,使得神山的高度变为原高度乘上神石的能力值,或者使得所有的神石能力值+1。第 0 天时,所有神石
阅读全文
摘要:描述 一日,崔克茜来到小马镇表演魔法。 其中有一个节目是开锁咒:舞台上有 n 个盒子,每个盒子中有一把钥匙,对于每个盒子而言有且仅有一把钥匙能打开它。初始时,崔克茜将会随机地选择 k 个盒子用魔法将它们打开。崔克茜想知道最后所有盒子都被打开的概率,你能帮助她回答这个问题吗? 输入 第一行一个整数 T
阅读全文
摘要:Times:5000ms; Memory limit:262144 kB 给定字符串S(|S|<=5000),下标由1开始。然后Q个问题(Q<=1e6),对于每个问题,给定L,R,回答区间[L,R]里有多少个回文串。 请想出两种或者以上的方法。 分界线 方法1:区间DP。 容斥一下,dp[i][j]
阅读全文
摘要:Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game
阅读全文
摘要:描述 给定N个正整数A1, A2, ... AN。 小Hi希望你能从中选出M个整数,使得它们的乘积末尾有最多的0。 输入 第一行包含两个个整数N和M。 第二行包含N个整数A1, A2, ... AN。 对于30%的数据,1 ≤ M ≤ N ≤ 12 对于100%的数据,1 ≤ M ≤ N ≤ 100
阅读全文
摘要:Median Sum 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 number. Le
阅读全文
摘要:Z国的骑士团是一个很有势力的组织,帮会中汇聚了来自各地的精英。他们劫富济贫,惩恶扬善,受到社会各界的赞扬。最近发生了一件可怕的事情,邪恶的Y国发动了一场针对Z国的侵略战争。战火绵延五百里,在和平环境中安逸了数百年的Z国又怎能抵挡的住Y国的军队。于是人们把所有的希望都寄托在了骑士团的身上,就像期待有一
阅读全文
摘要:以前KMP和后缀系列(主要是后缀数组,后缀自动机),都刷了一定数量的题,但是对于AC自动机,却有些冷落,罪过。 但是我感觉,在蓝桥杯比赛中AC自动机出现的概率比后缀系列大,简单的会考匹配,稍难一点会考AC自动机+DP ,AC自动机+矩阵乘法,或者套其他算法blabla... Trie图是AC自动机的
阅读全文
摘要:描述 某个夜晚,Bob将他弹奏的钢琴曲录下来发给Jack,Jack感动之余决定用吉他为他伴奏。 我们可以用一个整数表示一个音符的音高,并可认为Bob弹奏的曲子是由3N个整数构成的一个序列。其中每个整数的取值范围是[-200, 200]。 Jack共弹奏 N 个和弦,每个和弦由三个音符组成。Jack可
阅读全文
摘要:大概是需要前缀和优化DP,和记录左右范围。 还有一道题,没有下手,等做完了,再来总结。 1,数组分拆: 给定数组,问有多少种拆分法,使得每一段和不为0。 (1e5) (用map优化DP) #include<map> #include<cstdio> #include<cstdlib> #includ
阅读全文

浙公网安备 33010602011771号