摘要: http://poj.org/problem?id=1192题目大意:有一棵树,节点有整型的权值,如果定义,树中所有节点的权值和为树的权值,题目是求权值最大的子树 1 #include <stdio.h> 2 #include <string.h> 3 #include <vector> 4 5 #define N 1010 6 7 using namespace std; 8 9 int n, x[N], y[N], c[N], mark[N] = {0};10 vector<int> a[N];11 12 int abs(int x)13 { 阅读全文
posted @ 2013-03-27 22:47 Yuan1991 阅读(234) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=2378树状DP 1 #include <stdio.h> 2 #include <string.h> 3 #include <vector> 4 #include <set> 5 6 #define N 10010 7 8 using namespace std; 9 10 vector<int> a[N];11 set<int> set1;12 set<int>::iterator it;13 14 int n, father[N] = {0};15 16 阅读全文
posted @ 2013-03-27 16:32 Yuan1991 阅读(140) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=1655树状DP,双向建图,以1为树的根节点遍历一遍 1 #include <stdio.h> 2 #include <string.h> 3 #include <vector> 4 5 #define N 20010 6 7 using namespace std; 8 9 vector<int> a[N];10 11 int n, mark[N], result, resulti;12 13 int dfs(int x)14 {15 int i, j, temp, sum = 1, max_ 阅读全文
posted @ 2013-03-27 11:23 Yuan1991 阅读(141) 评论(0) 推荐(0)