0202. Sea Battle

Имя входного файла: sea.in
Имя выходного файла: sea.out
Ограничение по времени: 250 ms
Ограничение по памяти: 32 megabytes

You are given locations of ships on a 10*10 field in "Sea battle" game. According to game rules, field must contains the following ships:

  • one four-decks;
  • two three-decks;
  • three double-decks;
  • four single-decks.

Ships should be straight, oriented horizontally or vertically and can not touch each other. You are to write a program, that checks whether the set of play fields matchs described rules.

Input file

First line of the input contains single integer number N (1 ≤ N ≤ 10) – quantity of play fields. N descriptions of play fields follows. Each description contains 10 lines with 10 characters in each. Symbol `0' means that the corresponding cell is free, and `*' means that corresponding cell is covered by a ship. Fields descriptions are separated by blank lines.

Output file

Output file must consist of N lines. Each line should contain the word `YES' if the corresponding field is correct and `NO' otherwise.

Examples:

sea.insea.out
1 ****000000 0000000000 ***00***00 0000000000 00000000** 000**00000 00000000** 000*000000 00000*00*0 0*00000000YES


Источник: Petrozavodsk Summer 2003. Saratov SU Contest, Wednesday, August 27

Обсудить       Отправить решение



Версия для печати