http://oj.ecustacm.cn/problem.php?id=1317
/*#include <iostream>
using namespace std;
const int N = 15;
int vis[N][N];
char m[N][N];
int ans = 0;
void dfs(int x, int y) {
if (x < 0 || x > 9 || y < 0 || y > 9 ) {
ans++;
return;
} else {
if (m[x][y] == 'U' && vis[x][y] == 0) {
vis[x][y] = 1;
dfs(x - 1, y);
vis[x][y] = 0;
}
if (m[x][y] == 'D' && vis[x][y] == 0) {
vis[x][y] = 1;
dfs(x + 1, y);
vis[x][y] = 0;
}
if (m[x][y] == 'L' && vis[x][y] == 0) {
vis[x][y] = 1;
dfs(x, y - 1);
vis[x][y] = 0;
}
if (m[x][y] == 'R' && vis[x][y] == 0) {
vis[x][y] = 1;
dfs(x, y + 1);
vis[x][y] = 0;
}
}
}
int main() {
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
cin >> m[i][j];
}
}
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
dfs(i, j);
}
}
cout << ans << endl;
return 0;
}*/
#include<iostream>
using namespace std;
int main()
{
int count =0;
string A[10]={"UDDLUULRUL","UURLLLRRRU","RRUURLDLRD"
,"RUDDDDUUUU","URUDLLRRUU","DURLRLDLRL","ULLURLLRDU"
,"RDLULLRDDD","UUDDUDUDLL","ULRDLUURRR"};//迷宫地图
for(int i=0;i<10;i++)//遍历每一个位置
{
for(int j=0;j<10;j++)
{
int x=i,y=j;char a=A[i][j];char b=a;//b表示上一个位置的字符
//如果U上一个为D,则陷入循环状态,不能走出迷宫
while(true)
{
if(a=='U')//上
{
if(b=='D') break;
x--;
}
if(a=='R')//右
{
if(b=='L') break;
y++;
}
if(a=='L')//左
{
if(b=='R') break;
y--;
}
if(a=='D')//下
{
if(b=='U') break;
x++;
}
if(x<0||x>9||y<0||y>9)//如果x或者y超出界限,则可以出迷宫
{
count++;
break;
}
b=a;
a=A[x][y];
}
}
}
cout<<count;
return 0;
}