上一页 1 ··· 19 20 21 22 23 24 25 26 27 ··· 44 下一页
摘要: 题目链接状态转移算是比较好推把,但是匹配字符串很容易会超时,跟以前某个题目的用法很类似,从第i个字母往后找假如到第j个字母匹配了一个单词,这样dp[j] =dp[i-1]+j-i-l[k]+1,取小即可。 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 #include <algorithm> 6 using namespace std; 7 int dp[501]; 8 char str[601][31],s1[6 阅读全文
posted @ 2012-12-04 20:56 Naix_x 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 这个问题还是很有意思的,两个人分别按最优策略从两头取数,问最后的结果。 很简单的一个思路是爆搜就行,当然肯定会超时的。记忆化 一下,就过了。代码真短啊。。。 1 /* 2 ID: cuizhe 3 LANG: C++ 4 TASK: game1 5 */ 6 #include <iostream> 7 #include <cstdio> 8 #include <cstring> 9 #include <cmath>10 using namespace std;11 int sum[101],dp[101][101],p[101];12 int d 阅读全文
posted @ 2012-12-02 19:32 Naix_x 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 以前做过类似的。 1 /* 2 ID: cuizhe 3 LANG: C++ 4 TASK: range 5 */ 6 #include <iostream> 7 #include <cstdio> 8 #include <cstring> 9 #include <cmath>10 using namespace std;11 #define N 50112 char str[N][N];13 int key[N][N],x[N][N],y[N][N];14 int o[N],map[N][N];15 int Min(int a,int b,in 阅读全文
posted @ 2012-12-02 18:49 Naix_x 阅读(231) 评论(0) 推荐(0) 编辑
摘要: 题目链接WA+RE了20次。。。错了近20次发现 算法错了,需要注意优先队列,可是,没写过优先队列的BFS。。。虎哥提示用spfa来搞,然后重新了一个spfa的bfs,一次过了。。。注意特殊数据,DISCUSS有很多需要注意的。。。 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <iostream> 5 #include <queue> 6 using namespace std; 7 int mp1[501][501],mp2[501][ 阅读全文
posted @ 2012-11-29 19:30 Naix_x 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 题目链接纠结中,DFS统计写错了,到最后也没对拍出数据cha了,看了一下别人的写法,过了。 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <queue> 5 #include <iostream> 6 using namespace std; 7 char p[51][51]; 8 int o[51][51],n,m,sr,sc,er,ec,num,z; 9 int a[4] = {-1,0,1,0}; 10 int b[4] = {0,1 阅读全文
posted @ 2012-11-28 16:21 Naix_x 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 题目链接SPFA果真是功能强大,1Y。 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <queue> 5 #include <iostream> 6 using namespace std; 7 #define N 10000000 8 double p1[101][101],p2[101][101],d[101],v; 9 int n;10 int spfa(int str)11 {12 int in[101],u,i;13 memset 阅读全文
posted @ 2012-11-27 19:23 Naix_x 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 题目链接搞笑的题目。。。DFS过的。。。 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <iostream> 5 using namespace std; 6 #define N 10000000 7 int map[101][101],o[101],n,m,val[101],z[101]; 8 int dfs(int x,int a,int b) 9 {10 int i,ans = val[x],t;11 if(b - a > n) retur 阅读全文
posted @ 2012-11-27 17:14 Naix_x 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 题目链接这个题就是找到1 到 2之间的路径上所有经过路的最大值中的最小值。。。有点绕,反正就是最短路的变形。。。没太想清楚怎么写,写了spfa和floyd都错了,没想清楚怎么变形啊。。。一个地方想错了。。。改了都过了。。 1 #include <cstdio>//spfa算法 2 #include <cstring> 3 #include <cmath> 4 #include <queue> 5 using namespace std; 6 #define INF 0x3f3f3f3f 7 #define eps 1e-7 8 double dp 阅读全文
posted @ 2012-11-27 15:05 Naix_x 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 做的我好郁闷啊。。。卡到死了,想了一个暴力方法,枚举骑士和国王相遇的点,再枚举所有的骑士相遇的点。这样复杂度基本上上亿了,然后卡了几天,看了看题解,枚举国王和骑士的相遇的时候只需要枚举国王周围的几个点就行了。。。然后原来写的代码,各种BUG啊。。。各种调试,各种提交,各种错误n,m看错各种变量写错,实在是无语,最后终于检查不出错误了,提交还是挂了。。。找AC代码 换函数。。。最后还是没检查出那里错了,换了跟AC代码的写法,终于过了。。。这题真心不想做第二遍了。。。 1 /* 2 ID: cuizhe 3 LANG: C++ 4 TASK: camelot 5 ... 阅读全文
posted @ 2012-11-27 13:41 Naix_x 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 题目链接注意优先级问题,样例看清楚,过了样例应该就能看出优先级不一样了。 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 using namespace std; 5 char str[13] = "KQRBNP"; 6 int main() 7 { 8 char p[101][101]; 9 int i,j,k,z;10 for(i = 0;i <= 16;i ++)11 {12 gets(p[i]);13 }14 printf("White: 阅读全文
posted @ 2012-11-25 21:34 Naix_x 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 题目链接只要理解了题意之后,就不是很难了。学长们,把题意讲的很明白了。:和.交替出现,坐标系是按平常数学上的坐标系建法。居然1Y了,意外。 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 using namespace std; 5 char p[101][101]; 6 void judge(char *s1,char *s2) 7 { 8 int i,len1,len2; 9 len1 = strlen(s1);10 len2 = strlen(s2);11 for(i = 0; 阅读全文
posted @ 2012-11-25 21:06 Naix_x 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 和POJ上一个题一模一样,把输入顺序变了,改一点就行。 1 /* 2 ID: cuizhe 3 LANG: C++ 4 TASK: shopping 5 */ 6 #include <cstdio> 7 #include <cstring> 8 #include <cmath> 9 #include <queue>10 #include <map>11 using namespace std;12 int p[6],o[6],kk[1001];13 int cl[3001][6],vl[3001];14 int q[6][6][6][ 阅读全文
posted @ 2012-11-23 16:38 Naix_x 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 以前知道白书上的代码,一直不理解,本来以为对欧拉回路定理已经很熟了,就是不明白为什么错,终于对白书上的代码有认识了,就是必须把输出语句给存起来。。不能在函数dfs里输出啊。。。错了N次啊。。为什么要把输出压到栈里,讲解在http://www.nocow.cn/index.php/USACO/fence有提到,貌似是可能存在环的情况,至今不是很明白。和虎哥讨论了一下,直接把在dfs里直接输出的程序给cha掉了。orz一下。。。7 1 2 2 3 3 4 4 1 3 5 5 6 6 3这个数据就是1 2 3 4是一个环,3 5 6也是一个环,到3这个结点时候按字典序查的时候会先搜4,这样就出... 阅读全文
posted @ 2012-11-23 09:54 Naix_x 阅读(256) 评论(0) 推荐(0) 编辑
摘要: 和杭州赛区那个求最短路中的最长路很类似,悲剧的是模版一个地方给敲错了,很细小的错误,我检查了N遍,中间写了floyd,测试一下题意。。WA的都麻木了,这模版敲的很不熟啊。。。 1 /* 2 ID: cuizhe 3 LANG: C++ 4 TASK: butter 5 */ 6 #include <cstdio> 7 #include <cstring> 8 #include <cmath> 9 #include <queue> 10 using namespace std; 11 #define INF 0x3f3f3f3f 12 int... 阅读全文
posted @ 2012-11-22 18:24 Naix_x 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 题目链接熟悉这两个模版。这两个思路差不多,实现方式有所不同,好像dinic应该快一点,但是在POJ上都是16ms....dinic算法 1 #include //dinic算法 2 #include 3 #include 4 #include 5 using namespace std; 6 #define INF 0x7fffffff 7 queue que; 8 int flow[201][201],dis[201]; 9 int n,m;10 int bfs()11 {12 int t,i;13 memset(dis,-1,sizeof(dis));14 w... 阅读全文
posted @ 2012-11-22 16:14 Naix_x 阅读(183) 评论(0) 推荐(0) 编辑
上一页 1 ··· 19 20 21 22 23 24 25 26 27 ··· 44 下一页