https://codeforces.com/contest/1304/problem/D

 #include<bits/stdc++.h>
using namespace std;
void solve(){
int n;
string s;
cin>>n;
cin>>s;
int Min[n];
int t = n;
for(int i = ;i<s.length();i++){
int len = ,indx = i;
if(s[i] == '<'){
while(s[i]=='<'){
len++;
i++;
}
}
for(int j = i;j>=i-len;j--){
Min[j] = t,t--;
}
}
if(t) Min[n-] = t;
t = ;
int Max[n];
for(int i = ;i<s.length();i++){
int len = ,indx = i;
if(s[i] == '>'){
while(s[i]=='>'){
len++;
i++;
}
}
for(int j = i;j>=i-len;j--){
Max[j] = t,t++;
}
}
if(t == n) Max[n-] = t;
for(int i = ;i<n;i++) cout<<Min[i]<<" ";
cout<<endl;
for(int i = ;i<n;i++) cout<<Max[i]<<" ";
cout<<endl;
}
int main(){
int t;
cin>>t;
while(t--){
solve();
}
return ;
}

Codeforces 1304D. Shortest and Longest LIS 代码(构造 贪心)的更多相关文章

  1. Codeforces 1304D. Shortest and Longest LIS

    根据题目,我们可以找最短的LIS和最长的LIS,找最短LIS时,可以将每一个increase序列分成一组,从左到右将最大的还未选择的数字填写进去,不同组之间一定不会存在s[i]<s[j]的情况, ...

  2. Shortest and Longest LIS

    Codeforces Round #620 (Div. 2) D. Shortest and Longest LIS 题解: 贪心即可,对于最短序列,我们尽可能用可用的最大数字放入序列中,对于最长序列 ...

  3. [CF1304D] Shortest and Longest LIS - 贪心

    看样例,>><>><,要构造 LIS 最短的,我们需要找最小链划分的方案,即包含最少的下降列 很容易想到把连续 < 的看成一段,比如样例就是 .|.|. .| ...

  4. Codeforces1304D Shortest and Longest LIS

    前置扯淡 %%@\(wucstido\),思路是在是巧妙---link Description 给一个长度为\(n\)由 \(<\) 和 \(>\)组成的字符串,表示序列中相邻位置的数的大 ...

  5. Codeforces 985 最短水桶分配 沙堆构造 贪心单调对列

    A B /* Huyyt */ #include <bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a)) #define mkp(a, ...

  6. Codeforces Global Round 9 B. Neighbor Grid (构造,贪心)

    题意:给一个\(n\)X\(m\)的矩阵,矩阵中某个数字\(k\)表示其四周恰好有\(k\)个不为0的数字,你可以使任意位置上的数字变大,如果操作后满足条件,输出新矩阵,否则输出NO. 题解:贪心,既 ...

  7. Codeforces Round #620 (Div. 2) A-F代码 (暂无记录题解)

    A. Two Rabbits (手速题) #include<bits/stdc++.h> using namespace std; typedef long long ll; int ma ...

  8. [Codeforces 1205B]Shortest Cycle(最小环)

    [Codeforces 1205B]Shortest Cycle(最小环) 题面 给出n个正整数\(a_i\),若\(a_i \& a_j \neq 0\),则连边\((i,j)\)(注意i- ...

  9. 【Codeforces】Gym 101156E Longest Increasing Subsequences LIS+树状数组

    题意 给定$n$个数,求最长上升子序列的方案数 根据数据范围要求是$O(n\log n)$ 朴素的dp方程式$f_i=max(f_j+1),a_i>a_j$,所以记方案数为$v_i$,则$v_i ...

随机推荐

  1. pytorch --- word2vec 实现 --《Efficient Estimation of Word Representations in Vector Space》

    论文来自Mikolov等人的<Efficient Estimation of Word Representations in Vector Space> 论文地址: 66666 论文介绍了 ...

  2. 杭电-------2053Switch Game(C语言)

    /* 题目大意是指:有n个灯泡,按1-n编号,要操作n次,第i次操作是将标号是i的倍数的变成相反状态.最终求得是n次操作后,编号为n的灯泡的状态,其实就是求n的约束有多少个,及灯泡n被操作了多少次*/ ...

  3. React中使用 PropTypes 进行类型检查

    官方文档学习链接:https://zh-hans.reactjs.org/docs/typechecking-with-proptypes.html import React, { Component ...

  4. 珠峰-vue

  5. GNU make doc - 3.8

    Note that the directory prefix (D), as described in Implicit Rule Search Algorithm, is appended (aft ...

  6. OpenLayers要素拖拽

    //拖拽要素 function dragFeature (_map,_dragEndCallback) { let selFeature = null; _map.on("pointerdr ...

  7. 10.Android-SharedPreferences使用

    1.SharedPreferences介绍 SharedPreferences,它是一个轻量级的配置文件类,用于保存软件配置参数. 采用xml文件形式存储在/data/data/包名/shared_p ...

  8. cf1280B

    题意:给出一个n*m的矩阵,矩阵中的元素要么P要么是A 每次可以选择一个的子矩形,然后将矩阵中每一行都变为第一行,或者将矩阵中每一列都变为第一列 要求用最少的次数将矩阵中所有元素都变成A 题解:分类讨 ...

  9. Scheduled和HttpClient的连环坑

    首页 > JAVA > @Scheduled和HttpClient的连环坑 @Scheduled和HttpClient的连环坑 2018-03-22 曾经踩过一个大坑: 由于业务特殊性,会 ...

  10. 汇桔网被曝拖欠12月份工资至今,强制买产品,CEO称去年交易额超400亿

    三言财经消息,近日有汇桔网员工爆料,汇桔网拖欠12月工资至今,通知延迟到4月才发放. 此外爆料还指出,"各种手法逼迫大家离开,员工要么继续忍受,要么主动离职,要么停薪留职.都不同意只能仲裁. ...