字符串排序 nyoj 1149
来源:互联网 发布:淘宝联盟 退运费 福袋 编辑:程序博客网 时间:2024/04/19 15:08
题目http://acm.nyist.net/JudgeOnline/problem.php?pid=1149
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;string str,s;int ll;struct node{string len;int l;}a[100001];int com(struct node a,struct node b){return a.len<b.len;}void solve(int n,int m){if(a[n].len.length()==ll)return ;for(int i=n;i<=m;i++){a[i].len+=str[(a[i].l+a[i].len.length())%ll];//!!!!!}sort(a+n,a+m+1,com);for(int i=n;i<=m;i++){ if(a[i].len==a[i+1].len){ int j=i+2; for(;j<ll;j++){ if(a[j].len!=a[i].len){ break; } } j--; solve(i,j); i=j; } }}int main(){while(getline(cin,str)){ll=str.length();for(int i=0;i<ll;i++){a[i].len="";a[i].len+=str[i];a[i].l=i;}sort(a,a+ll,com); for(int i=0;i<ll-1;i++){ if(a[i].len==a[i+1].len){ int j=i+2; for(;j<ll;j++){ if(a[j].len!=a[i].len){ break; } } j--; solve(i,j); i=j; } } sort(a,a+ll,com); string ans=""; for(int i=0;i<ll;i++){ int t=a[i].l; int tmp=(ll+t)%ll;// cout<<a[i].len<<' '<<a[i].l<<' '<<tmp<<endl; if(tmp!=0){ ans+=str.substr(tmp-1,1); } else{ ans+=str.substr(tmp+ll-1,1); } } cout<<ans<<endl; }return 0;}
0 0
- 字符串排序 nyoj 1149
- 字符串排序(nyoj 1149)
- NYOJ 540 奇怪的排序(字符串)
- nyoj 差值 1233 (大数减法&&字符串排序)
- NYOJ +-字符串
- NYOJ--+-字符串
- NYOJ +-字符串
- NYOJ-+-字符串
- nyoj +-字符串
- NYOJ+-字符串
- NYOJ +-字符串
- NYOJ +-字符串
- nyoj 915 +-字符串 【字符串】
- nyoj 915 +-字符串【字符串】
- NYOJ 8 一种排序
- NYOJ - ASCLL码排序
- NYOJ - 对称排序
- NYOJ - 一种排序
- 求mat的连通域,并只显示最大轮廓的连通域
- Android 定义全局LOG打印日志,并显示调用者相关信息
- uva191 Intersection(线段之间相交)
- 直接量
- 监听通知,在程序退出前要移除
- 字符串排序 nyoj 1149
- BZOJ4386: [POI2015]Wycieczki
- SDWebImage的细节问题
- 讲一个数组内的对象属性保存到另一个数组
- myeclipse中Could not find the main class: org.apache.catalina.startup.Boostrap. Program will exit
- Js apply call方法
- 2016-05-09 随感,生活还是眼前的苟且
- Html5——本地数据库
- 错误调试与异常处理 错 误 类 型