아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Broken Sequence

시간 제한4초메모리 제한64 MB

요약
네 개의 부호 수열에서 일부 원소가 지워졌을 때, 모든 양의 이동에 대한 합성 자기상관이 0이 되도록 빠진 값을 복원한다.
난이도

보통10점 중 7점

유형
완전 탐색, 수학, 백트래킹
정답자
아직 제출이 없습니다

문제

Let XX be a sequence (x_1,x_2,…,x_n)(x\_1, x\_2, \dots , x\_n). Then the nonperiodic autocorrelation function N_X(s)N\_X(s) is: N_X(s)=∑_i=−∞∞x_ix_i+s,N\_X(s) = \sum\_{i=-\infty}^{\infty} x\_i x\_{i+s}, where ss is an integer. Here we assume that x_i=0x\_i=0 for i<1i<1 and i>ni>n.

Consider four sequences (A,B,C,D)(A,B,C,D) of length nn, nn, nn, and n−1n-1 correspondingly, all elements of which are from set −1,+1\\{ -1, +1 \\}. These four sequences form the TTTT-sequence (Turyn-Type sequence) if and only if N_A(s)+N_B(s)+2N_C(s)+2N_D(s)=0, for all integer s>0.N\_A(s) + N\_B(s) + 2N\_C(s) + 2N\_D(s) = 0,\text{ for all integer }s>0.

TTTT-sequences are very interesting because they allow building Hadamard matrices which find applications in such fields as signal processing and coding theory. For example, a TTTT-sequence for n=36n=36 (which has been found in 2005) allowed to construct a Hadamard matrix of order 428428 for the first time.

Given a TTTT-sequence where several elements are missing, restore the initial TTTT-sequence.

입력

The four lines contain four strings of length nn, nn, nn and n−1n-1 (2≤n≤362 \le n \le 36, nn is even) which encode sequences AA, BB, CC and DD. The ii-th symbol encodes the ii-th element of the corresponding sequence. "-" denotes −1-1, "+" denotes +1+1, and "?" denotes a missing element. The total number of the missing elements does not exceed 3030.

It is guaranteed that for the given data a single solution exists.

출력

Output four strings of length nn, nn, nn and n−1n-1 --- the restored TTTT-sequence. See samples for better understanding of output format.

예제2

  1. 예제 1

    입력
    ++-+-?-+
    +----?-+
    +--++?+-
    +++-+?-
    
    예상 출력
    ++-+-+-+
    +------+
    +--++++-
    +++-++-
    
  2. 예제 2

    입력
    +++----++-+-+?-?--++++-++-++++----+-
    +-+++++?-+-+--+--++--?+++-++++---++-
    +-+++++-+--?+++-+?+-++--+++-+--+-?-+
    +++-+?----++--+-+++?-+-+-+++-+?++-+
    
    예상 출력
    +++----++-+-+-----++++-++-++++----+-
    +-+++++--+-+--+--++--++++-++++---++-
    +-+++++-+--++++-+++-++--+++-+--+---+
    +++-+-----++--+-+++--+-+-+++-++++-+