HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Kovrov IT > problem:


2010.F. 50265 - Liars and Knights

Guest
• Discussion of problem (1)

Volume problems

• 2009.F. 50267 - Interesting permutat...
• 2009.G. 50260 - What about judges?
• 2009.H. 50268 - Triangles
• 2009.I. 50278 - ATM
• 2010.A. 50287 - Providers
• 2010.B. 50281 - Primes
• 2010.D. 50277 - Unusual Lottery
• 2010.E. 50664 - Polygons
• 2010.F. 50265 - Liars and Knights
• 2010.G. 50256 - Sequence
• 2010.H. 50282 - Coins
• 2010.I. 50257 - Galls village
• 2010.J. 50258 - String manipulations
• 2007.C. 50640 - Cubes
• 2007.D. 50271 - Factorial
• 2007.K. 50276 - Nice Floor
• 2007.A. 50671 - Phalanx

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 3000/4000/4000/4000 ms. Memory limit 65000/80000/80000/80000 Kb.
Автор: Павел Кузнецов, ПГУ.

NxM people have arrived to the congress of the largest party in Byteland, and they were all seated in N rows, M people in one row. The party consists of two fractions - liars and knights. The representatives of the fraction of knights always speak the truth, and the liars always lie. After the congress, each of the participants said that he had been sitting with the representatives of both fractions at his sides. Two participants are considered to be neighbors, if they are sitting next to each other in one row, or if they occupy the same places in two adjacent rows. The chairman of the party does not know how many there were liars and knights. So he wants to understand with what minimal number of liars such a situation could take place. Your task is to write a program, that will find out the minimal number of liars and the corresponding plan of seating the congress participants.

Input
The first line of the input gives two integers N and M - the number of rows and seats in each row, correspondingly (1 ≤ N ≤ 7, 1 ≤ M ≤ 100).

Output
Write in the first line of the output one number - the minimal quantity of liars in the required seating. The following N lines should show the seating itself, one row in each line. A knight must be shown by the symbol "." (point), and a liar by "x" (small Latin letter x). There should be no other symbols in the lines, not even the spaces. In case you find several ways of seating, show one of them.

Input 1 Output 1
2 3
2
..x
x..
Input 2 Output 2
6 6
10
x...x.
..x...
x....x
...x..
.x...x
x..x..

Для отправки решений необходимо выполнить вход.

www.contester.ru