题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6294
题意:
给你一个字符串,让你不断比较前后之间的字典序大小,
要是前面小输出 '<' , 否则输出 '>'
其实这题很简单,后来我才发现,原来从后往前看即可,只要相等没必要重新比较
贴上代码:
#include<bits/stdc++.h>
using namespace std;
const int maxn=2006500;
int main()
{
int T;
scanf("%d",&T);
string ans[200];
for(int t=0;t<T;t++){
int n;
char str[maxn]={0};
char tmp[maxn]={0};
scanf("%d",&n);
scanf("%s",str);
for(int i=n-2;i>=0;i--){
if(str[i]<str[i+1]){
tmp[i]='<';
}else if(str[i]==str[i+1]&&i!=n-2){
tmp[i]=tmp[i+1];
}else{
tmp[i]='>';
}
}
printf("%s\n",tmp);
}
return 0;
}