#P8846. 『JROI-7』PMK 配匹串符字

    ID: 9313 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>字符串2022洛谷原创Special Judge构造洛谷月赛

『JROI-7』PMK 配匹串符字

Background

The constraints are very loose, so the construction ends up being pretty dumb.

— command_block, "Pre-Exam Tips"

Problem Description

For a string SS, let S|S| denote the length of SS. Let SiS_i denote the ii-th character of SS, and let Sl,rS_{l,r} denote the string formed by Sl,Sl+1,...,SrS_l, S_{l+1}, ..., S_r. Two strings are defined to be equal if and only if they have the same length and the characters at every position are the same.

For a string SS and a positive integer iSi \le |S|, if kk is the largest positive integer satisfying k<ik < i and S1,k=Sik+1,iS_{1,k} = S_{i-k+1,i}, then nexti=knext_i = k. In particular, if no such kk exists, then nexti=0next_i = 0.

Please construct a string SS consisting of lowercase letters such that S=n|S| = n, and the sum of nextinext_i over all positive integers iSi \le |S| is minimized.

Input Format

One line containing a positive integer nn.

Output Format

One line containing a string, representing the SS you construct. Output any valid solution.

5
abcde

Hint

Constraints

This problem uses bundled testdata.

For 50%50\% of the testdata, n26n \le 26.

For 100%100\% of the testdata, 1n1051 \le n \le 10^5.

Translated by ChatGPT 5