#include <bits/stdc++.h>
using
namespace
std;
#define row 9
#define col 20
void
coronaVirus(
char
arr[row][col])
{
char
inverted[9][20];
char
temp[9][20];
int
count = 0;
int
total = 0;
for
(
int
i = 0; i <= 8; i++) {
for
(
int
j = 0; j < 20; j++) {
inverted[i][j] = arr[8 - i][j];
}
}
for
(
int
i = 0; i <= 8; i++) {
for
(
int
j = 0; j < 20; j++) {
if
(inverted[i][j] ==
'a'
|| inverted[i][j] ==
'c'
) {
total++;
}
temp[i][j] = inverted[i][j];
}
}
int
bound = 0;
int
i = 1;
int
j = 1;
int
direct = 1;
cout <<
"0 0"
<< endl;
int
flag = 0;
while
(bound <= 1 && flag < 1000) {
flag++;
cout << i <<
" "
<< j << endl;
if
(inverted[j][i] ==
'*'
&& bound == 1) {
break
;
}
if
(inverted[j][i] ==
'*'
) {
if
(i == 0 && j == 8 || i == 20 && j == 8
|| i == 20 && j == 0) {
break
;
}
}
if
(inverted[j][i] ==
'*'
&& bound == 0) {
bound++;
if
(i == 0 && j != 8 && j != 0) {
if
(direct == 2) {
direct = 1;
i++;
j++;
}
else
if
(direct == 4) {
direct = 3;
j--;
i++;
}
}
else
if
(i == 20 && j != 0 && j != 8) {
if
(direct == 1) {
direct = 2;
i--;
j++;
}
else
if
(direct == 3) {
direct = 4;
i--;
j--;
}
}
else
if
(j == 8 && i != 0 && i != 20) {
if
(direct == 2) {
direct = 4;
i--;
j--;
}
else
if
(direct == 1) {
direct = 3;
j--;
i++;
}
}
else
if
(j == 0 && i != 0 && i != 20) {
if
(direct == 4) {
direct = 2;
i--;
j++;
}
else
if
(direct == 3) {
direct = 1;
i++;
j++;
}
}
continue
;
}
if
(inverted[j][i] ==
'c'
) {
temp[j][i] =
'-'
;
if
(direct == 1) {
direct = 3;
j--;
i++;
}
else
if
(direct == 2) {
direct = 1;
i++;
j++;
}
else
if
(direct == 3) {
direct = 4;
i--;
j--;
}
else
if
(direct == 4) {
direct = 2;
i--;
j++;
}
count++;
continue
;
}
if
(inverted[j][i] ==
'a'
) {
temp[j][i] =
'-'
;
if
(direct == 1) {
direct = 2;
i--;
j++;
}
else
if
(direct == 2) {
direct = 4;
i--;
j--;
}
else
if
(direct == 3) {
direct = 1;
i++;
j++;
}
else
if
(direct == 4) {
direct = 3;
j--;
i++;
}
count++;
continue
;
}
if
(inverted[j][i] ==
'.'
) {
if
(direct == 1) {
i++;
j++;
}
else
if
(direct == 2) {
i--;
j++;
}
else
if
(direct == 3) {
j--;
i++;
}
else
if
(direct == 4) {
i--;
j--;
}
continue
;
}
}
for
(
int
i = 0; i <= 8; i++) {
for
(
int
j = 0; j < 20; j++) {
cout << temp[8 - i][j];
}
cout << endl;
}
cout <<
"safe="
<< (total - count) << endl;
cout <<
"infected="
<< (count) << endl;
}
int
main()
{
char
arr[row][col]
= { {
'*'
,
'*'
,
'*'
,
'*'
,
'*'
,
'*'
,
'*'
,
'*'
,
'*'
,
'*'
,
'*'
,
'*'
,
'*'
,
'*'
,
'*'
,
'*'
,
'*'
,
'*'
,
'*'
,
'*'
},
{
'*'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'*'
},
{
'*'
,
'.'
,
'.'
,
'c'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'*'
},
{
'*'
,
'.'
,
'.'
,
'.'
,
'.'
,
'c'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'*'
},
{
'*'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'a'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'.'
,
'*'
},
{
'*'
,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