随笔分类 - 基本算法
摘要:描述 小 B 最近迷上了华容道,可是他总是要花很长的时间才能完成一次。于是,他想到用编程来完成华容道:给定一种局面,华容道是否根本就无法完成,如果能完成,最少需要多少时间。 小 B 玩的华容道与经典的华容道游戏略有不同,游戏规则是这样的: 在一个 n*m 棋盘上有 n*m 个格子,其中有且只有一个格
阅读全文
摘要:【问题描述】 风景迷人的小城Y 市,拥有n 个美丽的景点。由于慕名而来的游客越来越多,Y 市特意安排了一辆观光公交车,为游客提供更便捷的交通服务。观光公交车在第0 分钟出现在1号景点,随后依次前往2、3、4……n 号景点。从第i 号景点开到第i+1 号景点需要Di 分钟。 任意时刻,公交车只能往前开
阅读全文
摘要:题目大意 给出一棵n个节点的树,根是1,要在除根节点以外的点建立检查点,使得从每条根到叶子的路径上都至少存在一个检查点。检查点由军队来建立。初始军队的位置是给定的,移动军队走一条边需要花费这条边的权值的时间。现在要求一个方案,移动军队到某个最佳位置,使得总用时最少。 【数据范围】 保证军队不会驻扎在
阅读全文
摘要:题目描述 Farmer John is gathering the cows. His farm contains a network of N (1 <= N <= 100,000) fields conveniently numbered 1..N and connected by N-1 un
阅读全文
摘要:Radar Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3684 Accepted Submission(s): 1398 Problem D
阅读全文
摘要:Description 牛牛最近迷上了一种叫斗地主的扑克游戏。斗地主是一种使用黑桃、红心、梅花、方片的A到K加上大小王的共54张牌来进行的扑克牌游戏。在斗地主中,牌的大小关系根据牌的数码表示如下:3<4<5<6<7<8<9<10<J<Q<K<A<2<小王<大王,而花色并不对牌的大小产生影响。每一局游
阅读全文
摘要:Description 在xoy直角坐标平面上有n条直线L1,L2,...Ln,若在y值为正无穷大处往下看,能见到Li的某个子线段,则称Li为 可见的,否则Li为被覆盖的. 例如,对于直线: L1:y=x; L2:y=-x; L3:y=0 则L1和L2是可见的,L3是被覆盖的. 给出n条直线,表示成
阅读全文
摘要:Description G系共有n位同学,M门必修课。这N位同学的编号为0到N-1的整数,其中B神的编号为0号。这M门必修课编号为0到M- 1的整数。一位同学在必修课上可以获得的分数是1到Ui中的一个整数。如果在每门课上A获得的成绩均小于等于B获 得的成绩,则称A被B碾压。在B神的说法中,G系共有K
阅读全文
摘要:Sample Input 12 2 8 9 12 6 1 1 5 1 4 8 10 6 10 1 2 3 5 6 7 8 9 10 11 1 3 2 3 3 4 4 5 4 6 4 7 7 8 8 9 9 10 10 11 11 12 Sample Output 10 这道题考虑树形DP,dp[x]
阅读全文
摘要:Yue Fei's Battle Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others)Total Submission(s): 760 Accepted Submission(s): 26
阅读全文
摘要:Matt’s friend K.Bro is an ACMer.Yesterday, K.Bro learnt an algorithm: Bubble sort. Bubble sort will compare each pair of adjacent items and swap them
阅读全文
摘要:As we all know, Matt is an outstanding contestant in ACM-ICPC. Graph problems are his favorite.Once, he came up with a simple algorithm for finding th
阅读全文
摘要:Matt has N friends. They are playing a game together.Each of Matt’s friends has a magic number. In the game, Matt selects some (could be zero) of his
阅读全文
摘要:Matt, a famous adventurer who once defeated a pack of dire wolves alone, found a lost court. Matt finds that there are N fluorescent lights which seem
阅读全文
摘要:Matt loves letter L.A point set P is (a, b)-L if and only if there exists x, y satisfying:P = {(x, y), (x + 1, y), . . . , (x + a, y), (x, y + 1), . .
阅读全文
摘要:Dire wolves, also known as Dark wolves, are extraordinarily large and powerful wolves. Many, if not all, Dire Wolves appear to originate from Draenor.
阅读全文
摘要:Description In mathematics, the four color theorem, or the four color map theorem, states that, given any separation of a plane into contiguous region
阅读全文
摘要:这道题目,我做的时候不会哈夫曼树,自己贪心是错的都不知晓。还可以发现这里不必用优先队列,可以用两个队列,毕竟插入的数是有单调性的。
阅读全文
摘要:Sample Input 2 3 2 1 2 3 2 5 5 2 1 7 3 1 7 4 2 5 5 2 6 Sample Output 7 63 这类题目就是分类讨论,需要多做做。 1 #include <iostream> 2 #include <cstring> 3 #include <cst
阅读全文
摘要:非常难想的树形DP。
阅读全文

浙公网安备 33010602011771号