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

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

Lingo

면접 대비

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

요약
일부 칸이 이미 가려진 n x n 격자에서 번호가 있는 칸 k개를 무작위로 뽑을 때, 어떤 행이나 열, 대각선이 모두 가려질 확률을 구한다.
난이도

보통10점 중 6점

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

문제

You are going to participate in the television show ‘lingo’. You are very confident that you will make the finals of the show. This is not only because you are well prepared, but also because you managed to find a way to use your pda unnoticed during the contest, and you have already written a program to help you with the bonuswords.

In the finals of the show, you first solve as many lingo words as possible within the allowed time. This determines how many balls you may take afterwards. The more balls you may take, the higher your probability is of winning the finals. But it is not easy to see what this probability is. Write a program to help you with this.

Figure 2: Grid of first sample case

For those who don’t know the game of lingo, here follows a description of the last part of the finals, where you take the balls. You are given a square grid. Some squares in this grid are covered and the other squares contain numbers. A hopper in front of you contains numbered balls; there is exactly one ball for each numbered grid square. You take a ball at random (without replacement) from this hopper for each lingo word you solved in the first part of the finals. When you take a ball, the corresponding square in the grid becomes covered. You win the finals if an entire row, column or diagonal consist of only covered squares.

입력

On the first line an integer t (1 ≤ t ≤ 100): the number of test cases. Then for each test case:

  • One line with the integers n (1 ≤ n ≤ 8) and k (0 ≤ k), where n is the size of the lingo grid and k is the number of words you solved in the first part of the finals.
  • n lines, with on each line exactly n characters. Each character will be either ‘*’ or ‘.’, representing a covered square and a numbered square respectively.

There will be at least k numbered squares on the board, and there is no row, column or diagonal covered yet.

출력

For each test case:

  • One line with the percentage of getting lingo with either an absolute or a relative error of at most 10−6.

예제1

  1. 예제 1

    입력
    1
    5 7
    .*.*.
    .**..
    .*.*.
    *....
    **..*
    
    예상 출력
    82.703962704