Language: C++

#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> Coor;
typedef pair<Coor, Coor> Coor;

const int dx[] = {0, 1, 0, -1};
const int dy[] = {-1, 0, 1, 0};

int H;
int W;
int sty[2];
int stx[2];
int y[2];
int x[2];
char field[2][50][50];
bool dp[50][50][50][50];

bool WithinRange(int y, int x) {
  if (y < 0 || H <= y) return false;
  if (x < 0 || W <= x) return false;
  return true;
}

int main() {
  while (1) {
    scanf("%d%d", &W, &H);
    if (W == 0 && H == 0) return 0;

    for (int i=0; i<H; i++) {
      for (int j=0; j<W; j++) {
        scanf(" %c", &field[0][i][j]);
        if (field[0][i][j] == '%') {
          sty[0] = i;
          stx[0] = j;
        } else if (field[0][i][j] == 'L') {
          y[0] = i;
          x[0] = j;
        } else assert(field[0][i][j] == '.' || field[0][i][j] == '#');
      }

      for (int j=W-1; j>=0; j--) {
        scanf(" %c", &field[1][i][j]);
        if (field[1][i][j] == '%') {
          sty[1] = i;
          stx[1] = j;
        } else if (field[1][i][j] == 'R') {
          y[1] = i;
          x[1] = j;
        } else assert(field[1][i][j] == '.' || field[1][i][j] == '#');
      }
    }

    for (int i=0; i<H; i++) {
      for (int j=0; j<W; j++) {
        for (int k=0; k<H; k++) {
          for (int l=0; l<W; l++) {
            dp[i][j][k][l] = false;
          }
        }
      }
    }

    dp[y[0]][x[0]][y[1]][x[1]] = true;
    queue<Pair> q;
    q.push(Pair(Coor(y[0], x[0]), Coor(y[1], x[1])));
    while (!q.empty()) {
      Pair p = q.front(); q.pop();
      Coor c1 = p.first;
      int y1 = c1.first;
      int x1 = c1.second;
      Coor c2 = p.second;
      int y2 = c2.first;
      int x2 = c2.second;

      for (int i=0; i<4; i++) {
        int newy1 = y1 + dy[i];
        int newx1 = x1 + dx[i];
        if (!WithinRange(newy1, newx1) || field[0][newy1][newx1] == '#') {
          newy1 -= dy[i];
          newx1 -= dx[i];
        }

        int newy2 = y2 + dy[i];
        int newx2 = x2 + dx[i];
        if (!WithinRange(newy2, newx2) || field[1][newy2][newx2] == '#') {
          newy2 -= dy[i];
          newx2 -= dx[i];
        }

        if (dp[newy1][newx1][newy2][newx2]) continue;
        dp[newy1][newx1][newy2][newx2] = true;
        q.push(Pair(Coor(newy1, newx1), Coor(newy2, newx2)));
      }
    }

    if (dp[sty[0]][stx[0]][sty[1]][stx[1]]) puts("Yes");
    else puts("No");
  }
}

Compiler output:
a.cc:5:26: error: conflicting declaration 'typedef struct std::pair<std::pair<int, int>, std::pair<int, int> > Coor'
    5 | typedef pair<Coor, Coor> Coor;
      |                          ^~~~
a.cc:4:24: note: previous declaration as 'typedef struct std::pair<int, int> Coor'
    4 | typedef pair<int, int> Coor;
      |                        ^~~~
a.cc: In function 'int main()':
a.cc:65:11: error: 'Pair' was not declared in this scope
   65 |     queue<Pair> q;
      |           ^~~~
a.cc:65:15: error: template argument 1 is invalid
   65 |     queue<Pair> q;
      |               ^
a.cc:65:15: error: template argument 2 is invalid
a.cc:66:7: error: request for member 'push' in 'q', which is of non-class type 'int'
   66 |     q.push(Pair(Coor(y[0], x[0]), Coor(y[1], x[1])));
      |       ^~~~
a.cc:67:15: error: request for member 'empty' in 'q', which is of non-class type 'int'
   67 |     while (!q.empty()) {
      |               ^~~~~
a.cc:68:11: error: expected ';' before 'p'
   68 |       Pair p = q.front(); q.pop();
      |           ^~
      |           ;
a.cc:68:29: error: request for member 'pop' in 'q', which is of non-class type 'int'
   68 |       Pair p = q.front(); q.pop();
      |                             ^~~
a.cc:69:17: error: 'p' was not declared in this scope
   69 |       Coor c1 = p.first;
      |                 ^
a.cc:93:11: error: request for member 'push' in 'q', which is of non-class type 'int'
   93 |         q.push(Pair(Coor(newy1, newx1), Coor(newy2, newx2)));
      |           ^~~~