Logo
(追記) (追記ここまで)

24964번 - Cancer DNA 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
10 초 (추가 시간 없음) 1024 MB143261818.182%

문제

The Investigation Center for Potential Cancer (ICPC) found out patterns of a DNA sequence that cause cancer! We would like you to write a computer program that approximates the probability that a random DNA sequence matches one of the given patterns.

A DNA sequence can be represented by a string consisting of four letters, ‘A’, ‘G’, ‘C’, and ‘T’. A DNA pattern is a string over the same four letters plus ‘?’. We say that a DNA pattern matches a DNA sequence of the same length if each of the characters in the pattern is either ‘?’ or is the same as the character at the corresponding position in the DNA sequence. For example, a pattern “AC?” matches DNA sequences “ACA”, “ACG”, “ACC”, and “ACT”.

Your task is to write a program that, given a set of DNA patterns of the same length, computes the probability that a uniformly random DNA sequence of the same length matches any of the given patterns. A multiplicative error up to 5% is permissible.

입력

The input consists of a single test case of the following format.

$\begin{align*}& n ,円 m \\ & P_1 \\ & \vdots \\ & P_m\end{align*}$

The first line of the input contains two positive integers $n$ and $m$ such that 1ドル ≤ n ≤ 100$ and 1ドル ≤ m ≤ 30$ hold. The next $m$ lines contain $m$ patterns $P_1,ドル $\dots,ドル $P_m$. Each pattern $P_i$ is a string of length $n$ over ‘A’, ‘G’, ‘C’, ‘T’, and ‘?’.

출력

Let $S$ be a DNA sequence of length $n$ chosen uniformly at random. Let $w$ be the probability that $S$ matches at least one of $P_1,ドル $\dots,ドル and $P_m$. The output is a real number $v$ that approximates $w$.

The output $v$ is judged to be correct if $v$ approximates $w$ within a multiplicative error of 5%, i.e.,

0ドル.95 × w ≤ v ≤ 1.05 × w$.

$v$ should be represented either with or without exponent component. For example, 0ドル.045$ can be represented as 4.5e-2 or 0.045.

제한

예제 입력 1

3 1
AC?

예제 출력 1

0.0625

예제 입력 2

6 2
AC??A?
A??A?T

예제 출력 2

0.0302734375

예제 입력 3

30 1
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

예제 출력 3

8.673617379884035e-19

힌트

In the first sample, there are 4ドル^3$ DNA sequences of length 3ドル$. There are 4ドル$ DNA sequences, “ACA”, “ACG”, “ACC”, and “ACT”, that match the pattern “AC?”. Thus, the probability is 4ドル/4^3 = 0.0625$. Any real number between 0ドル.059375$ and 0ドル.065625$ is accepted as a correct output.

As in the third sample, the probability can be a small real number. Note that “0” is not a correct output, as 0ドル$ is less than 95% of the precise probability.

출처

ICPC > Regionals > Asia Pacific > Japan > ICPC 2021 Asia Yokohama Regional H번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /