题目大意:给定一个串S,求最小表示法

n<=1000W,实在不敢写后缀自己主动机,就去学了最小表示法= =

记得用unsigned char不然WA= = 数据真是逗- -

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define M 10001000
using namespace std;
int n;
unsigned char s[M];
int Min_Representation()
{
int i,j,k;
for(i=1,j=2,k=0;i<=n&&j<=n&&k<=n;)
{
int t=s[i+k>n?i+k-n:i+k]-s[j+k>n?j+k-n:j+k];
if(!t) k++;
else
{
if(t>0) i+=k+1;
else j+=k+1;
if(i==j) ++j;
k=0;
}
}
return min(i,j);
}
int main()
{
scanf("%d\n",&n);
fread(s+1,1,n,stdin);
int ans=Min_Representation();
if(ans==1)
fwrite(s+1,1,n,stdout);
else
fwrite(s+ans,1,n-ans+1,stdout),fwrite(s+1,1,ans-1,stdout);
cout<<endl;
return 0;
}

BZOJ 2176 Strange string 最小表示法的更多相关文章

  1. BZOJ 2176 Strange string ——最小表示法

    本来想用来练习后缀自动机的,但是100w有点虚(事实证明确实T掉了). 只好上最小表示法. #include <cstdio> #include <cstring> #incl ...

  2. BZOJ 2176 Strange String (最小表示法)

    题目大意: 与别的裸题的唯一不同点是其符号的ASCII码值在3 ~ 254 之间. 算法讨论: 最小表示法直接上.但是唯一不同的就是注意这里的字符范围,用char是会get wa的,所以要用unsig ...

  3. bzoj2740 串 && bzoj2176 strange string(最小表示法模板)

    https://konnyakuxzy.github.io/BZPRO/JudgeOnline/2740.html 题解讲的很清楚了 (好像等于的情况应该归入case2而不是case1?并不确定) 具 ...

  4. BZOJ2176Strange string——最小表示法

    题目描述 给定一个字符串S = {S1, S2, S3 … Sn}, 如果在串SS中, 子串T(|T| = n)为所有长度为n的SS的字串中最小的(字符串的比较), 则称T为”奇怪的字串”. 你的任务 ...

  5. bzoj 2176 最小表示

    2176: Strange string Time Limit: 10 Sec  Memory Limit: 259 MBSubmit: 419  Solved: 174[Submit][Status ...

  6. bzoj2176 Strange string(字符串最小表示法)

    Time Limit: 10 Sec  Memory Limit: 259 MB 给定一个字符串S = {S1, S2, S3 … Sn}, 如果在串SS中, 子串T(|T| = n)为所有长度为n的 ...

  7. hdu String Problem(最小表示法入门题)

    hdu 3374 String Problem 最小表示法 view code#include <iostream> #include <cstdio> #include &l ...

  8. HDOJ3374 String Problem 【KMP】+【最小表示法】

    String Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) T ...

  9. hdu 3374 String Problem(kmp+最小表示法)

    Problem Description Give you a string with length N, you can generate N strings by left shifts. For ...

随机推荐

  1. -------------》》》【Vim】vim的一些简单配置~

    在linux下使用   :vsp ~/.vimrc   来打开配置文件 一些命令[任何命令前加上   !    强制执行]: :w     保存 :wq    保存退出 :q     退出 ctrl ...

  2. [Luogu1429]平面最近点对(加强版)

    题目大意: 平面最近点对. 思路: 分治. 首先将所有点排序 每次把当前区间分为两半,递归求解两个区间内部的情况,然后枚举区间两边的点. #include<cmath> #include& ...

  3. SSMS查看表行数以及使用空间 How to show table row count and space used in SSMS - SSMS Tutorials

    原文:How to show table row count and space used in SSMS - SSMS Tutorials There's a quick and convenien ...

  4. linux的file指令

    显示文件的类型,用命令 file 可以使你知道某个文件究竟是ELF格式的可执行文件, 还是shell script文 件或是其他的什么格式 例如:#file startx 语 法:file [-beL ...

  5. VirtualBox – Error In supR3HardenedWinReSpawn

    Genymotion 模拟器安装好虚拟机后,启动时报错: ————————— VirtualBox – Error In supR3HardenedWinReSpawn ————————— <h ...

  6. Linux文件压缩与解压命令

    1  .zip 格式压缩与解压 压缩命令 zip 压缩文件名 源文件 zip  -r   压缩目录名       源目录 解压命令 unzip 文件名 td@td-Lenovo-IdeaPad-Y41 ...

  7. cordova百度导航插件使用

    org.ssgroup.sope.cordova.baiduNavi 插件已经开源至 https://github.com/shenshouer/org.ssgroup.sope.cordova.ba ...

  8. nginx $document_uri 参数使用

    $document_uri  表示访问的url 现在我的需求是,访问 www.abc.com  请求到 www.abc.com/abc/在nginx配置文件中加入 if ($document_uri ...

  9. JS方面重点摘要(一)

    1.获取样式(1)style只能获取到行间样式的属性(2)火狐getComputedStyle(obj,null)[attr],IE:obj.currentStyle[attr] 2.ready.on ...

  10. linux bash 入门

    #!/bin/bash #shell使用的熟练成都反映用户对Unix/Linux使用的熟练程度 #shell 有两种执行命令的方式:交互式和批处理 #常见的shell脚本解释器有bash,sh,csh ...