11 2012 档案

摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1532题意: 从1开始到终点n,最多能通过多少的流量,就比如说1到2的流量是20,2到3的流量是10,那么到达终点3的流量为10,而1到2还能经过10的流量,2到3不能再通过。坑爹: 每次找到一条增广轨的时候要补一个反向的边,不然你走这一条路就认为你一定走了,因为有可能这条路不是最佳的路径。解法: 利用BFS搜索点,找到终点就返回1,没有则返回0,再设置一个maxflow函数,只要BFS的返回值为1,就将这条增广轨上的最大可以通过的流量(min)算出来(利用change_map函数),然后 max_fl... 阅读全文
posted @ 2012-11-24 17:38 pc.... 阅读(240) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1166View Code 1 /* 2 树状数组(二叉索引树,Binary Indexed Tree,BIT) 3 4 5 */ 6 7 #include <iostream> 8 #include <string> 9 using namespace std;10 11 const int maxn = 50010;12 int sum[maxn];13 int a[maxn];14 int n ;15 16 int lowbit (int x) //取x的最低位1,比如4,则... 阅读全文
posted @ 2012-11-10 12:15 pc.... 阅读(127) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1251题意: 给出你一些单词,然后在给出一些前缀,然后问你这些前缀是前面给的单词的前缀的有多少个。坑爹: 解法: 简单字典树。View Code 1 #include<iostream> 2 using namespace std; 3 4 struct Node 5 { 6 int a; 7 struct Node *son[26]; 8 int flag; 9 };10 struct Node *root;11 char str[26];12 13 void init(s... 阅读全文
posted @ 2012-11-03 16:50 pc.... 阅读(175) 评论(0) 推荐(0)