- 博客(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 293
原创 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 276
原创 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 374
原创 poj 2002 Squares 哈希
题意:给出平面上的n个点,求出能组成的正方形个数。(n 先考虑暴力,O(n^4),会超时。再考虑正方形的特点,已知两个点,可以推出另外两个点。所以枚举两个点,因为点的坐标|x,y|枚举两个点时,我曾经纠结于是否枚举对角线。但是细想一下,包含对角线的正方形其实应经在枚举过程中出现了,故不需要重复考虑。枚举时要考虑两个方向的正方形。最后每个正方形枚举了4次。关于哈希函数的选
2015-10-13 22:37:12 292
原创 poj Snowflakes snow snowflakes 哈希
题意:给出n个雪花的六条边的长度,求出是否有两个相同的雪花,即边的大小和顺序相同。因为只要考虑是否存在相同的雪花,结合雪花边长可能较大的条件,考虑哈希。需要顺时针和逆时针枚举比较。
2015-10-10 21:52:27 262
原创 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 290
原创 HDU 1258 Sum it up
题意:给出n个正整数,x[1..n],对于给定的t(t < 1000),找出所有满足和为t的x的组合。降序输出。
2015-09-17 16:54:56 348
原创 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 240
原创 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 278
原创 poj 2253 Frogger和 poj 2485 Highways
这两题有着相似的地方。都只求所有路径中的最长边的最小值。不同之处在于Frogger求的是固定起点和终点,而Highways是所有路径。所以Highways可以用最小生成树来求。而Frogger中起点和终点可以当成一组特值,所以可以考虑先求任意两点间的最小最长边,可以由此想到Warshell-Floyd算法,但是需要修改。当路径经过k时,分别考虑[i, k] 和 [k, j] 的最小最长边,
2015-07-23 22:47:25 252
原创 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 257
原创 UVa439 Knight Moves
Knight MovesTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluDescriptionA friend of you is doing research on the Traveling Knight Problem (T
2015-04-08 20:52:40 354
原创 UVa Parentheses Balance
Parentheses BalanceTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu
2015-04-08 20:43:08 329
原创 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 450
原创 UVa 1595 Symmetry
SymmetryTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescriptionThe figure shown on the left is left-right symmetric as
2015-03-15 17:44:52 357
原创 UVa 1593 Alignment of Code
Alignment of CodeTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescriptionYou are working in a team that writes Incredib
2015-03-15 16:24:56 329
原创 UVa 10763 Foreign Exchange
Problem EForeign ExchangeInput: standard inputOutput: standard outputTime Limit: 1 secondYour non-profit organization (iCORE - international Confederation of Revolver Enthusiasts) coordi
2015-03-15 15:25:36 289
原创 UVa 10935 Throwing cards away 1
Throwing cards away ITime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescriptionProblem B: Throwing cards away IGiven is
2015-03-15 14:57:56 367
原创 UVa 1594 Ducci Sequence
Ducci SequenceTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescriptionA Ducci sequence is a sequence of n-tuples of int
2015-03-15 13:34:11 334
原创 UVa 232 Crossword Answers
232 - Crossword AnswersTime 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 338
原创 zoj 1383 Binary Numbers
Binary NumbersTime Limit: 2 Seconds Memory Limit: 65536 KBGiven 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 360
原创 zoj 1331 Perfect Cubes
Perfect CubesTime 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 339
原创 zoj 2423 Fractal
FractalTime Limit: 2 Seconds Memory Limit: 65536 KBA 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 480
原创 zoj 1251 Box of Bricks
Box of BricksTime Limit: 2 Seconds Memory Limit: 65536 KBLittle 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 306
原创 zoj 1242 Carbon Dating
Carbon DatingTime Limit: 2 Seconds Memory Limit: 65536 KBUntil 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 719
原创 zoj 1241 Geametry Made Simple
Geometry Made SimpleTime Limit: 2 Seconds Memory Limit: 65536 KBMathematics 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 393
原创 zoj 1240 IBM Minus One
IBM Minus OneTime Limit: 2 Seconds Memory Limit: 65536 KBYou 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 316
原创 zoj 1037 Gridland
GridlandTime Limit: 2 Seconds Memory Limit: 65536 KBBackgroundFor years, computer scientists have been trying to find efficient solutions to different computing problems. For some of
2015-01-30 15:05:32 309
原创 zoj 1067 Color Me Less
Color Me LessTime Limit: 2 Seconds Memory Limit: 65536 KBProblemA 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 441
原创 zoj 1115 Digital Roots
Digital RootsTime Limit: 2 Seconds Memory Limit: 65536 KBBackgroundThe 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 346
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人