题目链接:

  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. D2JS 的数据绑定

    D2JS 将数据绑定视为"对象-路径-渲染/收集 "组成.主要 DOM  元素和对象绑定,称为 d2js.root,非主要元素指定数据路径,通过路径定位到值,根据值可进行渲染或收集 ...

  2. 点击其它地方隐藏div/事件冒泡/sweet-alert阻止冒泡

    点击document时把div隐藏,但点击div时阻止点击事件冒泡到document,从而实现“点击文档其它地方隐藏div,点击div本身不隐藏”.js代码如下:$("#div") ...

  3. 多线程lock(instance)中instance的选择.

    如我的提问:http://bbs.csdn.net/topics/390496351?page=1#post-394837834 拥有类原子功能的类: class ShareState { //原子功 ...

  4. 为什么选择Typescript

    上一节,我简单介绍了Typescript,并将Typescript和JavaScript进行了对比,有些网友提出了一些疑问,可能有些网友对于这个Typescript还不是特别的熟悉,这节,我做一些演示 ...

  5. 使用cocoapods管理第三方类库

    前言 在iOS项目中使用第三方类库可以说是非常常见的事,但是要正确地配置他们有时候是非常繁琐的事情,幸运的是CocoaPods是一个很好的解决方案. 什么是CocoaPods CocoaPods是OS ...

  6. 通常我们使用[NSDate date]方法得到的时间与当前时间不一致,如何解决?

    NSDate *date = [NSDate date];    NSTimeZone *zone = [NSTimeZone systemTimeZone];    NSInteger interv ...

  7. jQuery 获取并设置 CSS 类

    通过 jQuery,可以很容易地对 CSS 元素进行操作. 切换 CSS 类 jQuery 操作 CSS jQuery 拥有若干进行 CSS 操作的方法.我们将学习下面这些: addClass() - ...

  8. mac 连接linux

    1.ssh 通过ssh 的方式直接连接linux ssh name@ip -22 例:ssh  zyc@192.168.1.100 -22 这个的前提是linux 要开启ssh 服务 先看一下linu ...

  9. 【POJ3580】【块状链表】SuperMemo

    Description Your friend, Jackson is invited to a TV show called SuperMemo in which the participant i ...

  10. Ajax基础--JavaScript实现

    ajax原理 1.ajax 即“Asynchronous JavaScript and XML”(异步 JavaScript 和 XML),也就是无刷新数据读取. 通俗地讲就是:AJAX 通过在后台与 ...