Codeforces Round #620 (Div. 2)D(LIS,构造)
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int ans[];
int ans2[];
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin>>t;
while(t--){
int n;
string s;
cin>>n>>s;
int mx=n;
for(int i=;i<n;++i){
int cnt=;
while(i<n&&s[i]=='<'){
++cnt;
++i;
}
for(int j=i;j>i-cnt;--j){
ans[j]=mx;//尽可能将大的数放在前面
--mx;
}
}
int mn=;
for(int i=;i<n;++i){
int cnt=;
while(i<n&&s[i]=='>'){
++cnt;
++i;
}
for(int j=i;j>i-cnt;--j){
ans2[j]=mn;//尽可能将小的数放在前面
++mn;
}
}
for(int i=;i<n;++i)
cout<<ans[i]<<" ";
cout<<"\n";
for(int i=;i<n;++i)
cout<<ans2[i]<<" ";
cout<<"\n";
}
return ;
}
Codeforces Round #620 (Div. 2)D(LIS,构造)的更多相关文章
- Codeforces Round #620 (Div. 2)
Codeforces Round #620 (Div. 2) A. Two Rabbits 题意 两只兔子相向而跳,一只一次跳距离a,另一只一次跳距离b,每次同时跳,问是否可能到同一位置 题解 每次跳 ...
- Codeforces Round #620 (Div. 2)D dilworld定理
题:https://codeforces.com/contest/1304/problem/D 题意:给定长度为n-1的只含’>'和‘<’的字符串,让你构造出俩个排列,俩个排列相邻的数字之 ...
- Codeforces Round #277 (Div. 2) E. LIS of Sequence DP
E. LIS of Sequence Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/486/pr ...
- Codeforces Round #339 (Div. 1) C. Necklace 构造题
C. Necklace 题目连接: http://www.codeforces.com/contest/613/problem/C Description Ivan wants to make a n ...
- Codeforces Round #620 (Div. 2) D
构造一个排列,要求相邻之间的数满足给定的大小关系,然后构造出两个序列,一个序列是所有可能的序列中LIS最长的,一个所有可能的序列中LIS最短的 最短的构造方法:我们考虑所有单调递增的部分,可以发现要让 ...
- Codeforces Round #620 (Div. 2) A-F代码 (暂无记录题解)
A. Two Rabbits (手速题) #include<bits/stdc++.h> using namespace std; typedef long long ll; int ma ...
- Codeforces Round #620 (Div. 2)E LCA
题:https://codeforces.com/contest/1304/problem/E 题意:给定一颗树,边权为1,m次询问,每次询问给定x,y,a,b,k,问能否在原树上添加x到y的边,a到 ...
- Codeforces Round #181 (Div. 2) A. Array 构造
A. Array 题目连接: http://www.codeforces.com/contest/300/problem/A Description Vitaly has an array of n ...
- Codeforces Round #306 (Div. 2) ABCDE(构造)
A. Two Substrings 题意:给一个字符串,求是否含有不重叠的子串"AB"和"BA",长度1e5. 题解:看起来很简单,但是一直错,各种考虑不周全, ...
随机推荐
- CodeForces - 1105D 多源搜索
#include<bits/stdc++.h> using namespace std; typedef long long ll; struct node{ int x,y; ll se ...
- ffmpeg rtp rtmp udp 推流命令
推组播 组播地址指的范围是224.0.0.0—239.255.255.255 ffmpeg -re -i chunwan.h264 -vcodec mpeg2video -f mpeg2video u ...
- 路由算法之LS算法和DV算法全面分析
转载文章:https://blog.csdn.net/qq_22238021/article/details/80496138 很透彻!!!
- Python入门常识【入门必学】
直接上内容: print print 隔行 / 连续 / 间隔输出 print(a) == print(a,end='\n') print(a, end='') print(a, end ...
- Visual Studio Code 搭建 C/C++开发环境方法总结
之前看错资料踩了不少坑,先将可行经验总结如下: 1. 下载 Visual Studio Code 并安装.地址:https://code.visualstudio.com 2. 安装 C/C++插件与 ...
- JavaScript-事件处理程序
DOM事件流: 1.事件冒泡 2.事件捕获 DOM2事件流: 1.事件捕获阶段 2.处于目标阶段 3.事件冒泡阶段 DOM3事件 事件处理程序: 1.HTML事件处理程序: 例一:<input ...
- AcWing 1049. 大盗阿福
//f[i,j]表示所有走了i步,且当前位于状态j的所有走法 j=1表示选第i个 j=0表示不选 //如果j=0 那么表示不选第i个 那么就可以从f[i-1,0]和f[i-1,1]转移过来 //如果j ...
- pandas 读取excel时,遇到数字变为科学计数法了, 怎么破?? 别慌 这样来处理
# 指定字段以string 方式读取 df = pd.read_excel("./test.xlsx", converters={"id": str})
- C语言 栈的初始化,入栈,出栈,判断栈是否为空,清空栈等函数
#include <stdio.h>#include <stdlib.h> typedef struct Node{ int data ; struct Node * pNex ...
- 2、gitlab使用及权限管理
目录 1.创建用户组... 2 2.创建用户... 4 3.新建项目... 5 4.linux端访问项目... 6 4.1 通过ssh方式访问... 6 4.2 通过http访问... 9 5.win ...