自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 UVa1400

After doing Ray a great favor to collect sticks for Ray, Poor Neal becomes very hungry. In return for Neal’s help, Ray makes a great dinner for Neal. When it is time for dinner, Ray arranges all the di

2016-01-03 16:44:38 593

原创 UVa1428 - Ping pong

我有话说:这道题可以算是树状数组入门经典。要求在两个点之间找一个点,且这个点的值在两个点之间,求有这样的三点集合共有多少个。 这道题我们可以先后找一个点,假设a1到ai-1中有ci个小于ai,ai+1到an中有di个小于ai。那么以该店为中间点则共有ci(n-i-di)+di(i-1-ci)种点集。则转换为求ci和di。 我们这样计算ci,从左到右扫描ai令xi表示目前为止已考虑过的ai中是否存

2015-12-13 16:44:23 564

原创 POJ Unimodal Palindromic Decompositions(DP)

223:UNIMODAL PALINDROMIC DECOMPOSITIONS 查看 提交 统计 提问 总时间限制: 1000ms 内存限制: 65536kB 描述 A sequence of positive integers is Palindromic if it reads the same forward and backward. For example: 23 11 15 1

2015-11-04 20:24:25 492

原创 1232 - SKYLINE

The skyline of Singapore as viewed from the Marina Promenade (shown on the left) is one of the iconic scenes of Singapore. Country X would also like to create an iconic skyline, and it has put up a cal

2015-11-03 14:36:42 411

原创 12299 - RMQ with Shifts

In the traditional RMQ (Range Minimum Query) problem, we have a static array A. Then for each query (L, R) (L ≤ R), we report the minimum value among A[L], A[L + 1], … , A[R]. Note that the indices s

2015-11-03 13:22:42 293

原创 1159:Maze

查看 提交 统计 提问 总时间限制: 2000ms 内存限制: 65536kB 描述 Acm, a treasure-explorer, is exploring again. This time he is in a special maze, in which there are some doors (at most 5 doors, represented by ‘A’, ‘B’, ‘

2015-10-30 15:28:52 1010

原创 UVa1006 - Fixed Partition Memory Management

A technique used in early multiprogramming operating systems involved partitioning the available primary memory into a number of regions with each region having a fixed size, different regions potenti

2015-10-30 14:18:32 506

原创 UVa1411-Ants

我有话说: 这道题是KM算法的一个非常巧妙的应用。对图上的的黑点和白点(数量相等)进行二分图最佳完美匹配,最后得到的最大权值即答案。为什么呢? 我们看假设图中a1-b1和a2-b2相交,那么dist(a1,b1)+dist(a2,b2)>dist(a1,b2)+dist(a2,b1); 所以我们求所有点对之间的距离最小值就可以了。最小值?不是说要求最大

2015-10-29 19:34:22 436

原创 753 - A Plug for UNIX

A Plug for UNIXYou are in charge of setting up the press room for the inaugural meeting of the United Nations Internet eXecutive (UNIX), which has an international mandate to make the free flow of info

2015-10-29 10:56:58 286

原创 NOIP2014飞扬的小鸟

http://www.luogu.org/problem/show?pid=1941#我有话说: 这道题类似于完全背包问题。要注意细节问题。设dp(i,j)表示在坐标(i,j)时的最小点击屏幕次数。 状态转移方程: dp(i,j)=min{dp(i-1,j-x[i-1])+1,dp(i,j-x[i-1])+1,dp(i-1,j+y[i-1])};#in

2015-10-28 12:57:51 1388

原创 联合权值

http://www.luogu.org/problem/show?pid=1351 我有话说: 直接枚举。不过有一个策略可以优化时间。就是假设一个点和a,b,c等相连,那么ab+ac+ba+bc+ca+cb=(a+b+c)^2-a^2-b^2-c^2;#include<iostream>#include<string>#include<cstring>#include<ss

2015-10-28 09:25:07 516

原创 UVa307Sticks

George took sticks of the same length and cut them randomly until all parts became at most 50 units long. Now he wants to return sticks to the original state, but he forgot how many sticks he had origi

2015-10-28 08:51:53 363

原创 UVa11478 - Halum

#include<iostream>#include<string>#include<cstring>#include<sstream>#include<vector>#include<algorithm>#include<queue>#include<cstdio>using namespace std;const int maxn=3000+10;const int INF=

2015-10-27 16:09:09 286

原创 1604 - Cubic Eight-Puzzle

我有话说: 这道题叫做立体八数码问题。但绝对比八数码问题要难得多。一个是状态数量增加,另外一个是状态的难以表示。这道题的基本思路是双向广搜+深搜;并且对广搜的步数有一个上限,正向21,反向9,是试验过最快的一种。#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>#include

2015-10-20 20:27:13 561

原创 UVA11235 - Frequent values

我有话说: 这道题可以看作RMQ问题的入门。RMQ问题就是区间范围最小值问题。 下面给出模版算法:struct RMQ{ int d[maxn][maxlog]; void init(const vector<int>& A) { int n=A.size(); for(int i=0;i<n;i++)d[i][0]=A[i];

2015-10-18 20:19:58 292

原创 UVa816 Abbott's Revenge

// UVa816 Abbott's Revenge// Rujia Liu#include<cstdio>#include<cstring>#include<vector>#include<queue>using namespace std;struct Node { int r, c, dir; // 站在(r,c),面朝方向dir(0~3分别表示N, E, S, W) No

2015-10-16 20:17:10 563

原创 POJ月度开销

描述 农夫约翰是一个精明的会计师。他意识到自己可能没有足够的钱来维持农场的运转了。他计算出并记录下了接下来 N (1 ≤ N ≤ 100,000) 天里每天需要的开销。约翰打算为连续的M (1 ≤ M ≤ N) 个财政周期创建预算案,他把一个财政周期命名为fajo月。每个fajo月包含一天或连续的多天,每天被恰好包含在一个fajo月里。约翰的目标是合理安排每个fajo月包含的天数,使得开销最多的f

2015-10-16 20:08:47 3031

原创 POJ派

描述 我的生日要到了!根据习俗,我需要将一些派分给大家。我有N个不同口味、不同大小的派。有F个朋友会来参加我的派对,每个人会拿到一块派(必须一个派的一块,不能由几个派的小块拼成;可以是一整个派)。我的朋友们都特别小气,如果有人拿到更大的一块,就会开始抱怨。因此所有人拿到的派是同样大小的(但不需要是同样形状的),虽然这样有些派会被浪费,但总比搞砸整个派对好。当然,我也要给自己留一块,而这一块也要和其

2015-10-16 19:42:32 3591 1

原创 POJ网线主管

总时间限制: 1000ms 内存限制: 65536kB 描述 仙境的居民们决定举办一场程序设计区域赛。裁判委员会完全由自愿组成,他们承诺要组织一次史上最公正的比赛。他们决定将选手的电脑用星形拓扑结构连接在一起,即将它们全部连到一个单一的中心服务器。为了组织这个完全公正的比赛,裁判委员会主席提出要将所有选手的电脑等距离地围绕在服务器周围放置。为购买网线,裁判委员会联系了当地的一个网络解决方案提供商

2015-10-16 19:24:14 4637 2

原创 POJ 1.11编程基础之二分查找

01:查找最接近的元素 查看 提交 统计 提问 总时间限制: 1000ms 内存限制: 65536kB 描述 在一个非降序列中,查找与给定值最接近的元素。输入 第一行包含一个整数n,为非降序列长度。1 <= n <= 100000。 第二行包含n个整数,为非降序列各元素。所有元素的大小均在0-1,000,000,000之间。 第三行包含一个整数m,为要询问的给定值个数。1 <= m <

2015-10-14 20:35:09 2376 1

原创 1036 商务旅行(LCA例题)

http://codevs.cn/problem/1036/ 题目描述 Description 某首都城市的商人要经常到各城镇去做生意,他们按自己的路线去做,目的是为了更好的节约时间。假设有N个城镇,首都编号为1,商人从首都出发,其他各城镇之间都有道路连接,任意两个城镇之间如果有直连道路,在他们之间行驶需要花费单位时间。该国公路网络发达,从首都出发能到达任意一个城镇,并且公路网络不会存在环。你的

2015-10-06 13:29:59 933

原创 UVA1631 - Locker

#include #include #include #include #include #include using namespace std;const int maxn=1000+10;const int INF=100000000;char s1[maxn],s2[maxn];int cost[maxn][maxn],dp[2][maxn];void Init()

2015-09-15 13:18:12 464

原创 UVA1630 - Folding

#include #include #include #include #include #include using namespace std;const int maxn=100+10;const int INF=1000000;int dp[maxn][maxn];string flod[maxn][maxn];string str;int judge(int L

2015-09-08 12:59:02 419

原创 1629 - Cake slicing

https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=848&problem=4504&mosmsg=Submission+received+with+ID+16048725 我有话说: 这道题的大致思想是动态规划中的记忆化搜索。求对于给定区域

2015-09-05 17:06:01 280

原创 UVA10118 - Free Candies

我有话说: 这道题比较简单,总思路就是dfs+记忆化搜索#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#include <vector>#include <queue>using namespace std;const int maxn=100;int n;int c

2015-09-01 13:00:18 447

原创 1060 搞笑世界杯

http://codevs.cn/problem/1060/ 题目描述 Description 随着世界杯小组赛的结束,法国,阿根廷等世界强队都纷纷被淘汰,让人心痛不已. 于是有人组织了一场搞笑世界杯,将这些被淘汰的强队重新组织起来和世界杯一同比赛.你和你的朋友欣然去购买球票.不过搞笑世界杯的球票出售方式也很特别,它们只准备了两种球票.A 类票——免费球票 B 类票——-双倍价钱球票.购

2015-08-31 13:14:13 489

原创 1279 - Asteroid Rangers

我有话说: 这道题紫书上给出的提示是,在一个新最小生成树生成的时候一定会有两条边欧几里德距离相等。这是因为按照题意,任何情况下,形成的二叉树只有一种,即所有的边长度都不等。所以我们先按照题目给出的数据计算预判发生交换的时间点,我们称之为事件点,按照发生时间先后进行排序。并且逐个检验,是否有新的二叉树生成。#include <iostream>#include <cstdio>#i

2015-08-22 16:46:15 509

原创 UVa1658 Admiral

#include #include #include #include #include #include #include using namespace std;const int maxn=2000+10;const int INF=1000000000;struct Edge{ int from,to,cap,flow,cost; Edge(int u,int

2015-08-18 13:14:50 290

原创 1515 - Pool construction

我有话说: 在这道题里,首先我们根据题目可以想到的是要预先算出把边界的洞填上草所需要的花费,同时在图中修改。然后就是要考虑内部的情况。所有的点都是草或者洞,栅栏是把草和洞隔开的作用,就对应上图论中“割”的概念。我们可以把所有的草连上同一个源点s,所有的洞连上同一个汇点t。从s到草的边我们记其容量为d的边,即对应只有把这条边切断,这个点才会属于“洞”这一集合,即和t相连。然后根据在图中

2015-08-17 13:16:39 417

原创 1371 - Period

Given two strings A and B over an alphabet ∑ \sum , the edit distance between A and B is the minimum number of edit operations needed to convert A into B . The three edit operations are the following:

2015-08-07 22:49:57 408

原创 10271 - Chopsticks

#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>using namespace std;const int maxn=5000+10;const int INF=1000000000;int a[maxn],dp[maxn][maxn];int main(){ int T;

2015-08-07 21:55:50 326

原创 3286 火柴排队 2013年NOIP全国联赛提高组

http://codevs.cn/problem/3286/ 题目描述 Description 涵涵有两盒火柴,每盒装有 n 根火柴,每根火柴都有一个高度。现在将每盒中的火柴各自排成一列,同一列火柴的高度互不相同,两列火柴之间的距离定义为: ,其中 ai表示第一列火柴中第 i 个火柴的高度,bi表示第二列火柴中第 i 个火柴的高度。 每列火柴中相邻两根火柴的位置都可以交换,请你通过交换使得两

2015-07-24 13:02:52 340

原创 1151 - Buy or Build

World Wide Networks (WWN) is a leading company that operates large telecommunication networks. WWN would like to setup a new network in Borduria, a nice country that recently managed to get rid of its

2015-07-22 19:26:10 355

原创 UVA12174

我有话说: 这道题运用了滑动窗口这一技巧。转载了刘汝佳大神的代码。做了一下翻译。#include<iostream>#include<vector>using namespace std;const int maxn = 100000 + 5;int s, n, x[maxn*3], cnt[maxn], ok[maxn*2];int main() { int T; c

2015-07-22 11:27:26 600 3

原创 11882 - Biggest Number

题目大意: 给出nXm的矩阵方格。其中有一些是数字,有一些是#即障碍。 可以从任何一个数字个开始,取走格中的数字。不能走到障碍上,也不能经过同一个数字格两次。问所能得到的最大数字。 我有话说: 很明显是搜索。但是裸搜是肯定超时的。所以这道题可以说是剪枝的试验田。在写之前,我参看了网上大神们的各种强剪枝。最后写了一下代码。但因为自己两个小错误看了一

2015-07-21 13:17:52 644

原创 818 - Cutting Chains

Cutting Chains What a find! Anna Locke has just bought several links of chain some of which may be connected. They are made from zorkium, a material that was frequently used to manufacture jewelry in

2015-07-21 09:21:43 431

原创 UVa12107 - Digit Puzzle

题目大意是给你三个待定的字符串。形如7 * 8 。要求变换空格或者数字似的前一个字符串X后一个字符串=最后一个字符串有唯一解,且变换次数最少,多解时输出字典序最小的答案。规定空格的字典序小于数字。星号指代空格。 我有话说: 大致思想就是对每一位上的数字爆搜枚举,枚举完后并检验。这就要用到两个dfs。一个枚举数,一个检验。但在结构上都差不多。#include <iost

2015-07-21 07:47:05 1420

原创 690 - Pipeline Scheduling

Pipeline Scheduling An arithmetic pipeline is designed to process more than one task simultaneously in an overlap- ping manner. It includes function units and data paths among them. Tasks are process

2015-07-20 20:18:39 559

原创 10384 - The Wall Pushers

我有话说: 用了迭代加深搜索。主要就考虑两类。没有墙和有墙但是能推的两种情况。分别进行枚举。比较麻烦的不是程序过程,而是由于题目中x y坐标的设定,以及推墙后的运算,要有清晰的思路。#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;co

2015-07-20 16:17:28 452

原创 12569 - Planning mobile robot on Tree (EASY Version)

我有话说: 这是一道bfs。因为他要移动每一个石头或者机器人。换成dfs的话,一个是不知道目标状态(最小步数),二是容易爆栈。既然是bfs,那么要考虑一下如何判重,想法是转换成二进制,对于编号上的格子是否有石头或者机器人采用1或0表示。但是,数组开太小会RE太大会TLE,后来看了一个大神的题解,选择了一个恰好的maxstate。#include <iostream>#includ

2015-07-20 10:02:23 389

空空如也

空空如也

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

TA关注的人

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