【宽搜】BAPC2014 J Jury Jeopardy (Codeforces GYM 100526)
题目链接:
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)的更多相关文章
- 【线段树】BAPC2014 E Excellent Engineers (Codeforces GYM 100526)
题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...
- 【扩展欧几里得】BAPC2014 I Interesting Integers (Codeforces GYM 100526)
题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...
- 【模拟】BAPC2014 G Growling Gears (Codeforces GYM 100526)
题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...
- 【最短路】BAPC2014 B Button Bashing (Codeforces GYM 100526)
题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...
- 【中途相遇法】【STL】BAPC2014 K Key to Knowledge (Codeforces GYM 100526)
题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...
- 【最大流】BAPC2014 A Avoiding the Apocalypse (Codeforces GYM 100526)
题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...
- 【宽搜】ECNA 2015 D Rings (Codeforces GYM 100825)
题目链接: http://codeforces.com/gym/100825 题目大意: 给你一张N*N(N<=100)的图表示一个树桩,'T'为年轮,'.'为空,求每个'T'属于哪一圈年轮,空 ...
- 【宽搜】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) ...
- 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 ...
随机推荐
- CentOS 6.7编译安装MySQL 5.6
1.安装前准备 yum install make gcc gcc-c++ ncurses-devel perl bison-devel yum groupinstall "Developme ...
- 重新看php数组
闲来有空,最近看php手册数组这块,对于array_values() 还是第一次接触,array_values是不保留键名,只有键值的函数,还有一个作用就是 重新索引. unset() 函数,是删除 ...
- U3D 内置对象
在U3D里面提供了一个Time对象: void OnGUI(){ Debug.Log("########################"); GUILayout.Label (& ...
- The windows PowerShell snap-in 'Microsoft.Crm.PowerShell' is not installed on this computer
加载PowerShell插件时出现以下错误: The windows PowerShell snap-in 'Microsoft.Crm.PowerShell' is not installed on ...
- Linux软件
网上下载:Chrome Browser for Linux; sqlite; WPS; symbol-fonts; 软件中心:Terminator; Code::Blocks IDE; 新立得软件 ...
- .net excel利用NPOI导入oracle
1.链接数据库 引用System.Data.OracleClient: //数据库链接字符串 Data Source如:192.168.5.153:1521/orcl string linkStr ...
- 如何管理你的 Javascript 代码
今天不聊技术的问题,咱们来聊聊在前端开发中如何管理好自己的 Javascript 代码.首先,咱们先来说说一般都有哪些管理方式?我相信 seajs . requirejs 对于前端开发者而言都不陌 ...
- 【转】 C++库常用函数一览
本文中提到的函数库有:<string> <cctype> <algorithm> <cmath> <cstdlib> <iomanip ...
- c++面试(一)
1.在c++中可以通过"::"来直接操作全局变量. 2.i++与++i效率的比较. (1)內建数据类型时,他们的效率差别不大. (2)自定义数据类型(类等)的情况,(++i)可以返 ...
- Bridge 模式
Bridge 模式将抽象和行为划分开来,各自独立,但能动态的结合.在面向对象设计的基本概念中,对象这个概念实际是由属性和行为两个部分组成的,属性我们可以认为是一种静止的,是一种抽象,一般情况下,行为是 ...