2 # This program is contributed by Shin Nishiyama
22 [-ROW
, -1, 1, ROW
].each
{|d
|
23 if x
+d
> 0 and not a
.include?(x
+d
) and not nbc
.include?(x
+d
)
28 piece(n
+1,a
[0..n
],nbc
)
34 a
.collect
{|x
| x
- a
[0]}
37 kikaku(a
.collect
{|x
| ((x
+NP
)%ROW
)-ROW
*((x
+NP
)/ROW
) }.sort
)
40 kikaku(a
.collect
{|x
| ROW
*((x
+NP
)/ROW
)+ROW-
((x
+NP
)%ROW
)}.sort
)
43 kikaku(a
.collect
{|x
| ROW
*((x
+NP
)%ROW
) + (x
+NP
)/ROW
}.sort
)
60 $p.uniq
!.sort
! {|x
,y
| x
[0] <=> y
[0] }
64 (0...ROW
*COL
).each
{|i
|
70 $b[3*ROW
+3]=$b[3*ROW
+4]=$b[4*ROW
+3]=$b[4*ROW
+4]=-2
94 if a
.length
== $p.length
then
102 ($pnum - a
).each
do |i
|
129 $pnum = (0...$p.length
).to_a
152 for d
in [-ROW
, -1, 1, ROW
]
153 if x
+d
> 0 and not a
.include?(x
+d
) and not nbc
.include?(x
+d
)
158 piece(n
+1,a
[0..n
],nbc
)
164 a
.collect
{|x
| x
- a
[0]}
167 kikaku(a
.collect
{|x
| ((x
+NP
)%ROW
)-ROW
*((x
+NP
)/ROW
) }.sort
)
170 kikaku(a
.collect
{|x
| ROW
*((x
+NP
)/ROW
)+ROW-
((x
+NP
)%ROW
)}.sort
)
173 kikaku(a
.collect
{|x
| ROW
*((x
+NP
)%ROW
) + (x
+NP
)/ROW
}.sort
)
186 a
[7] = ud(rl(xy(a0
)))
190 $p.uniq
!.sort
! {|x
,y
| x
[0] <=> y
[0] }
200 $b[3*ROW
+3]=$b[3*ROW
+4]=$b[4*ROW
+3]=$b[4*ROW
+4]=-2
223 if a
.length
== $p.length
then
231 ($pnum - a
).each
do |i
|
258 $pnum = (0...$p.length
).to_a