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个位置的数字 ...
随机推荐
- Java入门 - 高级教程 - 05.网络编程
原文地址:http://www.work100.net/training/java-networking.html 更多教程:光束云 - 免费课程 网络编程 序号 文内章节 视频 1 概述 2 Soc ...
- 关于PDF阅读器
获取流程 1.点击下载xodo 2.跳转到如下界面,单击箭头所指的版本: 3.单击转到 中国-中文 4.点击获取 5.在跳出来的界面点击红框 6.打开本机的Microsoft Store下载应用 介绍 ...
- test api formdata
- 快速构建第三方api应用
1.使用框架和扩展 详细请看composer.json "php": "^7.1.3", "laravel-admin-ext/config" ...
- 解决Idea的Generate Sources无法生成QueryDSL问题
今天是2020年第一天在家办公,就出现了跟在公司不一样的现象,deploy项目到maven库时失败,之前一直成功. 查到原因在于QueryDSL类没有生成,但为何在公司可以而在家里就不行呢? 鉴于Id ...
- python3.6的安装及cx_oracle安装
一.创建所需目录mkdir -p /home/用户名/software/python3.6.1mkdir -p /home/用户名/priv/bydmkdir -p /home/用户名/priv/by ...
- php--->注册模式
注册模式 什么是注册树模式? 注册树模式当然也叫注册模式,注册器模式.注册树模式通过将对象实例注册到一棵全局的对象树上,需要的时候从对象树上采摘的模式设计方法. 优点:单例模式解决的是如何在整个项目中 ...
- 《即时消息技术剖析与实战》学习笔记10——IM系统如何应对高并发
一.IM 系统的高并发场景 IM 系统中,高并发多见于直播互动场景.比如直播间,在直播过程中,观众会给主播打赏.送礼.发送弹幕等,尤其是明星直播间,几十万.上百万人的规模一点也不稀奇.近期随着武汉新型 ...
- Web自动化测试项目(四)测试报告
测试报告生成 使用HTMLTestRunner 生成测试报告 本文使用的 HTMLTestRunner 来源于github: https://github.com/githublitao/HTMLTe ...
- 在 Ubuntu 上安装 K8S教程
在 Ubuntu 上安装 K8S教程 1,更新系统源 如果系统本身自带得镜像地址,服务器在国外,下载速度会很慢,可以打开 /etc/apt/sources.lis 替换为国内得镜像源. apt upg ...