Go: package main

import (
	"bufio"
	"os"
	"strings"
	"strconv"
	"fmt"
)

var points [5][5][4]bool

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for i := 0; i < 9; i++ {
		y := i/2
		if i%2 == 0 {
			scanner.Scan()
			info := strings.Split(scanner.Text(), "")
			for k := range info {
				e, _ := strconv.Atoi(info[k])
				if e != 0 {
					points[y][k][1], points[y][k+1][3] = true, true
				}
			}
		} else {
			scanner.Scan()
			info := strings.Split(scanner.Text(), "")
			for k := range info {
				e, _ := strconv.Atoi(info[k])
				if e != 0 {
					points[y][k][2], points[y+1][k][0] = true, true
				}
			}
		}
	}
	x := 1
	y := 0
	dir := 1
	dx := []int{0, 1, 0, -1}
	dy := []int{-1, 0, 1, 0}
	ds := "URDL"
	fmt.Printf("%s", string(ds[dir]))
	for !(x == 0 && y == 0) {
		if points[y][x][(dir+3)%4] {
			dir = (dir+3)%4
		} else if points[y][x][dir] {

		} else if points[y][x][(dir+1)%4] {
			dir = (dir+1)%4
		} else {
			dir = (dir+2)%4
		}
		x += dx[dir]
		y += dy[dir]
		fmt.Printf("%s", string(ds[dir]))
	}
	fmt.Println()
}

C++: #include <iostream>
#include <string>
using namespace std;

int a[12][12];
int dx[4]  = {1,0,-1,0};
int dy[4]  = {0,1,0,-1};
char dc[4] = {'R','D','L','U'};

//©ªÌüÍS}XÌÇÌóÔð²×é
void cheakWall(int* wall , const int& px ,const int& py ,const int& d ){
	for(int i=0 ; i<4 ; ++i ){
		int mx = px + dx[(d+i)%4];
		int my = py + dy[(d+i)%4];
		wall[i] = a[my][mx];
	}
}

//iñ¾ü«ðL^
void record(string& s,int* wall,const int d){
	if( wall[1] ){
		s.push_back( dc[d] );
	}
}

//iÞ
void go(int& px, int& py, const int& d,int* wall, string& s){
	px += dx[d]*2;
	py += dy[d]*2;
	record( s , wall , d );
}

int main(){
	string s;

	//zñÌú»
	for(int y=0 ; y<12 ; ++y )
		for(int x=0 ; x<12 ; ++x )
			a[y][x] = 0;

	//üÍ
	for(int i=0 ; i<9 ; ++i ){
		cin >> s;
		int y = i+1;
		int x = (i+1)%2 + 1;
		for(int j=0 ; j<(int)s.size() ; ++j , x+=2 ){
			a[y][x] = s[j] - '0';
		}
	}

	int px = 2, py = 0, d = 0;
	bool flag = false;
	s.clear();

	while( 1 ){
		if( px == 0 && py == 0 ) break;

		int wall[4]; 
		//©ªÌüèÌóÔ
		cheakWall( wall , px , py , d );

		if( !wall[1] ){//EªÇ¶áÈ©Á½ç
			//ü«ðEü«Éñé
			d = (d+1)%4;
			//iÞ
			go( px , py , d , wall , s );
			flag = false;
		}else{
			if( !wall[0] ){//OªÇ¶áÈ©Á½ç
				//iÞ
				go( px , py , d , wall , s );
				flag = false;
			}else{
				if( !wall[3] ){//¶ªÇ¶áÈ©Á½ç
					if( flag == false ){
						//iñ¾ü«ðL^
						record( s , wall , d );
					}
					//ü«ð¶ü«Éñé
					d = (d+3)%4;
					//iÞ
					go( px , py , d , wall , s );
					flag = false;
				}else{//OEEE¶ªÇ¾Á½ç
					flag = true;
					//iñ¾ü«ðL^
					record( s , wall , d );
					//ü«ðEü«Éñé
					d = (d+3)%4;
					//iñ¾ü«ðL^
					s.push_back( dc[d] );
				}
			}
		}
	}
	cout << s << endl;
}

C++: #include<iostream>
#include<vector>
#include<string>
using namespace std;
vector<pair<int, int>>x[10][10]; string S;
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 }; char V[5] = "RDLU";
int main() {
	int cnt = 0;
	for (int i = 0; i < 9;i++){
		cin >> S;
		if (i % 2 == 0) {
			for (int j = 0; j < S.size(); j++) {
				if (S[j] == '0')continue;
				x[cnt][j].push_back(make_pair(cnt, j + 1));
				x[cnt][j + 1].push_back(make_pair(cnt, j));
			}
		}
		else {
			for (int j = 0; j < S.size(); j++) {
				if (S[j] == '0')continue;
				x[cnt][j].push_back(make_pair(cnt + 1, j));
				x[cnt + 1][j].push_back(make_pair(cnt, j));
			}
			cnt++;
		}
	}
	int cx = 0, cy = 0, dir = 0;
	while (true) {
		cx += dx[dir]; cy += dy[dir]; cout << V[dir];
		if (cx == 0 && cy == 0)break;
		for (int i = 3; i <= 6; i++) {
			int F = (i + dir) % 4;
			for (int j = 0; j < x[cx][cy].size(); j++) {
				if (x[cx][cy][j] == make_pair(cx + dx[F], cy + dy[F])) {
					dir = F; goto E;
				}
			}
		}
	E:;
	}
	cout << endl;
	return 0;
}

C++: #include <string>
#include <iostream>
using namespace std;
int dir[] = { 0, 1, 0, -1 };
string e = "RDLU";
string s[9]; bool d[6][6][4];
int main() {
	for (int i = 0; i < 9; i++) cin >> s[i];
	for (int i = 0; i < 5; i++) {
		for (int j = 0; j < 4; j++) {
			if (s[i * 2][j] == '1') d[i][j + 1][1] = d[i + 1][j + 1][3] = true;
		}
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 5; j++) {
			if (s[i * 2 + 1][j] == '1') d[i + 1][j][0] = d[i + 1][j + 1][2] = true;
		}
	}
	string ret = "R";
	int x = 0, y = 1, dr = 0;
	while (true) {
		if (d[x][y][dr]) dr = (dr + 3) & 3, ret += e[dr];
		else {
			x += dir[dr], y += dir[dr ^ 1];
			if (x == 1 && y == 0) break;
			if (!d[x][y][(dr + 1) & 3]) {
				dr = (dr + 1) & 3;
				x += dir[dr], y += dir[dr ^ 1]; ret += e[dr];
			}
			else ret += e[dr];
		}
	}
	cout << ret << endl;
	return 0;
}

C++: #include<iostream>
#include<string>
#include<sstream>
enum direction
{
	L, R, U, D
};
int main()
{
	int wall[9][5];
	for (int i = 0; i < 9; i++)
	{
		std::string foo;
		std::cin >> foo;
		std::stringstream bar(foo);
		for (int j = 0;; j++)
		{
			char baz;
			bar >> baz;
			wall[i][j] = static_cast<int>(baz - '0');
			if (i % 2 == 0 && j == 3 || j == 4)
			{
				break;
			}
		}
	}
	direction dir = R;
	std::cout << 'R';
	int crd[2] = { 0,0 };
	while (true)
	{
		switch (dir)
		{
		case L:
			if (crd[1] != 8 && wall[crd[1] + 1][crd[0]] == 1)
			{
				crd[1]++;
				dir = D;
				std::cout << 'D';
			}
			else if (crd[0] == 0 || wall[crd[1]][crd[0] - 1] == 0)
			{
				crd[1]--;
				dir = U;
				std::cout << 'U';
			}
			else
			{
				crd[0]--;
				std::cout << 'L';
			}
			break;
		case R:
			if (crd[1] != 0 && wall[crd[1] - 1][crd[0] + 1] == 1)
			{
				crd[0]++;
				crd[1]--;
				dir = U;
				std::cout << 'U';
			}
			else if (crd[0] == 3 || wall[crd[1]][crd[0] + 1] == 0)
			{
				crd[0]++;
				crd[1]++;
				dir = D;
				std::cout << 'D';
			}
			else
			{
				crd[0]++;
				std::cout << 'R';
			}
			break;
		case U:
			if (crd[0] != 0 && wall[crd[1] - 1][crd[0] - 1] == 1)
			{
				crd[0]--;
				crd[1]--;
				dir = L;
				std::cout << 'L';
			}
			else if (crd[1] == 1 || wall[crd[1] - 2][crd[0]] == 0)
			{
				crd[1]--;
				dir = R;
				std::cout << 'R';
			}
			else
			{
				crd[1] -= 2;
				std::cout << 'U';
			}
			break;
		case D:
			if (crd[0] != 4 && wall[crd[1] + 1][crd[0]] == 1)
			{
				crd[1]++;
				dir = R;
				std::cout << 'R';
			}
			else if (crd[1] == 7 || wall[crd[1] + 2][crd[0]] == 0)
			{
				crd[0]--;
				crd[1]++;
				dir = L;
				std::cout << 'L';
			}
			else
			{
				crd[1] += 2;
				std::cout << 'D';
			}
			break;
		}
		if (crd[0] == 0 && crd[1] == 0)
		{
			std::cout << std::endl;
			break;
		}
	}
	return 0;
}