#abc319c. C - False Hope

C - False Hope

Score : 300300 points

问题描述

存在一个 3×33\times3 的网格,其中每个格子中填有从1到9(包括1和9)的数字。位于第ii行(从上数)和第jj列(从左数)的格子 (1i3,1j3)(1\leq i\leq3,1\leq j\leq3) 中包含数字 ci,jc _ {i,j}

同一个数字可能出现在不同的格子中,但不会在垂直、水平或对角线上连续的三个格子中出现。更具体地讲,保证ci,jc _ {i,j}满足以下所有条件:

  • 对于任意 1i31\leq i\leq3,不成立 ci,1=ci,2=ci,3c _ {i,1}=c _ {i,2}=c _ {i,3}
  • 对于任意 1j31\leq j\leq3,不成立 c1,j=c2,j=c3,jc _ {1,j}=c _ {2,j}=c _ {3,j}
  • 不成立 c1,1=c2,2=c3,3c _ {1,1}=c _ {2,2}=c _ {3,3}
  • 不成立 c3,1=c2,2=c1,3c _ {3,1}=c _ {2,2}=c _ {1,3}

高桥将按照随机顺序查看每个格子中的数字。当存在一条(垂直、水平或对角线)满足以下条件时,他会感到 失望

  • 他首先看到的两个格子中的数字相同,但最后一个格子中的数字不同。

请计算高桥在不感到失望的情况下查看所有格子中数字的概率。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

There is a 3×33\times3 grid with numbers between 11 and 99, inclusive, written in each square. The square at the ii-th row from the top and jj-th column from the left (1i3,1j3)(1\leq i\leq3,1\leq j\leq3) contains the number ci,jc _ {i,j}.

The same number may be written in different squares, but not in three consecutive cells vertically, horizontally, or diagonally. More precisely, it is guaranteed that ci,jc _ {i,j} satisfies all of the following conditions.

  • ci,1=ci,2=ci,3c _ {i,1}=c _ {i,2}=c _ {i,3} does not hold for any 1i31\leq i\leq3.
  • c1,j=c2,j=c3,jc _ {1,j}=c _ {2,j}=c _ {3,j} does not hold for any 1j31\leq j\leq3.
  • c1,1=c2,2=c3,3c _ {1,1}=c _ {2,2}=c _ {3,3} does not hold.
  • c3,1=c2,2=c1,3c _ {3,1}=c _ {2,2}=c _ {1,3} does not hold.

Takahashi will see the numbers written in each cell in random order. He will get disappointed when there is a line (vertical, horizontal, or diagonal) that satisfies the following condition.

  • The first two squares he sees contain the same number, but the last square contains a different number.

Find the probability that Takahashi sees the numbers in all the squares without getting disappointed.

Constraints

  • $c _ {i,j}\in\lbrace1,2,3,4,5,6,7,8,9\rbrace\ (1\leq i\leq3,1\leq j\leq3)$
  • ci,1=ci,2=ci,3c _ {i,1}=c _ {i,2}=c _ {i,3} does not hold for any 1i31\leq i\leq3.
  • c1,j=c2,j=c3,jc _ {1,j}=c _ {2,j}=c _ {3,j} does not hold for any 1j31\leq j\leq3.
  • c1,1=c2,2=c3,3c _ {1,1}=c _ {2,2}=c _ {3,3} does not hold.
  • c3,1=c2,2=c1,3c _ {3,1}=c _ {2,2}=c _ {1,3} does not hold.

Input

The input is given from Standard Input in the following format:

c1,1c _ {1,1} c1,2c _ {1,2} c1,3c _ {1,3}

c2,1c _ {2,1} c2,2c _ {2,2} c2,3c _ {2,3}

c3,1c _ {3,1} c3,2c _ {3,2} c3,3c _ {3,3}

Output

Print one line containing the probability that Takahashi sees the numbers in all the squares without getting disappointed. Your answer will be considered correct if the absolute error from the true value is at most 10810 ^ {-8}.

Sample Input 1

3 1 9
2 5 6
2 7 1

Sample Output 1

0.666666666666666666666666666667

For example, if Takahashi sees c3,1=2,c2,1=2,c1,1=3c _ {3,1}=2,c _ {2,1}=2,c _ {1,1}=3 in this order, he will get disappointed.

On the other hand, if Takahashi sees $c _ {1,1},c _ {1,2},c _ {1,3},c _ {2,1},c _ {2,2},c _ {2,3},c _ {3,1},c _ {3,2},c _ {3,3}$ in this order, he will see all numbers without getting disappointed.

The probability that Takahashi sees all the numbers without getting disappointed is 23\dfrac 23. Your answer will be considered correct if the absolute error from the true value is at most 10810 ^ {-8}, so outputs such as 0.6666666570.666666657 and 0.6666666760.666666676 would also be accepted.

Sample Input 2

7 7 6
8 6 8
7 7 6

Sample Output 2

0.004982363315696649029982363316

Sample Input 3

3 6 7
1 9 7
5 7 5

Sample Output 3

0.4

update @ 2024/3/10 09:07:02