BZOJ2176Strange string——最小表示法
题目描述
输入
输出
样例输入
asdfasdfas
样例输出
提示
数据范围
对于100%的数据, 保证n≤10000000;
给定的字符串中的字符保证在#33 ~ #254之间.
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
int n,m;
unsigned char s[20000010];
int find()
{
int l=1;
int r=2;
while(l<=n&&r<=n)
{
if(s[l]<s[r])
{
r++;
}
else if(s[l]>s[r])
{
l=r++;
}
else
{
int k;
for(k=1;k<n;k++)
{
if(s[l+k]>s[r+k])
{
l=r++;
break;
}
else if(s[l+k]<s[r+k])
{
r=r+k+1;
break;
}
}
if(k==n)
{
break;
}
}
}
return l;
}
int main()
{
scanf("%d",&n);
scanf("%s",s+1);
for(int i=n+1;i<=2*n;i++)
{
s[i]=s[i-n];
}
m=find();
for(int i=m;i-m+1<=n;i++)
{
printf("%c",s[i]);
}
}
BZOJ2176Strange string——最小表示法的更多相关文章
- BZOJ 2176 Strange string 最小表示法
题目大意:给定一个串S,求最小表示法 n<=1000W,实在不敢写后缀自己主动机,就去学了最小表示法= = 记得用unsigned char不然WA= = 数据真是逗- - #include & ...
- bzoj2740 串 && bzoj2176 strange string(最小表示法模板)
https://konnyakuxzy.github.io/BZPRO/JudgeOnline/2740.html 题解讲的很清楚了 (好像等于的情况应该归入case2而不是case1?并不确定) 具 ...
- BZOJ 2176 Strange string ——最小表示法
本来想用来练习后缀自动机的,但是100w有点虚(事实证明确实T掉了). 只好上最小表示法. #include <cstdio> #include <cstring> #incl ...
- 【最小表示法】BZOJ2176-Strange string(unsigned char!!!)
[题目大意] 给定一个字符串S = {S1, S2, S3 … Sn}, 如果在串SS中, 子串T(|T| = n)为所有长度为n的SS的字串中最小的(字符串的比较), 则称T为”奇怪的字串”. 你的 ...
- hdu String Problem(最小表示法入门题)
hdu 3374 String Problem 最小表示法 view code#include <iostream> #include <cstdio> #include &l ...
- HDOJ3374 String Problem 【KMP】+【最小表示法】
String Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- hdu 3374 String Problem(kmp+最小表示法)
Problem Description Give you a string with length N, you can generate N strings by left shifts. For ...
- hdu3374 String Problem【最小表示法】【exKMP】
String Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- hdu3374 String Problem KMP+最大最小表示法
Give you a string with length N, you can generate N strings by left shifts. For example let consider ...
随机推荐
- Chrome 谷歌浏览器清除HTTPS证书缓存
在地址栏输入 chrome://net-internals/#hsts 找到下图中的输入框,输入对于的域名执行删除就行了
- NanoFabric-ServiceFabric 操作手册
service-fabric-52abp-ocelot A Service Fabric sample with a Frontend, one API Gateway and 52abp Micro ...
- 最长递增子序列(lis)最长公共子序列(lcs) 最长公共上升子序列(lics)
lis: 复杂度nlgn #include<iostream> #include<cstdio> using namespace std; ],lis[],res=; int ...
- python的四种内置数据结构
对于每种编程语言一般都会规定一些容器来保存某些数据,就像java的集合和数组一样python也同样有这样的结构 而对于python他有四个这样的内置容器来存储数据,他们都是python语言的一部分可以 ...
- HDU 2006 求奇数的乘积
http://acm.hdu.edu.cn/showproblem.php?pid=2006 Problem Description 给你n个整数,求他们中所有奇数的乘积. Input 输入数据包 ...
- 分布式事务 spring 两阶段提交 tcc
请问分布式事务一致性与raft或paxos协议解决的一致性问题是同一回事吗? - 知乎 https://www.zhihu.com/question/275845393 分布式事务11_TCC 两阶段 ...
- git repository description
Git - Plumbing and Porcelainhttps://git-scm.com/book/en/v2/Git-Internals-Plumbing-and-Porcelain gith ...
- Baby-Step-Giant-Step 很酷的算法
Baby-Step-Giant-Step BSGS算法用于解决形如: A ^ x ≡ B ( mod C ) 的问题. 学这个算法前需要具备以下知识:快速幂取模.扩展欧几里 ...
- Ajax发送请求等待时弹出模态框等待提示
主要的代码分为两块,一个是CSS定义模态框,另一个是在Ajax中弹出模态框. 查看菜鸟教程中的模态框教程demo,http://www.runoob.com/try/try.php?filename= ...
- Bootstrap 字体图标(Glyphicons)
http://www.runoob.com/bootstrap/bootstrap-glyphicons.html 什么是字体图标? 字体图标是在 Web 项目中使用的图标字体.虽然,Glyphico ...