Language: C

#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
#include <vector>
#include<queue>
#include<map>
#define L(a) ((a)<<1)
#define R(a) ((a)<<1|1)
#define clr(x,y) memset(x,y,sizeof(x))
#define ll long long
using namespace std;
const int inf=1<<30;

int a[6][6],b[6][6];
int t;
int x[]={1,0,0,-1},y[]={0,-1,1,0};
char c[]="DLRU";
int p[]={1,0,2,3};
struct my{
    int x,y,d;
    my(){}
    my(int x,int y,int d):x(x),y(y),d(d){}
};
int txa,tya,txb,tyb;
bool in(int x,int y){
    return x>=0&&x<6&&y>=0&&y<6;
}
int h(int xa,int ya,int xb,int yb){
    queue <my> que;
    que.push(my(xa,ya,0));
    bool vis[6][6];
    clr(vis,0);
    vis[xa][ya]=1;
    int ans=inf;
    while(!que.empty()){
        my now=que.front();que.pop();
        int q=now.x,w=now.y,d=now.d;
        if(q==txa&&w==tya){
            ans=d;
            break;
        }
        for(int i=0;i<4;i++){
            int xx=q+x[i],yy=w+y[i];
            if(in(xx,yy)&&(a[q][w]&(1<<p[i]))==0&&(a[xx][yy]&(1<<4))){
                vis[xx][yy]=1;
                que.push(my(xx,yy,d+1));
            }
        }
    }
    while(!que.empty())que.pop();
    clr(vis,0);
    que.push(my(xb,yb,0));
    vis[xb][yb]=1;
    while(!que.empty()){
        my now=que.front();que.pop();
        int q=now.x,w=now.y,d=now.d;
        if(q==txb&&w==tyb){
            if(ans==inf)ans=d;
            else ans=max(ans,d);
            break;
        }
        for(int i=0;i<4;i++){
            int xx=q+x[i],yy=w+y[i];
            if(in(xx,yy)&&(b[q][w]&(1<<p[i]))==0&&(b[xx][yy]&(1<<4))){
                vis[xx][yy]=1;
                que.push(my(xx,yy,d+1));
            }
        }
    }
    return ans;
}
map<int,int> mapa;
char o[10000],ans[10000];
int lim;
int tmp;
void dfs(int xa,int ya,int xb,int yb,int d){
    if(xa==txa&&ya==tya&&xb==txb&&yb==tyb){
        o[d]=0;
        strcpy(ans,o);
        lim=d;
        return ;
    }
    if(d>=lim)return;
    tmp=xa*1000+ya*100+xb*10+yb;
    if(mapa.find(tmp)==mapa.end())mapa[tmp]=d;
    else if(mapa[tmp]>d)mapa[tmp]=d;
    else return ;
    if(d+h(xa,ya,xb,yb)>=lim)return ;
    for(int i=0;i<4;i++){
        int xxa=xa+x[i],yya=ya+y[i],xxb=xb+x[i],yyb=yb+y[i];
        if(in(xxa,yya)&&in(xxb,yyb)){
           if((a[xa][ya]&(1<<p[i])))xxa=xa,yya=ya;
           else if((a[xxa][yya]&(1<<4))==0)continue;
           if((b[xb][yb]&(1<<p[i])))xxb=xb,yyb=yb;
           else if((b[xxb][yyb]&(1<<4))==0)continue;
            o[d]=c[i];
            dfs(xxa,yya,xxb,yyb,d+1);
        }
    }
}
int sxa,sya,sxb,syb;
int main(){
    freopen("in","r",stdin);
    scanf("%d",&t);
    for(int ti=0;ti<t;ti++){
        if(ti==0){
            for(int i=0;i<6;i++)for(int j=0;j<6;j++){
                scanf("%d",&a[i][j]);
                if(a[i][j]&(1<<5))sxa=i,sya=j;
                if(a[i][j]&(1<<6))txa=i,tya=j;
            }
            continue;
        }
        for(int i=0;i<6;i++)for(int j=0;j<6;j++){
            scanf("%d",&b[i][j]);
            if(b[i][j]&(1<<5))sxb=i,syb=j;
            if(b[i][j]&(1<<6))txb=i,tyb=j;
        }
        lim=10000;
        mapa.clear();
        dfs(sxa,sya,sxb,syb,0);
        if(lim==10000)puts("-1");
        else puts(ans);
        memcpy(a,b,sizeof(a));
        sxa=sxb,sya=syb,txa=txb,tya=tyb;
    }
}

Compiler output:
main.c:2:9: fatal error: algorithm: No such file or directory
    2 | #include<algorithm>
      |         ^~~~~~~~~~~
compilation terminated.