Misdeed -la bonté de Dieu et l'origine du mal-

시간 제한5초메모리 제한1024 MB

요약
196개의 비트를 13x13 행렬에 부호화해, 어떤 7개 행과 7개 열을 골라도 원래 비트열이 복원되도록 한다.
난이도

어려움10점 중 10점

유형
조합론, 수학, 구현, 행렬
정답자
아직 제출이 없습니다

문제

This is a two-step problem.

Tairitsu and Chunipenguin join forces to overcome the Trial of Karma. The Trial of Karma is structured as follows.

  1. Tairitsu receives a binary sequence SS of length 196196. Subsequently, Tairitsu constructs a 13×1313\times 13 matrix AA where each element is between 00 and 1515.
  2. The Trial of Karma involves selecting positive integers 1≤r_1<r_2<…<r_7≤131 \le r\_1 < r\_2 < \ldots < r\_7 \le 13 and 1≤c_1<c_2<…<c_7≤131 \le c\_1 < c\_2 < \ldots < c\_7 \le 13. Then create a 7×77\times 7 matrix BB such that the iith row and jjth column of BB is A_r_i,c_jA\_{r\_i,c\_j}. Chunipenguin is given this matrix BB and the values r_1,r_2,…,r_7,c_1,c_2,…,c_7r\_1, r\_2, \ldots, r\_7, c\_1, c\_2, \ldots, c\_7.
  3. Chunipenguin must determine SS by examining BB.

Let's help Tairitsu and Chunipenguin overcome the trials of karma!

입력

The first line contains an integer tt that is either 00 or 11. If t=0t=0, it means you must execute Tairitsu's strategy; if t=1t=1, it means you must execute Chunipenguin's strategy.

If t=0t=0, the next line contains 196196 integers, either 00 or 11, given without spaces. This represents the binary sequence SS received by Tairitsu.

If t=1t=1, a total of 77 positive integers are given over two lines. The iith integer on the first line is r_ir\_i, and the iith integer on the second line is c_ic\_i.

Subsequently, over the next 77 lines, 77 integers are given per line, separated by spaces. The jjth element on the iith line represents B_ijB\_{ij}.

출력

If t=0t=0, the program must output a total of 1313 lines, each containing 1313 numbers separated by spaces, where the jjth element on the iith line represents A_ijA\_{ij}.

If t=1t=1, the program must output a total of 196196 integers, either 00 or 11, on a single line without spaces. This must be the binary sequence SS that Tairitsu initially received.

예제2

  1. 예제 1

    입력
    0
    000...000
    
    예상 출력
    0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0
    
  2. 예제 2

    입력
    1
    1 2 3 4 5 6 7
    1 2 3 4 5 6 7
    0 0 0 0 0 0 0
    0 0 0 0 0 0 0
    0 0 0 0 0 0 0
    0 0 0 0 0 0 0
    0 0 0 0 0 0 0
    0 0 0 0 0 0 0
    0 0 0 0 0 0 0
    
    예상 출력
    000...000