2011年5月18日

poj 1655

摘要: 题意:一棵树,定义每个节点的balance值:去掉这点节点后的森林里所有树的最大节点数。求出最小的balance值和其所对应的节点编号。代码:#include<iostream>#include<fstream>using namespace std;struct e{ int data; e *next;};e edge[20001];int v[20001];int a[20001];int b[20001];int n;void solve(int s){ int i,j=0,k=0; e *p=edge[s].next; v[s]=1; while(p){ if 阅读全文

posted @ 2011-05-18 21:20 宇宙吾心 阅读(399) 评论(0) 推荐(0)

poj 3264

摘要: rmq代码:#include<iostream>#include<fstream>#include<cmath>using namespace std;int n,m;int dp[50001][20];int b[50001][20];int a[50001];void read(){// ifstream cin("in.txt"); int i,j,k,s,t; cin>>n>>m; for(i=1;i<=n;i++) // cin>>a[i]; scanf("%d",& 阅读全文

posted @ 2011-05-18 20:11 宇宙吾心 阅读(351) 评论(0) 推荐(0)

poj 2195

摘要: 题意:一个row*col的矩阵,m表示人,H表示房子,.表示空地,人数和房子数相等,如下图:5 5HH..m...............mm..H现在要让所有的人都进入不同的房子内,问总共最少走多少步?代码:#include<iostream>#include<fstream>#include<queue>#include<cmath>using namespace std;int n,m;struct e{ int data; int c,f,w; e *next; e *op;};e edge[400];int x[101],y[101], 阅读全文

posted @ 2011-05-18 17:50 宇宙吾心 阅读(999) 评论(0) 推荐(0)

poj 1087

摘要: 题意:有n个不同的插座,有m台不同的机器需要m种插头,有k组转换:插头A能由插头B转换而来。问这些机器最少有几台不能插上插座。代码:#include<iostream>#include<fstream>#include<queue>using namespace std;struct e{ int data; e *next; int c,f; e *op;};e edge[500];int d[500];int start,end;int n,m;int build(){ int i,j,k; queue<int> q; memset(d,0, 阅读全文

posted @ 2011-05-18 16:30 宇宙吾心 阅读(888) 评论(0) 推荐(0)

导航