CF1227G.Not Same

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given an integer array a1,a2,…,ana_1, a_2, \dots, a_n, where aia_i represents the number of blocks at the ii-th position. It is guaranteed that 1≤ai≤n1 \le a_i \le n.

In one operation you can choose a subset of indices of the given array and remove one block in each of these indices. You can't remove a block from a position without blocks.

All subsets that you choose should be different (unique).

You need to remove all blocks in the array using at most n+1n+1 operations. It can be proved that the answer always exists.

给你一个整数数组 a1,a2,…,ana_1, a_2, \dots, a_n,其中 aia_i 表示第 ii 个位置上的方块数量。保证 1≤ai≤n1 \le a_i \le n。

在一次操作中,你可以选择该数组的一个下标子集,并在这些下标对应的位置上各移除一个方块。你不能从没有方块的位置移除方块。

你所选择的所有子集必须互不相同(即唯一)。

你需要在至多 n+1n+1 次操作内移除数组中的所有方块。可以证明,答案总是存在的。

输入格式

The first line contains a single integer nn (1≤n≤1031 \le n \le 10^3) — length of the given array.

The second line contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n (1≤ai≤n1 \le a_i \le n) — numbers of blocks at positions 1,2,…,n1, 2, \dots, n.

第一行包含一个整数 nn(1≤n≤1031 \le n \le 10^3)—— 给定数组的长度。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \dots, a_n(1≤ai≤n1 \le a_i \le n)—— 位置 1,2,…,n1, 2, \dots, n 上方块的编号。

输出格式

In the first line print an integer opop (0≤op≤n+10 \le op \le n+1).

In each of the following opop lines, print a binary string ss of length nn. If si=s_i='0', it means that the position ii is not in the chosen subset. Otherwise, sis_i should be equal to '1' and the position ii is in the chosen subset.

All binary strings should be distinct (unique) and aia_i should be equal to the sum of sis_i among all chosen binary strings.

If there are multiple possible answers, you can print any.

It can be proved that an answer always exists.

第一行输出一个整数 opop(0≤op≤n+10 \le op \le n+1)。

接下来的 opop 行中,每行输出一个长度为 nn 的二进制字符串 ss。若 si=s_i='0',表示位置 ii 不在所选子集中;否则 sis_i 应为 '1',表示位置 ii 在所选子集中。

所有二进制字符串必须互不相同(唯一),且对每个 ii,aia_i 应等于所有所选二进制字符串中第 ii 位上 '1' 的个数之和。

若存在多种可能的答案,输出任意一种即可。

可以证明答案一定存在。

输入输出样例

  • 输入#1

    5
    5 5 5 5 5

    输出#1

    6
    11111
    01111
    10111
    11011
    11101
    11110
  • 输入#2

    5
    5 1 1 1 1

    输出#2

    5
    11000
    10000
    10100
    10010
    10001
  • 输入#3

    5
    4 1 5 3 4

    输出#3

    5
    11111
    10111
    10101
    00111
    10100

说明/提示

In the first example, the number of blocks decrease like that:

{5,5,5,5,5}→{4,4,4,4,4}→{4,3,3,3,3}→{3,3,2,2,2}→{2,2,2,1,1}→{1,1,1,1,0}→{0,0,0,0,0}\lbrace 5,5,5,5,5 \rbrace \to \lbrace 4,4,4,4,4 \rbrace \to \lbrace 4,3,3,3,3 \rbrace \to \lbrace 3,3,2,2,2 \rbrace \to \lbrace 2,2,2,1,1 \rbrace \to \lbrace 1,1,1,1,0 \rbrace \to \lbrace 0,0,0,0,0 \rbrace. And we can note that each operation differs from others.

在第一个例子中,方块数量的变化过程如下:

{5,5,5,5,5}→{4,4,4,4,4}→{4,3,3,3,3}→{3,3,2,2,2}→{2,2,2,1,1}→{1,1,1,1,0}→{0,0,0,0,0}\lbrace 5,5,5,5,5 \rbrace \to \lbrace 4,4,4,4,4 \rbrace \to \lbrace 4,3,3,3,3 \rbrace \to \lbrace 3,3,2,2,2 \rbrace \to \lbrace 2,2,2,1,1 \rbrace \to \lbrace 1,1,1,1,0 \rbrace \to \lbrace 0,0,0,0,0 \rbrace。我们可以注意到,每次操作均互不相同。

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

首页