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

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

Hacked Exam

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

요약
학생들의 T/F 답안 문자열과 점수가 주어질 때, 일관된 정답 키에 대한 균등 사전분포에서 기대 점수가 가장 높은 답안 문자열과 그 기대값을 기약분수로 구한다.
난이도

보통10점 중 7점

유형
확률, 조합론, 완전 탐색, 구현
정답자
아직 제출이 없습니다

문제

There is an exam with Q true or false questions. The correct answer to each question is either T or F. Each student taking the exam selects either T or F for each question, and the student's score is the number of questions they answer correctly.

There are N students who have already taken this exam. For each of those students, you know the answers they gave to each question and their final score. Assuming that any sequence of answers that is consistent with all of those students' scores has the same probability of being the correct sequence of answers, you want to maximize your own expected score. Determine what that expected score is and how to answer the questions so that you achieve it.

입력

The first line of the input gives the number of test cases, T. T test cases follow. The first line of each test case contains two integers N and Q: the number of students and the number of questions, respectively. Each of the next N lines contains a string Ai and an integer Si: the i-th student's answers and their score, respectively. The j-th character of Ai is either T or F, representing the answer the i-th student gave to the j-th question.

출력

For each test case, output one line containing Case #x: y z/w, where x is the test case number (starting from 1), y is a string representing a sequence of answers that yields the maximum expected score (in the same format as the input), and z/w is the maximum expected score as an irreducible fraction (that is, w must be positive and of minimum possible value).

제한

  • 1 ≤ T ≤ 2021.
  • The length of Ai = Q, for all i.
  • Each character of Ai is an uppercase T or an uppercase F, for all i.
  • 0 ≤ Si ≤ Q, for all i.
  • There exists at least one sequence of correct answers consistent with the input.

예제2

  1. 예제 1

    입력
    4
    1 3
    FFT 3
    1 3
    FFT 2
    2 6
    FFTTTF 2
    FTFTFT 4
    2 2
    FF 1
    TT 1
    
    예상 출력
    Case #1: FFT 3/1
    Case #2: FFT 2/1
    Case #3: FTFFFT 4/1
    Case #4: TF 1/1
    
  2. 예제 2

    입력
    1
    3 120
    FFTFFFTFFFTTTTTTTFTFFFFFFTTTFTFFFTFTFFTTFTFFTFFTTTFTFTFFTFTFTTFFFFTFTFFFFTTTFTTFTTTTFFFTTFFFFFTTFFTFFTFFTTTFFFFTTFFTFTTF 55
    FFFTFFTTFFFFTFTFFTFFFTTTTTTFFFTTTFTTTTFFTFTTTFTTFFTTTFTFFFFTFFTTFFTTFTTFFTFTFFTFTTFTFTFFTTTFFTFTFTTFFTFTFTFTTFFTFFFTFTFT 62
    FFFTFTTFFFFFTFTFTTTTTTFFTTFTFFFTFFTTTTTTFFFTTTFFFTTFTFFFFFFTFTTFFTFTTTFTTTTFTTFFFFTFFTTFTFFTTTTTTFTFFFFFTTFFTFTFTFFTTTTT 64
    
    예상 출력
    Case #1: FFFTFTTTFFFFTFTFFTFTTTTTTTFFFFTTTFTTTTFFTFTTTTTFFFTFTFTFFFFTFFTTFTFTFTTTTTFFTFFFFFFFFTTFTTTTTTFTTTTFFFFTFTFTTFTFFFFTTTFT 189154508532118369075350624633/2901503505434414233388602018