gym/102059 E
待通过:A、D、G、J、M
已补过:E
E:电路题,判断一个图是不是简单电路。不需要特殊的技巧,利用set存图,把度数为2的点都删掉,融入到一条边上即可。
#include <algorithm>
#include <iterator>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <cassert> using namespace std;
#define lson (l , mid , rt << 1)
#define rson (mid + 1 , r , rt << 1 | 1)
#define debug(x) cerr << #x << " = " << x << "\n";
#define pb push_back
#define pq priority_queue typedef long long ll;
typedef unsigned long long ull;
//typedef __int128 bll;
typedef pair<ll ,ll > pll;
typedef pair<int ,int > pii;
typedef pair<int,pii> p3; //priority_queue<int> q;//这是一个大根堆q
//priority_queue<int,vector<int>,greater<int> >q;//这是一个小根堆q
#define fi first
#define se second
//#define endl '\n' #define OKC ios::sync_with_stdio(false);cin.tie(0)
#define FT(A,B,C) for(int A=B;A <= C;++A) //用来压行
#define REP(i , j , k) for(int i = j ; i < k ; ++i)
#define max3(a,b,c) max(max(a,b), c);
#define min3(a,b,c) min(min(a,b), c);
//priority_queue<int ,vector<int>, greater<int> >que; const ll mos = 0x7FFFFFFF; //
const ll nmos = 0x80000000; //-2147483648
const int inf = 0x3f3f3f3f;
const ll inff = 0x3f3f3f3f3f3f3f3f; //
const int mod = ;
const double esp = 1e-;
const double PI=acos(-1.0);
const double PHI=0.61803399; //黄金分割点
const double tPHI=0.38196601; template<typename T>
inline T read(T&x){
x=;int f=;char ch=getchar();
while (ch<''||ch>'') f|=(ch=='-'),ch=getchar();
while (ch>=''&&ch<='') x=x*+ch-'',ch=getchar();
return x=f?-x:x;
}
/*-----------------------showtime----------------------*/ const int maxn = 1e5+;
set<int>mp[maxn];
queue<int>que;
int vis[maxn];
int main(){
int n,m;
scanf("%d%d", &n, &m);
for(int i=; i<=m; i++){
int u,v;
scanf("%d%d", &u, &v);
mp[u].insert(v);
mp[v].insert(u);
} for(int i=; i<=n; i++){
if(mp[i].size() == ) que.push(i);
}
while(!que.empty()){ int u = que.front(); que.pop();
if(mp[u].size() != ) continue;
int s = *mp[u].begin(); mp[u].erase(s);
int x = *mp[u].begin(); mp[u].erase(x);
mp[s].erase(u);
mp[x].erase(u);
mp[s].insert(x);
mp[x].insert(s); if(mp[s].size() == ) que.push(s);
if(mp[x].size() == ) que.push(x);
}
int flag = ,cnt = ;
for(int i=; i<=n; i++){
if(mp[i].size() >= ) flag = ;
else if(mp[i].size() == ) cnt ++;
}
//debug(cnt);
if(flag && cnt == ) puts("Yes");
else puts("No");
return ;
}
E
gym/102059 E的更多相关文章
- 【GYM 102059】2018-2019 XIX Open Cup, Grand Prix of Korea
vp了一场gym,我又开心地划水了. A. Coloring Roads 题意:给定一棵树,树边一开始都是无色的,每次操作可以把一个点到根的路径染成某个颜色,每次询问当前树上出现过某个次数的颜色种数. ...
- Gym.102059: 2018-2019 XIX Open Cup, Grand Prix of Korea(寒假gym自训第一场)
整体来说,这一场的质量比较高,但是题意也有些难懂. E.Electronic Circuit 题意: 给你N个点,M根线,问它是否是一个合法的电路. 思路: 一个合法的电路,经过一些串联并联关系, ...
- gym/102059/problem/I. Game on Plane SG函数做博弈
传送门: 题意: 给定一个正n边形的点.双方轮流连点成线,要求所画的线不能与之前的线相交.当某个人连成一个回路,这个人就输了.问先手必胜还是后手必胜. 思路: SG函数,因为一条线相当于把图劈成了两半 ...
- ACM: Gym 101047M Removing coins in Kem Kadrãn - 暴力
Gym 101047M Removing coins in Kem Kadrãn Time Limit:2000MS Memory Limit:65536KB 64bit IO Fo ...
- ACM: Gym 101047K Training with Phuket's larvae - 思维题
Gym 101047K Training with Phuket's larvae Time Limit:2000MS Memory Limit:65536KB 64bit IO F ...
- ACM: Gym 101047E Escape from Ayutthaya - BFS
Gym 101047E Escape from Ayutthaya Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I6 ...
- ACM: Gym 101047B Renzo and the palindromic decoration - 手速题
Gym 101047B Renzo and the palindromic decoration Time Limit:2000MS Memory Limit:65536KB 64 ...
- Gym 101102J---Divisible Numbers(反推技巧题)
题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...
- Gym 100917J---Judgement(01背包+bitset)
题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...
随机推荐
- Iterator-Java
在Java中,Iterator的作用就是为了方便处理集合中的元素.例如获取和删除集合中的元素. 在JDK8,Iterator接口提供了如下方法: 迭代器Iterator最基本的两个方法是next()和 ...
- Windows上切换java8和java11
Windows上安装了java8和java11,时不时要切换,于是思考写行命令解决.思路是修改java_home变量.我的java_home变量是设置在系统级别的. 修改环境变量有2个命令,set和s ...
- 关于HostnameVerifier接口的解读
在项目中我们需要调用https接口请求.我们使用httpClient,构建HttpClient对象时涉及到使用HostnameVerifier接口实例. HostnameVerifier接口定义如下: ...
- 利用hash或history实现单页面路由
目录 html代码 css代码 JavaScript代码 hash方式 history 方式 浏览器端代码 服务器端 在chrome(版本 70.0.3538.110)测试正常 编写涉及:css, h ...
- Transformation HDU - 4578(线段树——懒惰标记的妙用)
Yuanfang is puzzled with the question below: There are n integers, a 1, a 2, …, a n. The initial val ...
- Spring入门(六):条件化的bean
1. 概念 默认情况下,Spring中定义的bean在应用程序启动时会全部装配,不管当前运行的是哪个环境(Dev,QA或者Prod),也不管当前运行的是什么系统(Windows或者Linux),但有些 ...
- Jmeter 01 Jmeter下载安装及入门
jmeter简介 Apache JMeter是Apache组织开发的基于Java的压力测试工具.用于对软件做压力测试,它最初被设计用于Web应用测试,但后来扩展到其他测试领域.--百度百科 下载 下载 ...
- Shell脚本书写规范
在日常的运维工作中,Shell脚本肯定是必不可少的工作内容.为方便问题排查.脚本执行历史问题追踪.方便大家共同维护,从网上搜罗结合以往的经验教训拟定以下Bash脚本书写规范.欢迎各位同学指正或补充. ...
- (三十二)c#Winform自定义控件-表格
前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...
- 驰骋工作流引擎ccflow-流转自定义功能使用说明
流转自定义功能使用说明 关键字: 驰骋工作流程快速开发平台 工作流程管理系统 工作流引擎 asp.net工作流引擎 java工作流引擎. 节点跳转 节点流转自定义 应用背景: 有一些流程在运行过程中是 ...