魔法宝石 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 254 Accepted Submission(s): 85 Problem Description 小s想要创造n种魔法宝石.小s可以用ai的魔力值创造一棵第i种魔法宝石,或是使用两个宝石合成另一种宝石(不消耗魔力值).请你帮小s算出合成某种宝石的所需的最小花费. Input 第一行…
One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call between A and B, we say that A and B is related. The weight of a relation is defined to be the total time length of all the phone calls made b…
import java.util.*; public class Main{ static int MAX_VERTEXNUM = 100; static int [] visited = new int[MAX_VERTEXNUM]; public static void main(String [] args){ Graph G = new Graph(); creatGraph(G); output(G); for(int i=0;i<G.vertex_num;i++) visited[i…
How far away [题目链接]How far away [题目类型]dfs+邻接表 &题意: 题目大意:一个村子里有n个房子,这n个房子用n-1条路连接起来,接下了有m次询问,每次询问两个房子a,b之间的距离是多少. &题解: 我以为是LCA的题,但dfs居然也能过,感觉是数据有点弱,(时间复杂度是4000x200x10,想了想10组又不能全是200,所以应该勉强可以)但学到了邻接表的数组形式,用数组表示链表,很厉害的样子,感觉和前向星好相似啊 &代码: #include…
Pet Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1809 Accepted Submission(s): 874 Problem Description One day, Lin Ji wake up in the morning and found that his pethamster escaped. He sear…
邻接矩阵实现如下: /* 主题:用邻接矩阵实现 DFS(递归) 与 BFS(非递归) 作者:Laugh 语言:C++ ******************************************* 样例输出如下: 请选择图的类型(a - 无向图, b - 有向图):a 请输入总顶点数,总边数:8 9 请依次输入点的信息:a b c d e f g h 输入一条边依附的顶点及权值 (eg: a b 6): a b 1 a c 1 b d 1 b e 1 d h 1 e h 1 c f 1…
ROADS Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10777 Accepted: 3961 Description N cities named with numbers 1 ... N are connected with one-way roads. Each road has two parameters associated with it : the road length and the toll…