Russian Box.
Statement
Goal
Imagine box in an array acting like russian doll...You have to print the box and then you have to count space inside each box from the smallest to the biggest box or print impossible if there multiple box inside the same box or if two box outline are in the same place.
You only count the inside, not the outline.
First box is represented by H and W and have
Each other box are represented by digit from
If two box have their outlines on the same place, print
See the first example for more detail.
Input
Line 1 : Three integer : H for the height of the 1st box, W for the width of the 1st box and N for the number of box inside.
N next line : X1Y1 X2Y2 Coordinate of the box.
N next line : X1Y1 X2Y2 Coordinate of the box.
Output
The N line of the box.
One integer per line, representing the space inside each box (space inside without outlane) from the smallest to the biggest, or printIMPOSSIBLE if there is more than one box inside the same box or if 2 box have their outline in the same place.
One integer per line, representing the space inside each box (space inside without outlane) from the smallest to the biggest, or print
Constraints
2 <= H,W <= 100.
0 < X1X2 < H.
0 < Y1Y2 < W.
0 <= N <= 10.
0 < X1X2 < H.
0 < Y1Y2 < W.
0 <= N <= 10.
Example
Input
10 10 2 2 2 7 7 4 4 5 5
Output
########## #........# #.000000.# #.0....0.# #.0.11.0.# #.0.11.0.# #.0....0.# #.000000.# #........# ########## 0 16 64
Tags
2D array, Conditions
Difficulty
Easy
Test cases
Example Test. Test
Input
10 10 2
2 2 7 7
4 4 5 5
Output
##########
#........#
#.000000.#
#.0....0.#
#.0.11.0.#
#.0.11.0.#
#.0....0.#
#.000000.#
#........#
##########
0
16
64
Easy Test. Validator
Input
12 12 2
2 2 7 7
3 4 5 6
Output
############
#..........#
#.000000...#
#.0.1110...#
#.0.1.10...#
#.0.1110...#
#.0....0...#
#.000000...#
#..........#
#..........#
#..........#
############
1
16
100
No box inside. Test
Input
3 3 0
Output
###
#.#
###
1
No box inside. Validator
Input
3 10 0
Output
##########
#........#
##########
8
Tight Box. Test
Input
2 10 0
Output
##########
##########
0
Tight Box. Validator
Input
10 2 0
Output
##
##
##
##
##
##
##
##
##
##
0
Multibox Test
Input
12 12 5
1 1 10 10
2 2 9 9
3 3 8 8
4 4 7 7
5 5 6 6
Output
############
#0000000000#
#0111111110#
#0122222210#
#0123333210#
#0123443210#
#0123443210#
#0123333210#
#0122222210#
#0111111110#
#0000000000#
############
0
4
16
36
64
100
Multibox Validator
Input
10 10 4
1 1 8 8
2 2 7 7
3 3 6 6
4 4 5 5
Output
##########
#00000000#
#01111110#
#01222210#
#01233210#
#01233210#
#01222210#
#01111110#
#00000000#
##########
0
4
16
36
64
Multi box in the same box. Test
Input
15 15 2
2 2 3 5
8 8 2 11
Output
###############
#.............#
#.0000..1111..#
#.0000..1..1..#
#.......1..1..#
#.......1..1..#
#.......1..1..#
#.......1..1..#
#.......1111..#
#.............#
#.............#
#.............#
#.............#
#.............#
###############
IMPOSSIBLE
Multi box in the same box. Validator
Input
20 20 3
2 2 3 5
14 2 8 5
8 8 2 11
Output
####################
#..................#
#.0000..2222.......#
#.0000..2..2.......#
#.......2..2.......#
#.......2..2.......#
#.......2..2.......#
#.......2..2.......#
#.1111..2222.......#
#.1..1.............#
#.1..1.............#
#.1..1.............#
#.1..1.............#
#.1..1.............#
#.1111.............#
#..................#
#..................#
#..................#
#..................#
####################
IMPOSSIBLE
Disorder. Test
Input
12 13 3
5 7 7 9
10 1 2 11
8 4 4 10
Output
#############
#...........#
#11111111111#
#1.........1#
#1..22222221#
#1..2..00021#
#1..2..0.021#
#1..2..00021#
#1..22222221#
#1.........1#
#11111111111#
#############
1
15
63
110
Disorder. Validator
Input
14 14 3
5 7 7 9
10 1 2 11
8 4 4 10
Output
##############
#............#
#11111111111.#
#1.........1.#
#1..22222221.#
#1..2..00021.#
#1..2..0.021.#
#1..2..00021.#
#1..22222221.#
#1.........1.#
#11111111111.#
#............#
#............#
##############
1
15
63
144
Oups? Test
Input
30 30 2
1 1 20 20
15 15 25 25
Output
##############################
#00000000000000000000........#
#0..................0........#
#0..................0........#
#0..................0........#
#0..................0........#
#0..................0........#
#0..................0........#
#0..................0........#
#0..................0........#
#0..................0........#
#0..................0........#
#0..................0........#
#0..................0........#
#0..................0........#
#0.............11111X11111...#
#0.............1....0....1...#
#0.............1....0....1...#
#0.............1....0....1...#
#0.............1....0....1...#
#00000000000000X00000....1...#
#..............1.........1...#
#..............1.........1...#
#..............1.........1...#
#..............1.........1...#
#..............11111111111...#
#............................#
#............................#
#............................#
##############################
IMPOSSIBLE
Oups? Validator
Input
20 20 3
2 2 10 10
4 4 15 6
3 9 18 7
Output
####################
#..................#
#.000000000........#
#.0....2220........#
#.0.1112.20........#
#.0.1.12.20........#
#.0.1.12.20........#
#.0.1.12.20........#
#.0.1.12.20........#
#.0.1.12.20........#
#.00X0XX0X0........#
#...1.12.2.........#
#...1.12.2.........#
#...1.12.2.........#
#...1.12.2.........#
#...1112.2.........#
#......2.2.........#
#......2.2.........#
#......222.........#
####################
IMPOSSIBLE
Solution language
Solution
Stub generator input