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

32469번 - Mukjjippa 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 1024 MB (추가 메모리 없음)132625752.294%

문제

Two players A and B are playing a game called mukjjippa.

The game consists of several turns.

At the $i$-th turn (1ドル\le i\le n$):

  • Each player chooses exactly one from $\{\mathrm R,\mathrm S,\mathrm P\}$ (meaning rock, scissors, and paper, respectively).
  • Let $X_i$ and $Y_i$ be the choices of A and B, respectively.
  • If $(X_i,Y_i)\in\{(\mathrm R,\mathrm S) ,(\mathrm S,\mathrm P) ,(\mathrm P,\mathrm R)\},ドル then A becomes an attacker for the $(i+1)$-th turn and the game continues.
  • Otherwise, if $(X_i,Y_i)\in\{(\mathrm R,\mathrm P) ,(\mathrm S,\mathrm R) ,(\mathrm P,\mathrm S)\},ドル then B becomes an attacker for the $(i+1)$-th turn and the game continues.
  • Otherwise, if there is an attacker for the $i$-th turn, then the attacker becomes a winner and the game ends.
  • Otherwise, there is no attacker for the $(i+1)$-th turn and the game continues.

Note that there is no attacker for the first turn.

If the game does not end until the beginning of the $(n+1)$-th turn, nobody is a winner.

The probability distribution of each choice is given. All choices are independent.

Find the probability that A wins.

입력

The first line contains an integer $n$.

The $i$-th of the next $n$ lines contains three integers $r_i,ドル $s_i,ドル and $p_i$. This means that the probabilities that $X_i$ is $\mathrm R,ドル $\mathrm S,ドル and $\mathrm P$ are $\frac{r_i}{r_i+s_i+p_i},ドル $\frac{s_i}{r_i+s_i+p_i},ドル and $\frac{p_i}{r_i+s_i+p_i},ドル respectively.

The $i$-th of the next $n$ lines contains three integers $r_i',ドル $s_i',ドル and $p_i'$. This means that the probabilities that $Y_i$ is $\mathrm R,ドル $\mathrm S,ドル and $\mathrm P$ are $\frac{r_i'}{r_i'+s_i'+p_i'},ドル $\frac{s_i'}{r_i'+s_i'+p_i'},ドル and $\frac{p_i'}{r_i'+s_i'+p_i'},ドル respectively.

출력

Let $\frac{x}{y}$ be the probability that A wins, where $x$ and $y$ are coprime integers, and $x\ge 0$ and $y>0$.

Print the integer $z$ such that $yz\equiv x\pmod{998,円 244,円 353}$ and 0ドル\le z<998,円 244,円 353$.

It can be proved that such an integer $z$ always exists and is uniquely determined, under the constraints of this problem.

제한

  • 1ドル\le n\le 2\times 10^5$
  • 0ドル\le r_i,s_i,p_i\le 10^6$ (1ドル\le i\le n$)
  • $r_i+s_i+p_i>0$ (1ドル\le i\le n$)
  • 0ドル\le r_i',s_i',p_i'\le 10^6$ (1ドル\le i\le n$)
  • $r_i'+s_i'+p_i'>0$ (1ドル\le i\le n$)

예제 입력 1

2
1 0 0
0 1 0
0 1 0
0 1 0

예제 출력 1

1

예제 입력 2

2
1 1 1
1 1 1
1 1 1
1 1 1

예제 출력 2

443664157

노트

출처

University > KAIST > KAIST ICPC Mock Competition > 2024 KAIST 14th ICPC Mock Competition I번

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

출처

대학교 대회

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

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