https://codeforces.com/contest/1144/problem/G

题解:我抄的,但是

a[i]<a[i+1]

这个为什么啊??? 做了一些测试,感觉可以证明。

/*
*@Author:   STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
#define endl "\n"
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=200000+10;
const int M=100000+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,p,l,r,u,v;
int cnt,flag,temp,sum;
int a[N];
char str;
struct node{};
int main()
{
#ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout);
#endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);//while(t--){scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%d",&a[i]);vector<int>v1={-1};vector<int>v2={INF};vector<int>ans;for(int i=1;i<=n;i++){u=v1.back()<a[i];v=v2.back()>a[i];if(u&&v){if(i+1<=n){if(a[i]<a[i+1]){v1.push_back(a[i]);ans.push_back(0);}else{v2.push_back(a[i]);ans.push_back(1);}}else{v1.push_back(a[i]);ans.push_back(0);}}else if(u||v){if(u){v1.push_back(a[i]);ans.push_back(0);}else{v2.push_back(a[i]);ans.push_back(1);}}else{flag=1;break;}}if(!flag){cout<<"YES"<<endl;for(int i:ans)cout<<i<<' ';}else{cout<<"NO"<<endl;}//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);
#endif//cout << "Hello world!" << endl;return 0;
}

Two Merged Sequences相关推荐

  1. Two Merged Sequences(CF 1144 G)

    前言 在做其它题的时候脑补到过这个题意,没想到还真有这样的题 题目相关 链接 题目大意 给一个序列,问是否能将这个序列完全划分成一个上升子序列和下降子序列 数据范围 n≤2⋅105n\le2·10^5 ...

  2. CodeForces - 1144G Two Merged Sequences

    题意:给出一个序列,请将它按原顺序分别分成一个递增和一个递减的序列,不行就输出no. 思路: 由于两个序列的顺序是不变的,只是两个序列之间互相穿插,那么我们记录当前递增的序列的最大值和当前递减序列的最 ...

  3. Two Shuffled Sequences

    C. Two Shuffled Sequences time limit per test2 seconds memory limit per test256 megabytes inputstand ...

  4. DAY1 Two Shuffled Sequences

    C. Two Shuffled Sequences time limit per test2 seconds memory limit per test256 megabytes inputstand ...

  5. C. Two Shuffled Sequences

    Two integer sequences existed initially - one of them was strictly increasing, and the other one - s ...

  6. Codeforces Round #550 (Div. 3) C.Two Shuffled Sequences

    C. Two Shuffled Sequences Two integer sequences existed initially - one of them was strictly increas ...

  7. Codeforces Round #550 (Div. 3)C. Two Shuffled Sequences

    Two integer sequences existed initially - one of them was strictly increasing, and the other one - s ...

  8. Codeforces1144C(C题)Two Shuffled Sequences

    C. Two Shuffled Sequences Two integer sequences existed initially - one of them was strictly increas ...

  9. 1144C C. Two Shuffled Sequences(优先队列和set的应用)

    Two integer sequences existed initially - one of them was strictly increasing, and the other one - s ...

最新文章

  1. 如何重装Domino服务器或者将Domino服务器从一台机器迁移到另外一台
  2. [模仿微软Live.cn]JavaScript输入邮箱自动提示
  3. python中导入包中的__init__文件夹的一个重要作用(去年对文件名的导入)
  4. PA银行面试之炮灰之程
  5. 服务注册发现consul之五:Consul移除失效服务的正确姿势
  6. tensorflow随笔-collection收集器
  7. 修改Linux字体出现乱码
  8. I.MX6 Surfaceflinger 机制
  9. thinkphp的select和find的区别(转)
  10. 【转载】ADS分散加载文件使用总结(lpc23xx)
  11. 理论基础 —— 栈 —— 双端栈
  12. 2017.9.14 仪仗队 思考记录
  13. 湾区人工智能私密圈|湾区AI精英汇
  14. MySQL数据库加密和解密~认证登陆密码(mysql.user)和MySQL不区分大小写
  15. 那么问题来了,什么才是正确的?我们就是为问题而生的
  16. golang的配置文件操作:viper
  17. 劳务派遣计算机信息管理系统,劳务派遣人员信息管理系统
  18. anjuta 连接mysql_anjuta的基本使用方法(包括如何设置MYSQL)
  19. 【Arduino实验16 步进电机的控制】
  20. python读取图片分辨率_Python 程序查找图像的大小(分辨率)

热门文章

  1. springboot 增加prometeus监控
  2. 浏览器卡怎么办_SD卡无法格式化怎么修复?简单修复方法介绍
  3. linux使用qemu教程,Linux:使用 QEMU 测试 U-BOOT的步骤
  4. 何杰月c语言课程,多线程 - 何杰leo的个人空间 - OSCHINA - 中文开源技术交流社区...
  5. 如何linux中文改为英文,CentOS系统如何将中文语言改成英文
  6. optfine的jar文件打不开_JAVA版1.14.4 装了最新版的optifine游戏打不开了 求助大佬们...
  7. 甘肃省计算机等级考试在线支付,甘肃计算机等级考试入口
  8. 八十八、Python | 十大排序算法系列(下篇)
  9. 简单php不用mysql_简单的PHP / MySQL不工作
  10. 享学金三银四一线大厂面试专题学习笔记