QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB Total points: 100

#3223. 元胞自动机

Statistics

设 $w$ 为正整数,$p$ 为长度为 $2^{2w+1}$ 的字符串。$(w, p)$-元胞自动机定义如下:

  • 单元格排列在无限长的 1 维直线上。
  • 每个单元格有两种状态:0 和 1。
  • 在时间 0,Snuke 选择一些(有限数量的)单元格并将它们的状态设为 1。他将其他单元格的状态设为 0。
  • 设 $f(t, x)$ 为单元格 $x$ 在时间 $t(> 0)$ 的状态。$f(t, x)$ 由 $f(t - 1, x - w), \dots, f(t - 1, x + w)$ 根据以下规则确定:

$$f(t, x) = p\left[\sum_{i=-w}^{w} 2^{w+i} f(t - 1, x + i)\right]$$

如果无论 Snuke 在时间 0 如何选择状态,1 的数量永远保持不变,则 Snuke 喜欢该元胞自动机。给定整数 $w$ 和字符串 $s$,计算满足 $s \le p$ 且 Snuke 喜欢该 $(w, p)$-元胞自动机的字典序最小的 $p$。

输入格式

第一行包含一个整数 $w$ ($1 \le w \le 3$)。下一行包含字符串 $s$ ($|s| = 2^{2w+1}$,$s$ 由 '0' 和 '1' 组成)。

输出格式

输出最小的可能的 $p$。如果不存在这样的字符串,则输出 “no”。

样例

样例输入 1

1
00011000

样例输出 1

00011101

样例输入 2

1
11111111

样例输出 2

no

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.