toj 3019 Hidden Password (最小表示法)
Hidden Password
总提交: 53 测试通过: 19
描述
Some time the programmers have very strange ways to hide their passwords. See
for example how Billy "Hacker" Geits hide his password. Billy chooses a string S
composed of small Latin letters with length L. Then he makes all L-1 one-letter
left cyclic shifts of the string and takes as a password one prefix of the
lexicographically first of the obtained strings (including S). For example let
consider the string alabala. The cyclic one-letter left shifts (including the
initial string) are:
alabala
labalaa
abalaal
balaala
alaalab
laalaba
aalabal
and lexicographically first of them is the string aalabal. The first letter
of this string is in position 6 in the initial string (the positions in the
string are counted from 0).
Write a program that for given string S finds the start position of the
smallest lexicographically one-letter left cyclic shift of this string. If the
smallest lexicographically left shift appears more than once then the program
have to output the smallest initial position.
输入
Your program has to be ready to solve more than one test case. The first line
of the input file will contains only the number T of the test cases. Each of the
following T lines will describe one test case - first the length L of the string
(5 <= L <= 100000) and then, separated by one space, the string S
itself.
输出
The output file have to
contain exactly T lines with a single number each - the initial position found
by your program.
样例输入
2
6 baabaa
7 alabala
样例输出
1
6
题目来源
最小表示法 学习资料:
http://blog.csdn.net/cclsoft/article/details/5467743
模板 & 练习:
toj 3019 Hidden Password (最小表示法)的更多相关文章
- [USACO5.5]隐藏口令Hidden Password [最小表示法模板]
最小表示法就是一个字符串构成一个环,找以哪个点为开头字典序最小. 然后我们就可以用n2的算法愉快的做啦~实际上有O(n)的做法的,就是用两个指针扫,如果这两个位置的字典序相等,就一起往后,如果某一个大 ...
- 洛谷P1709 [USACO5.5]隐藏口令Hidden Password(最小表示法)
题目描述 有时候程序员有很奇怪的方法来隐藏他们的口令.Binny会选择一个字符串S(由N个小写字母组成,5<=N<=5,000,000),然后他把S顺时针绕成一个圈,每次取一个做开头字母并 ...
- [洛谷P1709] [USACO5.5]隐藏口令Hidden Password
洛谷题目链接:[USACO5.5]隐藏口令Hidden Password 题目描述 有时候程序员有很奇怪的方法来隐藏他们的口令.Binny会选择一个字符串S(由N个小写字母组成,5<=N< ...
- zoj 1729 Hidden Password
Hidden Passwordhttp://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=729 Time Limit: 2 Seconds ...
- USACO 5.5 Hidden Password
Hidden Password ACM South Eastern Europe -- 2003 Sometimes the programmers have very strange ways of ...
- HDU 4162 Shape Number (最小表示法)
题意:给你一串n个数,求出循环来看一阶差的最小字典序:数字串看成一个顺时针的环,从某一点开始顺时针循环整个环,保证字典序最小就是答案 例如给你 2 1 3 就会得到(1-2+8 注意题意负数需要加8) ...
- POJ 1635 树的最小表示法/HASH
题目链接:http://poj.org/problem?id=1635 题意:给定两个由01组成的串,0代表远离根,1代表接近根.相当于每个串对应一个有根的树.然后让你判断2个串构成的树是否是同构的. ...
- HDU 2609 最小表示法
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2609 题意:给定n个循环链[串],问有多少个本质不同的链[串](如果一个循环链可以通过找一个起点使得和 ...
- HDU 4162 最小表示法
题目:http://acm.hdu.edu.cn/showproblem.php?pid=4162 题意:给定一个只有0-7数字组成的串.现在要由原串构造出一个新串,新串的构造方法:相邻2个位置的数字 ...
随机推荐
- [洛谷P4178] Tree (点分治模板)
题目略了吧,就是一棵树上有多少个点对之间的距离 \(\leq k\) \(n \leq 40000\) 算法 首先有一个 \(O(n^2)\) 的做法,枚举每一个点为起点,\(dfs\) 一遍可知其它 ...
- (转)宽字节编码类型的XSS
今晚又看了一遍PKAV-心上的瘦子写的xss腾讯系列的例子,收获挺大的,其中对宽字节注入有了更深的了解,又查找了一些相关的资料,整理一下,以备以后查阅 参考文档: http://book.2cto.c ...
- typescript step by step two
- Python 类中方法的内部变量,命名加'self.'变成 self.xxx 和不加直接 xxx 的区别
先看两个类的方法: >>> class nc(): def __init__(self): self.name ='tester' #name变量加self >>> ...
- Shell之用户与权限
用户与组 早期Linux系统设计为了能够实现多用户.多进程高效的利用服务器资源,在此种情况下,为了能够保证用户与用户之间的文件不被随意的访问及修改.删除等操作,用户.组的管理能在某种程序上实现管理用户 ...
- 使用NetBenchmark压测TCP,HTTP和Websocket服务
NetBenchmark是针对网络服务压测订制的开源组件,组件提供TCP,HTTP和Websocket的压力测试基础功能:为了更好的符合业务需求组件不提供UI配置信息源的方式(毕竟这种方式只能作有限制 ...
- Java虚拟机系列一:一文搞懂 JVM 架构和运行时数据区
前言 之前写博客一直比较随性,主题也很随意,就是想到什么写什么,对什么感兴趣就写什么.虽然写起来无拘无束,自在随意,但也带来了一些问题,每次写完一篇后就要去纠结下一篇到底写什么,看来选择太多也不是好事 ...
- 【WPF学习】第三十二章 执行命令
前面章节已经对命令进行了深入分析,分析了基类和接口以及WPF提供的命令库.但尚未例举任何使用这些命令的例子. 如前所述,RoutedUICommand类没有任何硬编码的功能,而是只表达命令,为触发命令 ...
- 3、MySQL 索引失效的场景
索引失效的场景: 1.没有 where 条件 直接看 SQL 语句 2.where 条件中所在的列没有建立索引 show index from t; 3.从表中取得数据超过某个阈值.通常认为是 ...
- js数组冷知识
省略数组值 在声明数组时,省略一些数组值 let a = [1,,3] //a.length为3 a = [,,] //a.length为2 0 in a //false,a在索引0处没有元素 稀疏数 ...