HDU 6029 Graph Theory
贪心。
每次找到后面最近的一个能连边的连边。
#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的更多相关文章
- 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 - ...
- 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 ...
- Introduction to graph theory 图论/脑网络基础
Source: Connected Brain Figure above: Bullmore E, Sporns O. Complex brain networks: graph theoretica ...
- hdu 4467 Graph
P. T. Tigris is a student currently studying graph theory. One day, when he was studying hard, GS ap ...
- The Beginning of the Graph Theory
The Beginning of the Graph Theory 是的,这不是一道题.最近数论刷的实在是太多了,我要开始我的图论与树的假期生活了. 祝愿我吧??!ShuraK...... poj18 ...
- 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} 然后就 ...
- [la P5031&hdu P3726] Graph and Queries
[la P5031&hdu P3726] Graph and Queries Time Limit: 10000/5000 MS (Java/Others) Memory Limit: ...
- CF1109D Sasha and Interesting Fact from Graph Theory
CF1109D Sasha and Interesting Fact from Graph Theory 这个 \(D\) 题比赛切掉的人基本上是 \(C\) 题的 \(5,6\) 倍...果然数学计 ...
- HDU6029 Graph Theory 2017-05-07 19:04 40人阅读 评论(0) 收藏
Graph Theory Time Limit: 2000/1000 M ...
随机推荐
- 关于HttpURLConnection/HttpsURLConnection请求出现了io.filenotfoundexception:url的解决方法
//从输入流读取返回内容InputStream is = null;int status = connection.getResponseCode();if(status>= HttpStatu ...
- vijos 1288 箱子游戏 计算几何
背景 hzy是箱子迷,他很喜欢摆放箱子,这次他邀请zdq,skoier一起来玩game... 描述 地板上有一个正方形的大箱子和许多三角型的小箱子.所有的小箱子都在大箱子里面,同时,一些三角形的小箱子 ...
- Python学习笔记(二十五)操作文件和目录
摘抄:https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/0014319253241 ...
- C11线程管理:线程创建
1.线程的创建 C11创建线程非常简单,只需要提供线程函数就行,标准库提供线程库,并可以指定线程函数的参数. #include <iostream> #include <thread ...
- Vue中使用vux的配置
一.根据vux文档直接安装,无需手动配置 npm install vue-cli -g // 如果还没安装 vue init airyland/vux2 my-project // 创建名为 my-p ...
- Shell编程——bash基础知识
# Bash中自动补全时忽略大小写 # 编辑~/.inputrc(没有的话,就新建一个),在最后加一行: set completion-ignore-case on # 若要用方向键Up,Down来搜 ...
- 【Foreign】减法 [二分][贪心]
减法 Time Limit: 10 Sec Memory Limit: 256 MB Description 给你一个n个数的序列A,并且给出m次操作B. 操作的含义是:每次从A中选出不同的B_i个 ...
- 【BZOJ】2301: [HAOI2011]Problem b
[题意]于给出的n个询问,每次求有多少个数对(x,y),满足a≤x≤b,c≤y≤d,且gcd(x,y) = k,gcd(x,y)函数为x和y的最大公约数.n,a,b,c,d,k<=50000. ...
- HTTP/2.0 简单总结(转载)
HTTP/2.0 简单总结(转载于https://linjunzhu.github.io/blog/2016/03/10/http2-zongjie/) 如何使用上 HTTP/2.0 需要浏览器的支持 ...
- C语言二分查找
#include <stdio.h> /* 二分查找条件: 1.有序序列 2.数据在数组中 */ int baseBinarySearch(int a[],int h,int k) { ; ...