CF700E.Cool Slogans
NOI/NOI+/CTSC
通过率:0%
时间限制:4.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Bomboslav set up a branding agency and now helps companies to create new logos and advertising slogans. In term of this problems, slogan of the company should be a non-empty substring of its name. For example, if the company name is "hornsandhoofs", then substrings "sand" and "hor" could be its slogans, while strings "e" and "hornss" can not.
Sometimes the company performs rebranding and changes its slogan. Slogan A is considered to be cooler than slogan B if B appears in A as a substring at least twice (this occurrences are allowed to overlap). For example, slogan A = "abacaba" is cooler than slogan B = "ba", slogan A = "abcbcbe" is cooler than slogan B = "bcb", but slogan A = "aaaaaa" is not cooler than slogan B = "aba".
You are given the company name w and your task is to help Bomboslav determine the length of the longest sequence of slogans _s_1, _s_2, ..., s__k, such that any slogan in the sequence is cooler than the previous one.
Bomboslav 创立了一家品牌设计公司,现在帮助各企业创建新标志和广告口号。在本题中,企业的口号必须是其名称的一个非空子串。例如,若公司名称为 "hornsandhoofs",则子串 "sand" 和 "hor" 均可作为其口号,而字符串 "e" 和 "hornss" 则不行。
有时公司会进行品牌重塑并更改其口号。若口号 A 中至少包含两次(允许重叠)口号 B 作为子串,则称口号 A 比口号 B “更酷”。例如,口号 A = "abacaba" 比口号 B = "ba" 更酷;口号 A = "abcbcbe" 比口号 B = "bcb" 更酷;但口号 A = "aaaaaa" 并不比口号 B = "aba" 更酷。
现给定公司名称 w,你的任务是帮助 Bomboslav 确定最长口号序列 $ s_1,\ s_2,\ \dots,\ s_k $ 的长度,使得该序列中每个口号均比前一个口号更酷。
输入格式
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the length of the company name that asks Bomboslav to help. The second line contains the string w of length n, that consists of lowercase English letters.
输入的第一行包含一个整数 n(1 ≤ n ≤ 200000)—— 表示需要 Bomboslav 协助处理的公司名称的长度。
第二行包含一个长度为 n 的字符串 w,由小写英文字母组成。
输出格式
Print a single integer — the maximum possible length of the sequence of slogans of the company named w, such that any slogan in the sequence (except the first one) is cooler than the previous
输出一个整数——公司名称为 w 的口号序列的最大可能长度,使得该序列中除第一个口号外的每个口号都比前一个更“酷”。
输入输出样例
输入#1
3 abc
输出#1
1
输入#2
5 ddddd
输出#2
5
输入#3
11 abracadabra
输出#3
3
输入解题思路,AI测评打分。不知道怎么写?