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;

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const char dir[] = "RDLU";

int main()
{
    string input;

    while (cin >> input) {
        bool map[5][5][4];

        // Initialization
        for (int i = 0; i < 5; i++)
            for (int j = 0; j < 5; j++)
                for (int k = 0; k < 4; k++)
                    map[i][j][k] = false;

        // Input (0,0) - (0,4)
        for (int i = 0; i < 4; i++) 
            if (input[i] == '1') {
                map[0][i][0] = true;
                map[0][i + 1][2] = true;
            }

        // Input Others
        for (int i = 0; i < 8; i++) {
            cin >> input;
            int lim;
            (i % 2) ? (lim = 4) : (lim = 5);

            for (int j = 0; j < lim; j++)
                if (input[j] == '1') {
                    if (i % 2) {
                        map[(i + 1) / 2][j][0] = true;
                        if (j)
                            map[(i + 1) / 2][j + 1][2] = true;
                    }
                    else {
                        map[i / 2][j][1] = true;
                        map[(i / 2) + 1][j][3] = true;
                    }
                }
        }

        // algorithm
        int x, y, d;

        x = y = d = 0;
        // do {
        //     if (map[y][x][d])
        //         ;
        //     else if (map[y][x][(d + 1) % 4]) 
        //         d = (d + 1) % 4;
        //     else if (map[y][x][(d + 3) % 4]) 
        //         d = (d + 3) % 4;

            // map[y][x][d] = false;
            // x += dx[d];
            // y += dy[d];
            // cout << dir[d];
        // } while (x || y);
        do {
            int del = (d + 3) % 4;
            for (int i = 0; i < 4; i++) 
                if (map[y][x][(del + i) % 4]) {
                    d = (del + i) % 4;
                    break;
                }

            map[y][x][d] = false;
            x += dx[d];
            y += dy[d];
            cout << dir[d];
        } while (x || y);

        cout << endl;
    }

    return 0;
}

C++: #include<cstdio>
#include<algorithm>

using namespace std;

int map[11][11]={-1};
int point[2]={1,1};
int m=0;//向き→0↓1←2↑3
int date[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
char cdate[4]={'R','D','L','U'};


bool fun()
{

	m=(m+2)%4;
	for(int i=0;i<4;i++)
	{
		m=(m+1)%4;
		if(map[point[1]+date[m][1]][point[0]+date[m][0]]==1)
		{
			point[0]+=2*date[m][0];
			point[1]+=2*date[m][1];
			printf("%c",cdate[m]);
			break;
		}
	}
	if(point[0]==1&&point[1]==1)return false;
	else true;
}

int main()
{
	for(int i=0;i<5;i++)
	{
		char c[15];
		scanf("%s",c);
		for(int j=0;j<4;j++)
		{
			map[i*2+1][(j+1)*2]=c[j]-'0';
		}
		if(i!=4)
		{
			scanf("%s",c);
			for(int j=0;j<5;j++)
			{
				map[(i+1)*2][j*2+1]=c[j]-'0';
			}
		}
	}

	fun();
	while(fun()){};
	printf("\n");
	return 0;
}

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

int main(){
    char ma[11][11];
    memset(ma,'0',sizeof(ma));
    for(int i=1;i<10;i++){
        if(i%2==1)
            for(int j=2;j<9;j+=2)
                cin>>ma[i][j];
        else
            for(int j=1;j<10;j+=2)
                cin>>ma[i][j];
    }
    int x=1,y=1,dir=0;
    int mv[4][2]={{2,0},{0,2},{-2,0},{0,-2}};
    int ts[4][6]={{1,-1,1,0,0,-1},{1,1,0,1,1,0},{-1,1,-1,0,0,1},{-1,-1,0,-1,-1,0}};
    string str[4]={"R","D","L","U"};
    string path="";
    int ch=0;
    for(int k=0;k<40;k++){
        int wen=1;
        while(ma[y+ts[dir][3]][x+ts[dir][2]]=='1'){
            y+=mv[dir][1];
            x+=mv[dir][0];
            wen=0;
            path+=str[dir];
            wen++;
        }
        if(x==1&&y==1)
            break;
        if(ma[y+ts[dir][5]][x+ts[dir][4]]=='1')ch=1;
        do{
            if(ch==0)dir=(dir+1)%4;
            else dir=(dir+4-1)%4;
        }while((y+ts[dir][3]>10||y+ts[dir][3]<0||x+ts[dir][2]>10||x+ts[dir][2]<0)||ma[y+ts[dir][1]][x+ts[dir][0]]=='1');
        
    }
    cout<<path<<endl;
}
//RRRRDDDDLLLUUURRDDLURULLDDDRRRUUUULLLL
//RRRRDDDDLLLUUURRDDLURULLDDDRRRUUUULLLL

C++: // AOL q0037
// YAMADA Terushige
// 2013.4.12

#include<iostream>
 
using namespace std;
int grid[5][5][4];
 
int main(){
 
  enum Direc {L,U,R,D};
  string s;

  int i,j,k,d;
  for(i=0;i<4;i++){
    cin >> s;
    for(j=0;j<4;j++){
      grid[i][j][R]=grid[i][j+1][L]=s[j]-'0';
    }
    cin >> s;
    for(j=0;j<5;j++){
      grid[i][j][D]=grid[i+1][j][U]=s[j]-'0';
    }
  }
  cin >> s;
  for(j=0;j<4;j++){
    grid[i][j][R]=grid[i][j+1][L]=s[j]-'0';
  }

  i=0;j=1;
  d=R;cout <<'R';
  while(i!=0 || j!=0){
    d=(d+2)%4;
    for(k=0;k<4;k++){
      d=(d+1)%4;
      if(grid[i][j][d]==1)break;
    }

    switch(d){
    case L:
      cout << 'L';j--;
      break;
    case U:
      cout << 'U';i--;
      break;
    case R:
      cout << 'R';j++;
      break;
    case D:
      cout << 'D';i++;
      break;
    }

  }
  cout << endl;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

string wall_01[5];
string wall_02[4];

char wall_1(int x, int y){
	if(x <= -1 || y <= -1 || x >= 4 || y >= 5){
		return '0';
	}
	return wall_01[y][x];
}

char wall_2(int x, int y){
	if(x <= -1 || y <= -1 || x >= 5 || y >= 4){
		return '0';
	}
	return wall_02[y][x];
}

int main(){
	
	for(int i = 0; i < 9; i++){
		if(i % 2 == 0){
			cin >> wall_01[i / 2];
		}else{
			cin >> wall_02[i / 2];
		}
	}
	
	int pos_x = 0;
	int pos_y = 0;
	
	char dir_list[4] = {'R', 'D', 'L', 'U'};
	
	char dir = 'R';
	
	while(true){
		
		//cout << pos_x << pos_y << dir << endl;
		
		if(dir == 'R'){
			if(wall_2(pos_x, pos_y - 1) == '1'){
				cout << "U";
				pos_y--;
				dir = 'U';
			}else if(wall_1(pos_x, pos_y) == '1'){
				cout << "R";
				pos_x++;
			}else if(wall_2(pos_x, pos_y) == '1'){
				dir = 'D';
			}else{
				dir = 'L';
			}
		}else if(dir == 'D'){
			if(wall_1(pos_x, pos_y) == '1'){
				cout << "R";
				pos_x++;
				dir = 'R';
			}else if(wall_2(pos_x, pos_y) == '1'){
				cout << "D";
				pos_y++;
			}else if(wall_1(pos_x - 1, pos_y) == '1'){
				dir = 'L';
			}else{
				dir = 'U';
			}
		}else if(dir == 'L'){
			if(wall_2(pos_x, pos_y) == '1'){
				cout << "D";
				pos_y++;
				dir = 'D';
			}else if(wall_1(pos_x - 1, pos_y) == '1'){
				cout << "L";
				pos_x--;
			}else if(wall_2(pos_x, pos_y - 1) == '1'){
				dir = 'U';
			}else{
				dir = 'R';
			}
		}else if(dir == 'U'){
			if(wall_1(pos_x - 1, pos_y) == '1'){
				cout << "L";
				pos_x--;
				dir = 'L';
			}else if(wall_2(pos_x, pos_y - 1) == '1'){
				cout << "U";
				pos_y--;
			}else if(wall_1(pos_x, pos_y) == '1'){
				dir = 'R';
			}else{
				dir = 'D';
			}
		}
		
		if(pos_x == 0 && pos_y == 0){
			cout << endl;
			break;
		}
	}
	
	return 0;
}