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

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

Pattern Overlap

메모리 제한1024 MB

요약
별표가 0개에서 4개의 글자를 대신하는 두 패턴이 주어질 때, 두 패턴에 모두 맞는 제목이 존재하는지 판정한다.
난이도

보통10점 중 7점

유형
동적 계획법, 문자열, 구현, 완전 탐색
정답자
아직 제출이 없습니다

문제

Alice likes reading and buys a lot of books. She stores her books in two boxes; each box is labeled with a pattern that matches the titles of all of the books stored in that box. A pattern consists of only uppercase/lowercase English alphabet letters and stars (*). A star can match between zero and four letters. For example, books with the titles GoneGirl and GoneTomorrow can be put in a box with the pattern Gone**, but books with the titles TheGoneGirl, Gonetomorrow, and GoneWithTheWind cannot.

Alice is wondering whether there is any book that could be stored in either of the boxes. That is, she wonders if there is a title that matches both boxes' patterns.

입력

The first line of the input gives the number of test cases, T. T test cases follow. Each consists of two lines; each line has one string in which each character is either an uppercase/lowercase English letter or *.

출력

For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is TRUE if there is a string that matches both patterns, or FALSE if not.

제한

  • 1 ≤ T ≤ 50.

힌트

In sample case #1, the title It matches both patterns. Note that it is possible for a * to match zero characters.

In sample case #2, the title Shakespeare matches both patterns.

In sample case #3, there is no title that matches both patterns. Shakespeare, for example, does not work because the * at the start of the *peare pattern cannot match six letters.

예제1

  1. 예제 1

    입력
    3
    ****
    It
    Shakes*e
    S*speare
    Shakes*e
    *peare
    
    예상 출력
    Case #1: TRUE
    Case #2: TRUE
    Case #3: FALSE