#R024F. [AGC024F] Simple Subsequence Problem
[AGC024F] Simple Subsequence Problem
Score : points
Problem Statement
You are given a set of strings consisting of 0 and 1, and an integer .
Find the longest string that is a subsequence of or more different strings in . If there are multiple strings that satisfy this condition, find the lexicographically smallest such string.
Here, is given in the format below:
- The data directly given to you is an integer , and strings . For every , the length of is .
- For every pair of two integers , the -th character of is
1if and only if the binary representation of with digits (possibly with leading zeros) belongs to . Here, the first and last characters in are called the -th and -th characters, respectively. - does not contain a string with length or more.
Here, a string is a subsequence of another string when there exists a sequence of integers such that, for every , the -th character of and the -th character of is equal.
Constraints
- is a string of length consisting of
0and1. - is an integer.
Input
Input is given from Standard Input in the following format:
Output
Print the lexicographically smallest string among the longest strings that are subsequences of or more different strings in .
3 4
1
01
1011
01001110
10
The following strings belong to : the empty string, 1, 00, 10, 11, 001, 100, 101 and 110.
The lexicographically smallest string among the longest strings that are subsequences of four or more of them is 10.
4 6
1
01
1011
10111010
1101110011111101
100
2 5
0
11
1111
The answer is the empty string.