自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(45)
  • 收藏
  • 关注

原创 UAa 11400 Lighting System Design DP

思路: 按电压进行排序,第i种灯泡可以替换第j种灯泡(i>j),所以可以将第j~i种灯泡全部用第i种灯泡表示,这样我们还需要求一下前缀和来快速得出第j~i种灯泡的数量,用d[i]表示使用前i种灯泡的最小开销,那么转移方程则是,d[i] = min(d[i], d[j] + (sum[i] - sum[j-1]) * c[i] + k[i]); sum[i]是前i种灯泡的数量...

2019-07-29 10:53:38 137

原创 UPC Financial Planning

题目描述Being a responsible young adult, you have decided to start planning for retirement. Doing some back-of-the-envelope calculations, you figured out you need at least M euros to retire comfortably....

2019-04-29 20:49:47 164

原创 HDU - 1565 方格取数 状压DP

题意:在n*n的格子里 取数 且 取得数两两不相邻,求最大的总和求出一行当中满足两两不相邻的状态->当前状态 & 当前状态左移一位, 如果结果为零则满足条件,否则不满足 存入st数组例: 101, 1010|11, 110然后 dp 处理一下st[j] & st[k] == 0 保证竖直方向不相邻dp[i][j] += dp[i-1]...

2019-04-24 20:27:15 221

原创 POJ - 3254 Corn Fields 状压DP

题意:把奶牛放在1的位置上,且两个奶牛之间不能相邻求出一行当中满足两两不相邻的状态 -> 当前状态 & 当前状态左移一位, 如果结果为零则满足条件,否则不满足 存入st数组例: 101, 1010 | 11, 110将每一行的1,0转成二进制存到一个数里,这里反着处理一下,010表示 第一三草坪可以放牛 存入a数组这样处理可以保证,当st & ...

2019-04-24 20:22:19 158

原创 CSU - 1592 石子归并 区间DP

思路:dp[i][j] 表示选i - j 这个区间的最小价值dp[0][0] = 0用前缀和表示来求去这个区间得到的代价dp[i][j] = min(dp[i][j],dp[i][k] + dp[k+1][j] + sum[j] - sum[i-1]) k 在 [i,j] 中AC代码#include<iostream>#include<algo...

2019-04-23 15:01:13 131

原创 Hie with the Pie 状压+最短路

The Pizazz Pizzeria prides itself in delivering pizzas to its customers as fast as possible. Unfortunately, due to cutbacks, they can afford to hire only one driver to do the deliveries. He will wait ...

2019-04-22 20:51:00 132

原创 Imperfect GPS

题目描述Lots of runners use personal Global Positioning System (GPS) receivers to track how many miles they run. No GPS is perfect,though: it only records its position periodically rather than continuo...

2019-04-13 17:09:32 221

原创 GlitchBot

题目描述One of our delivery robots is malfunctioning! The job of the robot is simple; it should follow a list of instructions in order to reach a target destination. The list of instructions is original...

2019-04-13 00:36:39 211

原创 Greeting Card

题目描述Quido plans to send a New Year greeting to his friend Hugo. He has recently acquired access to an advanced high-precision plotter and he is planning to print the greeting card on the plotter.He...

2019-04-13 00:31:11 298 1

原创 Progressive Scramble

题目描述You are a member of a naive spy agency. For secure communication,members of the agency use a very simple encryption algorithm – which changes each symbol in the message ‘progressively’, i.e., ba...

2019-04-13 00:19:32 194

原创 Canonical Coin Systems

题目描述A coin system S is a finite (nonempty) set of distinct positive integers corresponding to coin values, also called denominations, in a real or imagined monetary system. For example, the coin s...

2019-04-13 00:07:46 340

原创 Election of Evil dfs

题目描述Dylan is a corrupt politician trying to steal an election. He has already used a mind-control technique toenslave some set U of government representatives. However, the representatives who will...

2019-04-10 21:14:55 266

原创 Assembly Required

题目描述Princess Lucy broke her old reading lamp, and needs a new one. The castle orders a shipment of parts from the Slick Lamp Parts Company, which produces interchangable lamp pieces.There are m typ...

2019-04-10 21:08:46 333

原创 Ground Defense

题目描述You are a denizen of Linetopia, whose n major cities happen to be equally spaced along an east-west line. Infact, they are often numbered in order from 1 to n, where 1 is the westmost city and ...

2019-04-10 21:02:33 243

原创 Codeforces Round #527 (Div. 3) Tree with Maximum Cost

You are given a tree consisting exactly ofnnvertices. Tree is a connected undirected graph withn−1n−1edges. Each vertexvvof this tree has a valueavavassigned to it.Letdist(x,y)dist(x,y)be t...

2019-04-06 19:01:30 360

原创 [CodeForces 859C] Pie Rules

You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which ...

2019-04-03 21:35:49 222

原创 POJ - 1661 Help Jimmy

"Help Jimmy" 是在下图所示的场景上完成的游戏。 场景中包括多个长度和高度各不相同的平台。地面是最低的平台,高度为零,长度无限。Jimmy老鼠在时刻0从高于所有平台的某处开始下落,它的下落速度始终为1米/秒。当Jimmy落到某个平台上时,游戏者选择让它向左还是向右跑,它跑...

2019-04-02 17:12:25 155

原创 POJ - 3616 Milking Time

Bessie is such a hard-working cow. In fact, she is so focused on maximizing her productivity that she decides to schedule her nextN(1 ≤N≤ 1,000,000) hours (conveniently labeled 0..N-1) so that she...

2019-04-01 20:15:36 151

原创 HDU - 2859 Phalanx

Today is army day, but the servicemen are busy with the phalanx for the celebration of the 60th anniversary of the PRC.A phalanx is a matrix of size n*n, each element is a character (a~z or A~Z), st...

2019-04-01 18:12:10 198

原创 HDU - 1078 FatMouse and Cheese 记忆化搜索

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 < n and 0 <= q < n. At each grid lo...

2019-03-31 21:10:23 145

原创 POJ - 3186 Treats for the Cows

FJ has purchased N (1 <= N <= 2000) yummy treats for the cows who get money for giving vast amounts of milk. FJ sells one treat per day and wants to maximize the money he receives over a given p...

2019-03-31 21:02:45 113

原创 POJ - 2533 Longest Ordered Subsequence

第一种情况,序列只有他自己 dp[i] = 1第二种情况,a[i] > a[j] i>j dp[i] = max(dp[i],dp[j]+1)#include<iostream>#include<algorithm>#include<cstdio>#include<cstring>#include&l...

2019-03-30 21:58:45 100

原创 POJ - 1458 Common Subsequence 动态规划

A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = < x1, x2, ..., xm > another sequence Z = < z1, z2, ..., zk > is a ...

2019-03-30 21:55:43 149

原创 这是二叉搜索树吗? 天梯赛练习 数据结构瞎做QAQ

一棵二叉搜索树可被递归地定义为具有下列性质的二叉树:对于任一结点,其左子树中所有结点的键值小于该结点的键值; 其右子树中所有结点的键值大于等于该结点的键值; 其左右子树都是二叉搜索树。所谓二叉搜索树的“镜像”,即将所有结点的左右子树对换位置后所得到的树。给定一个整数键值序列,现请你编写程序,判断这是否是对一棵二叉搜索树或其镜像进行前序遍历的结果。输入格式:输入的第一行给出正整...

2019-03-29 22:36:17 301

原创 排座位 天梯赛练习 并查集

布置宴席最微妙的事情,就是给前来参宴的各位宾客安排座位。无论如何,总不能把两个死对头排到同一张宴会桌旁!这个艰巨任务现在就交给你,对任何一对客人,请编写程序告诉主人他们是否能被安排同席。输入格式:输入第一行给出3个正整数:N(≤100),即前来参宴的宾客总人数,则这些人从1到N编号;M为已知两两宾客之间的关系数;K为查询的条数。随后M行,每行给出一对宾客之间的关系,格式为:宾客1 宾客2 ...

2019-03-29 22:30:25 159

原创 点赞狂魔 天梯赛练习

微博上有个“点赞”功能,你可以为你喜欢的博文点个赞表示支持。每篇博文都有一些刻画其特性的标签,而你点赞的博文的类型,也间接刻画了你的特性。然而有这么一种人,他们会通过给自己看到的一切内容点赞来狂刷存在感,这种人就被称为“点赞狂魔”。他们点赞的标签非常分散,无法体现出明显的特性。本题就要求你写个程序,通过统计每个人点赞的不同标签的数量,找出前3名点赞狂魔。输入格式:输入在第一行给出一个...

2019-03-29 22:25:15 302

原创 HDU - 1160 FatMouse's Speed

FatMouse believes that the fatter a mouse is, the faster it runs. To disprove this, you want to take the data on a collection of mice and put as large a subset of this data as possible into a sequence...

2019-03-28 19:21:20 168

原创 HDU - 1257 最少拦截系统 最长上升子序列

某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天,雷达捕捉到敌国的导弹来袭.由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹.怎么办呢?多搞几套系统呗!你说说倒蛮容易,成本呢?成本是个大问题啊.所以俺就到这里来求救了,请帮助计算一下最少需要多少套拦截系统...

2019-03-28 19:14:27 178

原创 HDU - 1260 Tickets

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...

2019-03-28 19:11:41 127

原创 HDU - 1176 免费馅饼

都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼。说来gameboy的人品实在是太好了,这馅饼别处都不掉,就掉落在他身旁的10米范围内。馅饼如果掉在了地上当然就不能吃了,所以gameboy马上卸下身上的背包去接。但由于小径两侧都不能站人,所以他只能在小径上接。由于gameboy平时老呆在房间里玩游戏,虽然在游戏中是个身手敏捷的高手,但在现实中运动神经特别迟钝...

2019-03-28 19:09:46 182

原创 HDU - 1114 Piggy-Bank 完全背包

Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irreversibly Bound Money (IBM). The idea behind is simple...

2019-03-27 19:06:19 228

原创 HDU - 1087 Super Jumping! Jumping! Jumping! 最大上升子序列

思路:第一种情况,序列只有他自己 dp[i] = a[i]第二种情况,a[i] > a[j] i>j dp[i] = max(dp[i],dp[j]+a[i])#include<iostream>#include<algorithm>#include<cstdio>#include<cstring>...

2019-03-27 19:04:13 154

原创 HDU - 1074 Doing Homework 状压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 a deadline of handing in the homework. If Ignatius hands in the homework after th...

2019-03-27 19:00:16 148

原创 POJ - 2774 Long Long Message 后缀数组求最长公共子串

The little cat is majoring in physics in the capital of Byterland. A piece of sad news comes to him these days: his mother is getting ill. Being worried about spending so much on railway tickets (Byte...

2019-02-26 20:29:30 233

原创 SPOJ - DISUBSTR Distinct Substrings 后缀数组+统计不同字串个数

Given a string, we need to find the total number of its distinct substrings.InputT- number of test cases. T&lt;=20;Each test case consists of one string, whose length is &lt;= 1000OutputFor e...

2019-02-22 23:53:28 163

原创 POJ - 3261 Milk Patterns 后缀数组模板题

Farmer John has noticed that the quality of milk given by his cows varies from day to day. On further investigation, he discovered that although he can't predict the quality of milk from one day to th...

2019-02-22 15:36:10 135

原创 POJ - 1743 Musical Theme 后缀数组模板

A musical melody is represented as a sequence of N (1&lt;=N&lt;=20000)notes that are integers in the range 1..88, each representing a key on the piano. It is unfortunate but true that this representat...

2019-02-21 23:38:00 172

原创 HDU - 3336 Count the string [KMP]

It is well known that AekdyCoin is good at string problems as well as number theory problems. When given a string s, we can write down all the non-empty prefixes of this string. For example: s: "abab...

2019-02-13 15:22:41 153

原创 POJ - 2752 Seek the Name, Seek the Fame 前缀后缀匹配

The little cat is so famous, that many couples tramp over hill and dale to Byteland, and asked the little cat to give names to their newly-born babies. They seek the name, and at the same time seek th...

2019-02-10 22:39:01 183

原创 HDU - 1358 Period 循环节

For each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126, inclusive), we want to know whether the prefix is a periodic string. That is, for each i (2 ...

2019-02-05 15:33:46 175

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除