上一页 1 ··· 38 39 40 41 42 43 44 45 46 ··· 99 下一页

2011年8月8日

hdu 3549 Flow Problem 基本网络流。

摘要: #include <stdio.h>#include <string.h>#include <stdlib.h>#include <deque>using namespace std;int cap[100][100];int a[100];int flow[100][100];int path[1010];int N,M;const int inf = 0x7f7f7f7f;int f;void BFS( ){ int i, j, k, t, u, v; f = 0; memset(flow, 0, sizeof(flow)); for (; 阅读全文

posted @ 2011-08-08 09:30 more think, more gains 阅读(170) 评论(0) 推荐(0) 编辑

敌兵布阵 线段树 数组

摘要: #include<stdio.h>#include<string.h>struct node{ int r,l,val;}a[500000*3];int c[60000];/*动态和静态的差别。动态结构较为灵活,但是速度较慢;静态结构节省内存,速度较快。链表我用啦125ms,7376k数组,78ms,1944k树状数组62ms,388k*/int creat_tree(int l,int r,int i){ int mid; a[i].r=r;a[i].l=l; if(r==l) return a[i].val=c[r]; mid=(a[i].r+a[i].l)/2; 阅读全文

posted @ 2011-08-08 08:45 more think, more gains 阅读(168) 评论(0) 推荐(0) 编辑

敌兵布阵 线段树 链表

摘要: #include<stdio.h>#include<string.h>int c[60000];struct node{ struct node *rchild,*lchild; int right,left,val;};int creat_tree( int l,int r,struct node *q){ int mid; struct node *q1,*q2; q1=new node,q2=new node; q->lchild=q1,q->rchild=q2; q->left=l; q->right=r; if(q->right= 阅读全文

posted @ 2011-08-08 08:44 more think, more gains 阅读(198) 评论(0) 推荐(0) 编辑

线段树的第一个程序

摘要: 线段树的第一个程序问题是现在已知n条线段,把端点依次输入告诉你,然后有m个询问,每个询问输入一个点,要求这个点在多少条线段上出现过;数据量有可能很大。如40000条线段,询问3000次,算法复杂度为40000*3000,这样不用线段树做就会超时。。。刚学线段树,用数组写的,建立完全二叉树。。把问题得规模缩小了。。。#include <stdio.h>int sum=0, a1, a2; /* 顺序存储,数组,建立满二叉树 */struct node { int left; // 左端点 int right; // 右端点 int n; // 记录线段出现得次数}a[10000]; 阅读全文

posted @ 2011-08-08 08:37 more think, more gains 阅读(120) 评论(0) 推荐(0) 编辑

2011年8月6日

World Exhibition hdu 3592 差分约束

摘要: #include <stdio.h>#include <string.h>#include <stdlib.h>#include <vector>#include <deque>using namespace std;const int inf = 0x7f7f7f7f;struct node { int x, v; }Nd;int N1,M1,P1,f1;vector<node>T[11010];deque<int>q;bool flag[11010] = {false};int dis[11020];int 阅读全文

posted @ 2011-08-06 07:59 more think, more gains 阅读(144) 评论(0) 推荐(0) 编辑

上一页 1 ··· 38 39 40 41 42 43 44 45 46 ··· 99 下一页

导航