Problem A: The Monocycle |
A monocycle is a cycle that runs on one wheel and the one we will be considering is a bit more special. It has a solid wheel colored with five different colors as shown in the figure:
The colored segments make equal angles (72o) at the center. A monocyclist rides this cycle on an grid of square tiles. The tiles have such size that moving forward from the center of one tile to that of the next one makes the wheel rotate exactly 72o around its own center. The effect is shown in the above figure. When the wheel is at the center of square 1, the midpoint of the periphery of its blue segment is in touch with the ground. But when the wheel moves forward to the center of the next square (square 2) the midpoint of its white segment touches the ground.
Some of the squares of the grid are blocked and hence the cyclist cannot move to them. The cyclist starts from some square and tries to move to a target square in minimum amount of time. From any square either he moves forward to the next square or he remains in the same square but turns 90o left or right. Each of these actions requires exactly 1 second to execute. He always starts his ride facing north and with the midpoint of the green segment of his wheel touching the ground. In the target square, too, the green segment must be touching the ground but he does not care about the direction he will be facing.
Before he starts his ride, please help him find out whether the destination is reachable and if so the minimum amount of time he will require to reach it.
Input
The input may contain multiple test cases.
The first line of each test case contains two integers M and N (, ) giving the dimensions of the grid. Then follows the description of the grid in M lines of N characters each. The character `#' will indicate a blocked square, all other squares are free. The starting location of the cyclist is marked by `S' and the target is marked by `T'. The input terminates with two zeros for M and N.
Output
For each test case in the input first print the test case number on a separate line as shown in the sample output. If the target location can be reached by the cyclist print the minimum amount of time (in seconds) required to reach it exactly in the format shown in the sample output, otherwise, print ``destination not reachable".
Print a blank line between two successive test cases.
Sample Input
1 3 S#T 10 10 #S.......# #..#.##.## #.##.##.## .#....##.# ##.##..#.# #..#.##... #......##. ..##.##... #.###...#. #.....###T 0 0
Sample Output
Case #1 destination not reachable Case #2 minimum time = 49 sec
/* 是一般的宽度搜索题 */ #include<cstdio> #include<cstring> #include<iostream> #include<queue> using namespace std; struct node { int x; int y; int type; int forward; int step; }term,gold,t; queue<node>q; int fang[4][2]={-1,0,0,1,1,0,0,-1}; char map[27][27]; bool mask[27][27][5][4];//在一个方格同一种状态只能出现一次 int M,N; int main() { // freopen("in.txt","r",stdin); int T=1,flag; int i,j; while(scanf("%d%d",&M,&N),M) { while(!q.empty())q.pop(); memset(map,0,sizeof(map)); memset(mask,0,sizeof(mask)); if(T==1)printf("Case #%d\n",T++);//注意输出格式 else printf("\nCase #%d\n",T++); for(i=1;i<=M;i++) { for(j=1;j<=N;j++) { cin>>map[i][j]; if(map[i][j]=='#')map[i][j]=0; else if(map[i][j]=='S') { term.x=i; term.y=j; term.step=0; term.type=0; term.forward=0; q.push(term); mask[i][j][0][0]=true; } else if(map[i][j]=='T') { gold.x=i; gold.y=j; gold.type=0; } } } flag=0; while(!q.empty()) { term=q.front(); q.pop(); t.x=term.x+fang[term.forward][0]; t.y=term.y+fang[term.forward][1]; t.forward=term.forward; t.step=term.step+1; t.type=(term.type+1)%5; if(t.x==gold.x&&t.y==gold.y&&t.type==gold.type) { flag=1; break; } if(mask[t.x][t.y][t.type][t.forward]==false&&map[t.x][t.y]!=0) { mask[t.x][t.y][t.type][t.forward]=true; //printf("t.x=%d t.y=%d t.forward=%d t.step=%d t.type=%d\n",t.x,t.y,t.forward,t.step,t.type); q.push(t); } t.x=term.x; t.y=term.y; t.forward=(term.forward+1)%4; t.step=term.step+1; t.type=term.type; if(mask[t.x][t.y][t.type][t.forward]==false) { mask[t.x][t.y][t.type][t.forward]=true; //printf("t.x=%d t.y=%d t.forward=%d t.step=%d t.type=%d\n",t.x,t.y,t.forward,t.step,t.type); q.push(t); } t.forward=(term.forward+3)%4; if(mask[t.x][t.y][t.type][t.forward]==false) { mask[t.x][t.y][t.type][t.forward]=true; //printf("t.x=%d t.y=%d t.forward=%d t.step=%d t.type=%d\n",t.x,t.y,t.forward,t.step,t.type); q.push(t); } } if(flag)printf("minimum time = %d sec\n",t.step); else printf("destination not reachable\n"); } return 0; }
相关推荐
**超宽带单脉冲(UWB Monocycle)技术详解** 超宽带(Ultra-Wideband,简称UWB)是一种无线通信技术,它利用极短的脉冲信号在宽广的频谱上进行传输,通常这些脉冲的带宽远超过传统窄带通信系统的带宽。UWB ...
独轮车 MIPS 实现 使用 MIPS 架构模拟 CPU 的 VHDL 系统的实现。 该系统由 32 个寄存器组成,每个寄存器为 32 位,结构为寄存器组。 程序和数据存储器的容量为 256 字节。 系统处理字为 32 位。...
A novel all-optical method for ultra-wideband (UWB) ... After proper differential delay, an UWB monocycle pulse with 84-ps width and the fractional bandwidth of 153% is generated after photodetection.
UWB_monocycle.m 此 m 文件显示高斯脉冲函数的时间波形以及 0.5 纳秒脉冲宽度的高斯脉冲函数的一阶和二阶导数。 通过改变 fs,t,t1 可以使用其他脉冲宽度值。 该程序将实际的一阶和二阶导数方程式用于高斯脉冲波形。 ...
To combine the complementary pulses forming a monocycle UWB pulse, two schemes are used to implement incoherent summation structure. A proof-of-concept experiment of UWB-over-fiber down-link system ...
matlab开发-UWBMonocycle。显示高斯脉冲函数的时间波形。
这项研究属于光子学领域,主要探讨了如何在全光域中生成超宽带(UWB)单周期脉冲,并实现其在脉冲极性上的可切换性和脉冲宽度及射频(RF)谱上的可调谐性。 超宽带技术(UWB)被定义为在3.1GHz至10.6GHz的频谱范围...
A novel approach to generate and distribute ultra-wideband ... If the input Gaussian pulses are with the same sharp parameters but different time delays, a quasi-monocycle-waveform UWB signal can be gene
高斯脉冲的导数(如一阶导数Monocycle)因其无直流分量且可调节脉冲宽度以符合FCC的规定,成为构建UWB信号的理想选择。 接着,文章介绍了利用半导体光放大器(SOA)生成Monocycle信号的方法。通过调整SOA的注入电流...
uwb高斯脉冲的产生程序,请大家参考给个意见
单周期CPU设计是一种简化了的计算机处理器架构,它在单个时钟周期内完成指令的取指、译码、执行、访存和写回等所有操作。这种设计减少了硬件复杂性和延迟,但牺牲了处理速度,因为每个步骤都需要等待前一步骤完成。...
The control of the monocycle(=独轮车=獨輪車=segway=Self Balance Unicycle=SBU=赛格威=賽格威) was executed by using Open Dynamics Engine that was a physical engine together with this theory.
代码首先定义了一个Gaussian Monocycle脉冲作为UWB信号的基础单元。这种脉冲由公式`p=A*(1-4*pi*t.^2).*exp(-2*pi*t.^2)`生成,其中`A`是振幅,`t`是时间样本点。该脉冲具有高斯形状,中心频率约为零,常用于UWB系统...
- **基于单个偏振干涉仪(PI)**:提出并实验研究了一种将暗RZ信号输入到单个PI中,通过调整PC可获得一对极性相反的超宽带monocycle脉冲和一个超宽带doublet脉冲。 - **SOA级联PI**:利用SOA-XGM效应和PI的微分...
UWB信号的产生形式多样,但高斯脉冲和其导数——高斯单脉冲(Gaussian Monocycle)是常见的选择。高斯脉冲的时域表达式为一个指数函数,其频域表达式则揭示了它富含低频和直流分量,这不利于天线辐射。相比之下,...
\n\n- **“mono-”** 表示“单一”,如“monocycle”为独轮车,“monoplane”指单翼飞机,还有“monolithic”用于描述单片式构造。\n\n- **“uni-”** 同样表示“一”,如“unicolor”意为单色,“uniform”则有均匀...
6. `monocycle.m`:单周期检测可能涉及到脉冲的识别,是TOA测量的基础。 7. `tempt.m`、`tempt1.m`:这些可能是临时或辅助函数,用于中间计算或数据处理。 综上所述,这个压缩包包含了一个基于MATLAB的UWB TOA定位...
提出了一种基于半导体光放大器(SOA)和电吸收调制器(EAM)实现超宽带(UWB)脉冲波形调制(PSM)的方案,利用SOA的交叉增益调制(XGM)和增益饱和效应产生高斯单边带(monocycle)信号,利用EAM的交叉吸收调制(XAM)效应控制泵...