HDU 6029(思维)
Graph Theory
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 1220 Accepted Submission(s): 553
Let the set of vertices be {1, 2, 3, ..., n}. You have to consider every vertice from left to right (i.e. from vertice 2 to n). At vertice i, you must make one of the following two decisions:
(1) Add edges between this vertex and all the previous vertices (i.e. from vertex 1 to i−1).
(2) Not add any edge between this vertex and any of the previous vertices.
In the mathematical discipline of graph theory, a matching in a graph is a set of edges without common vertices. A perfect matching is a matching that each vertice is covered by an edge in the set.
Now Little Q is interested in checking whether a ''Cool Graph'' has perfect matching. Please write a program to help him.
In each test case, there is an integer n(2≤n≤100000) in the first line, denoting the number of vertices of the graph.
The following line contains n−1 integers a2,a3,...,an(1≤ai≤2), denoting the decision on each vertice.
#include <bits/stdc++.h>
using namespace std;
int main()
{int t;cin>>t;while(t--){int n,num;cin>>n;if(n%2==1){for(int i=1;i<n;i++){cin>>num;}puts("No");continue;}int que=1;for(int i=1;i<n;i++){cin>>num;if((num==1&&que==0)||num==2){que++;}else que--;}if(que==0){puts("Yes");}else puts("No");}return 0;
}
转载于:https://www.cnblogs.com/Chen-Jr/p/11007311.html
HDU 6029(思维)相关推荐
- 2018 Spring Team Contest D HDU - 6023、HDU - 6024、HDU - 6025 、HDU - 6027 、HDU - 6029
HDU - 6023 //编译错误不算罚时 #include<cstdio> #include<cstring> #include<iostream> #incl ...
- hdu 6029 Graph Theory 【直接连线】
hdu 6029 Graph Theory [直接连线] 对于输入的a等于1 如果前面有空闲的点 直接匹配 否则自己变成空闲的点 a=2 的时候 空闲的点加一 直到最后 如果没有空余的点 输出ye ...
- The Fool HDU 6555 思维/数论
开个根就行 #include <cstdio> #include <algorithm> #include <cmath> #include <cstring ...
- 2018 China Collegiate Programming Contest - Jilin Site F - The Hermit HDU - 6560 思维
链接Problem - 6560 题意 有n个站点每个站点可以发送完美信号 关于完美信号的定义 有i j k三个站点 分别保证 i<j<k dis(i,j)> dis(j,k) 并且 ...
- SDNU-多校训练赛2-[ABF]
问题虫洞--A:A - Just Skip The Problem HDU - 6600 黑洞内窥: 给出一个数n, 而你也将得到一个连你自己也不到的数X, 然后你可以用这个数X去和一个Y进行与运算, ...
- WHUT第七周训练整理
WHUT第七周训练整理 祝各位武理的ACMer们,新年快乐!在接下来的一年里继续训练,为武理的ACM揭开新的篇章!同为武汉的学子,武汉加油! 索引 (难度由题目自身难度与本周做题情况进行分类,仅供新生 ...
- hdu 3234 Exclusive-OR 题解(并查集,思维)
该死的期末复习终于结束了... 暑假来了\color{#ff0000}{暑假来了}暑假来了!!! 所以我就珂以非常开心的写博客了. 原题链接: hdu 题意简述 多组数据.你有一个没有确定的数列.有一 ...
- HDU - 6486 Flower(思维)
HDU - 6486 Flower 题目大意:有n堆草每次只能对n-1堆操作每次只能减1问最少操作几次能把这些草剪到相同高度如果不能输出-1 我们让n-1个数减1实际上可以看成使得剩下的那一个数加1. ...
- HDU - 5637 Transform (思维、bfs预处理)
HDU - 5637 题目大意: 给出n个数的序列a,对于一个整数x,有两种操作: 1.改变x二进制中任一位 2.将x变为x^a[i] m次查询,每次查询输入两个整数x和y,问x最少经过多少次操作可以 ...
最新文章
- LeetCode Minimum Path Sum(动态规划)
- stringstream精度问题
- python3小游戏源代码_如何用python3代码玩小游戏?
- boost::hana::zip用法的测试程序
- 566.重塑矩阵(力扣leetcode) 博主可答疑该问题
- 资产管理(记账系统)03
- 域格4G模组开机网络注册流程
- 微表情测试软件排行榜,微表情心理测试分析系统:以“微”见智,识情绪辨人心...
- PageHelper.startPage分页的使用和pageSize的值和list相同导致循环出来的total总数不对
- android opengl 帧动画,Android OpenGLES2.0(十三)——流畅的播放逐帧动画
- android bugly 错误分析,# app 3.6.1 Bugly中崩溃分析
- 微信小程序中苹果iOS手机显示时间格式NaN不正确的问题
- JQuery实现图片点击放大
- new HashMap(list.size())指定size就能完全避免扩容带来的额外开销了吗?
- Suzy找到实习了吗Day 14 | 二叉树开始啦 二叉树的分类、定义、遍历方法
- 烤仔说 | Babe Babe Běibèi oh~
- 铅酸蓄电池知识(待更新)
- 3个5相乘列乘法算式_「百树云课堂」初一数学必考的知识点(21个)
- 区块链阴谋与骗局 贴吧
- 华为imana命令行
热门文章
- 深度学习之卷积神经网络(6)梯度传播
- 原生js绑定click为什么点一次执行两次_前端小知识10点(2020.10.8)
- 『操作系统』 进程的描述与控制 Part2 进程同步
- C++获取当前系统时间并格式化输出
- Linux更改主机名称(hostname)和设置DNS解析以及设置IP
- linux下shell命令别名(alias)设置
- 【人脸对齐-Landmarks】300W 数据集
- angular 使用data-bs-datepicker时的一个小问题及解决
- 使用GridSearchCV和RandomizedSearchCV进行超参数调整
- SorterBot-第1部分