uva 1605 building for UN ——yhx
The United Nations has decided to build a new headquarters in Saint Petersburg, Russia. It will have a
form of a rectangular parallelepiped and will consist of several rectangular
oors, one on top of another.
Each
oor is a rectangular grid of the same dimensions, each cell of this grid is an office.
Two offices are considered adjacent if they are located on the same
oor and share a common wall,
or if one's
oor is the other's ceiling.
The St. Petersburg building will host n national missions. Each country gets several offices that
form a connected set.
Moreover, modern political situation shows that countries might want to form secret coalitions. For
that to be possible, each pair of countries must have at least one pair of adjacent offices, so that they
can raise the wall or the ceiling they share to perform secret pair-wise negotiations just in case they
need to.
You are hired to design an appropriate building for the UN.
Input
Input consists of several datasets. Each of them has a single integer number n (1 n 50) | the
number of countries that are hosted in the building.
Output
On the rst line of the output for each dataset write three integer numbers h, w, and l | height, width
and length of the building respectively.
h descriptions of
oors should follow. Each
oor description consists of l lines with w characters on
each line. Separate descriptions of adjacent
oors with an empty line.
Use capital and small Latin letters to denote offices of different countries. There should be at most
1 000 000 offices in the building. Each office should be occupied by a country. There should be exactly
n different countries in the building. In this problem the required building design always exists.
Print a blank line between test cases.
#include<cstdio>
#include<cstring>
char turn(int x)
{
if (x<=) return x+'a'-;
return x-+'A';
}
int main()
{
int i,j,k,m,n,p,q,x,y,z,l,h;
char c;
bool b=;
while (scanf("%d",&n)==)
{
if (b==) b=;
else printf("\n");
printf("2 %d %d\n",n,n);
for (i=;i<=n;i++)
{
for (j=;j<=n;j++)
printf("%c",turn(i));
printf("\n");
}
printf("\n");
for (i=;i<=n;i++)
{
for (j=;j<=n;j++)
printf("%c",turn(j));
printf("\n");
}
}
}
和http://www.cnblogs.com/AwesomeOrion/p/5380752.html这道题一样,只是让你找到一组解。那我只要存心构造万能解即可。
我的方法是:建两层,每一层n*n,第一层横着按顺序排列1..n,第二层竖着按顺序排列1..n,这样每两个国家都会交叉。
uva 1605 building for UN ——yhx的更多相关文章
- UVA 1605 Building for UN
题意: 有n个国家,要求你设计一栋楼并为这n个国家划分房间,要求国家的房间必须连通,且每两个国家之间必须有一间房间是相邻的 分析: 其实非常简单,完全被样例误导了.只需要设计两层就可以了,每个国家占第 ...
- UVA 1605 Building for UN(思维)
题目链接: https://cn.vjudge.net/problem/UVA-1605#author=0 /* 问题 设计一个包含若干层的联合国大厦,其中每一层都是等大的网格,每个格子分配给一个国家 ...
- Uva 1605 Building for UN【构造法】
题意:给出n个国家,给它们分配办公室,使得任意两个国家都有一对相邻的格子 看的紫书,最开始看的时候不理解 后来还是搜了题解--- 发现是这样的 比如说5个国家 应该输出 AAAA BBBB CCCC ...
- UVA - 1605 Building for UN (联合国大楼)
题意:一个联合国大楼每层都有数量相等大小相同的格子,将其分配给n个国家,使任意两个不同的国家都相邻(同层有公共边或相邻层的同一个格子). 分析:可以设计一个只有两层的大楼,第一层每个国家占一行,第二层 ...
- 贪心水题。UVA 11636 Hello World,LA 3602 DNA Consensus String,UVA 10970 Big Chocolate,UVA 10340 All in All,UVA 11039 Building Designing
UVA 11636 Hello World 二的幂答案就是二进制长度减1,不是二的幂答案就是是二进制长度. #include<cstdio> int main() { ; ){ ; ) r ...
- UVa 1605 (构造) Building for UN
题意: 有n个国家,要设计一栋长方体的大楼,使得每个单位方格都属于其中一个国家,而且每个国家都要和其他国家相邻. 分析: 紫书上有一种很巧妙的构造方法: 一共有2层,每层n×n.一层是每行一个国家,另 ...
- UVa 11039 - Building designing 贪心,水题 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- UVA 11039 Building designing 贪心
题目链接:UVA - 11039 题意描述:建筑师设计房子有两条要求:第一,每一层楼的大小一定比此层楼以上的房子尺寸要大:第二,用蓝色和红色为建筑染色,每相邻的两层楼不能染同一种颜色.现在给出楼层数量 ...
- UVA 11039 - Building designing(DP)
题目链接 本质上是DP,但是俩变量就搞定了. #include <cstdio> #include <cstring> #include <algorithm> u ...
随机推荐
- ahjesus解决win下U盘无法写入的问题
可能是由于不同品牌的U盘出厂时磁盘分区和格式化方式不同而引起的兼容性问题.解决方案如下 启动cmd.输入diskpart,启动DISKPART工具 在DISKPART窗口中输入以下命令: >li ...
- ASP.NET Core1.0 带来的新特性
1.采用新的文件系统,不再通过工程文件(.sln和.csproj)来定义项目文件清单. 解决方案文件还是*.sln,但项目文件变成*.xproj了.在项目文件夹下新增的文件会被自动添加到项目中,不用再 ...
- Office 365 - Windows PowerShell for SharePoint Online
Office 365 PowerShell for SharePoint Online 1. Get-SPOTenantLogEntry 并不能获取所有的Log信息,只能用于获取因外部资源而出错的lo ...
- iOS多线程技术
iOS多线程技术主要分配NSThread.NSOperation和GCD.下边来简单的介绍一下吧. 随性一点,就不按照顺序来了.所以先介绍一下NSOperation. ---------------- ...
- IOS 欢迎页(UIScrollView,UIPageControl)
本文介绍了app欢迎页的简单实现.只有第一次运行程序时才说会出现,其余时间不会出现.下面是效果图. 代码如下:(如有不明白的可以评论我,我会详细讲解) // // ViewController.m / ...
- iOS 核心动画
核心动画(Core Animation) : •CoreAnimation是一组非常强大的动画处理API,使用它能做出非常炫丽的动画效果,而且往往是事半功倍,使用它需要先添加QuartzCore.fr ...
- IOS设计模式-抽象工厂
抽象工厂的灵活性要比简单工程的灵活性强. 抽象工厂的UML图(第一次画UML图,可能关系和箭头的图意义有错误,但是请不要以建模规范去看图,以最基本的结合后面OC代码,理解相关关系): 抽象工厂原理:抽 ...
- Office 2013 激活工具
早上装机,顺便装了下Office 2013,界面还是不错的.网上找了下相关的激活工具. 发现还是独木成林做的最好呀,直接把别人的链接给拿过来好了,下载地址 http://pan.baidu.com/s ...
- 阿里云ECS服务器(ubuntu)下基本配置以及升级git
最近需要在阿里云服务器上远程搭建调试环境,这里把遇到的问题做一下记录: 1.ECS Linux解决SSH会话连接超时问题 用SSH客户端(我使用的Xshell)连接linux服务器时,经常会出现与服务 ...
- Html5如何使我们开发出来的应用或页面大小能适合各种高端手机使用
本文简介:1.手机移动端页面的自适应2.手机触摸手动滑动效果 一.header信息的设置(自适应) 1.声明信息 <!DOCTYPE HTML> 2.编码设置 <meta chars ...