아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Dividing DNA

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

요약
고정된 문자열에서 부분 문자열이 숨은 데이터베이스에 있는지 최대 2n번 물어보며, 데이터베이스에 없는 서로 겹치지 않는 부분 문자열의 최대 개수를 구한다.
난이도

보통10점 중 7점

유형
문자열, 동적 계획법, 이분 탐색, 그리디
정답자
아직 제출이 없습니다

문제

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 nn of the query string q_1…q_nq\_1\dots q\_n, and you can repeatedly ask the database whether it contains the substring q_i…q_j−1q\_i\dots q\_{j-1}.

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 33, 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 2n2n queries to the database.

예제2

  1. 예제 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. 예제 2

    입력
    10
    
    absent
    
    present
    
    present
    
    예상 출력
    
    ? 0 10
    
    ? 0 9
    
    ? 1 10
    
    ! 1