摘要: 题意:略分析:多询问问题,利用并查集加速。类似于kruskal对MST的构建:枚举最小的边,逐渐将更大的边加入集合,当查询的点在同一个集合,那么当前最小值,就是所加的最后一条边与第一条只差。注意:当枚举的最小边,把所有大边加入都不能使查询点(a,b)加入同一集合,那么终止枚举。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int MAXN=1111; 7 const int INF=0x7fffffff; 8 9 struct Edge{10 int u,v,c;11 Edge(... 阅读全文
posted @ 2013-10-16 16:33 Thousand Sunny 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 题意:给出n个人的属性(a,b),当A(a,b)与B(a',b')存在关系:(ax1)查找,所有(y2>y1)的点(x2,y2)都失去优势,从集合中删除。注意:若左侧没有点it==s.begin(),必然可以加入。 1 #include 2 #include 3 using namespace std; 4 5 struct P{ 6 int x,y; 7 bool operator s;13 multiset::iterator it;14 15 int main()16 {17 int T,n;18 scanf("%d",&T);19 .. 阅读全文
posted @ 2013-10-16 15:03 Thousand Sunny 阅读(245) 评论(0) 推荐(0) 编辑