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 ...
随机推荐
- 申请一个美国paypal账户
近期为了做PayPal支付,进口demo已经写好,就差一个美国PayPal账户进行支付测试,几经折腾,终于申请下来,附上参考链接: paypal官网: https://www.paypal.com ...
- navicat异常 - 1130-host ... is not allowed to connect to this MySql server
错误描述 用navicat连接数据库报错:1130-host ... is not allowed to connect to this MySql server如何处理 解决方案 1.连接服务器: ...
- Selenium模块/目录说明
目录说明: selenium/common #定义了webdriver的异常类 selenium/webdriver #定义了webdriver所有python实现: 1.各种浏览器支 ...
- php 对接国外支付 ipay88支付
ipay88支付 近期接了一个国外的项目,客户指定要这种支付,就搞搞呗,其实流程和思路都是差不多的,往下看 他的流程其实非常简单 下面的流程仔细看看,看懂了就会了 1 首先我们需要先获取下单所需要的 ...
- wpf 程序启动显示图片
一.设置图片的生成操作 程序启动时会出现0.5秒的图片显示,再显示程序界面. 二.写代码实现相同效果 /// <summary> /// App.xaml 的交互逻辑 /// </s ...
- promise的连缀写法
promise的连缀写法 以上写法相当于写了两个实例 promise.all() 1. promise.all() all这个方法是 promise 构造函数的成员不是实例对象成员,这个方法接受一个参 ...
- python&selenium自动化测试实战项目
https://www.cnblogs.com/linuxchao/p/linuxchao-python-selenium-demo.html
- 微信小程序 selectComponent 值为null
这个东西的执行时间感觉有点迷, 我遇到的情况是在page 的onReady onShow 当中 使用 selectComponent 无法获取到子组件的对象 只好退而求其次 在需要触发的方法当中 ...
- centos7 tar.gz zip 解压命令
tar负责打包,gzip负责压缩 tar -c: 建立压缩档案 -x:解压 -t:查看内容 -r:向压缩归档文件末尾追加文件 -u:更新原压缩包中的文件 这五个是独立的命令,压缩解压都要用到其中一个, ...
- 在MyEclipse中修改文件名出现问题
问题描述:An exception has been caught while processing the refactoring 'Rename Compilation Unit'. 问题原因:项 ...