http://codeforces.com/contest/962/problem/F

求没有被两个及以上的简单环包含的边

解法:双联通求割顶,在bcc中看这是不是一个简单环,是的话把整个bcc的环加到答案中即可(正确性显然,因为bcc一定是环了,然后如果一个bcc不是简单环,那么所有边一定包含在两个简单环中)

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define ll long long
#define vi vector<int>
#define mod 1000000007
#define C 0.5772156649
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define cd complex<double>
#define ull unsigned long long
#define base 1000000000000000000
#define fio ios::sync_with_stdio(false);cin.tie(0) using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=+,inf=0x3f3f3f3f,INF=0x3f3f3f3f3f3f3f3f; vector<pii>v[N];
int dfn[N],low[N];
int ind,iscut[N],n,m;
vi ans;
struct edge{int u,v,id;};
stack<edge>s;
int bcccnt,bccno[N],ed[N];
vi bcc[N],bb[N];
void tarjan(int u,int f)
{
dfn[u]=low[u]=++ind;
int ch=;
for(int i=;i<v[u].size();i++)
{
int x=v[u][i].fi;
if(x==f)continue;
edge e={u,x,v[u][i].se};
if(!dfn[x])
{
s.push(e);
ch++;
tarjan(x,u);
low[u]=min(low[u],low[x]);
if(low[x]>=dfn[u])
{
iscut[u]=;
bcccnt++;
bcc[bcccnt].clear();
while()
{
edge now=s.top();s.pop();
ed[bcccnt]++;bb[bcccnt].pb(now.id);//printf("%d++++%d\n",bcccnt,now.id);
if(bccno[now.u]!=bcccnt){bcc[bcccnt].pb(now.u);bccno[now.u]=bcccnt;}
if(bccno[now.v]!=bcccnt){bcc[bcccnt].pb(now.v);bccno[now.v]=bcccnt;}
if(now.u==u&&now.v==x)break;
}
}
}
else if(dfn[x]<dfn[u])
{
s.push(e);
low[u]=min(low[u],dfn[x]);
}
}
if(f<&&ch==)iscut[u]=;
}
int main()
{
scanf("%d%d",&n,&m);
for(int i=;i<=m;i++)
{
int a,b;scanf("%d%d",&a,&b);
v[a].pb(mp(b,i)),v[b].pb(mp(a,i));
}
ind=;
for(int i=;i<=n;i++)
if(!dfn[i])
tarjan(i,-);
// for(int i=1;i<=n;i++)printf("%d ",bccno[i]);puts("");
memset(dfn,,sizeof dfn);
for(int i=;i<=bcccnt;i++)
{
if(ed[i]==bcc[i].size()&&ed[i])
{
for(int j=;j<bb[i].size();j++)ans.pb(bb[i][j]);
}
}
sort(ans.begin(),ans.end());
printf("%d\n",ans.size());
for(int i=;i<ans.size();i++)printf("%d ",ans[i]);
puts("");
return ;
}
/***********************
5 6
1 2
1 3
2 3
3 4
4 5
3 5
***********************/

Educational Codeforces Round 42 (Rated for Div. 2)F - Simple Cycles Edges的更多相关文章

  1. Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings

    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://cod ...

  2. Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块

    Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块 [Problem Description] ​ ...

  3. Educational Codeforces Round 42 (Rated for Div. 2) E. Byteland, Berland and Disputed Cities

    http://codeforces.com/contest/962/problem/E E. Byteland, Berland and Disputed Cities time limit per ...

  4. Educational Codeforces Round 42 (Rated for Div. 2) D. Merge Equals

    http://codeforces.com/contest/962/problem/D D. Merge Equals time limit per test 2 seconds memory lim ...

  5. Educational Codeforces Round 42 (Rated for Div. 2) C

    C. Make a Square time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  6. Educational Codeforces Round 42 (Rated for Div. 2) B

    B. Students in Railway Carriage time limit per test 2 seconds memory limit per test 256 megabytes in ...

  7. Educational Codeforces Round 42 (Rated for Div. 2) A

    A. Equator time limit per test 2 seconds memory limit per test 256 megabytes input standard input ou ...

  8. D. Merge Equals(from Educational Codeforces Round 42 (Rated for Div. 2))

    模拟题,运用强大的stl. #include <iostream> #include <map> #include <algorithm> #include < ...

  9. Educational Codeforces Round 42 (Rated for Div. 2)

    A. Equator(模拟) 找权值的中位数,直接模拟.. 代码写的好丑qwq.. #include<cstdio> #include<cstring> #include< ...

随机推荐

  1. genymotion——VT-x is not available (VERR_VMX_NO_VMX) 的解决方案

    进入虚拟机设置页面

  2. Windows server 2003 伪静态配置方法

    Windows server 2003 伪静态配置方法   先我们下载Rewrite伪静态组件到服务器,然后解压到D:\Rewrite下,解压后如下图: 提示:ReWrite组件所在目录要有网站所有者 ...

  3. The adidas NMD XR1 singapore is a bit more cool

    The adidas NMD Singapore continues to be the right silhouette for summer time because of a mix of a ...

  4. Java设计原则—依赖倒置原则(转)

    依赖倒置原则(Dependence Inversion Principle,DIP)的原始定义: 高层模块不应该依赖底层模块,两者都应该依赖其抽象: 抽象不应该依赖细节: 细节应该依赖抽象. 依赖倒置 ...

  5. angular-selcet

    常规用法代码 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> < ...

  6. DevStore分享:详析消费者十大心理学

    做生意,其实就是一个恋爱的过程,让用户找到你.了解你,爱上你.而这个过程中的关键点就是用户.只要与用户心理相关的,那么就会影响到他们的购买决策.而作为卖方的你,就应该了解消费者心里面在想些什么. 第一 ...

  7. Visual studio插件 Reshaper--- 常用快捷键

    快速修复 alt+enter (alt+enter唤出快速修复面板,上下方向键进行选择,再次敲击enter键确定修改) 跳转到对象声明 ctl+鼠标左键 重构-重命名(ctl+r+r) esc键退出 ...

  8. httpd sshd firewalld 很多服务后面的d是什么意思

    在操作系统中,一般系统的服务都是以后台进程的方式存在,而且都会常驻系统中,直到关机才结束.这类服务也称Daemon,在Linux系统中就包含许多的Daemon. 判断Daemon最简单的方法就是从名称 ...

  9. Visual C++的DLL

    动态链接库 (DLL) 是作为共享函数库的可执行文件. 动态链接提供了一种方法,使进程可以调用不属于其可执行代码的函数. 函数的可执行代码位于一个 DLL 中,该 DLL 包含一个或多个已被编译.链接 ...

  10. OpenCV KNN 之 使用方法

    http://blog.csdn.net/WL2002200/article/details/43149229 OpenCV 中KNN构造函数如下. C++: CvKNearest::CvKNeare ...