Matching strings

2.3

3 votes
String, Linear Algebra, Mathamatics, Gaussian Elimination, Algorithms, Hash table, Math, Matrix
Problem

There are n strings s1,s2, ...,sn of length m and a set of strings S.
Here, f(str,S) denotes the numbers of substrings of str that are in S. For example, f(aab,{a,ab})=3.
Notestr is a string in f(str,S)

Now, you have removed S and you are given s1,s2, ...,sn and f(s1,S),f(s2,S), ...,f(sn,S). Find a set of string S that maximizes the following score formula:

score of test=(1tan1((f(si,S)f(si,S))2)π/2)×5

There are 20 tests for this problem.

Input format

  • The first line contains two integers n and m.
    1n,m64
  • Each of following n lines contains a string si and an integer f(si,S).
    1f(si,S)500
    Length of si is m

Output format

In the first line, print sz that is the size of S and in the following sz lines, print each S's element in any order.

The following conditions must be satisfied:

  • 1sz128
  • 1each S element lengthm
  • All elements must be unique.

It is guaranteed that S satisfies the mentioned conditions.

Time Limit: 7
Memory Limit: 256
Source Limit:
Explanation

The output is the original S.

Editor Image

?