题目链接:https://codeforces.com/contest/1250/problem/N 题意:给定一个图,点从1到1e9,边有2e5,修改一些边,使得最后所有边都在同一集合 题解:由于点比较多,需要离散化;对于每个联通块,把dfs过程中把每个联通块的最后遍历的点以及所在的边进行修改即可。
#include
using namespace std;
const int maxn=200010;
int n;
struct edge{
int v,nxt,id;
}e[maxn*2];
int head[maxn],tot;
struct node{
int x,y;
}a[maxn];
int b[maxn*2],bn;
int fa[maxn*2];
bool vis[maxn];
int pos,id;
void init(){
tot=0;
for(int i=0;i
关注
打赏
热门博文