自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 UVa 1509 Leet 枚举

题意: 有两条字符串alph和leet,alph由纯字母组成,长度小于等于15,能够映射到leet,每个字母能对应k个leet字符,对应后不再改变。1≤k≤3 如果alph中所有字符映射成功,输出1;否则输出0。 分析: 数据量小,可以枚举解决。alph是纯字母,所以可以放在大小为26的数组里,每个元素存储k个对应字符。 代码: #include #include #include

2016-05-30 14:06:49 363

原创 UVa 1629 Cake Slicing DP

这题空了好久,虽然现在想出来了很激动,但是花的时间略长呀。。。 每切一次蛋糕就相当于一次状态转移。设某时刻蛋糕的坐上顶点为(a, b),右下顶点为(c, d),将这块蛋糕切成只剩一个樱桃产生的切割线长度最短为d ( a, b, c, d)。 原来是想根据樱桃的位置来切蛋糕,但是很难实现。考虑到横竖共m + n 种切法,可以枚举状态。 纵向:min { d ( a, b, c, j ) + d

2015-12-15 05:50:18 331

原创 poj 1971 Parallelogram Counting 排序 + 计数

题意:给出平面上的n个点,求出组成的平行四边形个数。 考虑平行四边形的性质,对角线互相平分。 因为做之前提示可以哈希,所以想把所有中点哈希后计数,但是这样太麻烦。直接对所有点排序后,将重复的计数t,求所有t * (t - 1) / 2的和。 #include #include #include #include using namespace std; const int

2015-10-14 08:58:01 437

原创 poj 2002 Squares 哈希

题意:给出平面上的n个点,求出能组成的正方形个数。(n 先考虑暴力,O(n^4),会超时。 再考虑正方形的特点,已知两个点,可以推出另外两个点。所以枚举两个点,因为点的坐标|x,y| 枚举两个点时,我曾经纠结于是否枚举对角线。但是细想一下,包含对角线的正方形其实应经在枚举过程中出现了,故不需要重复考虑。 枚举时要考虑两个方向的正方形。最后每个正方形枚举了4次。 关于哈希函数的选

2015-10-13 22:37:12 344

原创 poj Snowflakes snow snowflakes 哈希

题意:给出n个雪花的六条边的长度,求出是否有两个相同的雪花,即边的大小和顺序相同。 因为只要考虑是否存在相同的雪花,结合雪花边长可能较大的条件,考虑哈希。 需要顺时针和逆时针枚举比较。

2015-10-10 21:52:27 310

原创 hdu 1800 Flying to Mars 字符串哈希

字符串哈希

2015-10-10 20:23:38 407

原创 POJ 1017 Packets 简单模拟

用1×1至6×6这六种正方形拼出尽可能少的6×6的正方形。

2015-10-06 00:04:43 348

原创 POJ 3026 Borg Maze 最小生成树

这道题大意很好懂,有一个S点和不超过100个A点,求这些点构成的完全图的最小生成树。 题意虽简单,但实现略繁琐,而且Input有陷阱。 在n,m这一行行末会有多余空格。。。(无聊。) 然后用了prim来做(代码有点乱)。 #include #include #include #include #include using namespace std; const int max

2015-10-03 23:59:48 339

原创 HDU 1258 Sum it up

题意:给出n个正整数,x[1..n],对于给定的t(t < 1000),找出所有满足和为t的x的组合。降序输出。

2015-09-17 16:54:56 396

原创 hdu 2795 Billboard

题意:有一块黑板h * w,可以往上面贴广告,优先顺序是先尽量靠上,再尽量靠左。广告的参数为1 × w[i],求每张广告贴的高度。 分析:开始居然被h骗了。。一开始半天都没想好怎么做。   在h上建树,维护区间最大值,即区间能放的最大广告牌宽度。需要插入广告时,先query一次w[i],判断是否有剩余宽度,如果有,返回的节点值k为尽量靠上(左)的,update(k, dat[k] - w[i]

2015-07-29 22:59:21 284

原创 hdu 1754 I hate it

此题也是一眼就能看出来的线段树。。。 但是爆栈了。记得hdu能加预编译命令扩栈,然后上网找到了。 #pragma comment(linker, "/STACK:1024000000,1024000000") #include #include #include #include #include #include #include #include #include usi

2015-07-29 00:58:34 329

原创 hdu 1166 敌兵布阵

hdu 1166 敌兵布阵 简单的线段树

2015-07-29 00:37:33 384

原创 poj 2253 Frogger和 poj 2485 Highways

这两题有着相似的地方。都只求所有路径中的最长边的最小值。 不同之处在于Frogger求的是固定起点和终点,而Highways是所有路径。 所以Highways可以用最小生成树来求。而Frogger中起点和终点可以当成一组特值,所以可以考虑先求任意两点间的最小最长边,可以由此想到Warshell-Floyd算法,但是需要修改。当路径经过k时,分别考虑[i, k] 和 [k, j] 的最小最长边,

2015-07-23 22:47:25 295

原创 dp小结

5道基础dp题

2015-06-30 11:59:38 322

原创 poj 2385 Apple Catching

分析: 题意大致为:两棵树每分钟仅有一棵会掉果子,设为Tree 1, Tree 2。可用数组记录,记为a[i][j] = 1或0。找时刻为 j 的状态,此时在树 i 上,可移动 k 次,即d[i][j][k]。     推测如何从前面的状态转移到此状态。前一状态有两种,即在j - 1时刻,这头牛要么在tree 1,要么在tree 2。可得状态转移方程:d[i][j][k] = max(d[i]

2015-06-19 00:24:05 297

原创 UVa439 Knight Moves

Knight Moves Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu Description A friend of you is doing research on the Traveling Knight Problem (T

2015-04-08 20:52:40 400

原创 UVa536 Tree Recovery

UVa536 Tree Recovery

2015-04-08 20:47:57 441

原创 UVa Parentheses Balance

Parentheses Balance Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu

2015-04-08 20:43:08 370

原创 UVa 12504 Updating a Dictioinary

题目:UVa 12504 Updating a Dictionary 分析: 键值对可用map来处理,即map[ key ] = value。 因为有三种情况要讨论,股分别用set保存对应变化的键值,顺便排序。 读入需要注意,通过冒号来区分key和value,不同键值对用 ',' 和 '}‘区分,而 '}' 代表此行的读入停止。 代码: #include #include #inc

2015-03-21 19:55:14 499

原创 UVa 1595 Symmetry

Symmetry Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu Submit Status Description The figure shown on the left is left-right symmetric as

2015-03-15 17:44:52 419

原创 UVa 1593 Alignment of Code

Alignment of Code Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu Submit Status Description You are working in a team that writes Incredib

2015-03-15 16:24:56 376

原创 UVa 10763 Foreign Exchange

Problem E Foreign Exchange Input: standard input Output: standard output Time Limit: 1 second Your non-profit organization (iCORE - international Confederation of Revolver Enthusiasts) coordi

2015-03-15 15:25:36 332

原创 UVa 10935 Throwing cards away 1

Throwing cards away I Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu Submit Status Description Problem B: Throwing cards away I Given is

2015-03-15 14:57:56 416

原创 UVa 1594 Ducci Sequence

Ducci Sequence Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu Submit Status Description A Ducci sequence is a sequence of n-tuples of int

2015-03-15 13:34:11 373

原创 UVa 201 Squares

Squares

2015-03-11 16:49:36 437

原创 UVa 1587 Box

Box

2015-02-27 19:24:28 405

原创 UVa 10340 All in all

All in all; subsequence

2015-02-27 18:34:14 474

原创 UVa 227 Puzzle

Puzzle

2015-02-27 13:02:53 490

原创 UVa 202 Repeating Decimals

Repeating Decimals

2015-02-26 17:16:35 437

原创 UVa 232 Crossword Answers

232 - Crossword Answers Time limit: 3.000 seconds  A crossword puzzle consists of a rectangular grid of black and white squares and two lists of definitions (or descriptions). One list of def

2015-02-24 12:28:49 380

原创 zoj 1383 Binary Numbers

Binary Numbers Time Limit: 2 Seconds      Memory Limit: 65536 KB Given a positive integer n, print out the positions of all 1's in its binary representation. The position of the least significan

2015-02-11 14:16:33 405

原创 zoj 1331 Perfect Cubes

Perfect Cubes Time Limit: 10 Seconds      Memory Limit: 32768 KB For hundreds of years Fermat's Last Theorem, which stated simply that for n > 2 there exist no integers a, b, c > 1 such that

2015-02-05 15:22:35 374

原创 zoj 2423 Fractal

Fractal Time Limit: 2 Seconds      Memory Limit: 65536 KB A fractal is an object or quantity that displays self-similarity, in a somewhat technical sense, on all scales. The object need not exhi

2015-02-04 16:22:00 526

原创 zoj 1251 Box of Bricks

Box of Bricks Time Limit: 2 Seconds      Memory Limit: 65536 KB Little Bob likes playing with his box of bricks. He puts the bricks one upon another and builds stacks of different height. ``Look

2015-02-04 16:13:02 347

原创 zoj 1242 Carbon Dating

Carbon Dating Time Limit: 2 Seconds      Memory Limit: 65536 KB Until the second half of the 20th century, determining the actual age of an archaeological find had been more or less a matter of

2015-02-04 15:35:34 775

原创 zoj 1241 Geametry Made Simple

Geometry Made Simple Time Limit: 2 Seconds      Memory Limit: 65536 KB Mathematics can be so easy when you have a computer. Consider the following example. You probably know that in a right-angl

2015-02-04 15:26:52 443

原创 zoj 1240 IBM Minus One

IBM Minus One Time Limit: 2 Seconds      Memory Limit: 65536 KB You may have heard of the book '2001 - A Space Odyssey' by Arthur C. Clarke, or the film of the same name by Stanley Kubrick. In i

2015-02-04 15:21:42 348

原创 zoj 1037 Gridland

Gridland Time Limit: 2 Seconds      Memory Limit: 65536 KB Background For years, computer scientists have been trying to find efficient solutions to different computing problems. For some of

2015-01-30 15:05:32 356

原创 zoj 1067 Color Me Less

Color Me Less Time Limit: 2 Seconds      Memory Limit: 65536 KB Problem A color reduction is a mapping from a set of discrete colors to a smaller one. The solution to this problem requires th

2015-01-30 14:55:29 523

原创 zoj 1115 Digital Roots

Digital Roots Time Limit: 2 Seconds      Memory Limit: 65536 KB Background The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a si

2015-01-30 14:49:58 387

空空如也

空空如也

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

TA关注的人

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