2013年8月10日

Cut Pieces (数学分析---杭电第六场)

摘要: 【题目链接】http://acm.hdu.edu.cn/showproblem.php?pid=4655Problem DescriptionSuppose we have a sequence of n blocks. Then we paint the blocks. Each block should be painted a single color and block i can have color 1 to color ai. So there are a total of prod(ai) different ways to color the blocks. Consider 阅读全文

posted @ 2013-08-10 00:28 Gddxz 阅读(161) 评论(0) 推荐(0) 编辑

2013年7月29日

图的深搜和广搜模板(多校联合第一场Park Visit)

摘要: #include #include #include #include #include using namespace std;int ans,end;vector graph[100001];int visited[100001] = {0};typedef struct{ int v,n;}Node; void dfs(int v){ vector::iterator it; visited[v] = 1; //printf("%5d", v); for (it = graph[v].begin(); it != graph[v].end(); ++it) ... 阅读全文

posted @ 2013-07-29 15:14 Gddxz 阅读(172) 评论(0) 推荐(0) 编辑

深度优先模板(POJ2488)

摘要: #include #include int dir[8][2]={{-2,-1},{-2,1},{-1,-2},{-1,2},{1,-2},{1,2},{2,-1},{2,1}};int flag[100][100],cnt,m,n;struct node{ char letter; int num;}arr[1000];void dfs(int a,int b,int cur){ /*赋值*/ arr[cur].letter='A'+a-1; arr[cur].num=b; flag[a][b]=1; /*判断结束条件*/ if(cur==m*n) { cnt=cur; re 阅读全文

posted @ 2013-07-29 11:34 Gddxz 阅读(119) 评论(0) 推荐(0) 编辑

2013年7月28日

广度优先搜索模板(poj2251)

摘要: 我的广度优先搜索的大致框架。。【代码】:#include #include #include #include using namespace std;typedef struct{ int x,y,z; int n;}Point;int dir[6][3]={-1,0,0,1,0,0,0,-1,0,0,1,0,0,0,-1,0,0,1};char map[31][31][31];int l,r,c,ans,flag[31][31][31];int Judge(int x,int y,int z){ if(x>=0 && x=0 && y=0 && 阅读全文

posted @ 2013-07-28 21:49 Gddxz 阅读(305) 评论(0) 推荐(0) 编辑

2013年7月27日

poj 3295 Tautology(经典构造算法题)

摘要: 思路:1)使用递归模拟,用备忘录优化,否则超时 另外:学到了一个不用递归即可枚举构造0-1序列的方法for(i=0;i>j)%2;【源程序】:#include "stdio.h"#include "string.h"int arr[101],flag,note[101][101];int IsCorrect(char *s,int start,int end){ if(note[start][end]!=-1) return note[start][end]; int i; if(end==start) { if(s[start]='p&# 阅读全文

posted @ 2013-07-27 13:59 Gddxz 阅读(208) 评论(0) 推荐(0) 编辑

2013年7月26日

大数模板(以poj2109为应用实例)

摘要: 主函数函数之外部分为大数模板,题目相关只在主函数中涉及。#include #include #include #include #include #include #define abs(a) ((a)>=0?(a):-(a)) using namespace std; //---------------------------------大数模板------------------------------------- class LargeInteger{public: LargeInteger(const char * s); LargeInteger(unsigned... 阅读全文

posted @ 2013-07-26 13:32 Gddxz 阅读(187) 评论(0) 推荐(0) 编辑

Flip Game(poj1753_阵列的枚举)

摘要: 题目:http://poj.org/problem?id=1753思路1:0MS1)递归枚举第一行,16种情况;2) 然后分别通过下一行的翻转来使上一行全‘b’或全'w';3)一旦第一行16种情况的其中一种形成,则下面的翻转情况就唯一确定了,所以枚举量为16;4)最后检查最后一行是否全‘b’或全‘w’来判断满不满足全‘b’或全‘w’。思路2:还可使用高斯消元法做#include #include #define INF 20int cnt1;char anti(char c){ if(c=='b') c='w'; else c='b 阅读全文

posted @ 2013-07-26 09:23 Gddxz 阅读(143) 评论(0) 推荐(0) 编辑

2013年7月24日

最长递增子序列(LIS) nlog(n)算法

摘要: 转自: http://www.felix021.com/blog/read.php?1587今天回顾WOJ1398,发现了这个当时没有理解透彻的算法。看了好久好久,现在终于想明白了。试着把它写下来,让自己更明白。最长递增子序列,Longest Increasing Subsequence 下面我们简记为 LIS。排序+LCS算法 以及 DP算法就忽略了,这两个太容易理解了。假设存在一个序列d[1..9] = 2 1 5 3 6 4 8 9 7,可以看出来它的LIS长度为5。下面一步一步试着找出它。我们定义一个序列B,然后令 i = 1 to 9 逐个考察这个序列。此外,我们用一个变量Len来记 阅读全文

posted @ 2013-07-24 13:52 Gddxz 阅读(213) 评论(0) 推荐(0) 编辑

2013年7月23日

暑期集训心得

摘要: 7.23(暑期集训第三天):收获:1.大概知道了哪些题自己能做,哪些题自己做不出来,这样就不至于比赛时妄想面面俱到,结果面面不到的尴尬场面;2.平时训练的题真是太水了,真到比赛时觉得赛题真是天方深不可测!完全比比赛低了不止一个档次!所以我决定以 后拿真是的赛题来训练!3.写程序怎样才能一次AC?怎样才能不漏洞百出?怎样才能不会给自己设一个死活都找不出来的陷阱?怎样才能不断优化? 那就是你要对你写的每一段,每一句代码负责!敲代码时一定要搞明白写这段代码的前因后果,前前后后的影响都要想的 清清楚楚!写代码不允许有一处含糊的地方!!同样,没有深究到底并完全想明白的的想法不要去写(除了万一)!! 阅读全文

posted @ 2013-07-23 20:21 Gddxz 阅读(120) 评论(0) 推荐(0) 编辑

Radar Installation(POJ1328转化为活动安排问题)

摘要: 【题目链接】:点击打开链接【解题思路】:刚开始没思路,但感觉是挺简单的动态问题,要么是贪心,要么动态,凭直觉认之为贪心(水平有限,暂时只能凭感觉)但如何贪心呢?无从下手啊,如果先按横坐标再按纵坐标排序,那最终距离X轴的距离并不是与之一样同序的,所以暂时 没有想法。。。 后来,索性把之前做过的一道贪心题(buct-oj 2082: Cover The Enemy)拿过来重温,受其启发,原来选择贪心要先选择一个合适的顺序,按先横坐标后纵坐 标的关系排列的话仍然距离关系无法确定,所以干脆将距离预处理一下,将距离作为贪心选择顺序的依据,这样为最大限 度利用雷达监测范围,对于某一个点可在X轴求出能够被雷 阅读全文

posted @ 2013-07-23 20:06 Gddxz 阅读(179) 评论(0) 推荐(0) 编辑

导航