- 博客(28)
- 收藏
- 关注
原创 2018 ccpc吉林站 现场赛 I题题解
代码还没平台提交,不保证正确比赛时没看懂题意,赛后根据官方题解写了一个能过样例的代码分成两次贪心,第一次贪心先看能不能干掉Bob所有的怪。如果可以,选择最优策略(用最少的花费干掉防御怪,剩下的直接加起来减去攻击怪的力量和就行) 得出最大伤害值。 第二次,直接用力量最大的怪去打Bob力量最小的怪(攻击怪,打防御怪没有用),直到打不赢为止最后选择两种贪心中伤害值更大的一个...
2018-09-25 21:09:52
1952
原创 2018 ccpc吉林站 D题题解 The Moon
比赛时没写出来导致没拿到银,自闭。一开始想到概率dp,但是没想到初始状态,就去推公式了,(思维僵化)。以 q 为 dp 数组下标,当 q 为100%时,期望步数为 1/p。把这个期望作为初始状态往下逆推。(这里要是想出来应该就好写了)因为还没有交题平台,所以也不能说自己写的是对的。。。 大体思路应该是对的吧,毕竟样例过了就是过了(滑稽脸)据说还有随机100w次过的(发抖) 我用...
2018-09-24 20:57:58
1736
原创 POJ - 2240 Arbitrage 求有无正环
这个题目没有规定初始位置,只要有路径成正环就行。用Floyd算法,计算最长路。如果有一个点到自身的长度大于1,说明存在正环,输出Yes。因为点的名字是字符串,所以用map映射一下。而且输入数据比较多,直接用cin,cout会超时。#include#include#include#include#include#include#define ll long long#defin
2017-11-12 19:50:05
243
原创 Currency Exchange POJ - 1860 Bellman-Ford最短路
用Bellman-Ford最短路径算法,判断是否存在正环,如果存在,说明可以无限增加金钱(你不停绕着正环走就能无限增加)。如果不存在,就输出NO;Bellman-Ford是求最短路并判断是否有负环,也能求是否有正环。因为有n个点的图,最优路径最多n-1个路径,所以从起点出发松弛n-1次就行。如果第n次还有路径变长,就说明存在正环。我们直接松弛n次就好(就是把每条路径判断n次,看是否能优化)
2017-11-12 00:45:53
283
原创 poj 3256 Wormholes 最短路Floyd
裸的Floyd,单纯三重循环,比较好理解有负权边,一起处理即可。#include#include#include#include#define ll long long#define ld long double#define INF 0x3f3f3f3fusing namespace std;int G[502][502],n;bool floyd() { for(i
2017-11-07 22:02:27
236
原创 UVA 351 Network 无向图求割点
裸的无向图求割点。自己的第一个求割点题目#include#include#include#include#define ll long long#define ld long double#define INF 0x3f3f3f3fusing namespace std;vector G[102];int dfn[102],low[102],f[102],Now;bool cu
2017-11-07 20:49:52
264
原创 poj-2387 Til the Cows Come Home dijkstra
Bessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep, so she wants to get b
2017-11-05 19:47:00
175
原创 poj 1236 Network of Schools 强连通
我的第一个强连通题目,利用这个题目入门。花了一晚上学习了啥是强连通和tarjan算法求强连通分量。感觉这个题只要理解了这个就可以做了,比较适合入门。如果还不会的,可以先了解一下再看题。A number of schools are connected to a computer network. Agreements have been developed among those scho
2017-11-03 22:50:51
140
原创 FatMouse and Cheese 【dp思想的dfs】
emmmmm 递归的dp? 就是在搜索的时候像dp一样找到最优子状态并储存。题目:FatMouse has stored some cheese in a city. The city can be considered as a square grid of dimension n: each grid location is labelled (p,q) where 0 <= p <
2017-10-12 17:26:20
274
转载 ACM动态规划总结 dp
转载请注明出处,谢谢。 http://blog.youkuaiyun.com/cc_again?viewmode=list ---------- Accagain 2014年5月15日动态规划一直是ACM竞赛中的重点,同时又是难点,因为该算法时间效率高,代码量少,多元性强,主要考察思维能力、建模抽象能力、灵活度。**********************
2017-10-11 21:16:23
465
原创 Doing Homework HDU1074 【dp】
dp,第一次做这种题目,第一天没有什么头绪,看了几个网上的代码,有了一定理解,第二晚磕磕碰碰的码出来了。写一下题解来理一下思路,顺便为后来找思路的尽一点微薄之力Ignatius has just come back school from the 30th ACM/ICPC. Now he has a lot of homework to do. Every teacher gives him
2017-10-11 20:49:38
257
原创 Tickets 【dp】
Jesus, what a great movie! Thousands of people are rushing to the cinema. However, this is really a tuff time for Joe who sells the film tickets. He is wandering when could he go back home as early as
2017-10-05 17:08:59
312
原创 Planning CodeForces - 854C
Helen works in Metropolis airport. She is responsible for creating a departure schedule. There aren flights that must depart today, the i-th of them is planned to depart at the i-th minute of the
2017-10-05 15:27:54
324
原创 Fliptile 暴力枚举(可以写成搜索。。。)
Farmer John knows that an intellectually satisfied cow is a happy cow who will give more milk. He has arranged a brainy activity for cows in which they manipulate anM × N grid (1 ≤ M ≤ 15; 1 ≤ N ≤ 1
2017-10-02 15:59:01
281
原创 Dungeon Master bfs
You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one minute to move one unit north, south
2017-10-01 17:34:36
174
原创 Catch That Cow bfs
Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a pointN (0 ≤ N ≤ 100,000) on a number line and the cow is at a point K (0 ≤ K ≤ 10
2017-10-01 16:25:02
263
原创 非常可乐 HDU1495
大家一定觉的运动以后喝可乐是一件很惬意的事情,但是seeyou却不这么认为。因为每次当seeyou买了可乐以后,阿牛就要求和seeyou一起分享这一瓶可乐,而且一定要喝的和seeyou一样多。但seeyou的手中只有两个杯子,它们的容量分别是N 毫升和M 毫升 可乐的体积为S (S<101)毫升 (正好装满一瓶) ,它们三个之间可以相互倒可乐 (都是没有刻度的,且 S==N+M,101>S>0,N
2017-10-01 15:05:43
945
原创 poj3984迷宫问题 bfs
定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0,};它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线。 Input一个5 ×
2017-09-30 17:33:42
266
原创 棋盘问题 dfs
在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。Input输入含有多组测试数据。 每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,以及摆放棋子的数目。 n 当为-1 -1时表示输入结束。
2017-09-30 15:44:59
233
原创 Common Subsequence dp
A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = another sequence Z = is a subsequence of X if there exists a strictly increa
2017-09-29 21:54:00
165
原创 Monkey and Banana dp
A group of researchers are designing an experiment to test the IQ of a monkey. They will hang a banana at the roof of a building, and at the mean time, provide the monkey with some blocks. If the monk
2017-09-29 20:28:47
231
原创 免费馅饼 dp
题目描述都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼。说来gameboy的人品实在是太好了,这馅饼别处都不掉,就掉落在他身旁的10米范围内。馅饼如果掉在了地上当然就不能吃了,所以gameboy马上卸下身上的背包去接。但由于小径两侧都不能站人,所以他只能在小径上接。由于gameboy平时老呆在房间里玩游戏,虽然在游戏中是个身手敏捷的高手,但在现实中运动
2017-09-29 16:42:24
164
原创 Super Jumping! Jumping! Jumping! dp
给定一个长为n的序列,求其中的一个上升序列,使其和最大并求和。要注意有负数的情况。很常规的dp#include#include#includeusing namespace std;int dp[10000],a[10000];int main() {// std::ios::sync_with_stdio(false); int n; while(cin>>n)
2017-09-29 15:57:32
157
原创 最少拦截系统 dp
某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天,雷达捕捉到敌国的导弹来袭.由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹.怎么办呢?多搞几套系统呗!你说说倒蛮容易,成本呢?成本是个大问题啊.所以俺就到这里来求救了,请帮助计算一下最少需要多少套拦截
2017-09-28 17:11:51
514
原创 Max Sum Plus Plus 动态规划
给定一长为n的数列,求将其分为m个不相交子段后,使子段和最大,求和。dp[i][j]为将前j个数分为i段的最大值,必须包括第j个数。用a[n]来储存这个数列。dp[i][j]=max(dp[i][j-1]+a[j],dp[i-1][x]+a[j]) ( i即dp[i][j]=max(dp[i][j-1],dp[i-1][x])+a[j] , 我们只需要找到dp[i][j-
2017-09-28 15:45:31
469
原创 A SPY in the Metro(城市里的间谍),UVA1025【dp】
用dp[i][j]来表示时间i时在车站j所需的时间,则dp[T][n]为0,及此时已达终点,还需等待时间为零。而dp[T][j]为INF(j往前递推时有三种状况:1,等一分钟,即dp[i][j]=dp[i+1][j]+1。 2.搭上往右开的车3.搭上往左开的车因为递推情况是在车站的情况,所以不存在在车上的状况#includeusing namespace std;#d
2017-09-22 21:51:58
333
原创 Two Paths HDU 次短路问题
You are given a undirected graph with n nodes (numbered from 1 to n) and m edges. Alice and Bob are now trying to play a game.Both of them will take different route from 1 to n (not necessary simp
2017-09-15 21:01:35
230
原创 Kolakoski HDU多校签到题 6130
Problem DescriptionThis is Kolakosiki sequence: 1,2,2,1,1,2,1,2,2,1,2,2,1,1,2,1,1,2,2,1……. This sequence consists of 1 and 2, and its first term equals 1. Besides, if you see adjacent and eq
2017-09-08 20:17:47
233
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人