构造,枚举起点,如果一个序列成立,那么将它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. STM 32 内部功能回顾

    EXTI   外部中断 NVIC 嵌套的向量式中断控制器 AHB 是高级高性能内部总线,主要是用在CPU.DMA.DSP(数字信号处理) APB 是外围总线,I2C. 串口 APB 分为高速APB2( ...

  2. npm 配置国内源

    淘宝镜像 npm config set registry http://registry.npm.taobao.org

  3. centos7中 yum的安装

    自己误将yum卸载, 在重装时由于依赖问题一直报错: error: Failed dependencies:     /usr/bin/python is needed by yum-3.4.3-16 ...

  4. (转)漫游Kafka入门篇之简单介绍

    转自:http://blog.csdn.net/honglei915/article/details/37564521 原文地址:http://blog.csdn.net/honglei915/art ...

  5. [CF]Round511

    这场比赛我及时的参加了,但是打的时候状态实在是太烂了,只做出来了Div2的AB题. A Little C loves 3 I 直接构造就行. B Cover Points 应该很容易就看出来这个等腰三 ...

  6. Quality and CCPC

    English foundation: the fractional part 小数部分 disclaimer 免责声明 fictitious  虚构的,编造的;假定的,虚设的;小说式的;假装的 No ...

  7. javascript 循环读取数组中的值

    //数组 var a = ["#F85C6F", "#78B0F0", "#DB83ED", "#8EC656", &q ...

  8. 如何去官网上下载tomcat的linux版本

    1.首先进入官网,进入如下位置 2.进入bin文件夹中下载: 原文链接:https://blog.csdn.net/zdb292034/article/details/82433072

  9. android 代码设置图标背景色(圆形图标)和图标颜色

    原图: 1.改变图标颜色: mImageView.setColorFilter(Color.parseColor("#ff0000")); 效果: 2.改变图标背景色(主要是圆形图 ...

  10. sql语句代码规范

    19年年底的时候领导一直强调代码规范化以前写代码的时候很随意后来越来越看自己写的代码难受逐渐的也像规范化走去,今天又学了一招记录分享一下 这张图就是以前写代码的时候正常情况很是杂乱无章 这张就是规范话 ...