浏览器标题切换
浏览器标题切换end

寒假Day32:CodeForces 1304-思维

Shortest and Longest LIS

 CodeForces - 1304D 

复制代码
 1 #include<stdio.h>
 2 #include<string.h>
 3 #include<iostream>
 4 using namespace std;
 5 const int N=2e5+20;
 6 
 7 char s[N];
 8 int a[N],b[N];
 9 
10 int main()
11 {
12     int t,n;
13     cin>>t;
14     while(t--)
15     {
16         scanf("%d %s",&n,s);
17         int p=0,nn=n;
18         for(int i=0; i<n; i++)
19         {
20             if(i==n-1||s[i]=='>')
21             {
22                 for(int j=i; j>=p; j--)
23                     a[j]=nn--;
24                 p=i+1;
25             }
26         }
27         int q=0,x=1;
28         for(int i=0; i<n; i++)
29         {
30             if(i==n-1||s[i]=='<')
31             {
32                 for(int j=i; j>=q; j--)
33                     b[j]=x++;
34                 q=i+1;
35             }
36         }
37         for(int i=0; i<n-1; i++)
38             cout<<a[i]<<" ";
39         cout<<a[n-1]<<endl;
40         for(int i=0; i<n-1; i++)
41             cout<<b[i]<<" ";
42         cout<<b[n-1]<<endl;
43     }
44     return 0;
45 }
View Code
复制代码

 

posted @   抓水母的派大星  阅读(122)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
点击右上角即可分享
微信分享提示