摘要: 这道题目也比较简单,先想好怎么写,稍微写写伪代码,之后实现了即可。/*ID: zhangyc1LANG: C++TASK: starry*/#include <string>#include <cstring>#include <cstdlib>#include <cstdio>using namespace std;struct SStar { int nStarNum, nLeft, nRight, nTop, nBottom; bool arrIsStar[100][100]; SStar():nStarNum(1), nLeft(0), 阅读全文
posted @ 2013-04-19 12:24 J.Z's World 阅读(211) 评论(0) 推荐(0) 编辑
摘要: 这道题目是很标准的凸包问题,看了第五章开头的说明,照着写就好。 判断向量夹角用交叉积,右手螺旋,注意交叉积不满足交换率,所以要注意前后顺序。/*ID: zhangyc1LANG: C++TASK: fc*/#include <string>#include <cstring>#include <cstdlib>#include <cstdio>#include <cmath>using namespace std;struct SPoint { double x, y, theta;};SPoint arrPoint[10000], 阅读全文
posted @ 2013-04-19 12:23 J.Z's World 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 这道题没什么难度,开始看错了,以为要输出的是从上到下的顺序。我用的dfs,尝试把一个个矩形从当前图中拿出来,拿出来后将所在位置置为'*',在下次循环时需要恢复未拿走时的字符串。/*ID: zhangyc1LANG: C++TASK: frameup*/#include <fstream>#include <iostream>#include <string>#include <cstring>#include <cstdlib>#include <sstream>#include <vector> 阅读全文
posted @ 2013-04-16 14:45 J.Z's World 阅读(219) 评论(0) 推荐(0) 编辑
摘要: 这道题,我觉得难想到的是 “If there are multiple sets of truck routes that achieve the goal at minimum cost, choose one that shuts down the minimum number of routes.”,也就是如何在多个最小割中,取边数最少的方案。怎么处理这个条件,我想到的方法有点像像用背包问题:先求出最小割P。然后判断路线1到路线M,该路线是否可以在最小割中(判断方式是:去掉该边后的最小这P',如果P-P‘==lenth[i],则该边可以在最小割中),所有满足条件的边组成集合S,下 阅读全文
posted @ 2013-04-15 14:57 J.Z's World 阅读(318) 评论(0) 推荐(0) 编辑
摘要: 开始试图找挪动的规律,找了半天,成功的挪动规律虽然没找到,但发现了失败的规律。如果出现两个连续的W或B,而它的连续没能连续到边界,则铁定失败。如:...W..BB..W.. 或者 ..B..WW..B..于是,可以递归挪动了~,速度很快,基本为0/*ID: zhangyc1LANG: C++TASK: shuttle*/#include <fstream>#include <iostream>#include <string>#include <cstring>#include <cstdlib>#include <stack& 阅读全文
posted @ 2013-04-11 18:31 J.Z's World 阅读(225) 评论(0) 推荐(0) 编辑
摘要: 这道题感觉没什么困难的。只是注意,不要重复。(也可以在输出的时候控制不输出重复结果)/*ID: zhangyc1LANG: C++TASK: lgame*/#include <fstream>#include <iostream>#include <string>#include <cstring>#include <cstdlib>#include <queue>using namespace std;char strGiven[10], strDict[10];int nSizeGiven = 0;int arrWei 阅读全文
posted @ 2013-04-11 18:27 J.Z's World 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 第一问,判断各节点被删除之后,是否可以从起点到终点,如不可以,则满足要求。第二问在第一问基础上,我用的bfs,判断是否成功:将图从当前节点分割成两部分(如果只分成了一部分,则为失败),是否所有边都为内部边,若是则当前节点满足。/*ID: zhangyc1LANG: C++TASK: race3*/#include <fstream>#include <iostream>#include <string>#include <cstring>#include <cstdlib>#include <queue>using nam 阅读全文
posted @ 2013-04-11 18:24 J.Z's World 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 这道题无论横着,竖着,一行/列来整体放都会超时,想不到什么好办法。只好写了个超长的switch case语句,想清楚瞅仔细,就省得调试麻烦了。//00-17-11-18-03//21-04-22-08-15//12-19-05-20-10//23-07-24-06-16//02-13-09-14-01上图是处理顺序,从00--24. 实际只用了15个case,因为有一些是可以计算出来的。之所以是这个顺序是为了把循环次数小的case放前头。运行速度还是很快的。/*ID: zhangyc1LANG: C++TASK: prime3*///00-17-11-18-03//21-04-22-08-15 阅读全文
posted @ 2013-04-11 18:17 J.Z's World 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 这道题的第一问比较简单,以a[i]结尾的最长减数列的长度f(i) = max{f(j)| j < i, a[j] > a[i]} + 1。第二问,可以先考虑简单一点的,不考虑重复的话,以a[i]结尾的最长减数列的个数 g(i) =∑{g(j)| j < i, a[j] > a[i], f(j) = f(i) - 1},我们要做的只是从中去除重复的情况,考虑一个例子:.......64(1)......64(2)....a[i](小于64)....64(1) 之前长度为L的减数列,将其与64(2)组合肯定还是一个减数列,而且64(2)为结尾的减数列最长长度肯定是 不小于L 阅读全文
posted @ 2013-04-02 09:16 J.Z's World 阅读(225) 评论(0) 推荐(0) 编辑
摘要: 这道题很抱歉,基本谈不上算法,暴力搜索过了(测试数据比较简单..)。唯一的收获就是把方差这个东西又捡起来好好复习了一下。注意:极差(最小和最大值的差)和方差的大小没有因果关系。代码如下:/*ID: zhangyc1LANG: C++TASK: cowcycle*/#include <fstream>#include <iostream>#include <cstdlib>#include <cstring>using namespace std;ofstream fileout("cowcycle.out");double a 阅读全文
posted @ 2013-03-20 15:58 J.Z's World 阅读(158) 评论(0) 推荐(0) 编辑