题目链接:

  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. 实现一个线程安全的Queue队列

    使用装饰者模式实现一个线程安全的Queue队列. public class SynchronizedQueue<E> implements Queue<E>, Serializ ...

  2. python 学习笔记(二)两种方式实现第一个python程序

    在交互模式下: 如果要让Python打印出指定的文字,可以用print语句,然后把希望打印的文字用单引号或者双引号括起来,但不能混用单引号和双引号: >>> print 'hello ...

  3. java中的类集框架

    1.什么是类集框架 1.是一组类和接口 2.位于java.util包当中 3.主要用于用户存储和管理对象 4.主要分为三大类——集合.列表和映射 2.类集框架图 虚线框的表示接口,实线框的表示实现类 ...

  4. asp.net手动填充TreeView生成树

    最近在做项目发现需要用到树的地方,页面的前台任然是使用一个asp.net的控件TreeView来显示树的结构,当然也可以自己在前台写一个树来展示,这在后期跟局功能的不同很大可能会要用到异步的知识,废话 ...

  5. HBuilder+移动APP开发实例

    mui: 官网:http://dcloudio.github.io/mui/ 说明:一般要把官网内容通读一遍,这是开发的基础 开始 1.新建项目 在首页点击新建移动App,如下: 或者在项目管理器内右 ...

  6. c# 左连接写法

    var itemandformulas = from i in AttendanceItemList join f in AttendanceFormulaList on i.AttendanceCo ...

  7. MySQL 5.6 解决InnoDB: Error: Table "mysql"."innodb_table_stats" not found.问题

    在安装MySQL 5.6.30时,安装完成后,后台日志报如下警告信息:2016-05-27 12:25:27 7fabf86f7700 InnoDB: Error: Table "mysql ...

  8. 查看Jquery版本

    1. $.fn.jquery > "1.11.1" 2. 通过这样可以 判断一个对象是否是jquery对象!!

  9. FlightGear 视角控制

    Flightgear提供了非常灵活的模块化功能 这里就简要记录一下视角切换功能 首先,需要了解一下Flightgear中的property tree的主要内容,这里暂略. http://wiki.fl ...

  10. ETLLib库走读

    以前从来也没想过要去看库里的代码,咱想,那怎么也是很底层的代码,居然发现库里的代码也可以这样写,那就先读懂这个ETLLib(跨windows与Linux平台,封装了一些基本的系统调用函数,然后实现定制 ...