Polish version    English version  
  Historia OI -> I OI 1993/1994 -> Zadania


 Aktualności
 O olimpiadzie
 Komitety
 XVIII OI 2010/2011
 Historia OI
XVII OI 2009/2010
XVI OI 2008/2009
XV OI 2007/2008
XIV OI 2006/2007
XIII OI 2005/2006
XII OI 2004/2005
XI OI 2003/2004
X OI 2002/2003
IX OI 2001/2002
VIII OI 2000/2001
VII OI 1999/2000
VI OI 1998/1999
V OI 1997/1998
IV OI 1996/1997
III OI 1995/1996
II OI 1994/1995
I OI 1993/1994
Zadania
 Książeczki OI
 Reprezentacja
 Obozy Olimpiady
 Galeria zdjęć
 Ciekawe odsyłacze
 OIG LiveCD
 IV OIG 2009/2010
 Historia OIG
 SIO
 MAIN
Ten dokument nie jest dostępny w polskiej wersji językowej.

Niebieskie ksi.eczki
I Olympiad in Informatics 1993/1994

Task: PIO
Author: Andrzej Walat
Draughtsmen

I stage contest  

We have a square board having 8x8 squares numbered as in the picture below, and 64 white draughtsmen and 64 black draughtsmen.

1 2 3 4 5 6 7 8
9101112 13141516
17181920 21222324
25262728 29303132
33343536 37383940
41424344 45464748
49505152 53545556
57585960 61626364

We are given an initial arrangement of draughts on the board, such that every square is occupied by exactly one draught of any colour. Our purpose is to obtain such an arrangement that all draughts on the board have the same colour, and we are going to reach this in as few moves as possible.

In a single move one points a number of any board square - we call the square a centre of changes. Then one exchanges the draughts on all the squares touching a side or a corner of the indicated centre of changes with opposite colour draughts. The draught in the centre is not exchanged. In the next move one points another square as a centre of changes, exchanges adjacent draughts accordingly, and so on.

The input data is a sequence of eight words, written in eight successive lines corresponding to the eight rows of the board. Every word consists of eight letters B (for "white") or C (for "black") describing the draughts' colours in the eight consecutive squares of the respective board row.

The answer in the first line should contain the minimal number of moves required. If the number is zero, that only line ends the answer. Otherwise, starting from the next line there should be given numbers of successive centres of changes, separated by a space or a single end-of-line character.

When there are many ways of getting a one-coloured arrangement in the minimal number of moves, one should present only one of them.

If the data is not correct, i.e. does not meet the above conditions, the word NONSENS ("nonsense") is the answer.

Examples

For the data file:

CCCCCCCC
BBBBBBBB
CCCCCCCC
CCCCCCCC
CCCCCCCC
CCCCCCCC
CCCCCCCC
CCCCCCCC
there is an example of correct answer:
26
57 59 62 64 50 55 42 47 33 35 38 40 25 26 28 29 31 32
18 19 22 23 2 3 6 7
For the data file:
CCCCCCCC
CCCCCCCC
CCCCCCCC
CCCCCCCC
CCCCCCCC
CCCCCCCC
CCCCCCCC
CCCCCCCC
the correct answer is:
0
For the data file:
CCCCCCCC
CCDDCCCCC
CCCCCCCC
CCCCCCCC
CCCCCCCC
CCCCCCCC
CCCCCCCC
CCCCCCCC
the correct answer is:
NONSENS

Task

Write a program, that successively for every data set from a file PIO.IN generates a correct answer and writes it to a file PIO.OUT.

The source text of the program should be written in a file named PIO.???, where ??? are substituted by a sequence of letters appropriate for the programming language used.

The executable program should be named PIO.EXE.




Wersja do druku