[题意]给定N个点,每个点有一个停留所需的时间Ci,和停留能够获得的满意度Si,有M条边,每条边代表着两个点走动所需的时间ti,现在问在规定的T时间内从指定的一点S到E能够获得的最大的满意度是多少?要求停留的点的满意度要依次上升,并且每个点可以选择路过和停留. 好题,收获很大-- 收获一:分层图的应用 收获二:越来越觉得Bellman-Ford or SPFA就是一种图上的DP,不仅仅是求最短路,更可以求某类最优问题. 收获三:像这种点有路过和停留两种状态的题目可以试着Floyd预处理,方便地处…
Problem Description One day, a hunter named James went to a mysterious area to find the treasures. James wanted to research the area and brought all treasures that he could. The area can be represented as a N*M rectangle. Any points of the rectangle…
与其说这是一次重温AC自动机+dp,倒不如说这是个坑,而且把队友给深坑了. 这个题目都没A得出来,我只觉得我以前的AC自动机的题目都白刷了——深坑啊. 题目的意思是给你两个串,每个串只含有R或者D,要求有多少种长为(n+m)的串(其中有n个R,m个D)同时含有这两个串作为子串.(我就不说题目描述了) 看完了题目我居然一开始用排列组合去做,搞了近一个小时,深坑队友啊. 其实正解是用AC自动机来dp出解的. 什么意思呢?把两个给定的串放到AC字典树上,并且弄好fail指针,变为tire图,构造好AC…
Problem Description Bob gets tired of playing games, leaves Alice, and travels to Changsha alone. Yuelu Mountain, Orange Island, Window of the World, the Provincial Museum etc...are scenic spots Bob wants to visit. However, his time is very limited,…
SDUST的训练赛 当时死磕这个水题3个小时,也无心去搞其他的 按照题意,转换成无向图,预处理去掉单向的边,然后判断剩下的图能否构成两个无向完全图(ps一个完全图也行或是一个完全图+一个孤点) 代码是赛后看的网上大神,所以转载过来了,dfs染色的时候很巧妙,巧妙的用到了就两个无向完全图 #include <cstdio> #include <cstring> #include <cmath> #include <vector> #include <qu…
题意:一个数列,给出这个数列中的某些位置的数,给出所有相邻的三个数字的和,数列头和尾处给出相邻两个数字的和.有若干次询问,每次问某一位置的数字的最大值. 分析:设数列为a1-an.首先通过相邻三个数字的和我们可以求出a3,a6,a9……是多少.a3=sum(a1,a2,a3)-sum(a1,a2).a6=sum(a4,a5,a6)-sum(a3,a4,a5).后面依次类推. 推到了数列的最右面,如果恰好知道了an或者a(n-1)中的一个,那么可以通过sum(an,a(n-1))减去它来求得另一个…
Alice's Print Service Time Limit: 2 Seconds      Memory Limit: 65536 KB Alice is providing print service, while the pricing doesn't seem to be reasonable, so people using her print service found some tricks to save money. For example, the price when…
Collision Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge There's a round medal fixed on an ideal smooth table, Fancy is trying to throw some coins and make them slip towards the medal to collide. There's also a round range which…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4573 Problem Description Remember our childhood? A few naked children throw stones standing on the same position, the one throws farther win the game. Aha, of course, there are some naughty boys who care…
Problem Description Let f(x) = anxn +...+ a1x +a0, in which ai (0 <= i <= n) are all known integers. We call f(x) 0 (mod m) congruence equation. If m is a composite, we can factor m into powers of primes and solve every such single equation after wh…