QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 512 MB مجموع النقاط: 100

#2873. 极端问题

الإحصائيات

我们考虑定义在 $[-10; 10] \times [-10; 10]$ 正方形区域上的二元整数变量函数。这意味着你仅能在 $x$ 和 $y$ 为整数且 $-10 \le x, y \le 10$ 时调用 $f(x, y)$。如果以下条件同时成立,则称函数 $f$ 在 $(x, y)$ 处有一个局部极小值: $f(x, y) < f(x - 1, y)$; $f(x, y) < f(x + 1, y)$; $f(x, y) < f(x, y - 1)$; $f(x, y) < f(x, y + 1)$.

局部极大值的定义类似,只需将不等号反转即可。如果以下至少有一个条件成立,则称函数 $f$ 在 $(x, y)$ 处有一个平台(plateau): $f(x, y) = f(x - 1, y)$; $f(x, y) = f(x + 1, y)$; $f(x, y) = f(x, y - 1)$; $f(x, y) = f(x, y + 1)$.

注意,上述所有函数调用必须发生在函数定义域内的点上,即 $[-10; 10] \times [-10; 10]$ 正方形区域内。特别地,这意味着该正方形边界上的点不能是局部极大值或局部极小值,但仍可以是平台。

你需要找到一个函数,根据输入信息,使其满足或不满足以下条件: 多个局部极大值; 多个局部极小值; * 存在平台。

注意,“多个”意味着“至少两个”。同时请注意,你的函数必须以特定方式定义;详见输出格式部分。

输入格式

输入包含三行。 第一行以 “Multiple local maxima: ” 开头,以 “Yes” 或 “No” 结尾。这指定了你的函数是否应该具有多个局部极大值。 第二行以 “Multiple local minima: ” 开头,以 “Yes” 或 “No” 结尾,处理方式与局部极小值相同。 * 第三行以 “Plateaus: ” 开头,以 “Yes” 或 “No” 结尾。这指定了你的函数是否应该具有平台。

输出格式

输出应包含一行,用于定义你的函数。 如果不存在符合格式要求的函数,请输出 “No solution”。

否则,请使用逆波兰表示法(Reverse Polish Notation)输出你的函数。逆波兰表示法是一种使用栈机描述函数的方法:它是一个操作序列,其中一些操作将值压入栈中,而另一些操作从栈顶弹出若干值,执行数学运算并将结果压回栈中。

你的函数应包含最多 1000 个标记(token),以单个空格分隔,每个标记为以下之一: $-9$ 到 $+9$ 之间的整数常量。这会将对应的数字压入栈中。 变量 $x$ 或 $y$。这会将该变量的值压入栈中。 运算符,可以是 +-、`^。星号表示乘法,^` 字符表示幂运算。每个运算符都会从栈中取出两个数字,应用运算并将结果压回栈中。求值顺序使得 “9 5 -” 计算结果为 4,类似地 “x 2 ^” 计算结果为 $x^2$。作为特殊情况,$0^0$ 的计算结果为 1。

注意,当发生以下任一情况时: 操作尝试从空栈中取数; ^ 操作尝试将某数提升到负幂; 运算结果溢出 32 位有符号整数; 或者在求值结束时栈的大小不等于 1; 你将在发生该情况的测试中收到 Wrong Answer 结果。

样例

样例输入 1

Multiple local maxima: No
Multiple local minima: No
Plateaus: No

样例输出 1

x 3 - 4 ^ y -5 + 2 ^ +

样例输入 2

Multiple local maxima: No
Multiple local minima: No
Plateaus: Yes

样例输出 2

1

说明

第一个测试的样例答案编码了函数 $(x-3)^4 + (y + (-5))^2$。注意它没有局部极大值,没有平台,且只有一个局部极小值。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.