后缀数组
来源:互联网 发布:假人交友app源码 编辑:程序博客网 时间:2024/05/21 11:12
后缀数组比较大小:
题目:给你一个字符串 s , 它有所有的 后缀串suffix[i]={s[i],s[i+1],....,s[len-1]};
现在给你 p(p<=1000000)个后缀串的两个下标,要你比较两个后缀字符串的字典序大小
#include<iostream>#include<algorithm>#include<cstring>#include<string>#include<cstdio>using namespace std;#define manx 10009string s,suffix[manx];int sa[manx],pos[manx];bool comp(const int &i, const int &j){ return suffix[i]<suffix[j];}int main(){ while(cin>>s){ int len=s.size(); for(int i=len-1; i>=0; i--){ suffix[i] = s[i]; suffix[i] += suffix[i+1]; sa[i] = i; } sort(sa,sa+len,comp); int n,m,p; for(int i=0;i<len;i++){ // cout<<suffix[sa[i]]<<endl; pos[sa[i]] = i; } scanf("%d",&p); for(int i=0;i<p;i++){ scanf("%d%d",&n,&m); if(pos[n]>pos[m]) cout<<"yes"<<endl; else cout<<"no"<<endl; } }}
- 后缀树/后缀数组
- 后缀树 后缀数组
- 【后缀数组】后缀排序
- 后缀数组
- 后缀数组
- 后缀数组
- 后缀数组
- 后缀数组
- 后缀数组
- 后缀数组
- 后缀数组
- 后缀数组
- 后缀数组
- 后缀数组
- 后缀数组
- 后缀数组
- 后缀数组
- 后缀数组
- Wikioi 天梯 Fibonacci数列 3(1978)
- ORA-00401: the value for parameter compatible is not supported by this release
- 管理回收站(Oracle)
- Flex调用js获取本地所选文件的路径
- winxp win7 sam 文件删除 恢复
- 后缀数组
- while(scanf("%d",&n)!=EOF)
- 映射集合属性之④:bag元素映射
- 快速搭建 php +myspl +apacheh环境下载
- 停车场(队列堆栈基础练习)
- 实例与数据库的区别
- 模拟港澳通行证办理流程系统(队列基础练习)
- 显示PG中的表的每一行
- C++结构体的定义、初始化和引用