CF2201G.Codeforces Heuristic Contest 1001

NOI/NOI+/CTSC

通过率:0%

时间限制:9.00s

内存限制:1001MB

AC君温馨提醒

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

题目描述

There is a graph of n2n^2 vertices, where vertices are labeled by integer pairs (r,c)(r,c) such that 1≤r,c≤n1 \le r,c \le n. Vertices (r1,c1)(r_1,c_1) and (r2,c2)(r_2,c_2) are directly connected if and only if (r1−r2)2+(c1−c2)2=13(r_1-r_2)^2+(c_1-c_2)^2=\color{red}{13}. This graph is called the Zebra Graph of dimensions n×nn \times n.

Please find a subset of vertices SS in the Zebra Graph of dimensions n×nn \times n, which satisfies the following condition.

  • The graph induced∗^{\text{∗}} by the subset SS is isomorphic to a cycle graph of at least ⌊n2e⌋\left\lfloor{\frac{n^2}{e}}\right\rfloor vertices†^{\text{†}}.

It can be shown that such a subset of vertices exists under the constraints of this problem.

∗^{\text{∗}}The induced graph of a subset of vertices XX is a graph that contains all vertices in XX and all edges whose both endpoints are in XX.

†^{\text{†}}Here, ee is the mathematical constant equal to the limit lim⁡n→∞(1+1n)n≈2.71828182\lim \limits_{n \to \infty} \left ({1 + \frac{1}{n}} \right )^n \approx 2.71828182. Note that the value of 1e\frac{1}{e} is approximately 0.367879440.36787944.

存在一个包含 n2n^2 个顶点的图,其顶点用整数对 (r,c)(r,c) 标记,其中 1≤r,c≤n1 \le r,c \le n。当且仅当 (r1−r2)2+(c1−c2)2=13(r_1-r_2)^2+(c_1-c_2)^2=\color{red}{13} 时,顶点 (r1,c1)(r_1,c_1) 与 (r2,c2)(r_2,c_2) 直接相连。该图称为 n×nn \times n 维的“斑马图”(Zebra Graph)。

请在 n×nn \times n 维斑马图中找出一个顶点子集 SS,使其满足如下条件:

  • 由子集 SS 所导出的子图∗^{\text{∗}} 同构于一个至少包含 ⌊n2e⌋\left\lfloor{\frac{n^2}{e}}\right\rfloor 个顶点的环图(cycle graph)†^{\text{†}}。

可以证明,在本题的约束条件下,这样的顶点子集 SS 必然存在。

∗^{\text{∗}} 顶点子集 XX 的导出子图是指:包含 XX 中所有顶点,并且包含所有两个端点均属于 XX 的边所构成的图。

†^{\text{†}} 此处 ee 是数学常数,定义为极限 lim⁡n→∞(1+1n)n≈2.71828182\lim \limits_{n \to \infty} \left ({1 + \frac{1}{n}} \right )^n \approx 2.71828182。注意,1e\frac{1}{e} 的值约为 0.367879440.36787944。

输入格式

The first and only line of input contains a single integer nn (n∈5,1001n\in {5,1001}).

There are only two input files for this problem:

  • The first input file (the example input) has n=5n=5;
  • The second input file has n=1001n=1001.

Hacks are disabled for this problem.

输入仅有一行,包含一个整数 nn(n∈{5,1001}n\in \{5,1001\})。

本题仅有两个输入文件:

  • 第一个输入文件(样例输入)中 n=5n=5;
  • 第二个输入文件中 n=1001n=1001。

本题禁用 Hack 功能。

输出格式

Output nn lines, each containing a string sis_i of length nn denoting the ii-th row of the graph. If the vertex (r,c)(r,c) is an element of SS, then the cc-th letter of srs_r should be '1'. Otherwise, the cc-th letter of srs_r should be '0'.

If there are multiple solutions, print any of them.

输出 nn 行,每行包含一个长度为 nn 的字符串 sis_i,表示图的第 ii 行。若顶点 (r,c)(r,c) 属于集合 SS,则 srs_r 的第 cc 个字符应为 '1';否则,srs_r 的第 cc 个字符应为 '0'。

若存在多个解,输出任意一个即可。

输入输出样例

  • 输入#1

    5

    输出#1

    01110
    11011
    10001
    11011
    01110

说明/提示

For the example output, the induced graph corresponding to the subset SS is shown below.

This graph is isomorphic to the cycle graph C16C_{16} consisting of 1616 vertices. As 16≥⌊n2e⌋=916 \ge \left\lfloor{\frac{n^2}{e}}\right\rfloor = 9, the output satisfies the problem's condition.

对于示例输出,子集 SS 对应的导出子图如下所示。

该图同构于由 1616 个顶点构成的环图 C16C_{16}。由于 16≥⌊n2e⌋=916 \ge \left\lfloor{\frac{n^2}{e}}\right\rfloor = 9,因此该输出满足题目的条件。

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

首页