Codeforces Round #604 (Div. 2)D(构造)
构造,枚举起点,如果一个序列成立,那么将它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(构造)的更多相关文章
- Codeforces Round #604 (Div. 2) D. Beautiful Sequence(构造)
链接: https://codeforces.com/contest/1265/problem/D 题意: An integer sequence is called beautiful if the ...
- Codeforces Round #604(Div. 2,
// https://codeforces.com/contest/1265/problem/D /* 感觉像是遍历的思维构造题 有思路就很好做的 可以把该题想象成过山车或者山峰...... */ # ...
- Codeforces Round #604 (Div. 2) A. Beautiful String(贪心)
题目链接:https://codeforces.com/contest/1265/problem/A 题意 给出一个由 a, b, c, ? 组成的字符串,将 ? 替换为 a, b, c 中的一个字母 ...
- Codeforces Round #604 (Div. 2) B. Beautiful Numbers(双指针)
题目链接:https://codeforces.com/contest/1265/problem/B 题意 给出大小为 $n$ 的一个排列,问对于每个 $i(1 \le i \le n)$,原排列中是 ...
- Codeforces Round #272 (Div. 1) B 构造 math
http://www.codeforces.com/contest/477/problem/C 题目大意:给你n个集合,每个集合里面有四个数字,他们的gcd是k,输出符合条件的集合中m,m为集合中最大 ...
- 题解——Codeforces Round #508 (Div. 2) T2 (构造)
按照题意构造集合即可 注意无解情况的判断 #include <cstdio> #include <algorithm> #include <cstring> #in ...
- 【cf比赛记录】Codeforces Round #604 (Div. 2)
比赛传送门 感觉这场是最近以来做过的最顺手的一场,持续上分,开心w A了 前三题,然后第四题其实还有半个多小时,但怕身体撑不住,就先退了,其实第四题也很简单 自己认为的算法标签: A.暴力模拟.字 ...
- 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 ...
- Codeforces Round #604 (Div. 2) C. Beautiful Regional Contest
链接: https://codeforces.com/contest/1265/problem/C 题意: So the Beautiful Regional Contest (BeRC) has c ...
随机推荐
- LED Keychain-A Tool To Drive Specific Market Segments
LED keychain are an excellent tool to drive specific market segments. They can focus on a small grou ...
- docker 的基本命令
查看命令 docker images 查看镜像 docker ps 查看正在运行的容器 docker ps -a 查看所有的容器 docker inspect container-name 记录着 D ...
- mac 命令行下 vim 的使用
vi/vim 使用实例 使用 vi 来建立名为 test.txt 的文件 vi test.txt1按下 ESC 按钮回到一般模式 在一般模式中按下 :wq 储存后离开 vi 基本上 vi/vim 共分 ...
- localStorage存、取数组
localStorage存储数组时需要先使用JSON.stringify()转成字符串,取的时候再字符串转数组JSON.parse(). var arr=[1,2,3,4]; localStorage ...
- 二分-A - Cable master
A - Cable master Inhabitants of the Wonderland have decided to hold a regional programming contest. ...
- Linux之温故知新1
1.touch命令的使用 2.使用(cd -)可以在上次使用的目录来回切换 3.ls通配符的使用*代表任意字符和任意个字符, ?代表任意一个字符, [12345]中的任意一个字符, [1-5]中的任意 ...
- 回环屏障CyclicBarrier
上一篇说的CountDownLatch是一个计数器,类似线程的join方法,但是有一个缺陷,就是当计数器的值到达0之后,再调用CountDownLatch的await和countDown方法就会立刻返 ...
- R data formats
R data formats: Rdata Rda Rds 1.概念 rds是R语言中利用二进制保存的源文件,加载readr包以后,使用write_rds(x,file='x.rds')保存文件,re ...
- day03_2hibernate
HQL.QBC详解.c3p0连接池的整合.事务的隔离级别.乐观锁.悲观锁 一.HQL详解: ①关于HQL的使用语法:[select/update/delete...][from...][类名 as ...
- C#WinForm 实现登录界面验证码功能(区分大小写+不区分大小写)
原文:C#WinForm 实现登录界面验证码功能(区分大小写+不区分大小写) 文章来自:https://blog.csdn.net/IT_xiao_guang_guang/article/detail ...