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的更多相关文章

  1. UVA 1605 Building for UN

    题意: 有n个国家,要求你设计一栋楼并为这n个国家划分房间,要求国家的房间必须连通,且每两个国家之间必须有一间房间是相邻的 分析: 其实非常简单,完全被样例误导了.只需要设计两层就可以了,每个国家占第 ...

  2. UVA 1605 Building for UN(思维)

    题目链接: https://cn.vjudge.net/problem/UVA-1605#author=0 /* 问题 设计一个包含若干层的联合国大厦,其中每一层都是等大的网格,每个格子分配给一个国家 ...

  3. Uva 1605 Building for UN【构造法】

    题意:给出n个国家,给它们分配办公室,使得任意两个国家都有一对相邻的格子 看的紫书,最开始看的时候不理解 后来还是搜了题解--- 发现是这样的 比如说5个国家 应该输出 AAAA BBBB CCCC ...

  4. UVA - 1605 Building for UN (联合国大楼)

    题意:一个联合国大楼每层都有数量相等大小相同的格子,将其分配给n个国家,使任意两个不同的国家都相邻(同层有公共边或相邻层的同一个格子). 分析:可以设计一个只有两层的大楼,第一层每个国家占一行,第二层 ...

  5. 贪心水题。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 ...

  6. UVa 1605 (构造) Building for UN

    题意: 有n个国家,要设计一栋长方体的大楼,使得每个单位方格都属于其中一个国家,而且每个国家都要和其他国家相邻. 分析: 紫书上有一种很巧妙的构造方法: 一共有2层,每层n×n.一层是每行一个国家,另 ...

  7. UVa 11039 - Building designing 贪心,水题 难度: 0

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  8. UVA 11039 Building designing 贪心

    题目链接:UVA - 11039 题意描述:建筑师设计房子有两条要求:第一,每一层楼的大小一定比此层楼以上的房子尺寸要大:第二,用蓝色和红色为建筑染色,每相邻的两层楼不能染同一种颜色.现在给出楼层数量 ...

  9. UVA 11039 - Building designing(DP)

    题目链接 本质上是DP,但是俩变量就搞定了. #include <cstdio> #include <cstring> #include <algorithm> u ...

随机推荐

  1. alter语法的简单的使用

    用alter语法来新增列名,修改列名,删除列

  2. mysql 5.7.15发布

    2016-09-06,mysql发布了5.7更新5.7.15,修复的bug数项目之前的版本已经大大减少,说明越来越稳定了.估计再过三四个版本,就会有很多公司开始考虑生产中使用了.

  3. 切换到percona server各种问题

    这两天把七八台服务器全部切换到了percona server,相关注意事项如下: 1.JDBC报ERROR 1862 (HY000): Your password has expired. To lo ...

  4. 在ALV中更新数据库表

    FORM usercommand USING ucomm TYPE sy-ucomm selfield TYPE slis_selfield. DATA: lr_grid TYPE REF TO cl ...

  5. virtualbox虚拟机迁移出现"connot find device eth0"错误

    我在自己的机器上面配置virtualbox虚拟机完毕以后,移植到另外一台机器上面,登陆页面总是在检查network,并且最后网络加载失败,不论我是用桥接还是NAT方式连接.登陆系统以后,我尝试连接网络 ...

  6. 安卓开发_慕课网_ViewPager与FragmentPagerAdapter实现Tab实现Tab(App主界面)

    学习内容来自“慕课网” ViewPager与FragmentPagerAdapter实现Tab 将这两种实现Tab的方法结合起来.效果就是可以拖动内容区域来改变相应的功能图标亮暗 思路: Fragme ...

  7. Android Plugin

    工欲善其事,必先利其器.以下介绍一些常用的Android Plugin,有助于开发. 1.adb-idea 支持在AS面板中,执行ADB命令.不过如果用惯命令行的话,可以不安装: 2.android- ...

  8. iOS加载程序视图的方式

    The UIViewController class provides built-in support for loading a view controller's views whenever ...

  9. 【原】iOSCoreAnimation动画系列教程(二):CAKeyFrameAnimation【包会】

    在上一篇专题文章[原]iOSCoreAnimation动画系列教程(一):CABasicAnimation[包会]中我们学习了iOS核心动画CoreAnimation中CABasicAnimation ...

  10. windows下vagrant使用及工作环境配置

    环境搭建记录(2014-08-01) 操作系统: Win7旗舰版 Vagrant版本: 1.6 搭建过程 安装vagrant 右键打开安装包按照提示安装即可 安装后会自动把vagrant添加到环境变量 ...