贪心。

每次找到后面最近的一个能连边的连边。

#include <bits/stdc++.h>
using namespace std;
const long long mod=1e9+;
int T,n,k;
int a[],b[],u[]; int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
int cnt=;
for(int i=;i<=n;i++)
{
scanf("%d",&a[i]);
if(a[i]==) cnt++;
}
k=;
for(int i=n;i>=;i--)
{
if(a[i]==) b[k++]=i;
}
int ok=;
memset(u,,sizeof(u));
k--;
for(int i=;i<=n;i++)
{
if(u[i]==) continue;
if(b[k]==i) {k--;}
if(k==-){ ok=;break;}
u[b[k]]=u[i]=;
k--;
}
if(ok) puts("Yes");
else puts("No");
}
return ;
}

HDU 6029 Graph Theory的更多相关文章

  1. HDU 6343.Problem L. Graph Theory Homework-数学 (2018 Multi-University Training Contest 4 1012)

    6343.Problem L. Graph Theory Homework 官方题解: 一篇写的很好的博客: HDU 6343 - Problem L. Graph Theory Homework - ...

  2. 2018 Multi-University Training Contest 4 Problem L. Graph Theory Homework 【YY】

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6343 Problem L. Graph Theory Homework Time Limit: 2000 ...

  3. Introduction to graph theory 图论/脑网络基础

    Source: Connected Brain Figure above: Bullmore E, Sporns O. Complex brain networks: graph theoretica ...

  4. hdu 4467 Graph

    P. T. Tigris is a student currently studying graph theory. One day, when he was studying hard, GS ap ...

  5. The Beginning of the Graph Theory

    The Beginning of the Graph Theory 是的,这不是一道题.最近数论刷的实在是太多了,我要开始我的图论与树的假期生活了. 祝愿我吧??!ShuraK...... poj18 ...

  6. Codeforces 1109D Sasha and Interesting Fact from Graph Theory (看题解) 组合数学

    Sasha and Interesting Fact from Graph Theory n 个 点形成 m 个有标号森林的方案数为 F(n, m) = m * n ^ {n - 1 - m} 然后就 ...

  7. [la P5031&hdu P3726] Graph and Queries

    [la P5031&hdu P3726] Graph and Queries Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: ...

  8. CF1109D Sasha and Interesting Fact from Graph Theory

    CF1109D Sasha and Interesting Fact from Graph Theory 这个 \(D\) 题比赛切掉的人基本上是 \(C\) 题的 \(5,6\) 倍...果然数学计 ...

  9. HDU6029 Graph Theory 2017-05-07 19:04 40人阅读 评论(0) 收藏

    Graph Theory                                                                 Time Limit: 2000/1000 M ...

随机推荐

  1. SSM框架整合遇到的问题

    1.Maven中Dubbo集成spring2.5以上版本 项目中dubbo集成spring4.x,配置pom时需要注意排除spring的依赖,我这里用的是tomcat,所以把jboss也排除了: &l ...

  2. 从零搭建SSM框架(四)手动实现Tomcat部署

    发布War包 Windows环境部署 增加如下配置 <Context path="/" docBase="cnki" debug="0" ...

  3. c#开发_Dev的关于XtraGrid的使用(GridControl小结)

    1,增加新行用InitNewRow事件,给新行某字段赋值.后结束编辑. private void grdView_InitNewRow(object sender, DevExpress.XtraGr ...

  4. 搭建cdh单机版版本的hive所遇到的问题总汇

    今天按照网上教程搭建了下 cdh 单机版的 hive  将相关配置记录下来 以便以后方便翻阅 版本 hive-0.13.1-cdh5.3.6.tar.gz 1. 直接解压 然后将 mysql驱动包 拷 ...

  5. 利用media query写响应式布局

    最近才接触到响应式布局的概念,之前用到的bootstrap就是一种响应式布局的框架.学习的时候参考了http://blog.csdn.net/shoyer/article/details/829301 ...

  6. SaltStack 使用笔记

    centos 7安装yum -y install epel-releaseyum clean allyum makecacheyum -y install salt-minionsed -i 's/# ...

  7. NB二人组(二)----归并排序

    归并排序的思路: 归并算法程序(配合下图进行思考): def merge(li,low,mid,high): i = low j = mid + 1 ltmp=[] while i <= mid ...

  8. Daily Report-1126

    今日: 上午主要是回顾了react,阅读官方文档的时候发现了list中key值设计的必要性. 看了部分react源码,发现有些吃力,在询问羽牧学长之后调整策略,从redux和mobx入手,先多熟悉用法 ...

  9. 海洋CMS v6.53 v6.54命令执行

    测试下载地址:https://pan.baidu.com/s/1jHQBKFk 至于分析实在是看的一脸懵逼就不累赘了.直接上exp POST /haiyang/upload/search.php HT ...

  10. 使用ctypes在Python中调用C++动态库

    使用ctypes在Python中调用C++动态库 入门操作 使用ctypes库可以直接调用C语言编写的动态库,而如果是调用C++编写的动态库,需要使用extern关键字对动态库的函数进行声明: #in ...