2011年4月25日

摘要: 第二个线段树,用malloc申请果断超内存,自己写了个销毁树的函数果断超时。最后还是默默地用数组实现了。2174ms 慢的可怕…… 1 #include <stdio.h> 2 3 typedef struct{ 4 int left,right,max; 5 int lChild,rChild; 6 }SegTree; 7 SegTree list[800000]; 8 9 int max(int a, int b){10 return a > b? a:b;11 }12 void createSegTree(int root, int left, int right){1 阅读全文
posted @ 2011-04-25 22:40 死线之蓝 阅读(375) 评论(0) 推荐(0)
摘要: 第一次学线段树,从头到尾敲了快一小时。其实add和sub是没必要写的,不过想想反正当练手,就敲上去了。 1 #include <stdio.h> 2 #include <string.h> 3 #include <malloc.h> 4 5 typedef struct Seg_Tree{ 6 int left,right; 7 int amount; 8 struct Seg_Tree *lChild, *rChild; 9 }SegTreeNode,* SegTree; 10 11 SegTree createSegTree(int left, int 阅读全文
posted @ 2011-04-25 21:43 死线之蓝 阅读(883) 评论(0) 推荐(0)
摘要: 基本上就是深搜……利用3个数组分别来表示行列宫有哪些数存在,用1个数组记录所有需要填数的位置,深搜过去即可 1 #include <stdio.h> 2 #include <string.h> 3 #include <time.h> 4 int rowok[9][10],colok[9][10],miyaok[9][10]; //用来记录行列宫有哪些数字 5 int sudoku[9][9],place[81][2],p,n; //place用来记录哪些位置需要填数 6 int search(int x, int y){ 7 int i,j; 8 if(p 阅读全文
posted @ 2011-04-25 13:08 死线之蓝 阅读(566) 评论(0) 推荐(0)

导航