Books

면접 대비

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

요약
책이 최대 21권, 학생이 최대 6명일 때, 각 학생의 단조 증가 읽기 능력 함수가 주어지면 후보 팀마다 두 학생이 함께 읽을 수 있는 책 집합을 모두 구한다.
난이도

보통10점 중 7점

유형
동적 계획법, 비트 연산, 완전 탐색, 조합론
정답자
아직 제출이 없습니다

문제

The Noname State University (NSU) is preparing for a new type of programming contest. Each university in this contest can be represented only by a single team of two students. There is also the official list of NN books which the contestants must read to perform successfully. There's little time left before the contest, and not every student is able to read all books in time.

Every student knows for each set of books whether she will be able to read it in time. There are MM students willing to participate in the contest in the NSU. The coach prepared a list of KK candidate teams. To choose a single team for the contest, she wants to know each team's reading capability.

Assume a team has read a book if at least one member of the team has read it. Your task is to find for each candidate team and for each set of books whether the team members can plan their training in such a way that the team will have read all the books of this set in time.

입력

The first line of the input file contains three integers: NN --- number of books, MM --- number of students, and KK --- number of candidate teams (1≤N≤211 \le N \le 21, 2≤M≤62 \le M \le 6, 1≤K≤61 \le K \le 6). Zero-based numbering is used everywhere in this problem.

The ii-th of the next MM lines defines the capabilities of the ii-th student. The student's capabilities are described with the string S_iS\_i of the length 2N2^N containing 0's and 1's. The kk-th position of the string contains information on whether the student is able to read the set of books with a bitmask of kk in time. This rule is described in detail below.

Let's number all books from 00 to N−1N-1. Let XX be a set of books. Define an array a_0,a_1,a_2,…,a_N−1a\_0, a\_1, a\_2, \ldots, a\_{N-1} such that a_j=1a\_j = 1, if jj-th book belongs to XX, and a_j=0a\_j = 0 otherwise. Let's call the number k=∑_j=0N−1a_j2jk = \displaystyle\sum\limits\_{j=0}^{N-1} a\_j 2^j the bitmask of the set XX. Then the ii-th student is able to read the set of books XX in time if and only if the kk-th symbol of the string S_iS\_i equals one.

tt-th of the next KK lines describes tt-th candidate team. The team is defined by two integers a_ta\_t and b_tb\_t --- the numbers of the students in the team. (0≤a_t,b_t<M0 \le a\_t, b\_t < M, a_t≠b_ta\_t \neq b\_t, t=0…K−1t = 0 \ldots K-1).

Regarding the capabilities of each student the following is guaranteed. First, if a student can read a subset of books, she can read any of its subsets. Second, a student can always read an empty set of books, i.e. the starting symbol of her capability string always equals one.

출력

The output file must contain KK lines consisting of 0's and 1's, each containing 2N2^N symbols. The tt-th line must contain the capabilities of the tt-th team in the same format in which the students' capabilities are given in the input. I. e. the kk-th symbol of the tt-th line must equal 11 if and only if the tt-th team is able to read the set XX of books with a bitmask kk in time.

힌트

The 00-th student can read one of the following sets: ∅\emptyset, 0\\{0\\}, 1\\{1\\}, 2\\{2\\}, 0,1\\{0, 1\\}, 1,2\\{1, 2\\}. The first student can only read the 00-th book (or nothing). The second student can read either the 00-th book or the book numbered 22 (or nothing). The third and the fourth students can read any single book (or nothing).

The 00-th team together is able to read all the books if the 00-th student reads the books 1,2\\{1, 2\\}, and the first student reads the book 00. It's easy to check that the team can also read any other set of books.

The first team can read the books 00 and 22, if its members read different books. The team can also ready any subsets of the set 0,2\\{0, 2\\}.

In the second team any member can read not more than one book. Hence, the team together can read any set of two or less books.

예제1

  1. 예제 1

    입력
    3 5 3
    11111010
    11000000
    11001000
    11101000
    11101000
    0 1
    1 2
    3 4
    
    예상 출력
    11111111
    11001100
    11111110