题目链接:

  http://codeforces.com/gym/100526

  http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=11673&courseid=0

题目大意:

  一个机器人一开始位于迷宫入口,面朝东,接下来按照右前左后的顺序遍历迷宫,如果有墙'#'就执行下一个方向

  直到找到一个是路'.'的方向并且往那个方向移动一格,并改为面朝该方向。

  现在给你机器人右前左后的字符数组,求原来的地图,数据保证没有不能遍历的点。最顶端,右端和下端都应该有一层墙壁'#'。

  数据保证最后机器人回到起点。地图大小不超过100x100

题目思路:

  【宽搜】

  选定起点(我选的是200,200)然后开始按照字符串中的方向字符走,并且把这个点覆盖成路'.'。接着改变朝向。

  做的过程中记录到达的边界大小,最后按边界输出地图即可。

 //
//by coolxxx
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<map>
#include<memory.h>
#include<time.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//#include<stdbool.h>
#include<math.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(a) ((a)>0?(a):(-(a)))
#define lowbit(a) (a&(-a))
#define sqr(a) ((a)*(a))
#define swap(a,b) ((a)^=(b),(b)^=(a),(a)^=(b))
#define mem(a,b) memset(a,b,sizeof(a))
#define eps (1e-8)
#define J 10
#define mod 1000000007
#define MAX 0x7f7f7f7f
#define PI 3.14159265358979323
#define N 504
#define M 10000004
using namespace std;
typedef long long LL;
int cas,cass;
int n,m,lll,ans;
int l,r,u,d;
char s[M];
int dx[]={,-,,};
int dy[]={,,-,};
int R[]={,,,},F[]={,,,},L[]={,,,},B[]={,,,};
char mapp[N][N];
void print()
{
int i,j;
printf("%d %d\n",d-u+,r-l+);
for(i=u-;i<=d+;i++)
{
for(j=l;j<=r+;j++)
printf("%c",mapp[i][j]);
puts("");
}
}
int main()
{
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
// freopen("2.txt","w",stdout);
#endif
int i,j,k;
int x,y,way;
// for(scanf("%d",&cas);cas;cas--)
// for(scanf("%d",&cas),cass=1;cass<=cas;cass++)
// while(~scanf("%s",s+1))
// while(~scanf("%d",&n))
scanf("%d",&cas);
printf("%d\n",cas);
while(cas--)
{
scanf("%s",s);
for(i=;i<N;i++)
for(j=;j<N;j++)
mapp[i][j]='#';
n=strlen(s);
r=l=u=d=,x=,y=;way=;
mapp[x][y]='.';
for(i=;i<n;i++)
{
if(s[i]=='R')
{
way=R[way];
x+=dx[way];
y+=dy[way];
mapp[x][y]='.';
}
else if(s[i]=='F')
{
way=F[way];
x+=dx[way];
y+=dy[way];
mapp[x][y]='.';
}
else if(s[i]=='L')
{
way=L[way];
x+=dx[way];
y+=dy[way];
mapp[x][y]='.';
}
else if(s[i]=='B')
{
way=B[way];
x+=dx[way];
y+=dy[way];
mapp[x][y]='.';
}
u=min(u,x);d=max(d,x);l=min(l,y);r=max(r,y);
}
print();
}
return ;
}
/*
// //
*/

【宽搜】BAPC2014 J Jury Jeopardy (Codeforces GYM 100526)的更多相关文章

  1. 【线段树】BAPC2014 E Excellent Engineers (Codeforces GYM 100526)

    题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...

  2. 【扩展欧几里得】BAPC2014 I Interesting Integers (Codeforces GYM 100526)

    题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...

  3. 【模拟】BAPC2014 G Growling Gears (Codeforces GYM 100526)

    题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...

  4. 【最短路】BAPC2014 B Button Bashing (Codeforces GYM 100526)

    题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...

  5. 【中途相遇法】【STL】BAPC2014 K Key to Knowledge (Codeforces GYM 100526)

    题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...

  6. 【最大流】BAPC2014 A Avoiding the Apocalypse (Codeforces GYM 100526)

    题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...

  7. 【宽搜】ECNA 2015 D Rings (Codeforces GYM 100825)

    题目链接: http://codeforces.com/gym/100825 题目大意: 给你一张N*N(N<=100)的图表示一个树桩,'T'为年轮,'.'为空,求每个'T'属于哪一圈年轮,空 ...

  8. 【宽搜】ECNA 2015 E Squawk Virus (Codeforces GYM 100825)

    题目链接: http://codeforces.com/gym/100825 题目大意: N个点M条无向边,(N<=100,M<=N(N-1)/2),起始感染源S,时间T(T<10) ...

  9. Codeforces gym 101343 J.Husam and the Broken Present 2【状压dp】

     2017 JUST Programming Contest 2.0 题目链接:Codeforces gym 101343 J.Husam and the Broken Present 2 J. Hu ...

随机推荐

  1. Python之路【第十篇】:HTML -暂无等待更新

    Python之路[第十篇]:HTML -暂无等待更新

  2. js获取上一个月、下一个月

    /** * 获取上一个月 * * @date 格式为yyyy-mm-dd的日期,如:2014-01-25 */ function getPreMonth(date) { var arr = date. ...

  3. python爬虫scrapy的Selectors参考文档

    http://doc.scrapy.org/en/1.0/topics/selectors.html#topics-selectors-htmlcode

  4. retain two decimal digits.

    package kju.o; import static kju.print.Printer.*; import java.text.*; class MathDemo { public static ...

  5. TFS扩展开发中遇到的坑

    本码农最近开发一个VS扩展,其中有些功能涉及到文件的签出.我们公司用的是TFS,遇到了一些奇特的现象,将解决过程记录如下. 一.明明在线的连接却Offline属性等于True public stati ...

  6. ajax xmlhttp下open方法POST、GET参数的区别

    1. get是从服务器上获取数据(会暴露客户端ip),post是向服务器传送数据.2. get是把参数数据队列加到提交表单的ACTION属性所指的URL中,值和表单内各个字段一一对应,在URL中可以看 ...

  7. TOM大师脚本-show space 多个版本,谢谢大牛们

    示例一 该脚本需区分 对象的管理方式是 自动还是 手动, 对手动管理方式 的表显示很全面 SQL> exec show_space_old('MAN_TAB','DEV','TABLE'); F ...

  8. UITableViewCell 添加长按手势

    UILongPressGestureRecognizer *lpgr = [[UILongPressGestureRecognizer alloc] initWithTarget:self actio ...

  9. JS实现页面跳转重定向的几种方式

    1.重定向 <script language="javascript"type="text/javascript">  window.locatio ...

  10. U盘美化(更换U盘logo和页面背景软件)

    U盘内新建txt文本后,输入 [autorun] ICON=ooopic_1459309050.ico 保存的文件名包括后缀更改为autorun.inf 必须为icon图标