QOJ.ac

QOJ

时间限制: 4.0 s 内存限制: 64 MB 总分: 100

#18080. 損壞的序列

统计

令 $X$ 為一個序列 $(x_1, x_2, \dots, x_n)$。則非週期自相關函數 $N_X(s)$ 定義為:

$$N_X(s) = \sum_{i=-\infty}^{\infty} x_i x_{i+s}$$

其中 $s$ 為整數。在此我們假設對於 $i < 1$ 以及 $i > n$ 的情況,有 $x_i = 0$。

考慮四個長度分別為 $n, n, n$ 以及 $n-1$ 的序列 $(A, B, C, D)$,其所有元素皆來自集合 $\{-1, +1\}$。這四個序列構成一個 $TT$-序列(Turyn-Type sequence)若且唯若對於所有整數 $s > 0$:

$$N_A(s) + N_B(s) + 2N_C(s) + 2N_D(s) = 0$$

$TT$-序列非常有趣,因為它們可以用來建構 Hadamard 矩陣,這些矩陣在訊號處理和編碼理論等領域有廣泛應用。例如,一個 $n = 36$ 的 $TT$-序列(於 2005 年被發現)首次允許人們建構出階數為 428 的 Hadamard 矩陣。

給定一個其中若干元素缺失的 $TT$-序列,請還原出原始的 $TT$-序列。

輸入格式

輸入包含四行,分別為長度 $n, n, n$ 和 $n-1$ 的字串($2 \le n \le 36$,$n$ 為偶數),這些字串編碼了序列 $A, B, C$ 和 $D$。第 $i$ 個符號編碼了對應序列的第 $i$ 個元素。「-」代表 $-1,「+」代表 $+1,「?」代表缺失的元素。缺失元素的總數不超過 30 個。

保證給定的資料存在唯一解。

輸出格式

輸出四個長度分別為 $n, n, n$ 和 $n-1$ 的字串,代表還原後的 $TT$-序列。請參考範例以更了解輸出格式。

範例

範例 1

輸入

++-+-?-+
+----?-+
+--++?+-
+++-+?-

輸出

++-+-+-+
+------+
+--++++-
+++-++-

範例 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.