Вопрос задан 28.04.2019 в 17:04. Предмет Информатика. Спрашивает Globalavto Globalavto.

Бригаде строителей поручили уложить квадратной плиткой пол на кухне в виде шахматного узора. Но

строители работали не очень слаженно, и когда весь пол уже был уложен, оказалось, что в некоторых местах плитки одинакового цвета граничат друг с другом.По заданному замощению определите, какое минимальное число строителей могло укладывать плитку. Входные данные Входной файл INPUT.TXT содержит восемь строк, состоящих из восьми символов W и B – полученное замощение. Символ W обозначает плитку белого цвета, а символ B – чёрную. Выходные данные В выходной файл OUTPUT.TXT нужно вывести одно число - искомое число строителей.
0 0
Перейти к ответам

Ответы на вопрос

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Игнатенкова Настя.
Var  
i, j, k : integer; 
 a : array [0..9,0..9] of char; 
procedure U(i,j:integer);  
var c : char; 
begin 
 c:=a[i,j]; a[i,j]:=' ';  
if (c='W')and(a[i+1,j]='B') then U(i+1,j);
  if (c='B')and(a[i+1,j]='W') then U(i+1,j); 
 if (c='W')and(a[i-1,j]='B') then U(i-1,j); 
 if (c='B')and(a[i-1,j]='W') then U(i-1,j); 
 if (c='W')and(a[i,j+1]='B') then U(i,j+1);  
if (c='B')and(a[i,j+1]='W') then U(i,j+1); 
 if (c='W')and(a[i,j-1]='B') then U(i,j-1); 
 if (c='B')and(a[i,j-1]='W') then U(i,j-1); 
end; 
begin  
assign(input,'input.txt');
reset(input); 
 assign(output,'output.txt');
 rewrite(output);  
for i:=1 to 8 do begin  for j:=1 to 8 do
 read(a[i,j]); 
 readln  
end;  
for i:=1 to 8 do
 begin 
 a[0,i]:=' '; a[9,i]:=' ';  a[i,0]:=' '; a[i,9]:=' '  
end; 
 k:=0; 
 for i:=1 to 8 do 
 for j:=1 to 8 do 
 if a[i,j]<>' ' then
begin 
 k:=k+1; U(i,j)  
end;  
write(k); 
 close(output) 
end. 
0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Task Analysis

The task requires determining the minimum number of builders needed to lay the tiles according to a given pattern. The input consists of an 8x8 grid representing the tile pattern, with 'W' representing white tiles and 'B' representing black tiles. The output should be a single number representing the minimum number of builders required.

Approach

To solve this problem, we need to analyze the given tile pattern and determine the minimum number of builders required to lay the tiles. We will need to identify the areas where tiles of the same color are adjacent to each other and count the minimum number of builders needed to lay the tiles according to the given pattern.

Let's proceed with the analysis and calculation.

Code Implementation

To calculate the minimum number of builders required, we can use the following Python code:

```python # Read the input tile pattern from the file with open('INPUT.TXT', 'r') as file: tile_pattern = [list(line.strip()) for line in file]

# Count the minimum number of builders required min_builders = 0 for i in range(7): for j in range(7): if tile_pattern[i][j] == tile_pattern[i][j+1]: min_builders += 1 if tile_pattern[i][j] == tile_pattern[i+1][j]: min_builders += 1

# Write the minimum number of builders to the output file with open('OUTPUT.TXT', 'w') as file: file.write(str(min_builders)) ```

This code reads the input tile pattern from the file, analyzes the adjacent tiles, and calculates the minimum number of builders required. Finally, it writes the result to the output file.

Conclusion

The Python code provided can be used to determine the minimum number of builders required to lay the tiles according to the given pattern. If you have any further questions or need additional assistance, feel free to ask!

0 0

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос