Marica is very angry with Mirko because he found a new girlfriend and she seeks revenge.Since she doesn't live in the same city, she started preparing for the long journey.We know for every road how many minutes it takes to come from one city to anot…
A. Shortest path of the king time limit per test 1 second memory limit per test 64 megabytes input standard input output standard output The king is left alone on the chessboard. In spite of this loneliness, he doesn't lose heart, because he has busi…
transaction transaction transaction Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 132768/132768 K (Java/Others) Total Submission(s): 88    Accepted Submission(s): 39 Problem Description Kelukin is a businessman. Every day, he travels around…
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1224 Free DIY Tour Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8692    Accepted Submission(s): 2804 Problem Description Weiwei is a software en…
把点编号改成1-N,加一点0,从0点到之前任意入度为0的点之间连一条边权为0的边,求0点到所有点的最长路. SPFA模板留底用 #include <cstdio> #include <cstring> #include <algorithm> #include <queue> #include <string> #include <iostream> #include <cmath> #define ll long lon…
https://vjudge.net/contest/68966#problem/J [Accepted] #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<algorithm> using namespace std; ; struct node { int w; int s; int id;…
题意:有n个点,n-1条边的无向图,已知每个点书的售价,以及在边上行走的路费,问任选两个点作为起点和终点,能获得的最大利益是多少. 分析: 1.从某个结点出发,首先需要在该结点a花费price[a]买书,然后再在边上行走,到达目的地后,在目的地b获得price[b]. 2.因此可以建立两个虚拟结点, 虚拟结点1连向n个点,边权分别为-price[i],表示以i为起点,需花费price[i]买书. n个点连向虚拟结点2,边权分别为price[i],表示以i为终点,通过卖书可得price[i]. 3…
题意:先给两个水果的名字然后得出一个最短的序列包含这两个词. 思路:我一开始的思路是先求出最长公共子序列,然后做一些处理将其他的部分输出来:两种水果的字符串和最长公共子序列的字符串这三个字符串做对比,当他们三个相同的时候将最长公共子序列里面的字符去掉,如果不相同,将水果中的字符串中的字符去掉直到相同为止,不过网上用了一个好像比较方便的方法,在输出最长公共子序列的路径时候也能输出其他的字符(利用递归回溯). 注意:网上有一个求最长公共子序列的过程的二维的图值得一看,方便理解!! 我的方法: //最…
HDU 3416 Marriage Match IV (最短路径,网络流,最大流) Description Do not sincere non-interference. Like that show, now starvae also take part in a show, but it take place between city A and B. Starvae is in city A and girls are in city B. Every time starvae can…
Marica is very angry with Mirko because he found a new girlfriend and she seeks revenge.Since she doesn't live in the same city, she started preparing for the long journey.We know for every road how many minutes it takes to come from one city to anot…