上一页 1 ··· 29 30 31 32 33 34 35 36 37 ··· 44 下一页
摘要: 题目链接好久没有 搞递推,这个题在DP专题,其实是赤裸裸的一维的递推,想了好一会啊。F(n)可以由第一个不放F(n-1)加第一个放第二个不放f(n-2)加。。。F(N) = F(N-1)+F(N-2)...F(N-M)删除中间输出的时候,改错了2次。。。 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 __int64 p[51]; 5 int main() 6 { 7 int bi[7]; 8 int i,j,n,m; 9 bi[0] = 1;10 for(i = 1;i 阅读全文
posted @ 2012-08-15 20:55 Naix_x 阅读(285) 评论(0) 推荐(0) 编辑
摘要: 题目链接这种黑白问题,遇到好几次了,杭电1838和这个非常类似,这个题是他的加强版,不仅要求正方形还要求矩形的最大面积。先是两个标记数组o1,o2标记颜色不同的最大长度。sq存在正方形的最大边长正方形的状态转移就是if(p[i][j] == p[i-1][j-1])sq[i][j] = getmin(sq[i-1][j-1]+1,o1[i][j],o2[i][j]);最复杂的是矩形的最大面积。矩形分两种情况,一种是横着,一种是竖着放,开4个数组分别标记长宽。最后找最大就好。写的有点繁琐。PS:刚看了一下讨论区,我晕我的程序这么搓啊,内存多+程序跑的慢。。。 1 #include <std 阅读全文
posted @ 2012-08-15 19:22 Naix_x 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 题目大意:n个人要分成两个队,m种敌对关系,选出两个相同人数去比赛,一个人至多有两个敌人,敌对的不能在一个队伍,求最少有个人不能上场。我竟然没发现一个人至多有两个敌人这句话。。。然后就悲剧啊!!!用并查集去判断,是否存在奇数环。。研究了好一会别人代码。。才发现了那个条件,我本来以为并查集有很神的用法或者有证明神马的呢。。这就算个规律题吧。 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #include <math.h> 5 #define N 10000000 阅读全文
posted @ 2012-08-15 17:16 Naix_x 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 题目链接模板。 1 #include <stdio.h> 2 #include <string.h> 3 #include <math.h> 4 #define eps 1e-9 5 double px[101],py[101]; 6 double cross(double x1,double y1,double x2,double y2) 7 { 8 return x1*y2 - x2*y1; 9 }10 int main()11 {12 int n,i;13 double sum;14 while(scanf("%d",&n) 阅读全文
posted @ 2012-08-14 10:19 Naix_x 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 题目链接写的太渣了,依旧RE了几次。。。 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 char str[500001][101]; 5 char word[500001]; 6 char ch[5001]; 7 struct node 8 { 9 int flag; 10 struct node *next[26]; 11 }; 12 int num = 1; 13 struct node *build() 14 { 15 int i; 16 struct... 阅读全文
posted @ 2012-08-13 20:36 Naix_x 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 题目链接我那个纠结啊。。。。看了大半天终于,把tire树敲出来,数组开小RE了N次,还死活以为是指针越界别的什么的。。。没看开始字符数组开小了。。无语啊。 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 char word[50001][101]; 5 struct node 6 { 7 int flag; 8 struct node *next[26]; 9 };10 struct node *build()11 {12 int i;13 struct node *p;1 阅读全文
posted @ 2012-08-13 16:56 Naix_x 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 题目链接和求最大子矩阵和,神似。。。宝哥用树状数组做的,数据量挺小的,我直接暴力O(n^2)水过了。。 1 #include <stdio.h> 2 #include <string.h> 3 int p[101][101],o[101][101],map[101][101],key[101][101]; 4 int main() 5 { 6 int i,j,x,y,n,m,nu,r,c,max; 7 while(scanf("%d",&nu)!=EOF) 8 { 9 if(!nu) break;10 memset(p,0,sizeof(.. 阅读全文
posted @ 2012-08-12 19:34 Naix_x 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 题目链接先是经典的DP,敲的不熟啊,很久没打了吗?初始化都忘了,调试了会,然后过了样例各种WA,不过也应该,那次多校完,就听说是编辑距离,就按照等于算的,看了下题解是小于等于,越来越不愿意看题了。1#include<stdio.h>2#include<string.h>3#include<stdlib.h>4#include<math.h>5#defineN1000000006intmin(intx,inty,intz)7{8intq;9q=x;10if(q>y)11q=y;12if(q>z)13q=z;14returnq;15}16 阅读全文
posted @ 2012-08-12 16:34 Naix_x 阅读(206) 评论(0) 推荐(0) 编辑
摘要: 题目链接问了下学长,开始质量+价值反着背包,老是WA,油耗作为体积,核电做价值就AC了。。反着背的时候 没取最小值啊 。。。。又想当然的以为大于1/2的时候,输出就行了,得取最小啊!!!! 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #include <math.h> 5 #define N 10000000 6 int p[101][101],low[101],v[101],key[20000]; 7 int main() 8 { 9 int t,i,j, 阅读全文
posted @ 2012-08-11 19:28 Naix_x 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 题目链接好繁琐,想了好半天,开始以为暴搜。。比赛时一直卡这个题了,暴搜不出结果换了一个5维背包。。。瞎改一下过了,样例。。。交WA。。再改还是WA。。。自己对背包,理解的太肤浅啊。。。其实我也不知道为什么过,在多次,WA后,正着写就A了,倒着写就是WA。。。 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #include <math.h> 5 int p[6],o[6],kk[1001]; 6 int cl[3001][6],vl[3001]; 7 int q 阅读全文
posted @ 2012-08-11 15:36 Naix_x 阅读(336) 评论(0) 推荐(0) 编辑
摘要: 题目链接裸Kruskal。注意两个圆想加的时候特判。无奈比赛时,没看懂题意。。求翻译啊。。 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #include <math.h> 5 struct node 6 { 7 int sv; 8 int ev; 9 double w;10 }p[100000];11 int o[101];12 double x[101],y[101],z[101],r[101];13 int num;14 double sum1;15 i 阅读全文
posted @ 2012-08-11 14:53 Naix_x 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 题目链接蛋疼的精度,蛋疼的多组数据。。 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #include <math.h> 5 #define eps 1e-9 6 double a,b; 7 double getsum(double c) 8 { 9 double p,sum = 0;10 p = (a+b+c)/2;11 sum += sqrt(p*(p-a)*(p-b)*(p-c));12 sum += c*c/4;13 return sum;14 }15 阅读全文
posted @ 2012-08-10 20:32 Naix_x 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 题目链接调试了好一会。。把模版上的lz标记,如何满足题意就OK了。。。 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #define N 100001 5 int p[4*N],lz[4*N]; 6 void pushup(int rt) 7 { 8 p[rt] = p[rt<<1]+p[rt<<1|1]; 9 }10 void pushdown(int rt,int m)11 {12 if(lz[rt])13 {14 lz[rt<<1 阅读全文
posted @ 2012-08-10 17:30 Naix_x 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 题目链接这个真费劲。。。其实我也不懂 为什么。。。大体思想是,如果把区间更新了,开始的时候只把用懒惰标记标记那个区间,而不更新底层元素,而如果查询的时候顺带着把lz标记给消除。。。多敲几遍,多调试一下,看看中间过程,就应该理解了。 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #define N 100001 5 #define ll __int64 6 ll p[4*N],lz[4*N]; 7 void pushup(int rt) 8 { 9 p[rt] = p[rt 阅读全文
posted @ 2012-08-10 16:16 Naix_x 阅读(204) 评论(0) 推荐(0) 编辑
摘要: 题目链接线段树 不熟啊。。。#include <stdio.h>#include <stdlib.h>#include <string.h>#define N 262145__int64 sum;struct node{ int l; int r; __int64 v;}p[4*N];void push(int rt){ p[rt].v = p[rt<<1].v+p[rt<<1|1].v;}void build(int l,int r,int rt){ int m; p[rt].l = l; p[rt].r = r; if(l == 阅读全文
posted @ 2012-08-10 10:35 Naix_x 阅读(152) 评论(0) 推荐(0) 编辑
上一页 1 ··· 29 30 31 32 33 34 35 36 37 ··· 44 下一页