贪心。

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

#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. phpstrom+xdebug+chrome+postman调试工具搭建

    php是解释性语言,大部分调试的时候使用var_dump+exit就可以搞定了,但是在大项目或遇到了负载的问题的时候你就需要断点调试.变量打印.性能分析了,php也有非常程序的解决方案,我们现在就动手 ...

  2. [吴恩达机器学习笔记]12支持向量机1从逻辑回归到SVM/SVM的损失函数

    12.支持向量机 觉得有用的话,欢迎一起讨论相互学习~Follow Me 参考资料 斯坦福大学 2014 机器学习教程中文笔记 by 黄海广 12.1 SVM损失函数 从逻辑回归到支持向量机 为了描述 ...

  3. ios 字符串截取

    NSString *str = @"my name is jiemu"; 1.从第三个字符开始,截取长度为4的字符串 NSString *str2 = [str substring ...

  4. PHP函数方法

    补充一个P可以HP的特点函数:动态调用 function t(){ echo "welcome"; } function t2(){ echo "beatch" ...

  5. Linux两台服务器上互传文件

    主服务器:192.168.100.30: 文件所在服务器:192.168.100.31: 1. 在主服务上拷贝文件: #scp root@192.168.100.31:/home/a.txt /hom ...

  6. IIC总线学习

    IIC总线 IIC协议简要说明: 1.2条双向串行线,一条数据线称为SDA,一条时钟线SCL,双向半双工 2.传输的设备之间只是简单的主从关系,主机可以作为主机发送也可以作为主机接收,任何时候只能由一 ...

  7. 【BZOJ】2599: [IOI2011]Race 点分治

    [题意]给一棵树,每条边有权.求一条简单路径,权值和等于K,且边的数量最小.N <= 200000, K <= 1000000.注意点从0开始编号,无解输出-1. [算法]点分治 [题解] ...

  8. 2017ACM暑期多校联合训练 - Team 1 1006 HDU 6038 Function (排列组合)

    题目链接 Problem Description You are given a permutation a from 0 to n−1 and a permutation b from 0 to m ...

  9. juery下拉刷新,div加载更多元素并添加点击事件(二)

    buffer.append("<div class='col-xs-3 "+companyId+"' style='padding-left: 10px; padd ...

  10. 选中一行并且选中该行的radio

    $("tr").bind("click",function(){ $("input:radio").attr("checked&q ...