1159: 硬币翻转

文件提交:无需freopen 内存限制:128 MB 时间限制:1.000 S
评测方式:普通裁判 命题人:
提交:1 解决:1

题目描述

在桌面上有一排硬币,共 lns="http://www.w3.org/1998/Math/MathML"> 枚,每一枚硬币均为正面朝上。现在要把所有的硬币翻转成反面朝上,规则是每次可翻转任意 lns="http://www.w3.org/1998/Math/MathML">1 枚硬币(正面向上的被翻转为反面向上,反之亦然)。求一个最短的操作序列(将每次翻转 lns="http://www.w3.org/1998/Math/MathML">1 枚硬币成为一次操作)。

输入

一个自然数 lns="http://www.w3.org/1998/Math/MathML">lns="http://www.w3.org/1998/Math/MathML"> 为不大于 lns="http://www.w3.org/1998/Math/MathML">100 的偶数)。

输出

第一行包含一个整数 lns="http://www.w3.org/1998/Math/MathML">,表示最少需要的操作次数。

接下来的 lns="http://www.w3.org/1998/Math/MathML"> 行每行分别表示每次操作后桌上硬币的状态(一行包含 lns="http://www.w3.org/1998/Math/MathML"> 个整数 lns="http://www.w3.org/1998/Math/MathML">0 或 lns="http://www.w3.org/1998/Math/MathML">1,表示每个硬币的状态,lns="http://www.w3.org/1998/Math/MathML">0 表示正面向上,lns="http://www.w3.org/1998/Math/MathML">1 表示反面向上。不允许输出多余空格。

对于有多种操作方案的情况,则只需操作的字典序最小输出一种。

操作的字典序是指,对于一次操作中的每个位置,lns="http://www.w3.org/1998/Math/MathML">1 表示翻转,lns="http://www.w3.org/1998/Math/MathML">0 表示不反转。

但是需要你输出的是每一次操作完的状态,lns="http://www.w3.org/1998/Math/MathML">0 表示正面朝上,lns="http://www.w3.org/1998/Math/MathML">1 表示反面朝上。

样例输入

4

样例输出

4
0111
1100
0001
1111