Problem - D - Codeforces

题意 : 有 a 个0,b个1,c个2,d个3,构成一个序列,使得每两个数字之间的差值为1

题解: 就是以四种数字分别为起点,暴力模拟

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const int N=4e5+50;
const ll inf=1e18;
const ll mod=998244353;
ll a[N];
pll q[N];
ll vis[N];
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll sum=0;
for(ll i=1;i<=4;i++){ cin>>a[i];sum+=a[i];}
for(ll i=1;i<=4;i++){
if(!a[i]) continue;
vector<ll> temp(5,0);
vector<ll> pt;
for(ll j=1;j<=4;j++) temp[j]=a[j];
ll now=i;
while(1){
pt.push_back(now);
temp[now]--;
if(now>=2&&temp[now-1]) now--;
else if(now<=3&&temp[now+1]) now++;
else break;
}
if(pt.size()!=sum) continue;
if(temp[1]+temp[2]+temp[3]+temp[4]==0){
cout<<"YES"<<endl;
for(ll j=0;j<pt.size();j++) cout<<pt[j]-1<<" ";
cout<<endl;
return 0;
}
}
cout<<"NO";
}

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

  1. Codeforces Round #604(Div. 2,

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

  2. 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 ...

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

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

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

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

  5. Codeforces Round #604 (Div. 2) B. Beautiful Numbers

    链接: https://codeforces.com/contest/1265/problem/B 题意: You are given a permutation p=[p1,p2,-,pn] of ...

  6. Codeforces Round #604 (Div. 2) A. Beautiful String

    链接: https://codeforces.com/contest/1265/problem/A 题意: A string is called beautiful if no two consecu ...

  7. Codeforces Round #604 (Div. 2) E. Beautiful Mirrors 题解 组合数学

    题目链接:https://codeforces.com/contest/1265/problem/E 题目大意: 有 \(n\) 个步骤,第 \(i\) 个步骤成功的概率是 \(P_i\) ,每一步只 ...

  8. Codeforces Round #604 (Div. 2) 部分题解

    链接:http://codeforces.com/contest/1265 A. Beautiful String A string is called beautiful if no two con ...

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

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

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

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

随机推荐

  1. 老子云AMRT全新三维格式正式上线,其性能全面超越现有的三维数据格式

    9月16日,老子云AMRT全新三维格式正式上线,其性能远超现有的三维数据格式.目前已有含国家超算长沙中心.中科院空间所.中车集团等上百家政企事业单位的项目中使用了AMRT格式,大大提升了可视化项目的开 ...

  2. 『现学现忘』Docker基础 — 40、发布镜像到Docker Hub

    目录 1.准备工作 2.Docker登陆命令 3.Docker提交命令 4.总结: 5.补充:docker tag命令 1.准备工作 Docker Hub地址:https://hub.docker.c ...

  3. python实现人脸关键部位检测(附源码)

    人脸特征提取 本文主要使用dlib库中的人脸特征识别功能. dlib库使用68个特征点标注出人脸特征,通过对应序列的特征点,获得对应的脸部特征.下图展示了68个特征点.比如我们要提 取眼睛特征,获取3 ...

  4. docker删除镜像报错 Error response from daemon: conflict: unable to delete f73fe6298efc (cannot be forced) - image has dependent child images

    方法1 docker rmi 镜像ID 方法2 docker rmi -f 镜像ID 方法3 docker rmi 镜像仓库名:tag

  5. NC14893 栈和排序

    NC14893 栈和排序 题目 题目描述 给你一个1->n的排列和一个栈,入栈顺序给定 你要在不打乱入栈顺序的情况下,对数组进行从大到小排序 当无法完全排序时,请输出字典序最大的出栈序列 输入描 ...

  6. Spring XmlBeanFactory 容器的基本实现

    容器的基本用法 熟悉 Spring 的朋友应该都很了解下段代码: public void testBeanFactory() { BeanFactory bf = new XmlBeanFactory ...

  7. 2022DASCTF Apr X FATE 防疫挑战赛-- SimpleFlow

    1.SimpleFlow 得到pcapng文件,协议分级统计显示大部分为TCP流和http流 过滤http流,发现了flag.zip,foremost分离,得到加密的zip 在pcapng中寻找pas ...

  8. Redis 渐进集群介绍

    redis 凭借着强大的功能和可靠的稳定性,应用场景越来越广.逐渐成为软件开发工程师必备的技能之一. 本篇文章,暂不做基本功能的介绍.直接教大家如何部署redis集群. 集群演进主要分为2部分. 一. ...

  9. 07 MySQL_SQL数据类型

    数据类型 整数类型: int(m) 对应java中的int bigint(m) 对应java中的long m代表显示长度,需要结合 zerofill使用 create table t_int(id i ...

  10. SpringBoot到底是什么?

    摘要:Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程. 本文分享自华为云社区<SpringBoot到底是什么?如何理解p ...