Dividing DNA
문제
At the Bacteria And Protein Centre, you own a large collection of DNA. In fact, new strands of DNA come in all the time. To organise the vast amount of data, you identify each piece by its unique substrings: substrings that do not already occur in the database.
Your database can quickly determine whether a given piece of DNA occurs as a substring in the database or not. Naturally, if a certain DNA string is found in the database, it also contains all its substrings.
You now want to determine the uniqueness of a given piece of DNA: the maximal number of disjoint substrings it contains that are absent from the database.
You are given the length of the query string , and you can repeatedly ask the database whether it contains the substring .
As an example, consider the first sample interaction. In this case, the database contains strings "TGC" and "CT", and the query string is "CTGCAA". It has uniqueness , because it can be split into the new substrings "CTGC", "A", and "A". The new substring "CTGC" cannot be split up further: for example, the subdivision "CT" and "GC" is not allowed, because both substrings occur (possibly as substrings) in the database. Note that the actual characters in the string are not used in the interaction.
You may use at most queries to the database.
예제
예제 1
6 absent absent absent present present present present absent
? 4 6 ? 4 5 ? 5 6 ? 0 1 ? 0 2 ? 2 4 ? 1 4 ? 0 4 ! 3
예제 2
10 absent present present
? 0 10 ? 0 9 ? 1 10 ! 1