#include<iostream> #include<vector> using namespace std; const int N=40010; int pre[N];//并查集 int visit[N];//是否经过 int ancestor[N];//祖先 int dis[N];//储存距离 int result[N];//储存结果 struct tre{ int x,length; }; vector<tre>tree[N]; struct qu{ i…
#include<iostream> #include<vector> using namespace std; const int MAX=10001; int pre[MAX],visit[MAX],indegree[MAX]; vector<int>qury[MAX],tree[MAX]; int ancestor[MAX]; void init(int n) {//初始化 int i; for(i=1;i<=n;i++) { visit[i]=0;…
题目链接:http://poj.org/problem?id=1273 Time Limit: 1000MS Memory Limit: 10000K Description Every time it rains on Farmer John's fields, a pond forms over Bessie's favorite clover patch. This means that the clover is covered by water for awhile and takes…
http://poj.org/problem?id=3461 Oulipo Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 41051 Accepted: 16547 Description The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e'. He was a mem…
POJ 1741. Tree Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 34141 Accepted: 11420 Description Give a tree with n vertices,each edge has a length(positive integer less than 1001). Define dist(u,v)=The min distance between node u and…