参考:https://blog.csdn.net/sd_invol/article/details/15813671 要点 每个任务的结束时间是固定的,不受任何因素影响 机器只在最一开始有用,在那之后都是任务之间的转换 连边 将任务拆点,入点 i, 出点 i', 连边 (i, i' [1,1], 0) 设源点 s_, 汇点 t_ 对于机器 \(i (i \in [1, m])\), 连 (s_, i, 1, 0),即流量为1,费用为0 对每个任务 \(j\) 如果 \(C[i][j] \le s…
Lights Against Dudely http://acm.hdu.edu.cn/showproblem.php?pid=4770 15个位置,所以可以暴力枚举那些放,对于放的再暴力枚举哪个转,对于转的,再枚举转哪个方向.选位置放我用了2进制枚举,选出哪个转和枚举4个方向for循环就行.可以加个小剪枝. #include<cstdio> #include<cstring> #include<algorithm> #define mt(a,b) memset(a,b…
http://acm.hdu.edu.cn/showproblem.php?pid=4771 题目大意: 给你一幅图(N*M)“@”是起点,"#"是墙,“.”是路,然后图上有K个珠宝, 问是否能全部取走珠宝,若能则输出最小步数,否则-1. 思路,可以bfs处理珠宝与珠宝,珠宝与起点的距离同时还可以判断是否可达, 最后因为K<=4,所以枚举路径输出最小ans #include <iostream> #include <cstdio> #include <…
Problem Description Josh Lyman is a gifted painter. One of his great works is a glass painting. He creates some well-designed lines on one side of a thick and polygonal glass, and renders it by some special dyes. The most fantastic thing is that it c…
Problem Description City C is really a nightmare of all drivers for its traffic jams. To solve the traffic problem, the mayor plans to build a RTQS (Real Time Query System) to monitor all traffic situations. City C is made up of N crossings and M roa…
Friend Chains http://acm.hdu.edu.cn/showproblem.php?pid=4460 图的最远两点距离,任意选个点bfs,如果有不能到的点直接-1.然后对于所有距离最远的点都bfs一次.最坏n^2 邻接表 #include<cstdio> #include<cstring> #include<iostream> #include<queue> #include<map> #define mt(a,b) mems…
hdu 4786 Fibonacci Tree http://acm.hdu.edu.cn/showproblem.php?pid=4786 copyright@ts 算法源于ts,用最小生成树可以求出最小权值,把所有边权取反可以求出最大权值,算法是如果有个斐波那契数在最小到最大值之间,就一定能构成.也就是如果大了就把1边换成0边,反之亦然. #include<cstdio> #include<cstring> #include<algorithm> #define m…
Description Could you imaging a monkey writing computer programs? Surely monkeys are smart among animals. But their limited intelligence is no match for our human beings. However, there is a theorem about monkeys, and it states that monkeys can write…
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=4800 Problem Description A role-playing game (RPG and sometimes roleplaying game) is a game in which players assume the roles of characters in a fictional setting. Players take responsibility for acting…
Conquer a New Region Time Limit: 5 Seconds      Memory Limit: 32768 KB The wheel of the history rolling forward, our king conquered a new region in a distant continent. There are N towns (numbered from 1 to N) in this region connected by several road…