CodeForces 103B Cthulhu
http://codeforces.com/problemset/problem/103/B
找环,一个环
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=511111;
int mm[105][105];
bool vis[1005];
int m,n;
void dfs(int u)
{vis[u]=1;for(int i=1;i<=n;i++){if(vis[i]==0&&mm[u][i]==1)dfs(i);}
}
int main()
{while(~scanf("%d%d",&n,&m)){int i;for(i=0;i<m;i++){int u,v;cin>>u>>v;mm[u][v]=mm[v][u]=1;}int flag=0;memset(vis,0,sizeof(vis)); dfs(1);for(int i=1;i<=n;i++)if(!vis[i])flag=1;if(flag==0&&m==n)cout<<"FHTAGN!"<<endl;else cout<<"NO"<<endl;}return 0;
}
CodeForces 103B Cthulhu相关推荐
- Codeforces 103B. Cthulhu 并查集运用
题目链接: 题面: ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to ...
- Codeforces 103B - Cthulhu(并查集 找环和块)
传送门:https://codeforces.com/problemset/problem/103/B 题意: 给一个n个结点,m条边的无向图 判断给定图是否满足以下条件: 能被表示为有3个及以上的有 ...
- Codeforces 103B Cthulhu
题意: 给你n个点m条边的无向图(无重边和自环),问你是否存在一个简单的环且环上的点都是某棵树的树根. 思路: 注意这句话:an undirected graph that can be repres ...
- A - Cthulhu CodeForces - 103B (并查集)
-Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for th ...
- Round 2 A - Cthulhu CodeForces - 103B -图同构,DFS
题目链接: http://codeforces.com/problemset/problem/103/B 大意: 判断图的形状是否为一个章鱼型(?) 由几棵树构成,树的根节点围成一个环. 思路: 只需 ...
- Codeforces 104C Cthulhu dfs暴力 || 点双连通缩点
题目链接:点击打开链接 题意: 给定n个点m条边的无向图 问图中是否存在 有且仅有一个简单环和一些树,且这些树的root都在这个简单环上. 瞎写了个点双..== #include <stdio. ...
- 【CodeForces】CF103B Cthulhu
题目地址: https://www.luogu.com.cn/problem/CF103B 题面翻译: 很久很久以前的一天,一位美男子来到海边,海上狂风大作.美男子希望在海中找到美人鱼,但是很不幸他只 ...
- codeforces Cthulhu 简单图论
题意:给定一个点集,和边集,问这个它的结构是不是像妖怪. 做法:水,只要DFS判断是否只有一个联通分量,然后再判断N=M即可 #include <iostream> #include &l ...
- CodeForces:103(div1)104(div2)
文章目录 前言 CF104A Blackjack Description\text{Description}Description Solution\text{Solution}Solution Co ...
最新文章
- 教学思路SQL之入门习题《学员成绩》 一、建表
- 【Boost】boost库asio详解2——io_service::run函数无任务时退出的问题
- 使用VC6.0创建和运行C程序的方法
- 《计算机组成与体系结构:性能设计》读后小记 18、多核计算机
- 10个迷惑新手的CocoaObjective-c开发问题
- 技术干货 | 如何在 Electron 上实现 IM SDK 聊天消息全文检索
- 内网用户之间使用MSN Messenger快速传送文件的小窍门
- Qt配置VS2017
- mac vagrant 虚拟机nfs挂载点
- 遍历输出所有子视图(View)
- [AngularJS]Chapter 1 AnjularJS简介
- 关于MyEclips新导入项目报错问题,解决方法!(基础)
- IDEA+Maven+Git
- java.lang.IllegalStateException: Max number of active transactions reached:50
- 【Taro开发】-自定义导航栏NavBar(五)
- Excel文本自动换行
- 霆智服务器安装Windows系统,无人值守全自动安装windows系统
- 【BX学习之常用网址】 开发常用网址
- 前端求职系列:如何写一份小程序简历(二)
- 【Android工具】更新观影渠道,安卓、iOS、PC三端通用,免费电影在线观看