2018-11-05 20:29:49

### Description

$n,m \le 10^5$

### Output

1. 环上的边
2. 链上的边

代码

#include<cstdio>
#include<algorithm>
#include<iostream>
#define R register
#define lo long long

using namespace std;

const int gz=1e5+8;

inline void in(R int &x)
{
int f=1;x=0;char s=getchar();
while(!isdigit(s)){if(s=='-')f=-1;s=getchar();}
while(isdigit(s)){x=x*10+s-'0';s=getchar();}
x*=f;
}

struct cod{int u,v;lo w;}edge[gz<<2];

lo p[64],dis[gz];

inline void add(R int x,R int y,R lo z)
{
edge[tot].v=y;
edge[tot].w=z;
}

int n,m;

bool vis[gz];

inline void ins(R lo x)
{
for(R int i=63;i>=0;i--)
{
if((x>>i)&1LL)
{
if(p[i])
x^=p[i];
else
{
p[i]=x;
break;
}
}
}
}

inline lo query(R lo o)
{
R lo res=o;
for(R int i=63;i>=0;i--)
if((res^p[i])<res)res^=p[i];
return res;
}

void dfs(R int u,R lo now)
{
vis[u]=true;dis[u]=now;
{
if(!vis[edge[i].v])
dfs(edge[i].v,now^edge[i].w);
else ins(now^edge[i].w^dis[edge[i].v]);
}
}

int main()
{
in(n);in(m);
for(R int i=1,x,y;i<=m;i++)
{
R lo z;
in(x),in(y);
scanf("%lld",&z);
}