随笔分类 -  01. . . . . |UVA

UVA 1594:Ducci Sequence (模拟 Grade E)
摘要:题意:对于一个n元组(a0,a1,...),一次变换后变成(|a0-a1|,|a1-a2|,...)问1000次变换以内是否存在循环。思路:模拟,map判重代码:#include #include #include #include #include using namespace std;stru... 阅读全文

posted @ 2014-10-17 20:19 ShineCheng 阅读(854) 评论(1) 推荐(1)

UVA 1593: Alignment of Code(模拟 Grade D)
摘要:题意:格式化代码。每个单词对齐,至少隔开一个空格。思路:模拟。求出每个单词最大长度,然后按行输出。代码:#include #include #include char words[1200][190][90];int maxLen[190];char tmp[200];typedef char * ... 阅读全文

posted @ 2014-10-17 19:59 ShineCheng 阅读(823) 评论(0) 推荐(0)

UVA 1589:Xiangqi (模拟 Grade D)
摘要:题目:象棋,黑棋只有将,红棋有帅车马炮。问是否死将。思路:对方将四个方向走一步,看看会不会被吃。代码:很难看……WA了很多发,还越界等等。#include #include #include char graph[13][13];int go[4][2] = {{1,0},{0,1},{-1,0},... 阅读全文

posted @ 2014-10-16 21:45 ShineCheng 阅读(1613) 评论(1) 推荐(0)

UVA 1604:Cubic Eight-Puzzle(模拟,BFS Grade C)
摘要:题意:3*3方格,有一个是空的。其他的每个格子里有一个立方体。立方体最初上下白色,前后红色,左右蓝色。移动的方式为滚。给出初态空的位置,终态上面颜色情况,问最少多少步能到达。如果超过30步不能到达,-1。思路:模拟。另外再加了一个A*优化。就是估计一下。应该还能优化的。感觉像二进制上可以优化。实在不... 阅读全文

posted @ 2014-10-15 19:33 ShineCheng 阅读(435) 评论(0) 推荐(0)

UVALive 6451:Tables(模拟 Grade D)
摘要:VJ题目链接题意:模拟输出表格思路:模拟……很暴力代码:#include #include #include #include using namespace std;int graph[100][100];int main() { int n; while (scanf("%d", &... 阅读全文

posted @ 2014-10-02 16:05 ShineCheng 阅读(189) 评论(0) 推荐(0)

UVA 11925:Generating Permutations(冒泡排序 Grade D)
摘要:VJ题目链接题意:n个数(n#include #include using namespace std;#define n 1023int a[n+10];int n;int hd;bool check() { for (int i = 1; i a[(hd+1)%n] && (!(a[hd... 阅读全文

posted @ 2014-10-01 14:05 ShineCheng 阅读(317) 评论(0) 推荐(0)

UVALive 3507:Keep the Customer Satisfied(贪心 Grade C)
摘要:VJ题目链接题意:知道n(n d[j]。假设我们现在有一个工作方案,使得i工作在j工作之前完成。如 ..., i , ... , j , ...记做 preI, i, midIJ, j, afterJ此时将这个工作方案的i移动到j后面一个完成,其他不动。则变成 preI , midIJ , j ,... 阅读全文

posted @ 2014-09-29 16:12 ShineCheng 阅读(223) 评论(0) 推荐(0)

UVALive 3835:Highway(贪心 Grade D)
摘要:VJ题目链接题意:平面上有n个点,在x轴上放一些点,使得平面上所有点都能找到某个x轴上的点,使得他们的距离小于d。求最少放几个点。思路:以点为中心作半径为d的圆,交x轴为一个线段。问题转换成用最少的店覆盖所有的线段。经典贪心。按右点从小到大排序,然后从左往右扫,每次选择区间右点就行了。代码:#inc... 阅读全文

posted @ 2014-09-29 14:52 ShineCheng 阅读(130) 评论(0) 推荐(0)

UVALive 3517:Feel Good(单调栈 Grade C)
摘要:VJ题目链接题意:n个数,求区间[l,r] 使得 sum[l,r]*min(a[l],a[l+1],...,a[r]) 最大。若有多种答案,输出区间最短的。若还有多组,输出最先出现的。思路:求出a[i]为最小数时,最大的区间范围,即求a[i]的最左边的小于a[i]的位置,最右边的位置。坑点:因为要最... 阅读全文

posted @ 2014-09-29 11:08 ShineCheng 阅读(307) 评论(0) 推荐(0)

UVALive 3664:Guess(贪心 Grade E)
摘要:vj题目链接题意:有n (n#include #include using namespace std;#define N 20000struct Man{ int a[3]; int possible[8]; void read() { for (int i = 0... 阅读全文

posted @ 2014-09-26 20:03 ShineCheng 阅读(246) 评论(0) 推荐(0)

uva 1611:Crane(构造 Grade D)
摘要:题目链接题意:一个序列,你可以选择其中偶数长度的一段,然后中间切开,左右两段交换。现给你一个1~n的某个排列,求一个交换方案,使得排列最终有序。(交换次数 #include #include #include #include using namespace std;#define N 10100i... 阅读全文

posted @ 2014-09-26 11:57 ShineCheng 阅读(283) 评论(0) 推荐(0)

uva 177:Paper Folding(模拟 Grade D)
摘要:题目链接题意:一张纸,每次从右往左对折。折好以后打开,让每个折痕都自然的呈90度。输出形状。思路:模拟折……每次折想象成把一张纸分成了正面在下的一张和反面在上的一张。维护左边和方向,然后输出。细节有点多。代码:#include #include #include #include using nam... 阅读全文

posted @ 2014-09-25 23:09 ShineCheng 阅读(429) 评论(0) 推荐(0)

UVALive 6514:Crusher’s Code(概率dp)
摘要:题目链接 https://icpcarchive.ecs.baylor.edu/external/65/6514.pdf题意:给出n个数(n a[max(i,j)]) swap(a[i], a[j]) ;}//Carlos's Codewhile (!sorted(a)) { int i... 阅读全文

posted @ 2014-09-25 21:02 ShineCheng 阅读(238) 评论(0) 推荐(0)

uva 11491:Erasing and Winning(贪心)
摘要:题意:给一个长n(n a[i-1],则删除a[i-1]。我暴力的用链表实现了……#include #include #include #include using namespace std;#define N 100020char str[N];int main() { int n, d; ... 阅读全文

posted @ 2014-09-24 19:44 ShineCheng 阅读(561) 评论(0) 推荐(1)

uva 1149:Bin Packing(贪心)
摘要:题意:给定N物品的重量,背包容量M,一个背包最多放两个东西。问至少多少个背包。思路:贪心,最大的和最小的放。如果这样都不行,那最大的一定孤独终生。否则,相伴而行。代码:#include #include #include using namespace std;#define N 100100int... 阅读全文

posted @ 2014-09-23 21:56 ShineCheng 阅读(257) 评论(0) 推荐(0)

uva 1442:Cave(贪心)
摘要:题意:一个洞穴长n,告诉你每个位置的地面高度和顶部高度,让你往里灌水,要求水不能碰到天花板(但可以无限接近)。求最多的水量。(洞穴两边视为封闭)思路:如果知道一个位置向左看最高可以多高,向右看最高可以多高,就可以知道这个位置最终的高度了。方法是扫两次。每次扫的时候,定义一个之前最高值。若之前最高值高... 阅读全文

posted @ 2014-09-23 21:37 ShineCheng 阅读(187) 评论(0) 推荐(0)

UVA - 10288 Coupons
摘要:题形:概率DP题意:收集齐n个不同的优惠卷的期望开箱次数。(开一次箱子会等概率的得到其中一张优惠卷)思路:期望递推法。正常做就行。就是分数输出麻烦了点。e[i] = i/n(e[i]+1) + (n-i)/n(e[i+1]+1)然后移项,递推就行了。代码:#include #include #include #include using namespace std;#define N 50 struct fraction { long long numerator; // 分子 long long denominator; // 分母 fraction() { ... 阅读全文

posted @ 2014-03-07 16:15 ShineCheng 阅读(339) 评论(0) 推荐(0)

导航