Green Boy Can't You Solve It Out? Ep. 2

Solved!
Difficulty: Div2B

1 problem for div3 participants.

Beautiful Dice Painting

When Epis is bored, she will draw dices.

The canvas contains n*n dots. Initially they are all white. You need to paint exactly v dots black so that the final canvas is central symmetric. The canvas is central symmetric if and only if for all pairs of locations (i,j) (k,l) such that i+k=l+j=n+1, the color of (i,j) is the same as the color of (k,l).

For example, when n=3,v=3, here are some possible drawings:

WBW
WBW
WBW

or

BWW
WBW
WWB

Now you are given v. Find the smallest n that could have the dice painted and show a possible approach. If there are many approaches, print any.

Examples

v=2

Ans:

2
BW
WB

v=6

Ans:

3
BWB
BWB
BWB

v=11
Ans:

5
BBWBB
WWBWW
WWBWW
WWBWW
BBWBB

It can be proven that n=4 will not work.

Constraints

1\leq v\leq 10^6

Solution

By XGN

If we have already known n, then you can only consider a half of the grid... You can draw whatever you like!

If n=\left\lceil\sqrt v\right\rceil doesn't work, try n+1! At least one of them will work.

版权声明:
作者:XGN
链接:https://blog.hellholestudios.top/archives/1201
来源:Hell Hole Studios Blog
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>
文章目录
关闭
目 录