Problem:


Dropping Ink

As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (x, y) coordinate system.

We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells.

Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells.

For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side):

In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point.

Your task is to write a program which reads a sequence of points of fall (x, y) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density.

You may assume that the paper always consists of 10 &times; 10, and 0 ≤ x < 10, 0 ≤ y < 10.

Input

x1,y1,s1
x2,y2,s2
  :
  :

(xi, yi) represents the position of the i-th drop and si denotes its size. The number of drops is less than or equal to 50.

Output

Print the number of cells whose density value is 0 in first line.

Print the maximum value of density in the second line.

Sample Input

2,5,3
3,6,1
3,4,2
4,5,2
3,6,3
2,4,1

Output for the Sample Input

77
5



Sample input:
2,5,3
3,6,1
3,4,2
4,5,2
3,6,3
2,4,1


Sample output:
77
5

Submission status: Runtime Error

Solution code:
import numpy as np

area = [[0 for i in range(10)] for j in range(10)]
area = np.array(area)

while True:
    try:
        x, y, s = map(int, input().split(','))
    except:
        break

    if s == 3:
        if (0 <= x+2 <= 9) and (0 <= y <= 9):
            area[x+2][y] += 1
        if (0 <= x <= 9) and (0 <= y+2 <= 9):
            area[x][y+2] += 1
        if (0 <= x-2 <= 9) and (0 <= y <= 9):
            area[x-2][y] += 1
        if (0 <= x <= 9) and (0 <= y-2 <= 9):
            area[x][y-2] += 1
    if s >= 2:
        if (0 <= x+1 <= 9) and (0 <= y+1 <= 9):
            area[x+1][y+1] += 1
        if (0 <= x+1 <= 9) and (0 <= y-1 <= 9):
            area[x+1][y-1] += 1
        if (0 <= x-1 <= 9) and (0 <= y+1 <= 9):
            area[x-1][y+1] += 1
        if (0 <= x-1 <= 9) and (0 <= y-1 <= 9):
            area[x-1][y-1] += 1
    if s >= 1:
        if (0 <= x+1 <= 9) and (0 <= y <= 9):
            area[x+1][y] += 1
        if (0 <= x <= 9) and (0 <= y+1 <= 9):
            area[x][y+1] += 1
        if (0 <= x-1 <= 9) and (0 <= y <= 9):
            area[x-1][y] += 1
        if (0 <= x <= 9) and (0 <= y-1 <= 9):
            area[x][y-1] += 1
        area[x][y] += 1

print(len(np.where(area == 0)[0]))
print(area.max())

Submission status: Runtime Error

Solution code:
import numpy as np

area = [[0 for i in range(10)] for j in range(10)]
area = np.array(area)

while True:
    try:
        y, x, s = map(int, input().split(','))
    except:
        break

    if s == 3:
        if (0 <= x+2 <= 9) and (0 <= y <= 9):
            area[x+2][y] += 1
        if (0 <= x <= 9) and (0 <= y+2 <= 9):
            area[x][y+2] += 1
        if (0 <= x-2 <= 9) and (0 <= y <= 9):
            area[x-2][y] += 1
        if (0 <= x <= 9) and (0 <= y-2 <= 9):
            area[x][y-2] += 1
    if s >= 2:
        if (0 <= x+1 <= 9) and (0 <= y+1 <= 9):
            area[x+1][y+1] += 1
        if (0 <= x+1 <= 9) and (0 <= y-1 <= 9):
            area[x+1][y-1] += 1
        if (0 <= x-1 <= 9) and (0 <= y+1 <= 9):
            area[x-1][y+1] += 1
        if (0 <= x-1 <= 9) and (0 <= y-1 <= 9):
            area[x-1][y-1] += 1
    if s >= 1:
        if (0 <= x+1 <= 9) and (0 <= y <= 9):
            area[x+1][y] += 1
        if (0 <= x <= 9) and (0 <= y+1 <= 9):
            area[x][y+1] += 1
        if (0 <= x-1 <= 9) and (0 <= y <= 9):
            area[x-1][y] += 1
        if (0 <= x <= 9) and (0 <= y-1 <= 9):
            area[x][y-1] += 1
        area[x][y] += 1
        print(area)

print(len(np.where(area == 0)[0]))
print(area.max())

Submission status: Runtime Error

Solution code:
import numpy as np

p = np.zeros((14,14), dtype=int)
while True:
    try:
        x_inp, y_inp, s = map(int, input().split(","))
        x = x_inp + 2
        y = y_inp + 2
        if s == 1:
            p[y-1][x] += 1
            p[y][x-1:x+2] += 1
            p[y+1][x] += 1
        elif s == 2:
            p[y-1][x-1:x+2] += 1
            p[y][x-1:x+2] += 1
            p[y+1][x-1:x+2] += 1
        else:
            p[y-2][x] += 1
            p[y-1][x-1:x+2] += 1
            p[y][x-2:x+3] += 1
            p[y+1][x-1:x+2] += 1
            p[y+2][x] += 1
    except:
        break
p_trim = p[2:12,2:12]
print(len(np.where(p_trim==0)[0]))
print(np.max(p_trim))

Submission status: Runtime Error

Solution code:
import numpy as np
p = np.zeros((14,14), dtype=int)
while True:
    try:
        x_inp, y_inp, s = map(int, input().split(","))
        x = x_inp + 2
        y = y_inp + 2
        if s == 1:
            p[y-1][x] += 1
            p[y][x-1:x+2] += 1
            p[y+1][x] += 1
        elif s == 2:
            p[y-1][x-1:x+2] += 1
            p[y][x-1:x+2] += 1
            p[y+1][x-1:x+2] += 1
        else:
            p[y-2][x] += 1
            p[y-1][x-1:x+2] += 1
            p[y][x-2:x+3] += 1
            p[y+1][x-1:x+2] += 1
            p[y+2][x] += 1
    except:
        break
p_trim = p[2:12,2:12]
print(len(np.where(p_trim==0)[0]))
print(np.max(p_trim))

Submission status: Runtime Error

Solution code:
p = np.zeros((14,14), dtype=int)
while True:
    try:
        x_inp, y_inp, s = map(int, input().split(","))
        x = x_inp + 2
        y = y_inp + 2
        if s == 1:
            p[y-1][x] += 1
            p[y][x-1:x+2] += 1
            p[y+1][x] += 1
        elif s == 2:
            p[y-1][x-1:x+2] += 1
            p[y][x-1:x+2] += 1
            p[y+1][x-1:x+2] += 1
        else:
            p[y-2][x] += 1
            p[y-1][x-1:x+2] += 1
            p[y][x-2:x+3] += 1
            p[y+1][x-1:x+2] += 1
            p[y+2][x] += 1
    except:
        break
p_trim = p[2:12,2:12]
print(len(np.where(p_trim==0)[0]))
print(np.max(p_trim))

Submission status: Runtime Error

Solution code:
import numpy as np

Submission status: Runtime Error

Solution code:
import sys

lines = []
for line in sys.stdin:
    lines.append(line.strip().split(','))

field = [[0 for i in range(10)] for j in range(10)]

def drop(x, y, z):
    if z==1:
        for i in range(-1,2):
            for j in range(-1,2):
                if abs(i)+abs(j)<2 and 0<=y+j<=10 and 0<=x+i<=10:
                    field[y+j][x+i] += 1
    elif z==2:
        for i in range(-1,2):
            for j in range(-1,2):
                if 0<=y+j<=10 and 0<=x+i<=10:
                    field[y+j][x+i] += 1
    else:
        for i in range(-2,3):
            for j in range(-2,3):
                if abs(i)+abs(j)<3 and 0<=y+j<=10 and 0<=x+i<=10:
                    field[y+j][x+i] += 1



for line in lines:
    x,y,z = map(int, line)
    print(x,y,z)
    drop(x,y,z)

n = 0
m = 0
for f in field:
    for e in f:
        if e > m:
            m = e
        if e==0:
            n+=1

print(n)
print(m)

Submission status: Runtime Error

Solution code:
import sys

lines = []
for line in sys.stdin:
    lines.append(line.strip().split(','))

field = [[0 for i in range(10)] for j in range(10)]

def drop(x, y, z):
    if z==1:
        for i in range(-1,2):
            for j in range(-1,2):
                if abs(i)+abs(j)<2 and 0<=y+j<=10 and 0<=x+i<=10:
                    field[y+j][x+i] += 1
    elif z==2:
        for i in range(-1,2):
            for j in range(-1,2):
                if 0<=y+j<=10 and 0<=x+i<=10:
                    field[y+j][x+i] += 1
    else:
        for i in range(-2,3):
            for j in range(-2,3):
                if abs(i)+abs(j)<3 and 0<=y+j<=10 and 0<=x+i<=10:
                    field[y+j][x+i] += 1



for line in lines:
    x,y,z = map(int, line)
    print(x,y,z)
    drop(x,y,z)

n = 0
m = 0
for f in field:
    for e in f:
        if e > m:
            m = e
        if e==0:
            n+=1

Submission status: Runtime Error

Solution code:
import sys

lines = []
for line in sys.stdin:
    lines.append(line.strip().split(','))

field = [[0 for i in range(10)] for j in range(10)]

def drop(x, y, z):
    if z==1:
        for i in range(-1,2):
            for j in range(-1,2):
                if abs(i)+abs(j)<2 and 0<=y+j<=10 and 0<=x+i<=10:
                    field[y+j][x+i] += 1
    elif z==2:
        for i in range(-1,2):
            for j in range(-1,2):
                if 0<=y+j<=10 and 0<=x+i<=10:
                    field[y+j][x+i] += 1
    else:
        for i in range(-2,3):
            for j in range(-2,3):
                if abs(i)+abs(j)<3 and 0<=y+j<=10 and 0<=x+i<=10:
                    field[y+j][x+i] += 1



for line in lines:
    x,y,z = map(int, line)
    drop(x,y,z)

n = 0
m = 0
for f in field:
    for e in f:
        if e > m:
            m = e
        if e==0:
            n+=1

print(n)
print(m)

Submission status: Runtime Error

Solution code:
import sys

lines = []
for line in sys.stdin:
    lines.append(line.strip().split(','))

field = [[0 for i in range(10)] for j in range(10)]

def drop(x, y, z):
    if z==1:
        for i in range(-1,2):
            for j in range(-1,2):
                if abs(i)+abs(j)<2 and 0<=y+j<=10 and 0<=x+i<=10:
                    field[y+j][x+i] += 1
    elif z==2:
        for i in range(-1,2):
            for j in range(-1,2):
                if 0<=y+j<=10 and 0<=x+i<=10:
                    field[y+j][x+i] += 1
    else:
        for i in range(-2,3):
            for j in range(-2,3):
                if abs(i)+abs(j)<3 and 0<=y+j<=10 and 0<=x+i<=10:
                    field[y+j][x+i] += 1



for line in lines:
    x,y,z = map(int, line)
    drop(x,y,z)

Submission status: Runtime Error

Solution code:
import sys

lines = []
for line in sys.stdin:
    lines.append(line.strip().split(','))

field = [[0 for i in range(10)] for j in range(10)]

def drop(x, y, z):
    if z==1:
        for i in range(-1,2):
            for j in range(-1,2):
                if abs(i)+abs(j)<2 and 0<=y+j<=10 and 0<=x+i<=10:
                    field[y+j][x+i] += 1
    elif z==2:
        for i in range(-1,2):
            for j in range(-1,2):
                if 0<=y+j<=10 and 0<=x+i<=10:
                    field[y+j][x+i] += 1
    elif z==3:
        for i in range(-2,3):
            for j in range(-2,3):
                if abs(i)+abs(j)<3 and 0<=y+j<=10 and 0<=x+i<=10:
                    field[y+j][x+i] += 1



for line in lines:
    x,y,z = map(int, line)
    drop(x,y,z)

n = 0
m = 0
for f in field:
    for e in f:
        if e > m:
            m = e
        if e==0:
            n+=1

print(n)
print(m)

Submission status: Runtime Error

Solution code:
mass = [[0 for p in xrange(14)] for q in xrange(14)]
while True:
	try:
		x,y,size = map(int,raw_input().split(','))
		if   size = 1:
			mass[x-2][y-2]+=0,mass[x-1][y-2]+=0,mass[x][y-2]+=0,mass[x+1][y-2]+=0,mass[x+2][y-2]+=0
			mass[x-2][y-1]+=0,mass[x-1][y-1]+=0,mass[x][y-1]+=1,mass[x+1][y-1]+=0,mass[x+2][y-1]+=0
			mass[x-2][y]  +=0,mass[x-1][y]  +=1,mass[x][y]  +=1,mass[x+1][y]  +=1,mass[x+2][y]  +=0
			mass[x-2][y+1]+=0,mass[x-1][y+1]+=0,mass[x][y+1]+=1,mass[x+1][y+1]+=0,mass[x+2][y+1]+=0
			mass[x-2][y+2]+=0,mass[x-1][y+2]+=0,mass[x][y+2]+=0,mass[x+1][y+2]+=0,mass[x+2][y+2]+=0
		elif size = 2:
			mass[x-2][y-2]+=0,mass[x-1][y-2]+=0,mass[x][y-2]+=0,mass[x+1][y-2]+=0,mass[x+2][y-2]+=0
			mass[x-2][y-1]+=0,mass[x-1][y-1]+=1,mass[x][y-1]+=1,mass[x+1][y-1]+=1,mass[x+2][y-1]+=0
			mass[x-2][y]  +=0,mass[x-1][y]  +=1,mass[x][y]  +=1,mass[x+1][y]  +=1,mass[x+2][y]  +=0
			mass[x-2][y+1]+=0,mass[x-1][y+1]+=1,mass[x][y+1]+=1,mass[x+1][y+1]+=1,mass[x+2][y+1]+=0
			mass[x-2][y+2]+=0,mass[x-1][y+2]+=0,mass[x][y+2]+=0,mass[x+1][y+2]+=0,mass[x+2][y+2]+=0
		elif size = 3:
			mass[x-2][y-2]+=0,mass[x-1][y-2]+=0,mass[x][y-2]+=1,mass[x+1][y-2]+=0,mass[x+2][y-2]+=0
			mass[x-2][y-1]+=0,mass[x-1][y-1]+=1,mass[x][y-1]+=1,mass[x+1][y-1]+=1,mass[x+2][y-1]+=0
			mass[x-2][y]  +=1,mass[x-1][y]  +=1,mass[x][y]  +=1,mass[x+1][y]  +=1,mass[x+2][y]  +=1
			mass[x-2][y+1]+=0,mass[x-1][y+1]+=1,mass[x][y+1]+=1,mass[x+1][y+1]+=1,mass[x+2][y+1]+=0
			mass[x-2][y+2]+=0,mass[x-1][y+2]+=0,mass[x][y+2]+=1,mass[x+1][y+2]+=0,mass[x+2][y+2]+=0
	except: break
white = 0
max = 0
for p in xrange(2,12):
	for val in xrange(2,12):
		if mass[p][q] == 0: white += 1
		if mass[p][q] > figure: max = mass[p][q]
print white
prit max

Submission status: Runtime Error

Solution code:
mass = [[0 for p in xrange(14)] for q in xrange(14)]
while True:
	try:
		x,y,size = map(int,raw_input().split(','))
		if size = 1:
			mass[x-2][y-2]+=0,mass[x-1][y-2]+=0,mass[x][y-2]+=0,mass[x+1][y-2]+=0,mass[x+2][y-2]+=0
			mass[x-2][y-1]+=0,mass[x-1][y-1]+=0,mass[x][y-1]+=1,mass[x+1][y-1]+=0,mass[x+2][y-1]+=0
			mass[x-2][y]  +=0,mass[x-1][y]  +=1,mass[x][y]  +=1,mass[x+1][y]  +=1,mass[x+2][y]  +=0
			mass[x-2][y+1]+=0,mass[x-1][y+1]+=0,mass[x][y+1]+=1,mass[x+1][y+1]+=0,mass[x+2][y+1]+=0
			mass[x-2][y+2]+=0,mass[x-1][y+2]+=0,mass[x][y+2]+=0,mass[x+1][y+2]+=0,mass[x+2][y+2]+=0
		elif size = 2:
			mass[x-2][y-2]+=0,mass[x-1][y-2]+=0,mass[x][y-2]+=0,mass[x+1][y-2]+=0,mass[x+2][y-2]+=0
			mass[x-2][y-1]+=0,mass[x-1][y-1]+=1,mass[x][y-1]+=1,mass[x+1][y-1]+=1,mass[x+2][y-1]+=0
			mass[x-2][y]  +=0,mass[x-1][y]  +=1,mass[x][y]  +=1,mass[x+1][y]  +=1,mass[x+2][y]  +=0
			mass[x-2][y+1]+=0,mass[x-1][y+1]+=1,mass[x][y+1]+=1,mass[x+1][y+1]+=1,mass[x+2][y+1]+=0
			mass[x-2][y+2]+=0,mass[x-1][y+2]+=0,mass[x][y+2]+=0,mass[x+1][y+2]+=0,mass[x+2][y+2]+=0
		elif size = 3:
			mass[x-2][y-2]+=0,mass[x-1][y-2]+=0,mass[x][y-2]+=1,mass[x+1][y-2]+=0,mass[x+2][y-2]+=0
			mass[x-2][y-1]+=0,mass[x-1][y-1]+=1,mass[x][y-1]+=1,mass[x+1][y-1]+=1,mass[x+2][y-1]+=0
			mass[x-2][y]  +=1,mass[x-1][y]  +=1,mass[x][y]  +=1,mass[x+1][y]  +=1,mass[x+2][y]  +=1
			mass[x-2][y+1]+=0,mass[x-1][y+1]+=1,mass[x][y+1]+=1,mass[x+1][y+1]+=1,mass[x+2][y+1]+=0
			mass[x-2][y+2]+=0,mass[x-1][y+2]+=0,mass[x][y+2]+=1,mass[x+1][y+2]+=0,mass[x+2][y+2]+=0
	except: break
white = 0
max = 0
for p in xrange(2,12):
	for val in xrange(2,12):
		if mass[p][q] == 0: white += 1
		if mass[p][q] > figure: max = mass[p][q]
print white
prit max

Submission status: Runtime Error

Solution code:
mass = [[0 for p in xrange(14)] for q in xrange(14)]
while True:
	try:
		x,y,size = map(int,raw_input().split(','))
		if   size == 1:
			mass[x-2][y-2]+=0,mass[x-1][y-2]+=0,mass[x][y-2]+=0,mass[x+1][y-2]+=0,mass[x+2][y-2]+=0
			mass[x-2][y-1]+=0,mass[x-1][y-1]+=0,mass[x][y-1]+=1,mass[x+1][y-1]+=0,mass[x+2][y-1]+=0
			mass[x-2][y]  +=0,mass[x-1][y]  +=1,mass[x][y]  +=1,mass[x+1][y]  +=1,mass[x+2][y]  +=0
			mass[x-2][y+1]+=0,mass[x-1][y+1]+=0,mass[x][y+1]+=1,mass[x+1][y+1]+=0,mass[x+2][y+1]+=0
			mass[x-2][y+2]+=0,mass[x-1][y+2]+=0,mass[x][y+2]+=0,mass[x+1][y+2]+=0,mass[x+2][y+2]+=0
		elif size == 2:
			mass[x-2][y-2]+=0,mass[x-1][y-2]+=0,mass[x][y-2]+=0,mass[x+1][y-2]+=0,mass[x+2][y-2]+=0
			mass[x-2][y-1]+=0,mass[x-1][y-1]+=1,mass[x][y-1]+=1,mass[x+1][y-1]+=1,mass[x+2][y-1]+=0
			mass[x-2][y]  +=0,mass[x-1][y]  +=1,mass[x][y]  +=1,mass[x+1][y]  +=1,mass[x+2][y]  +=0
			mass[x-2][y+1]+=0,mass[x-1][y+1]+=1,mass[x][y+1]+=1,mass[x+1][y+1]+=1,mass[x+2][y+1]+=0
			mass[x-2][y+2]+=0,mass[x-1][y+2]+=0,mass[x][y+2]+=0,mass[x+1][y+2]+=0,mass[x+2][y+2]+=0
		elif size == 3:
			mass[x-2][y-2]+=0,mass[x-1][y-2]+=0,mass[x][y-2]+=1,mass[x+1][y-2]+=0,mass[x+2][y-2]+=0
			mass[x-2][y-1]+=0,mass[x-1][y-1]+=1,mass[x][y-1]+=1,mass[x+1][y-1]+=1,mass[x+2][y-1]+=0
			mass[x-2][y]  +=1,mass[x-1][y]  +=1,mass[x][y]  +=1,mass[x+1][y]  +=1,mass[x+2][y]  +=1
			mass[x-2][y+1]+=0,mass[x-1][y+1]+=1,mass[x][y+1]+=1,mass[x+1][y+1]+=1,mass[x+2][y+1]+=0
			mass[x-2][y+2]+=0,mass[x-1][y+2]+=0,mass[x][y+2]+=1,mass[x+1][y+2]+=0,mass[x+2][y+2]+=0
	except: break
white = 0
max = 0
for p in xrange(2,12):
	for val in xrange(2,12):
		if mass[p][q] == 0: white += 1
		if mass[p][q] > figure: max = mass[p][q]
print white
prit max

Submission status: Runtime Error

Solution code:
mass = [[0 for p in xrange(14)] for q in xrange(14)]
while True:
	try:
		x,y,size = map(int,raw_input().split(','))
		if   size == 1:
			mass[x-2][y-2]+=0;mass[x-1][y-2]+=0;mass[x][y-2]+=0;mass[x+1][y-2]+=0;mass[x+2][y-2]+=0
			mass[x-2][y-1]+=0;mass[x-1][y-1]+=0;mass[x][y-1]+=1;mass[x+1][y-1]+=0;mass[x+2][y-1]+=0
			mass[x-2][y]  +=0;mass[x-1][y]  +=1;mass[x][y]  +=1;mass[x+1][y]  +=1;mass[x+2][y]  +=0
			mass[x-2][y+1]+=0;mass[x-1][y+1]+=0;mass[x][y+1]+=1;mass[x+1][y+1]+=0;mass[x+2][y+1]+=0
			mass[x-2][y+2]+=0;mass[x-1][y+2]+=0;mass[x][y+2]+=0;mass[x+1][y+2]+=0;mass[x+2][y+2]+=0
		elif size == 2:
			mass[x-2][y-2]+=0;mass[x-1][y-2]+=0;mass[x][y-2]+=0;mass[x+1][y-2]+=0;mass[x+2][y-2]+=0
			mass[x-2][y-1]+=0;mass[x-1][y-1]+=1;mass[x][y-1]+=1;mass[x+1][y-1]+=1;mass[x+2][y-1]+=0
			mass[x-2][y]  +=0;mass[x-1][y]  +=1;mass[x][y]  +=1;mass[x+1][y]  +=1;mass[x+2][y]  +=0
			mass[x-2][y+1]+=0;mass[x-1][y+1]+=1;mass[x][y+1]+=1;mass[x+1][y+1]+=1;mass[x+2][y+1]+=0
			mass[x-2][y+2]+=0;mass[x-1][y+2]+=0;mass[x][y+2]+=0;mass[x+1][y+2]+=0;mass[x+2][y+2]+=0
		elif size == 3:
			mass[x-2][y-2]+=0;mass[x-1][y-2]+=0;mass[x][y-2]+=1;mass[x+1][y-2]+=0;mass[x+2][y-2]+=0
			mass[x-2][y-1]+=0;mass[x-1][y-1]+=1;mass[x][y-1]+=1;mass[x+1][y-1]+=1;mass[x+2][y-1]+=0
			mass[x-2][y]  +=1;mass[x-1][y]  +=1;mass[x][y]  +=1;mass[x+1][y]  +=1;mass[x+2][y]  +=1
			mass[x-2][y+1]+=0;mass[x-1][y+1]+=1;mass[x][y+1]+=1;mass[x+1][y+1]+=1;mass[x+2][y+1]+=0
			mass[x-2][y+2]+=0;mass[x-1][y+2]+=0;mass[x][y+2]+=1;mass[x+1][y+2]+=0;mass[x+2][y+2]+=0
	except: break
white = 0
max = 0
for p in xrange(2,12):
	for val in xrange(2,12):
		if mass[p][q] == 0: white += 1
		if mass[p][q] > figure: max = mass[p][q]
print white
prit max

Submission status: Runtime Error

Solution code:
mass = [[0 for p in xrange(14)] for q in xrange(14)]
while True:
	try:
		x,y,size = map(int,raw_input().split(','))
		if   size == 1:
			mass[x-2][y-2]+=0;mass[x-1][y-2]+=0;mass[x][y-2]+=0;mass[x+1][y-2]+=0;mass[x+2][y-2]+=0
			mass[x-2][y-1]+=0;mass[x-1][y-1]+=0;mass[x][y-1]+=1;mass[x+1][y-1]+=0;mass[x+2][y-1]+=0
			mass[x-2][y]  +=0;mass[x-1][y]  +=1;mass[x][y]  +=1;mass[x+1][y]  +=1;mass[x+2][y]  +=0
			mass[x-2][y+1]+=0;mass[x-1][y+1]+=0;mass[x][y+1]+=1;mass[x+1][y+1]+=0;mass[x+2][y+1]+=0
			mass[x-2][y+2]+=0;mass[x-1][y+2]+=0;mass[x][y+2]+=0;mass[x+1][y+2]+=0;mass[x+2][y+2]+=0
		elif size == 2:
			mass[x-2][y-2]+=0;mass[x-1][y-2]+=0;mass[x][y-2]+=0;mass[x+1][y-2]+=0;mass[x+2][y-2]+=0
			mass[x-2][y-1]+=0;mass[x-1][y-1]+=1;mass[x][y-1]+=1;mass[x+1][y-1]+=1;mass[x+2][y-1]+=0
			mass[x-2][y]  +=0;mass[x-1][y]  +=1;mass[x][y]  +=1;mass[x+1][y]  +=1;mass[x+2][y]  +=0
			mass[x-2][y+1]+=0;mass[x-1][y+1]+=1;mass[x][y+1]+=1;mass[x+1][y+1]+=1;mass[x+2][y+1]+=0
			mass[x-2][y+2]+=0;mass[x-1][y+2]+=0;mass[x][y+2]+=0;mass[x+1][y+2]+=0;mass[x+2][y+2]+=0
		elif size == 3:
			mass[x-2][y-2]+=0;mass[x-1][y-2]+=0;mass[x][y-2]+=1;mass[x+1][y-2]+=0;mass[x+2][y-2]+=0
			mass[x-2][y-1]+=0;mass[x-1][y-1]+=1;mass[x][y-1]+=1;mass[x+1][y-1]+=1;mass[x+2][y-1]+=0
			mass[x-2][y]  +=1;mass[x-1][y]  +=1;mass[x][y]  +=1;mass[x+1][y]  +=1;mass[x+2][y]  +=1
			mass[x-2][y+1]+=0;mass[x-1][y+1]+=1;mass[x][y+1]+=1;mass[x+1][y+1]+=1;mass[x+2][y+1]+=0
			mass[x-2][y+2]+=0;mass[x-1][y+2]+=0;mass[x][y+2]+=1;mass[x+1][y+2]+=0;mass[x+2][y+2]+=0
	except: break
white = 0
max = 0
for p in xrange(2,12):
	for val in xrange(2,12):
		if mass[p][q] == 0: white += 1
		if mass[p][q] > figure: max = mass[p][q]
print white
print max

Submission status: Runtime Error

Solution code:

import sys


class Paper:
    def __init__(self):
        self.paper = [[0 for x in range(10)] for y in range(10)]

    def white_space(self):
        s = 0
        for x in range(10):
            for y in range(10):
                if self.paper[x][y] == 0:
                    s += 1
        return s

    def most_dark(self):
        s = 0
        for x in range(10):
            for y in range(10):
                if self.paper[x][y] > s:
                    s = self.paper[x][y]
        return s

    def drop(self, x, y, size):
        r = []
        if size == 1:
            r.append((x,y))
            r.append((x-1,y))
            r.append((x+1,y))
            r.append((x,y-1))
            r.append((x,y+1))
        elif size == 2:
            r = [(i,j) for i in range(x-1, x+2) for j in range(y-1, y+2)]
        elif size == 3:
            r = [(i,j) for i in range(x-1, x+2) for j in range(y-1, y+2)]
            r.append((x-2, y))
            r.append((x+2, y))
            r.append((x, y-2))
            r.append((x, y+2))
        else:
            pass
        for p in r:
            self.paper[p[0]][p[1]] += 1
        return self


#input_file = open(sys.argv[1], 'r')

paper = Paper()
for line in sys.stdin:
    (x, y, size) = tuple(map(int, line.split(',')))
    paper.drop(x, y, size)
print paper.white_space()
print paper.most_dark()

Submission status: Runtime Error

Solution code:

import sys


class Paper:
    def __init__(self):
        self.paper = [[0 for x in range(10)] for y in range(10)]

    def white_space(self):
        s = 0
        for x in range(10):
            for y in range(10):
                if self.paper[x][y] == 0:
                    s += 1
        return s

    def most_dark(self):
        s = 0
        for x in range(10):
            for y in range(10):
                if self.paper[x][y] > s:
                    s = self.paper[x][y]
        return s

    def drop(self, x, y, size):
        r = []
        if size == 1:
            r.append((x,y))
            r.append((x-1,y))
            r.append((x+1,y))
            r.append((x,y-1))
            r.append((x,y+1))
        elif size == 2:
            r = [(i,j) for i in range(x-1, x+2) for j in range(y-1, y+2)]
        elif size == 3:
            r = [(i,j) for i in range(x-1, x+2) for j in range(y-1, y+2)]
            r.append((x-2, y))
            r.append((x+2, y))
            r.append((x, y-2))
            r.append((x, y+2))
        else:
            pass
        r = filter(self.out_of_paper, r)
        try:
            for p in r:
                self.paper[p[0]][p[1]] += 1
        except:
            pass
        return self

    def out_of_paper(p):
        if p[0] >= 0 and p[1] >= 0:
            True
        else:
            False


#input_file = open(sys.argv[1], 'r')

paper = Paper()
for line in sys.stdin:
    (x, y, size) = tuple(map(int, line.split(',')))
    paper.drop(x, y, size)
print paper.white_space()
print paper.most_dark()

Submission status: Runtime Error

Solution code:
#use 14x14 paper
paper = [[0 for i in range(14)] for i in range(14)]
while True:
    try:
        x, y, s = map(int, raw_input().split(","))
        x += 2;	y += 2
        if s == 1:
            paper[x][y] += 1
            for i in range(-1,2,2):
                paper[x+i][y] += 1
                paper[x][y+1] += 1
        elif s == 2:
            for i in range(-1,2):
                for j in range(-1,2):
                    paper[x+i][y+j] += 1
        else:
            paper[x+2][y] += 1; paper[x-2][y] += 1
            paper[x][y+2] += 1; paper[x][y-2] += 1
            for i in range(-1,2):
                for j in range(-1,2):
                    paper[x+i][y+j] += 1
    except:
        break

#count white and check max element in paper
white = 0
max = 0
for i in range(2,12):
    for j in range(2,12):
        if paper[i][j] == 0:
            white += 1
	elif paper[i][j] > max:
            max = paper[i][j]
print "%d" % (white)
print "%max" % (max)

Submission status: Runtime Error

Solution code:
import sys
def ink(x,y,size):
    global P
    P[y][x]+=1
    for d in [-1,1]:
        P[y+d][x]+=1
        P[y][x+d]+=1
    if size==1: return
    for d in [-1,1]:
        P[y+d][x+d]+=1
        P[y+d][x-d]+=1
    if size==2: return
    for d in [-2,2]:
        P[y+d][x]+=1
        P[y][x+d]+=1
    return

R=range(14)
A=[-1:1]
P=[[0 for i in R] for j in R]
for s in sys.stdin:
    x,y,size = map(int, s.split(","))
    ink(x+2,y+2,size)
c=0
m=0
for e in P[2:-2]:
    x=e[2:-2]
    c+=x.count(0)
    m=max(max(x),m)
print c
print m