2014牡丹江网络预选赛B题(找规律)zoj3810

A Volcanic Island


Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge



An underwater volcano has erupted massively in somewhere of the deep Atlantis Ocean. This large eruption led to the birth of a new volcanic island, which had a shape of square. Near the
island, there are N countries. All of them have claimed the sovereignty over the island.

After a lot of multilateral negotiation and occasional armed conflicts, the N countries decided to divide the square volcanic island equally. They partitioned the island into N x N small
equal-sized square chunks. Each country could get a connected region consists of exact N chunks.

Two chunks A and B are called "connected" if they share an edge, or there exists another chunk C connected with both A and B. A group of chunks are called "connected region" if any two
of these chunks are connected.

Every country want a unique region. It means the N regions should be different with each other. Two regions are considered as the same if and only if one can transform into
the other by an isometry (a combination of rigid motions, including translation, rotation and reflection).

In a nutshell, your task is to divide a square island with N x N chunks into N connected regions with different shape. You also need to draw a map to
color the regions of the map so that no two edge-adjacent regions have the same color. Most of the people in these countries believed that four different colors are enough. So you can mark these regions with at most four colors, red, green, blue and yellow.

Input

There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:

There is only an integer N (1 <= N <= 100).

Output

For each test case, output a valid map described above. If there is no solution, output "No solution!" instead. Please note that only four colors (‘R‘, ‘G‘, ‘B‘ and ‘Y‘) can be used to
drawing the map.

Sample Input

2
2
5

Sample Output

No solution!
YYYGR
YGGGR
YGYYR
BYYYR
BBBBR

题意:在n*n的地图上用四种颜色划分出n个不同形状的连通块,如果可行输出任意可行的方案

思路 :           如图所示,不同颜色表示不同的块,8*8为例

n=1,直接输出任意颜色

1<n<=4,无解

n=6,特殊判断

n等于其它,规律如上8*8的地图

时间: 2024-10-10 13:03:42

2014牡丹江网络预选赛B题(找规律)zoj3810的相关文章

2014牡丹江网络预选赛D题(状压DP)zoj3812

We Need Medicine Time Limit: 10 Seconds      Memory Limit: 65536 KB      Special Judge A terrible disease broke out! The disease was caused by a new type of virus, which will lead to lethal lymphoedema symptom. For convenience, it was named LL virus.

2014牡丹江网络预选赛E题(线段树)zoj3813

Alternating Sum Time Limit: 2 Seconds      Memory Limit: 65536 KB There is a digit string S with infinite length. In addition, S is periodic and it can be formed by concatenating infinite repetitions of a base string P. For example, if P = 3423537, t

2014牡丹江网络预选赛F题(隐式图BFS暴搜)zoj3814

Sawtooth Puzzle Time Limit: 10 Seconds      Memory Limit: 65536 KB Recently, you found an interesting game called Sawtooth Puzzle. This is a single-player game played on a grid with 3 x 3 cells. Each cell contains a part of an image. Besides, each ed

2014牡丹江网络预选赛I题(字符串hash+简单DP)zoj3817

Chinese Knot Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge Chinese knot is a decorative handicraft that began as a form of Chinese folk artifact in the Tang and Song Dynasty in China. It was later popularized in the Ming. Alice

ZOJ-3811 Untrusted Patrol DFS 2014牡丹江网络赛C题

n个点,m条双向边,k个传感器.其中有l个传感器记录到了第一次到达的时间顺序,求是否有可能检查了所有的顶点. 首先判断l,l<k一定是不行的.然后按照传感器的时间顺序dfs,先从第一个传感器位置搜索dfs搜到所有的到达传感器的位置结束,如果这个传感器被标记为可访问,则从这个传感器继续搜索下一层传感器,否则是不能满足时间顺序的.最后还要判断整个图的连通性,所有的顶点都要可以到达的. #include <iostream> #include <cstdio> #include &

HDU 5703 Desert 水题 找规律

已知有n个单位的水,问有几种方式把这些水喝完,每天至少喝1个单位的水,而且每天喝的水的单位为整数.看上去挺复杂要跑循环,但其实上,列举几种情况之后就会发现是找规律的题了= =都是2的n-1次方,而且这题输出二进制数就行了......那就更简单了,直接输出1,然后后面跟n-1个0就行了╮(╯_╰)╭ 下面AC代码 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm>

HDU 1337 The Drunk Jailer--(模拟题找规律)

题意:有n个监狱,共n轮,第 i 轮警察会去编号为 i 的倍数的监狱,如果是锁的就开锁,如果是开的就锁上,求n轮过后有多少犯人会逃出来 分析:这题实际上是个模拟题,因为数据很小我直接用两重循环模拟的,如果数据很大的话,就不能直接模拟了,模拟题卡时间多半是找规律. 这题的规律是:如果一个监狱被查看了偶数次的话相当于则什么都没发生,还是锁的,也就是说找没有锁上的监狱只要n以内找因数为奇数个的数有多少个即可 代码: #include<iostream> using namespace std; in

2014鞍山网络预选赛1006(LCT模板题)hdu5002

Tree Time Limit: 16000/8000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 41    Accepted Submission(s): 10 Problem Description You are given a tree with N nodes which are numbered by integers 1..N. Each node is as

2014牡丹江网络赛解题报告

The 2014 ACM-ICPC Asia Mudanjiang Regional First Round 题目链接 A题解题报告 B题解题报告 C题解题报告 D题解题报告 E题解题报告 F题解题报告 G题(未完成) H题解题报告 I题解题报告 J题解题报告