Problem   Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Input The first line contains a single integer nn (2≤n≤150000) — the number of kittens. Each of the following n−1lines contains integers xi and yi (1≤xi,…
题目链接 给定一张含$n$个点$m$条边的无向图,每个点有一个重要指数$a_i$.有两种操作:1.在$x$和$y$之间连一条边:2.求$x$所在连通块中重要程度第$k$小的点. --------------------------------- 维护第$k$小,很容易想到权值线段树.看到合并二字,可以想到用线段树合并的方法.维护连通块可以用并查集做. 注意并查集合并的方向和线段树合并的方向要一致.查询的时候要先找出并查集的根再查询. 代码: #include<bits/stdc++.h> us…
[CF878C]Tournament 题意:有k个项目,n个运动员,第i个运动员的第j个项目的能力值为aij.一场比赛可以通过如下方式进行: 每次选出2个人和一个项目,该项目能力值高者获胜,败者被淘汰,胜者继续比赛.最后一个人是冠军. 在一场比赛中,你可以任意安排比赛顺序,任意选择每次的参赛者和项目,现在想知道的是有多少人可能成为最后的冠军. 为了加大难度,一共有n次询问,第i次询问是前i个人进行比赛,问最终由多少人可能成为总冠军. n<=50000,k<=10,aij<=10^9 题解…
题意:给定 3 种操作, 第一种 1 u v 把 u 和 v 合并 第二种 2 l r 把 l - r 这一段区间合并 第三种 3 u v 判断 u 和 v 是不是在同一集合中. 析:很容易知道是用并查集来做,但是如果单纯的用并查集,肯定是要超时的,所以要用链表,如果合并了,就把链表指向, 这样就搞定了这个题. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #i…
P1525 关押罪犯  题目 #include<iostream> #include<cstdlib> #include<cstdio> #include<cmath> #include<cstring> #include<iomanip> #include<algorithm> #include<queue> #include<ctime> #define ll long long #define…
$des$Berland要举行 $n$ 次锦标赛,第一次只有一个人,之后每一次会新加入一个人.锦标赛中有 $k$ 种运动项目,每个人在这 $k$ 种项目上都有一个能力值,每次会选择任意两个还未被淘汰的人进行某个项目的比赛,能力值高的人胜出,输的人被淘汰,直至只剩下一个人成为冠军.给出每个人每个项目的能力值,保证它们两两不同,求每次锦标赛有多少人可能成为冠军. $sol$只要选手 $a$ 在某个项目上比选手 $b$ 强, $a$ 就可以淘汰 $b$,我们可以连一条 $a$ 到 $b$ 的边.对整个…
Codeforces Round #268 (Div. 2)D Codeforces Round #268 (Div. 1)B CF468B D. Two Sets time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little X has n distinct integers: p1, p2, ..., pn. He want…
CF456E Codeforces Round #260 (Div. 1) C Codeforces Round #260 (Div. 2) E http://codeforces.com/contest/455/problem/C C. Civilization time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Andrew p…
C. Not Equal on a Segment 题目连接: http://www.codeforces.com/contest/622/problem/C Description You are given array a with n integers and m queries. The i-th query is given with three integers li, ri, xi. For the i-th query find any position pi (li ≤ pi …
C. Civilization Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/455/problem/C Description Andrew plays a game called "Civilization". Dima helps him. The game has n cities and m bidirectional roads. The cities are numbe…