当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5959:A Random Turn Connection Game

题目描述
Alice and Bob play a random turn connection game in a square board with 8×8 cells. In each move, a player tosses a fair coin to decide who gets the move. That is, both Alice and Bob will get the next move with 50% chance, no matter who has moved before. Once a player gets a move, she will place a piece in an empty cell. Both Alice and Bob play randomly. That is, if there are k empty cells, each cell will be chosen with 1/k chance. Once Alices pieces connect the top side and the bottom side of the board, she will win the game. Similarly, once Bobs pieces connect the left side and the right side of the board, he will win the game. Pieces only connect horizontally or vertically, and cannot connect diagonally. Your task is to calculate the winning probabilities of Alice and Bob.
输入解释
The first line is the number of test cases. Each test case contains 8 lines and each line contains 8 characters, representing the current status of the board. The cells occupied by Alice are marked as “A”, the cells occupied by Bob are marked as “B”, and the empty cells are marked as “.”. There is an empty line between test cases.
输出解释
For each test case, output the probability that Alice and Bob will win with the precision of 6 digits.
输入样例
4
....A...
....A...
....A...
....A...
....A...
....A...
....A...
....A...
....A...
....A...
....A...
....A...
BBBB.BBB
....A...
....A...
....A...
....A...
....A...
....A...
BBBBA...
...ABBBB
...A....
...A....
...A....
........
........
........
........
........
........
........
.......A
输出样例
Alice 1.000000 Bob 0.000000
Alice 0.500000 Bob 0.500000
Alice 0.000000 Bob 0.000000
Alice 0.223093 Bob 0.198498
来自杭电HDUOJ的附加信息
Recommend jiangzijing2015

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5959

最后修改于 2020-10-25T23:27:04+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 65536/65536K(Java/Others)