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. C#实现简单的委托异步调用

    delegate void textAsy(); static void Main(string[] args) { textAsy t = texts; AsyncCallback callBack ...

  2. git 查看远程分支、本地分支、创建分支、把分支推到远程repository、删除本地分支

    1 查看远程分支 $ git branch -a * br-2.1.2.2 master remotes/origin/HEAD -> origin/master remotes/origin/ ...

  3. [ubuntu] adb devices出现no permissions

    简书排版 http://www.jianshu.com/p/46e8848c6646 今天把一款测试的华为手机带回家,发现无法联机调试 笔者操作系统是 ubuntu 14.04 如果是windows找 ...

  4. ExtJs知识点概述

    1.前言 ExtJS的前身是YUI(Yahoo User Interface).经过不断的发展与改进,ExtJS现在已经成功发布到了ExtJS 6版本,是一套目前最完整和最成熟的javascript基 ...

  5. eclipse中安装adt插件

    对于程序开发的学者来说,eclipse并不陌生,它为我们提供了一个非常广阔的平台来开发程序.同样我们也可以用它来开发android程序.但是在eclipse中并不能直接开发android程序,需要我们 ...

  6. 如何优化sql语句

    1. 首先要搞明白什么叫执行计划? 执行计划是数据库根据SQL语句和相关表的统计信息作出的一个查询方案,这个方案是由查询优化器自动分析产生的,比如一条SQL语句如果用来从一个 10万条记录的表中查1条 ...

  7. jQuery动画特效笔记

    show().hide().fadeIn().fadeOut().slideDown.slideUp.slideToggle()都接受可选的时长和回调参数(选项对象参数). toggle(durati ...

  8. 利用带关联子查询Update语句更新数据

    Update是T-sql中再简单不过的语句了,update table set column=expression  [where condition],我们都会用到.但update的用法不仅于此,真 ...

  9. 【转】webGL与OpenGL的不同

    原链接 http://www.khronos.org/webgl/wiki/WebGL_and_OpenGL_Differences WebGL and OpenGL Differences     ...

  10. 1996: [Hnoi2010]chorus 合唱队

    链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1996 Description Input Output Sample Input 4 1701 ...