首页 > 其他分享 >Codeforces Round #617 (Div. 3) E1

Codeforces Round #617 (Div. 3) E1

时间:2022-10-31 21:01:46浏览次数:44  
标签:return int 617 Codeforces 序列 const Div E1

E1. String Coloring (easy version)

观察样例我们发现要是最长下降子序列要是>=3 那我们显然不可能有解
然后我们考虑构造
要是最长最长下降子序列只是2的话 那显然我们只需要让在后面的比较小的值
也就是下降子序列的第二个位置变成1 其他位置都是0 即可

#include <bits/stdc++.h>
using namespace std;
const int N = 3e5+10;
const int M = 998244353;
const int mod = 998244353;
#define int long long
int up(int a,int b){return a<0?a/b:(a+b-1)/b;}
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define _ 0
#define pi acos(-1)
#define INF 0x3f3f3f3f3f3f3f3f
#define fast ios::sync_with_stdio(false);cin.tie(nullptr);

void solve(){
    int n;cin>>n;
    string a;cin>>a;
    vector<int>f;
    for(int i=0;i<n;i++){
        if(lower_bound(f.begin(),f.end(),a[i],greater<>())==f.end())f.push_back(a[i]);
        else f[lower_bound(f.begin(),f.end(),a[i],greater<>())-f.begin()]=a[i];
    }
    if(f.size()>=3){NO return;}else YES
    for(int i=0;i<n;i++){
        for(int j=i;j>=0;j--){
            if(a[j]>a[i]){
                cout<<1;
                goto out;
            }
        }
        cout<<0;
        out:1;
    }
}
signed main(){
    fast
    int t;t=1;//cin>>t;
    while(t--) {
        solve();
    }
    return ~~(0^_^0);
}

标签:return,int,617,Codeforces,序列,const,Div,E1
From: https://www.cnblogs.com/ycllz/p/16845769.html

相关文章

  • HTML如何让IMG自动适应DIV容器大小
    HTML如何让IMG自动适应DIV容器大小为了让IMG自适应大小,如下我做了一个横向自适应的示例:IMG样式(横向拉伸,纵向自动匹配大小)DIV样式(元素居中显示)IMG样式(横向拉伸,纵向自动匹配大......
  • html-span与div
    Div自己独占一行一行上可以有多个span实现网络布局<div>我是一个div标签我一个人占一整行</div>  <span>新浪</span>  <span>百度</span>Div相当于一个独占......
  • 固定高度的div在屏幕中居中方法
    如何将一个固定高度的div居中在屏幕中间呢?先来看个例子,定义一个div并设置其高度为600px;html代码:<divclass='a'></div>css样式代码:.a{height:600px;background......
  • Algorithm: Lecture 4. Divide-and-Conquer Homework
    author:Miyasakadate:2022-10-31title:"Algorithm:Lecture4.Divide-and-ConquerHomework"*Inthiswork,alltheindexofarraystartsby1.Question:Bin......
  • Codeforces Round #658 (Div. 1) B
    B.Unmerge看完样例发现31243后面跟着的12肯定是和3一组的因为他们不如3大所以他们一定是被直接排出来的就这样我们可以将这个序列分成好多组然后就是金典背包......
  • js/jq 点击按钮显示div,点击页面其他任何地方隐藏div
    1、HTML页面<!DOCTYPEhtml><html><head><metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/><title>无标题文档</title><stylet......
  • Codeforces Round #683 (Div. 1, by Meet IT) B
    B.CatchingCheaters对于我们做过的模板提来说这道题是子串那显然我们要改变一下我们的状态表示dp[i][j]表示以ai,bj结尾的max我们状态转移就是dp[i][j]=max{dp[i-1]......
  • Educational Codeforces Round 110 (Rated for Div. 2) D
    D.PlayoffTournament观察完题发现没改变一个只会修改自己及以上的权值所以我们直接暴力qlogn但是这个题恶心的就是他那个是倒着给的我们要reverse一遍注意这时候......
  • dp-leetcode152
    动态规划问题,存在重叠子问题/***<p>给你一个整数数组<code>nums</code>&nbsp;,请你找出数组中乘积最大的非空连续子数组(该子数组中至少包含一个数字),并返回该子数......
  • Codeforces Round #826 (Div. 3)
    题目链接CodeforcesRound#826(Div.3)F.Multi-ColoredSegmentsMulti-ColoredSegments题面翻译给定一维数轴上\(n\)条线段,每条线段都有给定的颜色\(c_i\)。对......