寒假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 }