构造,枚举起点,如果一个序列成立,那么将它reverse依然成立,所以两个方向(从小到大或从大到小)没有区别,选定一个方向进行探测,直到探测不到以后回头,只要所给数据能成立,那么能探测进去就能探测出来,否则就不能构造。

 #define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int num[];
int sum;
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int a[]={};
for(int i=;i<=;++i)
cin>>a[i];
for(int i=;i<=;++i){
num[i]=a[i];
sum+=num[i];
}
for(int i=;i<=;++i){
for(int i=;i<=;++i)
num[i]=a[i];
vector<int>v;
int now=i;
for(int i=;i<=sum;++i){
if(!num[now])
break;
--num[now];
v.push_back(now-);
if(num[now+])
++now;
else
--now;
}
if(v.size()==sum){
cout<<"YES\n";
for(auto it:v)
cout<<it<<" ";
return ;
}
}
cout<<"NO";
return ;
}

Codeforces Round #604 (Div. 2)D(构造)的更多相关文章

  1. Codeforces Round #604 (Div. 2) D. Beautiful Sequence(构造)

    链接: https://codeforces.com/contest/1265/problem/D 题意: An integer sequence is called beautiful if the ...

  2. Codeforces Round #604(Div. 2,

    // https://codeforces.com/contest/1265/problem/D /* 感觉像是遍历的思维构造题 有思路就很好做的 可以把该题想象成过山车或者山峰...... */ # ...

  3. Codeforces Round #604 (Div. 2) A. Beautiful String(贪心)

    题目链接:https://codeforces.com/contest/1265/problem/A 题意 给出一个由 a, b, c, ? 组成的字符串,将 ? 替换为 a, b, c 中的一个字母 ...

  4. Codeforces Round #604 (Div. 2) B. Beautiful Numbers(双指针)

    题目链接:https://codeforces.com/contest/1265/problem/B 题意 给出大小为 $n$ 的一个排列,问对于每个 $i(1 \le i \le n)$,原排列中是 ...

  5. Codeforces Round #272 (Div. 1) B 构造 math

    http://www.codeforces.com/contest/477/problem/C 题目大意:给你n个集合,每个集合里面有四个数字,他们的gcd是k,输出符合条件的集合中m,m为集合中最大 ...

  6. 题解——Codeforces Round #508 (Div. 2) T2 (构造)

    按照题意构造集合即可 注意无解情况的判断 #include <cstdio> #include <algorithm> #include <cstring> #in ...

  7. 【cf比赛记录】Codeforces Round #604 (Div. 2)

    比赛传送门 感觉这场是最近以来做过的最顺手的一场,持续上分,开心w A了 前三题,然后第四题其实还有半个多小时,但怕身体撑不住,就先退了,其实第四题也很简单 自己认为的算法标签: ​ A.暴力模拟.字 ...

  8. Codeforces Round #604 (Div. 2) E. Beautiful Mirrors

    链接: https://codeforces.com/contest/1265/problem/E 题意: Creatnx has n mirrors, numbered from 1 to n. E ...

  9. Codeforces Round #604 (Div. 2) C. Beautiful Regional Contest

    链接: https://codeforces.com/contest/1265/problem/C 题意: So the Beautiful Regional Contest (BeRC) has c ...

随机推荐

  1. 记录 Docker 的学习过程 (dockerfile自动制作镜像)

    自动制作镜像 通过编写dockerfile来自动创建镜像 #vi Dockerfile #编辑dockerfile文件,一定要以这个名字命名 #cat Dockerfile #导入哪个基础镜像FROM ...

  2. 记录 Docker 的学习过程 (数据挂载)

    docker 存储篇 容器中的存储是分层的, 在容器中,如果我们要创建一个文件,会在文件的最上层(可写层)创建 容器中内置的文件,默认来讲是只读的,只有自己创建的文件才是可写状态 比如说 /etc/p ...

  3. numpy学习(四)

    练习篇(Part 4) 41. How to sum a small array faster than np.sum? (★★☆) arr = np.arange(10) print(np.add. ...

  4. Laravel通过用户名和密码查询

    一.如果要检查要验证的用户数据是否正确,可以使用: if (Auth::validate($credentials)) { // } 二.但是如果您想通过用户和密码从数据库中获取用户,您可以使用: / ...

  5. update(十)

    Vue 的 _update 是实例的一个私有方法,它被调用的时机有 2 个,一个是首次渲染,一个是数据更新的时候:由于我们这一章节只分析首次渲染部分,数据更新部分会在之后分析响应式原理的时候涉及._u ...

  6. SpringBoot学习- 7、问题Could not autowire. No beans of 'xxxx' type found处理

    SpringBoot学习足迹 这个问题网上有好多同学都提到这个问题,代码可以运行,但是就是有红线,强迫症不能忍 自己试验下 1.增加一个final编译一下,再删掉就不会出红线了 public clas ...

  7. Mvc-WebAPI特性路由(自定义路由)Demo

    Demo由VS2017编写. 1.先建一个WebApi项目 2.WebApiConfig.cs需要注册特性路由,config.MapHttpAttributeRoutes(); 3.项目默认有2个Co ...

  8. 0003 配置完整的url访问路径

    本文本以OrgsAndUser APP为例,每增加一个url都需要做以下步骤: 1 创建模板 在OrgsAndUsers/Templates目录下创建一个名为org-home.html的文件,内容如下 ...

  9. 如何在linux主机上运行/调试 arm/mips架构的binary

    如何在linux主机上运行/调试 arm/mips架构的binary 原文链接M4x@10.0.0.55 本文中用于展示的binary分别来自Jarvis OJ上pwn的add,typo两道题 写这篇 ...

  10. python setup.py 安装和卸载 的正确姿势

    1.install python setup.py install --record files.txt 2. uninstall 删除这些文件 cat files.txt | xargs rm -r ...