UVa 101 The Blocks Problem (超级模拟)

101 - The Blocks Problem

Time limit: 3.000 seconds

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=37

Background

Many areas of Computer Science use simple, abstract domains for both analytical and empirical studies. For example, an early AI study of planning and robotics (STRIPS) used a block world in which a robot arm performed tasks involving the manipulation of blocks.

In this problem you will model a simple block world under certain rules and constraints. Rather than determine how to achieve a specified state, you will ``program'' a robotic arm to respond to a limited set of commands.

The Problem

The problem is to parse a series of commands that instruct a robot arm in how to manipulate blocks that lie on a flat table. Initially there are n blocks on the table (numbered from 0 ton-1) with block bi adjacent to block bi+1 for all

as shown in the diagram below:

 

Figure: Initial Blocks World

The valid commands for the robot arm that manipulates blocks are:

move a onto b

where a and b are block numbers, puts block a onto block b after returning any blocks that are stacked on top of blocks a and b to their initial positions.

move a over b

where a and b are block numbers, puts block a onto the top of the stack containing blockb, after returning any blocks that are stacked on top of block a to their initial positions.

pile a onto b

where a and b are block numbers, moves the pile of blocks consisting of block a, and any blocks that are stacked above block a, onto block b. All blocks on top of block b are moved to their initial positions prior to the pile taking place. The blocks stacked above block a retain their order when moved.

pile a over b

where a and b are block numbers, puts the pile of blocks consisting of block a, and any blocks that are stacked above block a, onto the top of the stack containing block b. The blocks stacked above block a retain their original order when moved.

quit

terminates manipulations in the block world.

Any command in which a = b or in which a and b are in the same stack of blocks is an illegal command. All illegal commands should be ignored and should have no affect on the configuration of blocks.

The Input

The input begins with an integer n on a line by itself representing the number of blocks in the block world. You may assume that 0 < n < 25.

The number of blocks is followed by a sequence of block commands, one command per line. Your program should process all commands until the quit command is encountered.

You may assume that all commands will be of the form specified above. There will be no syntactically incorrect commands.

The Output

The output should consist of the final state of the blocks world. Each original block position numbered i (

where n is the number of blocks) should appear followed immediately by a colon. If there is at least a block on it, the colon must be followed by one space, followed by a list of blocks that appear stacked in that position with each block number separated from other block numbers by a space. Don't put any trailing spaces on a line.

There should be one line of output for each block position (i.e., n lines of output where n is the integer on the first line of input).

时间: 2024-10-01 05:53:07

UVa 101 The Blocks Problem (超级模拟)的相关文章

UVa 101 The Blocks Problem 数据结构专题

题目链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=103&page=show_problem&problem=37 题目类型: 数据结构, 二叉树 题意: 有N个位置, 编号为 0-N-1, 初始下,各个位置上放置这和位置编号相同的砖块,即砖块1,砖块2--砖块N-1. 然后有四种命令操作方式: 1.move a onto b :把砖a移动到砖b上面,如果a

uva 101 - The Blocks Problem

点击打开链接 题目意思: 在早期人工智慧的領域中常常會用到機器人,在這個問題中有一支機器手臂接受指令來搬動積木,而你的任務就是輸出最後積木的情形. (編號從0到n-1)0號積木放在0號位置上,1號積木放在1號位置上 機器手臂有以下幾種合法搬積木的方式(a和b是積木的編號) move a onto b 在將a搬到b上之前,先將a和b上的積木放回原來的位置(例如:1就放回1的最開始位罝) move a over b 在將a搬到b所在的那堆積木之上之前,先將a上的積木放回原來的位罝(b所在的那堆積木不

印度政府CryEngine3引擎研发3D超级模拟游戏

据海外媒体报道,印度政府下属的科技和政策研究中心正在主持开发一款专门用于训练突发事件应急人员的超级模拟游戏. 这款游戏将用超级逼真的3D虚拟世界模拟位于印度班加罗尔的加路达购物中心及其周边环境,通过先进的游戏互动来模拟加路达购物中心在发生突发公共事件和恐怖袭击后,训练包括警察.安保.医生.消防员等在内的专业应急人员如何在第一时间处置事发现场并进行救援. 众所周知,恐怖主义一直是印度国内公共安全的主要问题.2008年11月26日至29日,印度孟买的泰姬玛哈酒店遭遇了令全球震惊的连环恐怖袭击,造成至

印度政府正研发3D超级模拟游戏训练防恐应急

据海外媒体报道,印度政府下属的科技和政策研究中心正在主持开发一款专门用于训练突发事件应急人员的超级模拟游戏. 这款游戏将用超级逼真的3D虚拟世界模拟位于印度班加罗尔的加路达购物中心及其周边环境,通过先进的游戏互动来模拟加路达购物中心在发生突发公共事件和恐怖袭击后,训练包括警察.安保.医生.消防员等在内的专业应急人员如何在第一时间处置事发现场并进行救援. 众所周知,恐怖主义一直是印度国内公共安全的主要问题.2008年11月26日至29日,印度孟买的泰姬玛哈酒店遭遇了令全球震惊的连环恐怖袭击,造成至

UVa 11507 Bender B. Rodríguez Problem:模拟&amp;amp;异或

11507 - Bender B. Rodríguez Problem Time limit: 4.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2502 Bender is a robot built by Mom's Friendly Robot Company at its pl

UVa 550 Multiplying by Rotation:模拟乘法

550 - Multiplying by Rotation Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=100&page=show_problem&problem=491 Warning: Not all numbers in this problem are decimal numbers! Multiplic

UVa 105 The Skyline Problem (想法题)

105 - The Skyline Problem Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=41 这题有个很巧的思路:离散化. 什么意思呢?既然每栋大楼的高和左右边界都是整数,那么不妨把线段用一个个整点表示.既然最后只求一个轮廓,那么对每个横坐标,就记

UVa 133 The Dole Queue:模拟循环链表

133 - The Dole Queue Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=103&page=show_problem&problem=69 In a serious attempt to downsize (reduce) the dole queue, The New National Green

UVa 327 Evaluating Simple C Expressions (模拟)

327 - Evaluating Simple C Expressions Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=104&page=show_problem&problem=263 The task in this problem is to evaluate a sequence of simple C