CF85A.Domino

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

We all know the problem about the number of ways one can tile a 2 × n field by 1 × 2 dominoes. You probably remember that it goes down to Fibonacci numbers. We will talk about some other problem below, there you also are going to deal with tiling a rectangular field with dominoes.

You are given a 4 × n rectangular field, that is the field that contains four lines and n columns. You have to find for it any tiling by 1 × 2 dominoes such that each of the n - 1 potential vertical cuts along the grid lines intersects at least one domino, splitting it in two. No two dominoes in the sought tiling should overlap, each square of the field should be covered by exactly one domino. It is allowed to rotate the dominoes, that is, you can use 2 × 1 as well as 1 × 2 dominoes.

Write a program that finds an arbitrary sought tiling.

我们都知道用 1×21 \times 2 多米诺骨牌铺满 2×n2 \times n 矩形区域的方案数问题。你可能还记得,该问题最终归结为斐波那契数列。下面我们将讨论另一个类似的问题:同样涉及用多米诺骨牌铺满矩形区域。

现给定一个 4×n4 \times n 的矩形区域,即包含四行 nn 列的网格。你需要找出一种用 1×21 \times 2 多米诺骨牌对该区域的铺法,使得所有 n−1n-1 条可能的纵向切割线(沿网格线、位于相邻两列之间)中,每一条都至少穿过一个骨牌,从而将该骨牌一分为二。所求铺法中任意两个骨牌不得重叠,且区域中的每个方格必须恰好被一个骨牌覆盖。允许旋转骨牌,即既可使用 1×21 \times 2 骨牌,也可使用 2×12 \times 1 骨牌。

请编写一个程序,输出任意一种满足上述要求的铺法。

输入格式

The input contains one positive integer n (1 ≤ n ≤ 100) — the number of the field's columns.

输入包含一个正整数 nn(1≤n≤1001 \leq n \leq 100)—— 表示场地的列数。

输出格式

If there's no solution, print "-1" (without the quotes). Otherwise, print four lines containing n characters each — that's the description of tiling, where each vertical cut intersects at least one domino. You should print the tiling, having painted the field in no more than 26 colors. Each domino should be painted a color. Different dominoes can be painted the same color, but dominoes of the same color should not be side-neighbouring. To indicate colors you should use lowercase Latin letters. Print any of the acceptable ways of tiling.

如果无解,请输出 -1(不带引号)。否则,输出四行,每行包含 n 个字符——即所求的铺砖方案,其中每条竖直切割线至少与一个骨牌相交。你需要用不超过 26 种颜色对整个区域进行着色。每个骨牌应被染成一种颜色。不同骨牌可以染成相同颜色,但同色骨牌不能相邻(共享一条边)。颜色需用小写拉丁字母表示。请输出任意一种满足条件的铺砖方案。

输入输出样例

  • 输入#1

    4

    输出#1

    yyzz
    bccd
    bxxd
    yyaa

输入解题思路,AI测评打分。不知道怎么写?

首页