51 lines
1.0 KiB
C++
51 lines
1.0 KiB
C++
|
#include <cstring>
|
||
|
#include <iostream>
|
||
|
using namespace std;
|
||
|
int main()
|
||
|
{
|
||
|
char s[10][10];
|
||
|
int b[2],l[2],r[2],ans=0;
|
||
|
for (int i = 0; i < 10; i++) {
|
||
|
for (int j = 0; j < 10; j++) {
|
||
|
cin >> s[i][j];
|
||
|
int u = s[i][j];
|
||
|
if (u == 'L') {
|
||
|
l[0] = i, l[1] = j;
|
||
|
}
|
||
|
if (u == 'B') {
|
||
|
b[0] = i, b[1] = j;
|
||
|
}
|
||
|
if (u == 'R') {
|
||
|
r[0] = i, r[1] = j;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
int t=b[1],w=l[1];
|
||
|
if(t>w){
|
||
|
int e=t;
|
||
|
t=w;
|
||
|
w=e;
|
||
|
}
|
||
|
if(l[0]==b[0]&&b[0]==r[0]){
|
||
|
if(r[1]>t&&r[1]<w){
|
||
|
ans+=2;
|
||
|
}
|
||
|
}
|
||
|
t=b[0],w=l[0];
|
||
|
if(t>w){
|
||
|
int e=t;
|
||
|
t=w;
|
||
|
w=e;
|
||
|
}
|
||
|
if(l[1]==b[1]&&b[1]==r[1]){
|
||
|
if(r[0]>t&&r[0]<w){
|
||
|
ans+=2;
|
||
|
}
|
||
|
}
|
||
|
int ax=b[0]-l[0];
|
||
|
int bx=b[1]-l[1];
|
||
|
if(ax<0) ax*=-1;
|
||
|
if(bx<0) bx*=-1;
|
||
|
ans=ans+ax+bx-1;
|
||
|
cout<<ans;
|
||
|
}
|