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 ...
随机推荐
- 未安装Oracle数据库,使用PL\SQL Developer连接远程数据库解决方案
使用PL/SQL远程连接Oracle服务器 背景:本地未安装oracle数据库服务器,希望远程连接Oracle服务器 1.下载oracle数据库客户端 下载64位windows的instantclie ...
- linux centos7环境下安装apache2.4+php5.6+mysql5.6 安装及踩坑集锦
linux centos7环境下安装apache2.4+php5.6+mysql5.6 安装及踩坑集锦(一) 一.Linux下安装MySQL 1.下载 下载地址:http://dev.mysql.co ...
- C# asp.net 连接Mysql 数据库
首先添加 引用: using System.Data;using MySql.Data.MySqlClient; 代码: 这里只写了 后台代码 Mysql 连接和sql 连接代码几乎一样 只要把 My ...
- VS Code的一些常用插件
1.Bracket Pair Colorizer(括号对彩色化)功能:vscode中括号提醒比较简答,对于层级比较多的比较难看出他的结构,它为代码中的各种结对的括号提供了颜色高亮等功能,将括号对用线连 ...
- JUC-LOCK接口
Synchronized 1.多线程编程模版上 (1)线程 操作 资源类 (2)高内聚低耦合 2.实现步骤 (1)创建资源类 (2)资源类里创建同步方法,同步代码块 3.例子:卖票 LOCK 接口 锁 ...
- excel用xlrd日期变成42631.0
datetime的解决办法混合数据的表中有个日期:2016/9/18 通过table.row_values(row_number)[1]读取时,显示的结果为:42631.0 查看row_values方 ...
- NG-ALAIN 边学边记1
在文件夹下右键启动powerShell ng new my-project --skip-npm cd my-project ng add ng-alainnpm installng serve np ...
- 如何在vivado中调用ultraedit 编辑器
ISE下点击菜单Edit -> Preferences -> Editor. 在Editor选项框里选择Custom,在Command line syntax文本框里输入: {C:/Pro ...
- SpringMVC进行Ajax请求页面显示乱码
最近在项目的使用过程中发现在springmvc的项目中,使用返回页面的请求方式,数据都能正常显示,但是对于ajax的请求,始终显示乱码. 首先第一种是因为我们在web.xml中配置了spring的字符 ...
- 阿里云MySQL安装到centos,并链接。
Last login: Wed Jan 22 11:21:17 on ttys001 wulaguixiaomianyangdeMacBook-Pro:~ xingwen$ ssh root@47.9 ...