寒假Day32:CodeForces 1304-思维
Shortest and Longest LIS

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 }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」