您当前的位置: 首页 >  图论

对方正在debug

暂无认证

  • 5浏览

    0关注

    399博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

N - Wires(dfs 图论 离散化)

对方正在debug 发布时间:2019-11-13 21:50:29 ,浏览量:5

题目链接: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            
关注
打赏
1664895754
查看更多评论
0.0436s