三次函数的锯齿码AI (CI翻译)
Problem Statement
题目描述
AI (CI翻译)You are given positive integers $A,B,C,L,R$. Here, $L \leq R$. Define
$f(n)=n^3+An^2+Bn+C$.
For a non-empty string $S$ consisting of $\mathtt{+}$ and $\mathtt{-}$, define
$g(S) = \sum_{i=1}^{|S|} \begin{cases} f(i) & (S_i = \mathtt{+}) \\ -f(i) & (S_i = \mathtt{-}) \end{cases}$.
Here, $S_i$ denotes the $i$-th character of $S$.
An integer $k$ is said to be generable from $S$ if there exists a non-empty substring $S'$ of $S$ such that $g(S')=k$.
给定正整数 $A,B,C,L,R$,其中 $L \leq R$。定义
$f(n)=n^3+An^2+Bn+C$。
对于一个由 $\mathtt{+}$ 和 $\mathtt{-}$ 构成的非空字符串 $S$,定义
$g(S) = \sum_{i=1}^{|S|} \begin{cases} f(i) & (S_i = \mathtt{+}) \\ -f(i) & (S_i = \mathtt{-}) \end{cases}$。
其中,$S_i$ 表示 $S$ 的第 $i$ 个字符。
如果存在 $S$ 的一个非空子串 $S'$ 满足 $g(S')=k$,则称整数 $k$ 可以由 $S$ 生成。AI (CI翻译)
Construct a string $S$ that satisfies the following conditions.
构造一个满足以下条件的字符串 $S$。AI (CI翻译)
$1 \leq |S| \leq 2 \times 10^6$$S$is a string consisting of$\mathtt{+}$and$\mathtt{-}$.- Among the strings satisfying the two conditions above,
$S$maximizes the number of integers between$L$and$R$, inclusive, that are generable from$S$.
$1 \leq |S| \leq 2 \times 10^6$$S$是一个由$\mathtt{+}$和$\mathtt{-}$构成的字符串。- 在满足上述两个条件的字符串中,
$S$使得区间$[L,R]$内(含端点)可以由$S$生成的整数数量最大。
Furthermore, for the constructed string $S$ and each $k=L,L+1,\dots,R$, determine whether there exist two integers $l,r$ satisfying the following conditions, and if they exist, find one such pair.
此外,对于构造出的字符串 $S$,对每个 $k=L,L+1,\dots,R$,判断是否存在满足以下条件的两个整数 $l,r$;若存在,输出一组这样的 $l,r$。AI (CI翻译)
$1 \leq l \leq r \leq |S|$- Letting
$S'$be the string formed by the$l$-th through$r$-th characters of$S$, we have$g(S')=k$.
$1 \leq l \leq r \leq |S|$- 令
$S'$为由$S$的第$l$个至第$r$个字符构成的字符串,则$g(S')=k$。
What is a substring? A substring of $S$ is a string obtained by deleting zero or more characters from the beginning and zero or more characters from the end of $S$. For example, AB is a substring of ABC, but AC is not a substring of ABC.
什么是子串?$S$ 的子串是指从 $S$ 的开头删除零个或多个字符,并从结尾删除零个或多个字符后得到的字符串。例如,AB 是 ABC 的子串,但 AC 不是 ABC 的子串。AI (CI翻译)
Constraints
约束条件
AI (CI翻译)$1 \leq A,B,C \leq 10^5$$1 \leq L \leq R \leq \min(L+10^5,10^{14})$- All input values are integers.
$1 \leq A,B,C \leq 10^5$$1 \leq L \leq R \leq \min(L+10^5,10^{14})$- 所有输入值均为整数。
Input
输入格式
AI (CI翻译)The input is given from Standard Input in the following format:
输入从标准输入中按以下格式给出:AI (CI翻译)
A B C L R
A B C L RAI (CI翻译)
Output
输出格式
AI (CI翻译)Print a solution in the following format:
按以下格式输出一个解:AI (CI翻译)
S
\mathrm{output}_{L}
\mathrm{output}_{L+1}
\vdots
\mathrm{output}_{R}
S
\mathrm{output}_{L}
\mathrm{output}_{L+1}
\vdots
\mathrm{output}_{R}AI (CI翻译)
Here, $\mathrm{output}_i$ denotes the output for $k=i$.
If there exist two integers $l,r$ satisfying the conditions, print them in the following format:
这里,$\mathrm{output}_i$ 表示 $k=i$ 时的输出。
如果存在满足条件的两个整数 $l,r$,按以下格式输出:AI (CI翻译)
l r
l rAI (CI翻译)
If they do not exist, print -1.
如果不存在,则输出 -1。AI (CI翻译)
If there are multiple solutions, you may print any of them.
如果有多个解,可以输出其中任意一个。AI (CI翻译)
样例
2 2 3 22 23
+---+--+
2 5
6 8
1 2 2 5 7
++
-1
2 2
-1
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。