2022 软件学院 ACM 集训队筛选赛

Problem G. Living in Peace with Errors

Hefeng wakes up and tolds everything to her friends. With their efforts, Hefeng finally persuades Yunyan to choose a peace way. They keep constructing the Blue Planet, making it even more prosperous and developed.

Later, Tianjiang comes back and notices the note left by Hefeng. With curiosity, he goes to the Blue Planet. He is greatly thrilled at the miracles they made. It's a world combines technology with magic perfectly which is better than any other worlds created by Tianjiang. Everything here is living in peace. So Tianjiang decides not to remove the Abyss and appoints Yunyan as the administrator of the Blue Planet, hoping to observe greater achievements they could make.

Construction completed, new construction options... Having a brand new life, Yunyan is now burying himself constructing the Blue Planet energetically.

Yunyan can construct some buildings on the Blue Planet, and each building can have some(or none) relationships with other buildings. Each building has a positive integer value pp , and if a building has dd relationships with other buildings, then it has pdp^d contributions. The total contributions tt is the sum of contributions of all the buildings.

Given total contributions tt, you can assign value pp for each building, and construct nn buildings with at most 58005800 relationships in total. Please construct a scheme to make the total contributions equal to tt and output this scheme. If none of schemes is available, please output 1-1.

输入

A single line with an integer t(1t109)t(1\le t\le10^{9}) .

输出

If there exists scheme to get total contributions of tt :

Output an integer n(1n580)n(1\le n\le580) in the first line denoting the number of buildings you construct.

Output nn integer in the second line, the ii-th integer pi(2pi58)p_i(2\le p_i\le58) denotes the important value of the ii-th building.

Then output nn lines, each line includes nn integers. The ii-th line's jj-th integer is cijc_{ij} . If cij=1c_{ij}=1 , it denotes that the ii-th building has relationship with the jj-th building. If cij=0c_{ij}=0 , they have no relationship. You should guarantee that 1i,jn,cij=cji\forall1\le i,j\le n, c_{ij}=c_{ji} , cii=0c_{ii}=0 and i=1nj=1icij5800,0cij1\sum_{i=1}^n\sum_{j=1}^ic_{ij}\le 5800, 0\le c_{ij}\le 1.

If multiple schemes are available, output any of them.

If there is not exist any schemes to get total contributions of tt , output -1 in an single line.

样例

标准输入 复制文本
580
标准输出 复制文本
3
2 24 2
0 1 0
1 0 1
0 1 0
标准输入 复制文本
1437
标准输出 复制文本
8
6 6 3 8 6 2 2 8
0 1 0 0 0 0 0 0
1 0 1 0 0 1 1 0
0 1 0 1 0 1 1 0
0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0
0 1 1 0 1 0 1 0
0 1 1 0 0 1 0 1
0 0 0 0 0 0 1 0

提示

In the first example, one possible scheme is like this, t=21+242+21=580t=2^1+24^2+2^1=580:

In the second example, one possible scheme is like this,

t=61+64+34+81+61+24+24+81=1437t=6^1+6^4+3^4+8^1+6^1+2^4+2^4+8^1=1437 :

登录以提交代码。
单点时限 1 秒
内存限制 128 MB
提交 0
通过 0

A B C D E F G H

鉴于过题情况不理想,比赛时间延长1小时,22:00开始封榜。
可以尝试一下做D,G或H题。
C题是签到题。
请注意题目难度与题目顺序无关。