Manhattan 2025
Time Limit: 1000MS   Memory Limit: 30000K
Total Submissions: 1318   Accepted: 703

Description

Background Manhattan in the year 2025 - it is so densely populated that its old two-dimensional grid of streets and avenues fails to provide enough space for all the traditional vehicles such as cars, bicycles, or busses.Accordingly, the newly developed 3D-Skyjetters become very popular, because they allow to pass the traffic jams on the ground by flying in the air. After a series of horrible accidents caused by 3D-Skyjetters cutting a corner, New York authorities have put into place new regulations of air traffic and are determined to enforce them rigorously. The key point of these regulations is that 3D-Skyjetters must follow virtual airways on a three-dimensional rectangular grid, easy enough for the New Yorkers who had to use the two-dimensional rectangular grid of roads on the ground all their life. Problem You own a company that rents out 3D-Skyjetters. As 3D-Skyjetters are in such an early state of development,they are far from being economical. So your customers keep running out of petrol at all the wrong places,and you need a system to inform them about their current range at all times. You may assume that travelling from one intersection to the next in the grid takes one unit of petrol, no matter if the customer is moving horizontally or vertically, up or down. You may also assume that your customer is located at some intersection where his or her movements are not restricted by the ground or other obstacles, but just by the amount of remaining petrol. Given the amount of petrol, provide a graphical representation of all the intersections in the range of your customer, along with the amount of petrol that is needed to go there.

Input

The first line of the input contains the number of scenarios. For each scenario, there is a line containing the units of remaining petrol, i.e an integer u satisfying 0 <= u <= 9. If more than 9 units of petrol remain, the customer will ignore the display anyway.

Output

Start the output for each scenario with a line containing "Scenario #i:", where i is the number of the scenario starting at 1. Then print a graphical (or rather textual) representation of all intersections that can be reached with the given amount of petrol, along with the units of petrol necessary to go there. In this graphical representation, print the slices of the smallest axis-aligned three-dimensional cube containing all the intersections in the range, and label the slices from the bottom to the top starting at 1. For each slice,start the output with a line containing "slice #s:", where s is the number of the slice. In the lines that follow, print a graphical representation of all the intersections in that slice, using

  • the digits 0 to 9 for intersections in the range, representing the amount of petrol necessary to go there,
  • and the dot "." for intersections not in the range.

Print an additional blank line after each scenario.

Sample Input

2
0
2

Sample Output

Scenario #1:
slice #1:
0 Scenario #2:
slice #1:
.....
.....
..2..
.....
.....
slice #2:
.....
..2..
.212.
..2..
.....
slice #3:
..2..
.212.
21012
.212.
..2..
slice #4:
.....
..2..
.212...2.. ..... slice #5: ..... ..... ..2.. ..... .....

Source

TUD Programming Contest 2003, Darmstadt, Germany
#include <stdio.h>
#include <string.h>
#include <stdlib.h> int Scenario,Oil,Slice,M[][];
void Display()
{
int i,j;
for (i=;i<Slice;i++)
{
for (j=;j<Slice;j++)
{
if (M[i][j]<=Oil)
printf("%d",M[i][j]);
else
printf(".");
}
printf("\n");
}
}
void left_up(int x,int y,int m,int t)
{
if (m==Oil+)
return;
M[x][y]=m;
left_up(x-,y,m+t,t);
left_up(x,y-,m+t,t); }
void up_right(int x,int y,int m,int t)
{
if (m==Oil+)
return;
M[x][y]=m;
up_right(x+,y,m+t,t);
up_right(x,y-,m+t,t);
}
void right_down(int x,int y,int m,int t)
{
if (m==Oil+)
return;
M[x][y]=m;
right_down(x+,y,m+t,t);
right_down(x,y+,m+t,t); }
void down_left(int x,int y,int m,int t)
{
if (m==Oil+)
return;
M[x][y]=m;
down_left(x,y+,m+t,t);
down_left(x-,y,m+t,t);
}
void func(int x,int y,int m,int t)
{
left_up(x,y,m,t);
up_right(x,y,m,t);
right_down(x,y,m,t);
down_left(x,y,m,t);
}
int main()
{
int i,j,x,y;
scanf("%d",&Scenario);
for(i=;i<=Scenario;i++)
{
scanf("%d",&Oil);
printf("Scenario #%d:\n",i);
if (Oil==)
{
printf("slice #1:\n0\n");
}
else
{
Slice=*Oil+;
for (j=;j<Slice;j++)
{
memset(M,,sizeof(M));
x=Oil;
y=Oil;
printf("slice #%d:\n",j+);
if (j<=Oil)
func(x,y,Oil-j,);
else
func(x,y,j-Oil,);
Display();
}
}
printf("\n");
}
return ;
}

注意方位的把握~~~

poj 1806 分块模拟的更多相关文章

  1. P1972 [SDOI2009]HH的项链[离线+树状数组/主席树/分块/模拟]

    题目背景 无 题目描述 HH 有一串由各种漂亮的贝壳组成的项链.HH 相信不同的贝壳会带来好运,所以每次散步完后,他都会随意取出一段贝壳,思考它们所表达的含义.HH 不断地收集新的贝壳,因此,他的项链 ...

  2. poj 3077Rounders(模拟)

    转载请注明出处:viewmode=contents">http://blog.csdn.net/u012860063? viewmode=contents 题目链接:http://po ...

  3. POJ 1068 Parencodings 模拟 难度:0

    http://poj.org/problem?id=1068 #include<cstdio> #include <cstring> using namespace std; ...

  4. POJ 1036 Rails 模拟堆栈

    水题,主要是思路清晰,判断明确. 记x为A站最前方的车,y表示下一列要进入B站的车厢,初识时,x=1;y=a1;C=[]; 在调度过程中: if(y==0)那么调度成功,退出模拟过程:否则 if(x= ...

  5. POJ 1001 Exponentiation 模拟小数幂

    模拟小数幂 小数点位 pos 非零末位 e 长度 len 只有三种情况 pos > len pos < e e < pos < len #include <iostrea ...

  6. A Simple Problem with Integers POJ - 3468 (分块)

    题目链接:https://cn.vjudge.net/problem/POJ-3468 题目大意:区间加减+区间查询操作. 具体思路:本来是一个线段树裸题,为了学习分块就按照分块的方法做吧. 分块真的 ...

  7. POJ 1008 简单模拟题

    e.... 虽然这是一道灰常简单的模拟题.但是米做的时候没有读懂第二个日历的计时方法.然后捏.敲完之后华丽的WA了进一个点.坑点就在一年的最后一天你是该输出本年的.e ...但是我好想并没有..看di ...

  8. poj 1806 Frequent values(RMQ 统计次数) 详细讲解

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1806 题目大意:给你一个非降序排列的整数数组,你的任务是对于一系列的询问,(i,j),回答序列中出现次 ...

  9. Crashing Robots POJ 2632 简单模拟

    Description In a modernized warehouse, robots are used to fetch the goods. Careful planning is neede ...

随机推荐

  1. Mysql:Forcing close of thread xxx user: 'root' 的解决方法

    MySQL server在中午的时候忽然挂掉.重启mysql也尽是失败,只有重启电脑才能解决,然而重装了MySQL也是不行,晚上还是挂, 去看mysql的errorlog,只能看到类似如下的信息: F ...

  2. Java监控工具介绍,VisualVm ,JProfiler,Perfino,Yourkit,Perf4J,JProbe,Java微基准测试

    本文是本人前一段时间做一个简单Java监控工具调研总结,主要包括VisualVm ,JProfiler,Perfino,Yourkit,Perf4J,JProbe,以及对Java微基准测试的简单介绍, ...

  3. 半小时快速了解redis,基于ubuntu 12.04 + redis 2.8.9

    一.什么是redis ? 其官方介绍是: Redis is what is called a key-value store, often referred to as a NoSQL databas ...

  4. python学习之——eclipse+pydev 环境搭建

    最终选用 eclipse+pydev,网上相关资料也是极多的~~~ 1.安装python: 2.安装eclipse: 3.eclipse中安装pydev,eclipse中help—>eclipl ...

  5. javascript json转为 go struct 小工具代码

    /** * Created by cdpmac on 15/10/20. */ var topname="Ap"; var jdata={ "item": { ...

  6. 在本地创建angular-ui/bootstrap项目

    在本地创建完整的angular-ui/Bootstrap项目 git clone the repo, then switch to the tag you want,then use grunt bu ...

  7. My安卓知识3--多个activity之前共享数据的方法

    在网上搜这个问题的时候看到了有一篇文章说有五种方法: 1.基于消息的通信机制  Intent ---boudle ,extra 数据类型有限,比如遇到不可序列化的数据Bitmap,InputStrea ...

  8. iOS随机页面NSClassFromString

      NSString *className = self.classNameArray[randomNumber]; Class viewClass = NSClassFromString(class ...

  9. linux修改主机名称

    http://blog.csdn.net/qq_20480611/article/details/51017033 ========================================== ...

  10. angular js 自定义js错误处理(Angularjs js error handler)

    使用AngularJS的时候,对JS错误如何自定义处理?(比如用Google Analytics记录angularjs使用中出现的js错误) AngularJS自带一个错误处理service:$exc ...