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

18728번 - To argue, or not to argue 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 512 MB128777.778%

문제

You are a director of a very successful theatre. Above all, you like William Shakespeare, even despite his inclination for bloody endings. It was said about some of his plays – like “Hamlet” and “King Lear” – that if they had just one more act, it would be necessary to start murdering people from the first rows of the audience.

Right now, you are close to developing a grudge for Shakespeare for not including this final act. It is because of the 2k people that have just come to your theatre. These are k pairs of celebrities – football players, models, YouTube streamers – who seem not to fully grasp the idea of theatre plays. Each pair is very likely to start a heated argument during the play, disrupting the performance entirely. But there is a solution – it is up to you to assign seats to people, and if a pair is not given adjacent seats, fight is much less likely.

The auditorium consists of n rows with m seats in each one. Some places are already booked by “normal” viewers, whom you do not want to reseat. There are k pairs of celebrities, and to every celebrity you must assign a seat, such that no pair occupies two adjacent spots (we consider two seats adjacent only if they share a common side, i.e. one is next to or behind the other). To cheer yourself up, compute the total number of ways you can do it – it is usually a very large number, so it is enough to compute its remainder modulo 109 + 7. Two assignments are considered distinct if any celebrity is given a different seat. Please note that we distinguish all the celebrities (consider them not identical).

입력

The first line of input contains the number of test cases z (1 ≤ z ≤ 100). The descriptions of the test cases follow.

The first line of each test case contains three positive integers n, m, k (1 ≤ n · m ≤ 144, 1 ≤ k ≤ mn/2) – the number of rows, seats in a row, and celebrity pairs. The next n lines describe the rows – each one is a string of characters ‘X’ and ‘.’, where ‘.’ denotes a free seat, ‘X’ – an occupied (unavailable) seats. You may assume that there are at least 2k free seats.

출력

For each test case, output a single number – the number of possible assignments of seats to celebrities such that no pair is given adjacent seats, modulo 109 + 7.

제한

예제 입력 1

2
2 2 2
..
..
4 4 3
X.X.
....
.X..
...X

예제 출력 1

8
347040

힌트

In the first example, all ways of assigning seats are presented below (‘A’ and ‘a’ denote seats assigned to the first pair, ‘B’ and ‘b’ — to the second):

 AB Ab ab aB BA bA ba Ba
 ba Ba BA bA ab aB AB Ab

출처

Camp > Petrozavodsk Programming Camp > Winter 2020 > Day 5: Ja giellonian U Contest K번

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

출처

대학교 대회

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

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