5940 {
5941 char farm[10][10] = {};
5942 pair<int, int> b;
5943 pair<int, int> l;
5944 for(int i = 0; i < 10; i++) {
5945 for(int j = 0; j < 10; j++) {
5946 cin >> farm[i][j];
5947 if(farm[i][j] == 'B') {
5948 b = make_pair(i, j);
5949 } else if(farm[i][j] == 'L') {
5950 l = make_pair(i, j);
5951 }
5952 }
5953 }
5954 priority_queue<status> pq;
5955 pq.push(
status(0, l, b));
5956 while(!pq.empty()) {
5958 pq.pop();
5959 if(s.current == b) {
5960 cout << s.len - 1;
5961 return 0;
5962 }
5963 pair<int, int> nexts[4] = {make_pair(s.current.first + 1, s.current.second),
5964 make_pair(s.current.first - 1, s.current.second),
5965 make_pair(s.current.first, s.current.second + 1),
5966 make_pair(s.current.first, s.current.second - 1)};
5967 for(const auto next: nexts) {
5968 if(0 <= next.first && next.first < 10 && 0 <= next.second && next.second < 10 && farm[next.first][next.second] != 'R') {
5969 pq.push(
status(s.len + 1, next, b));
5970 }
5971 }
5972 }
5973 return 0;
5974 }