codeforces-103B Cthulhu
#include<iostream>
#include<cstring>
#include<map>
#include<vector>
#include<cstdio>
#include<stdlib.h>
#include<algorithm>
using namespace std;int n, m;
int fa[110];
vector<int> G[110];int Find(int x){return x == fa[x]?x:fa[x] = Find(fa[x]);
}void join(int x, int y){int root1 = Find(x);int root2 = Find(y);if(root1!=root2){fa[root1] = root2;}
}int main(){cin>>n>>m;for(int i = 1; i<=n; i++) fa[i] = i;for(int i =0 ;i<m; i++){int u, v;cin>>u>>v;G[u].push_back(v);G[v].push_back(u);join(u, v);}/*for(int i = 1; i<=n; i++){cout<<i<<" "<<fa[i]<<endl;}*/bool flag = true;for(int i = 1; i<=n; i++){if(Find(i)!=Find(1)){flag = false;}}if(n!=m) flag = false;if(flag == false) cout<<"NO"<<endl;else cout<<"FHTAGN!"<<endl;return 0;
}
codeforces-103B Cthulhu相关推荐
- CodeForces 103B Cthulhu
http://codeforces.com/problemset/problem/103/B 找环,一个环 #include<bits/stdc++.h> using namespace ...
- 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 ...
最新文章
- 允许活动内容如脚本和activex控件
- php进程学习(一)
- P1199 三国游戏
- 前端学习(2165):vuecli3创建项目和目录结构
- ubuntu 16.04下git的安装与使用
- 理论+实践,带你掌握动态规划法
- 《Java 8 in Action》Chapter 12:新的日期和时间API
- 拼接Sql语句的写法
- 第十四章 深度确定性策略梯度(Deep Deterministic Policy Gradient Algorithms,DDPG)-强化学习理论学习与代码实现(强化学习导论第二版)
- [导入]+ADO.NET读书笔记系列 一+
- 简易语音助手—python
- 苹果安卓最新看片神器各种实用功能,帮你一年省下上千块!
- 住宅内部通信系统市场现状研究分析与发展前景预测报告
- 如何正确的将拼多多的买家晒图采集并保存
- 柏拉图式爱情 (精神爱情)
- c语言choice的用法,名词choice的用法与搭配
- FinalShell连接超时解决方法
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):的三种解决方式
- UE4中的玩家类UPlayer、ULocalPlayer 和 UNetConnection
- isEmpty与null的区别
热门文章
- pythonista3中文设置教程_Pythonista中文文档:使用Pythonista
- 百度文字转语音免费接口使用实例
- 条码打印实现预览功能(winform)
- iphone,ipad分辨率大全
- (keil4 51单片机)D:\uVision\C51\Inc\reg52.h(13): error C231: ‘P0‘: redefinition
- 联通研究院注重自主研发能力提升, 3人荣获CKA认证
- 送口红分不清色号,送花认不全品种?机器学习一键搞定!
- C++ sizeof(struct)计算结构体大小
- Loading 用户体验 - 加载时避免闪烁
- oracle怎么查询关键字,9、oracle表查询关键字