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: Accepted

Solution code:
import sys

field = []
for i in range(0, 10):
	lst = []
	for j in range(0, 10):
		lst.append(0)
	field.append(lst)

for line in sys.stdin:
	x, y, s = map(int, line.split(','))
	field[x][y] += 1
	for i in range(0, 2):
		nextx = x-1+2*i
		nexty = y-1+2*i
		if 0 <= nextx and nextx < 10: field[nextx][y] += 1
		if 0 <= nexty and nexty < 10: field[x][nexty] += 1
	if s >= 2:
		for i in range(0, 2):
			nextx = x-1+2*i
			if 0 <= nextx and nextx < 10:
				for j in range(0, 2):
					nexty = y-1+2*j
					if 0 <= nexty and nexty < 10:
						field[nextx][nexty] += 1
	if s == 3:
		for i in range(0, 2):
			nextx = x-2+4*i
			nexty = y-2+4*i
			if 0 <= nextx and nextx < 10: field[nextx][y] += 1
			if 0 <= nexty and nexty < 10: field[x][nexty] += 1

cnt = 0
max = 0
for i in range(0, 10):
	for j in range(0, 10):
		if field[i][j] == 0: cnt += 1
		else:
			if max < field[i][j]: max = field[i][j]
print cnt
print max

Submission status: Accepted

Solution code:
paper=[[0 for i in range(10)] for j in range(10)]
while 1:
    try:
        x,y,s=map(int,input().split(","))
        if s==1:
            r=[[-1,0],[1,0],[0,0],[0,-1],[0,1]]
        elif s==2:
            r=[[-1,-1],[-1,0],[-1,1],[0,-1],[0,0],[0,1],[1,-1],[1,0],[1,1]]
        elif s==3:
            r=[[-2,0],[-1,-1],[-1,0],[-1,1],[0,-2],[0,-1],[0,0],[0,1],[0,2],[1,-1],[1,0],[1,1],[2,0]]
        for i in r:
            if y+i[0]<0 or y+i[0]>9 or x+i[1]<0 or x+i[1]>9:pass
            else:
                paper[y+i[0]][x+i[1]]+=1
    except:break
ans=0
dark=0
for i in paper:
    for j in i:
        if j==0:ans+=1
        else:dark=max(dark,j)
print(ans)
print(dark)

Submission status: Accepted

Solution code:
a = [[0 for i in range(14)] for j in range(14)]
drop = [0 for i in range(3)]
drop[0] = [
	[0,0,0,0,0],
	[0,0,1,0,0],
	[0,1,1,1,0],
	[0,0,1,0,0],
	[0,0,0,0,0]
]
drop[1] = [
	[0,0,0,0,0],
	[0,1,1,1,0],
	[0,1,1,1,0],
	[0,1,1,1,0],
	[0,0,0,0,0]
]
drop[2] = [
	[0,0,1,0,0],
	[0,1,1,1,0],
	[1,1,1,1,1],
	[0,1,1,1,0],
	[0,0,1,0,0]
]

while(1):
	try:
		x,y,n = [int(i) for i in input().split(",")]
		for i in range(5):
			for j in range(5):
				a[x+i][y+j] = a[x+i][y+j] + drop[n-1][i][j]
	except EOFError:
		b = [[0 for i in range(10)] for j in range(10)]
		for i in range(10):
			for j in range(10):
				b[i][j] = a[i+2][j+2]
		zero = [sum([1 if b[i][j] == 0 else 0 for j in range(10)]) for i in range(10)]
		print(sum(zero))
		print(int(max([max(i) for i in b])))
		break

Submission status: Accepted

Solution code:
paper = [[0]*10 for l in range(10)]
while True:
    try:
        x,y,s = map(int, input().split(","))
        # s size
        paper[x][y] += 1
        if y - 1 >= 0:
            paper[x][y - 1] += 1
        if x - 1 >= 0:
            paper[x - 1][y] += 1
        if x + 1 < 10:
            paper[x + 1][y] += 1
        if y + 1 < 10:
            paper[x][y + 1] += 1

        # m size
        if s >= 2:
            if x - 1 >= 0 and y - 1 >= 0:
                paper[x - 1][y - 1] += 1
            if x + 1 < 10 and y - 1 >= 0:
                paper[x + 1][y - 1] += 1
            if x - 1 >= 0 and y + 1 < 10:
                paper[x - 1][y + 1] += 1
            if x + 1 < 10 and y + 1 < 10:
                paper[x + 1][y + 1] += 1

        # l size
        if s >= 3:
            if x - 2 >= 0:
                paper[x - 2][y] += 1
            if x + 2 < 10:
                paper[x + 2][y] += 1
            if y - 2 >= 0:
                paper[x][y - 2] += 1
            if y + 2 < 10:
                paper[x][y + 2] += 1
    except EOFError:
        break
flat_paper = sum(paper, [])
print(flat_paper.count(0))
print(max(flat_paper))

Submission status: Accepted

Solution code:
paper = [[0 for i in range(15)] for j in range(15)]
base = 2
 
while True:
    try:
        x, y, s = list(map(int, input().split(',')))
    except EOFError:
        break
         
    x += 2
    y += 2
    if s == 3:
        paper[x-2][y] += 1
        paper[x+2][y] += 1
        paper[x][y-2] += 1
        paper[x][y+2] += 1
 
    if s >= 2:
        paper[x-1][y-1] += 1
        paper[x-1][y+1] += 1
        paper[x+1][y-1] += 1
        paper[x+1][y+1] += 1
 
    paper[x][y] += 1
    paper[x-1][y] += 1
    paper[x+1][y] += 1
    paper[x][y-1] += 1
    paper[x][y+1] += 1
 
cnt = max = 0;
for x in range(2, 12):
    for y in range(2, 12):
        if paper[x][y] == 0:
            cnt += 1
        if paper[x][y] > max:
            max = paper[x][y]
 
print(cnt, max, sep='\n')

Submission status: Accepted

Solution code:
ar = [[0]*14 for _ in range(14)]

while(True):
    try:
        x,y,s = map(int,input().split(","))
        if s == 3:
            for x1,y1 in [[-2,0],[0,2],[2,0],[0,-2],[-1,-1],[0,-1],[1,-1],[-1,0],[0,0],[1,0],[-1,1],[0,1],[1,1]]:
                ar[y1+y+2][x1+x+2] += 1
        elif s == 2:
            for x1,y1 in [[-1,-1],[0,-1],[1,-1],[-1,0],[0,0],[1,0],[-1,1],[0,1],[1,1]]:
                ar[y1+y+2][x1+x+2] += 1
        elif s == 1:
            for x1,y1 in [[0,-1],[-1,0],[0,0],[1,0],[0,1]]:
                ar[y1+y+2][x1+x+2] += 1
    except:
        break
br = [ a[2:12] for a in ar[2:12] ]
print(sum([b.count(0) for b in br]))
print(max([max(b) for b in br]))

Submission status: Accepted

Solution code:
import sys

class Board():
    
    def __init__(self):
        self.B = [0 for _ in range(12 * 12)]
        
        for i in range(0, 12):
            self.B[i] = -1
        for i in range(12, 12 * 12, 12):
            self.B[i] = -1
        for i in range(11, 11 * 12, 12):
            self.B[i] = -1
        for i in range(12 * 11, 12 * 12):
            self.B[i] = -1
    
    def print(self):
        cnt = 0
        for b in self.B:
            if b == 0:
                cnt += 1
        
        print(cnt)
        print(max(self.B))
    
    def inc_if_non_wall(self, x, y):
        idx = (y + 1) * 12 + (x + 1)
        
        if self.B[idx] != -1:
            self.B[idx] += 1
    
    def drop_s(self, x, y):
        self.inc_if_non_wall(x, y)
        self.inc_if_non_wall(x, y - 1)
        self.inc_if_non_wall(x - 1, y)
        self.inc_if_non_wall(x + 1, y)
        self.inc_if_non_wall(x, y + 1)
    
    def drop_m(self, x, y):
        self.drop_s(x, y)
        self.inc_if_non_wall(x - 1, y - 1)
        self.inc_if_non_wall(x + 1, y - 1)
        self.inc_if_non_wall(x - 1, y + 1)
        self.inc_if_non_wall(x + 1, y + 1)
    
    def drop_l(self, x, y):
        self.drop_m(x, y)
        
        idx = (y + 1) * 12 + (x + 1)
        if 12 * 3 < idx:
            self.inc_if_non_wall(x, y - 2)
        if idx < 12 * 9:
            self.inc_if_non_wall(x, y + 2)
        
        self.inc_if_non_wall(x - 2, y)
        self.inc_if_non_wall(x + 2, y)
    

if __name__ == "__main__":
    B = Board()
    for l in sys.stdin:
        x, y, s = map(int, l.split(','))
        if s == 1:
            B.drop_s(x, y)
        elif s == 2:
            B.drop_m(x, y)
        elif s == 3:
            B.drop_l(x, y)
    
    B.print()

Submission status: Runtime Error

Solution code:
paper = {}
counter = 0
for i in range(10):
	for j in range(10):
		paper.update({(i,j):0})
while True:
	try:
		x, y, s = list(map(int,input().split(",")))
	except:
		break
	if s == 3:
		paper[(x+2,y)] += 1
		paper[(x-2,y)] += 1
		paper[(x,y+2)] += 1
		paper[(x,y-2)] += 1
	if s >= 2:
		paper[(x+1,y+1)] += 1
		paper[(x+1,y-1)] += 1
		paper[(x-1,y+1)] += 1
		paper[(x-1,y-1)] += 1
	paper[(x,y)] += 1
	paper[(x,y-1)] += 1
	paper[(x,y+1)] += 1
	paper[(x+1,y)] += 1
	paper[(x-1,y)] += 1
	#print(paper.values())

for i in range(10):
	for j in range(10):
		if paper[(i,j)] == 0:
			counter += 1
print(counter)
print(max(paper.values()))

Submission status: Runtime Error

Solution code:
paper = {}
counter = 0
i = 0
for i in range(10):
	for j in range(10):
		paper.update({(i,j):0})
while i < 50:
	try:
		x, y, s = list(map(int,input().split(",")))
	except:
		break
	if s == 3:
		paper[(x+2,y)] += 1
		paper[(x-2,y)] += 1
		paper[(x,y+2)] += 1
		paper[(x,y-2)] += 1
	if s >= 2:
		paper[(x+1,y+1)] += 1
		paper[(x+1,y-1)] += 1
		paper[(x-1,y+1)] += 1
		paper[(x-1,y-1)] += 1
	paper[(x,y)] += 1
	paper[(x,y-1)] += 1
	paper[(x,y+1)] += 1
	paper[(x+1,y)] += 1
	paper[(x-1,y)] += 1
	i += 1

for i in range(10):
	for j in range(10):
		if paper[(i,j)] == 0:
			counter += 1
print(counter)
print(max(paper.values()))

Submission status: Runtime Error

Solution code:
paper = {}
counter = 0
i = 0
for i in range(10):
	for j in range(10):
		paper.update({(i,j):0})
while i < 50:
	try:
		x, y, s = list(map(int,input().split(",")))
	except:
		break
	if x - 1 < 0 and x - 2 < 0 and x - 3 < 0 and y - 1 < 0 and y - 2 < 0 and y - 3 < 0:
		if s == 3:
			paper[(x+2,y)] += 1
			paper[(x,y+2)] += 1
		if s >= 2:
			paper[(x+1,y+1)] += 1
		paper[(x,y)] += 1
		paper[(x,y+1)] += 1
		paper[(x+1,y)] += 1
	else:
		if s == 3:
			paper[(x+2,y)] += 1
			paper[(x-2,y)] += 1
			paper[(x,y+2)] += 1
			paper[(x,y-2)] += 1
		if s >= 2:
			paper[(x+1,y+1)] += 1
			paper[(x+1,y-1)] += 1
			paper[(x-1,y+1)] += 1
			paper[(x-1,y-1)] += 1
		paper[(x,y)] += 1
		paper[(x,y-1)] += 1
		paper[(x,y+1)] += 1
		paper[(x+1,y)] += 1
		paper[(x-1,y)] += 1
	i += 1

for i in range(10):
	for j in range(10):
		if paper[(i,j)] == 0:
			counter += 1
print(counter)
print(max(paper.values()))

Submission status: Runtime Error

Solution code:
paper = {}
counter = 0
i = 0
for i in range(10):
	for j in range(10):
		paper.update({(i,j):0})
while i < 50:
	try:
		x, y, s = list(map(int,input().split(",")))
	except:
		break
	if x - 1 < 0 and  x - 2 < 0 and  x - 3 < 0 and y - 1 < 0 and y - 2 < 0 and  y - 3 < 0:
		if s == 3:
			paper[(x+2,y)] += 1
			paper[(x,y+2)] += 1
		if s >= 2:
			paper[(x+1,y+1)] += 1
		paper[(x,y)] += 1
		paper[(x,y+1)] += 1
		paper[(x+1,y)] += 1
	elif x - 1 < 0 and  x - 2 < 0 and  x - 3 < 0:
		if s == 3:
			paper[(x+2,y)] += 1
			paper[(x,y+2)] += 1
			paper[(x,y-2)] += 1
		if s >= 2:
			paper[(x+1,y+1)] += 1
			paper[(x+1,y-1)] += 1
		paper[(x,y)] += 1
		paper[(x,y-1)] += 1
		paper[(x,y+1)] += 1
		paper[(x+1,y)] += 1
	elif y - 1 < 0 and y - 2 < 0 and  y - 3 < 0:
		if s == 3:
			paper[(x+2,y)] += 1
			paper[(x-2,y)] += 1
			paper[(x,y+2)] += 1
		if s >= 2:
			paper[(x+1,y+1)] += 1
			paper[(x-1,y+1)] += 1
		paper[(x,y)] += 1
		paper[(x,y+1)] += 1
		paper[(x+1,y)] += 1
		paper[(x-1,y)] += 1
	else:
		if s == 3:
			paper[(x+2,y)] += 1
			paper[(x-2,y)] += 1
			paper[(x,y+2)] += 1
			paper[(x,y-2)] += 1
		if s >= 2:
			paper[(x+1,y+1)] += 1
			paper[(x+1,y-1)] += 1
			paper[(x-1,y+1)] += 1
			paper[(x-1,y-1)] += 1
		paper[(x,y)] += 1
		paper[(x,y-1)] += 1
		paper[(x,y+1)] += 1
		paper[(x+1,y)] += 1
		paper[(x-1,y)] += 1
	i += 1

for i in range(10):
	for j in range(10):
		if paper[(i,j)] == 0:
			counter += 1
print(counter)
print(max(paper.values()))

Submission status: Runtime Error

Solution code:
paper = {}
counter = 0
i = 0
for i in range(10):
	for j in range(10):
		paper.update({(i,j):0})
while i < 50:
	try:
		x, y, s = list(map(int,input().split(",")))
	except:
		break
	if x - 1 < 0 or  x - 2 < 0 or  x - 3 < 0 or y - 1 < 0 or y - 2 < 0 or  y - 3 < 0:
		if s == 3:
			paper[(x+2,y)] += 1
			paper[(x,y+2)] += 1
		if s >= 2:
			paper[(x+1,y+1)] += 1
		paper[(x,y)] += 1
		paper[(x,y+1)] += 1
		paper[(x+1,y)] += 1
	elif x - 1 < 0 or  x - 2 < 0 or  x - 3 < 0:
		if s == 3:
			paper[(x+2,y)] += 1
			paper[(x,y+2)] += 1
			paper[(x,y-2)] += 1
		if s >= 2:
			paper[(x+1,y+1)] += 1
			paper[(x+1,y-1)] += 1
		paper[(x,y)] += 1
		paper[(x,y-1)] += 1
		paper[(x,y+1)] += 1
		paper[(x+1,y)] += 1
	elif y - 1 < 0 or y - 2 < 0 or  y - 3 < 0:
		if s == 3:
			paper[(x+2,y)] += 1
			paper[(x-2,y)] += 1
			paper[(x,y+2)] += 1
		if s >= 2:
			paper[(x+1,y+1)] += 1
			paper[(x-1,y+1)] += 1
		paper[(x,y)] += 1
		paper[(x,y+1)] += 1
		paper[(x+1,y)] += 1
		paper[(x-1,y)] += 1
	else:
		if s == 3:
			paper[(x+2,y)] += 1
			paper[(x-2,y)] += 1
			paper[(x,y+2)] += 1
			paper[(x,y-2)] += 1
		if s >= 2:
			paper[(x+1,y+1)] += 1
			paper[(x+1,y-1)] += 1
			paper[(x-1,y+1)] += 1
			paper[(x-1,y-1)] += 1
		paper[(x,y)] += 1
		paper[(x,y-1)] += 1
		paper[(x,y+1)] += 1
		paper[(x+1,y)] += 1
		paper[(x-1,y)] += 1
	i += 1

for i in range(10):
	for j in range(10):
		if paper[(i,j)] == 0:
			counter += 1
print(counter)
print(max(paper.values()))

Submission status: Runtime Error

Solution code:
paper = [0 for i in range(100)]
white_points = None
deep_points = None

def small(x, y):
    p = [[x, y]]
    for i, j in zip([-1, 0, 1, 0], [0, -1, 0, 1]):
        p.append([x + i, y + j])
    return p

def middle(x, y):
    p = small(x, y)
    for i, j in zip([1, -1] * 2, [1, 1, -1, -1]):
        p.append([x + i, y + j])
    return p

def big(x, y):
    p = middle(x, y)
    for i, j in zip([-2, 0, 2, 0], [0, -2, 0, 2]):
        p.append([x + i, y + j])
    return p

while True:
    try:
        x, y, size = map(int, input().split(','))
    except:
        print(paper.count(0))
        print(max(paper))
        break

    if size == 1:
        bp = small(x, y)
    elif size == 2:
        bp = middle(x, y)
    elif size == 3:
        bp = big(x, y)
    for p in bp:
        paper[p[0] * 10 + p[1]] += 1

Submission status: Runtime Error

Solution code:
paper = [0 for i in range(100)]
white_points = None
deep_points = None

def small(x, y):
    p = [[x, y]]
    for i, j in zip([-1, 0, 1, 0], [0, -1, 0, 1]):
        p.append([x + i, y + j])
    return p

def middle(x, y):
    p = small(x, y)
    for i, j in zip([1, -1, 1, -1], [1, 1, -1, -1]):
        p.append([x + i, y + j])
    return p

def big(x, y):
    p = middle(x, y)
    for i, j in zip([-2, 0, 2, 0], [0, -2, 0, 2]):
        p.append([x + i, y + j])
    return p

while True:
    try:
        x, y, size = map(int, input().split(','))
    except:
        print(paper.count(0))
        print(max(paper))
        break

    if size == 1:
        bp = small(x, y)
    elif size == 2:
        bp = middle(x, y)
    elif size == 3:
        bp = big(x, y)
    for p in bp:
        if not 0 <= p[0] * 10 + p[1] <= 99: continue
        paper[p[1] * 10 + p[0]] += 1

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
def density_adder(array,x,y,delta_list):
    for dx,dy in zip(delta_list):
        cell_num = 10*(x-dx) + (y-dy) 
        if 0 <= cell_num <=100:
            array[10*x + y][2] += 1
            
while True:
    array = [[i,j,0] for i in range(10)
        for j in range(10)]
    try:
        x,y,size = map(int,raw_input().split())
        
    except EOFError:
        break
    
    small_delta_ls = [(0,0),(-1,0),(1,0),(0,-1),(0,1)] 
    medium_delta_ls = small_delta_ls + [(1,1),(1,-1),(-1,1),(-1,-1)]
    large_delta_ls = medium_delta_ls + [(-2,0),(2,0),(0,2),(0,-2)]
    
    if size == 1: # Small
        density_adder(array,x,y,small_delta_ls)
    elif size == 2: #　Medium
        density_adder(array,x,y,medium_delta_ls)
    elif size ==3 : # Large
        density_adder(array,x,y,large_delta_ls)
    
    ink_zero = 0
    densest = 0
    for k in xrange(100):
        if array[k][2]==0:
            ink_zero +=1
        if array[k][2] > densest:
            densest = array[k][2]
    
    print ink_zero
    print densest

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
def density_adder(array,x,y,delta_list):
    for k in delta_list:
        dx,dy = k
        cell_num = 10*(x-dx) + (y-dy) 
        if 0 <= cell_num <100:
            array[10*x + y][2] += 1

array = [[i,j,0] for i in range(10)
    for j in range(10)]   
input_list = []
while True:
    x,y,size = map(int,raw_input().split(","))
    input_list.append((x,y,size))
    
else:
    small_delta_ls = [(0,0),(-1,0),(1,0),(0,-1),(0,1)] 
    medium_delta_ls = small_delta_ls + [(1,1),(1,-1),(-1,1),(-1,-1)]
    large_delta_ls = medium_delta_ls + [(-2,0),(2,0),(0,2),(0,-2)]
    
    for j in input_list:
        x,y,size = j
        if size == 1: # Small
            density_adder(array,x,y,small_delta_ls)
        elif size == 2: #　Medium
            density_adder(array,x,y,medium_delta_ls)
        elif size ==3 : # Large
            density_adder(array,x,y,large_delta_ls)
        
    ink_zero = 0
    densest = 0
    for k in xrange(100):
        if array[k][2]==0:
            ink_zero +=1
        if array[k][2] > densest:
            densest = array[k][2]

    print ink_zero
    print densest

Submission status: Runtime Error

Solution code:
import sys
p = [[0 for a in range(10)] for b in range(10)]
def smallink(x,y):
    return [(x+i,y+j) for i in range(-1,2,1) for j in range(-1,2,1)\
            if abs(i)+abs(j)<=1 and x+i>=0 and y+j>=0]
def ink(x,y):
    return [(x+i,y+j) for i in range(-1,2,1) for j in range(-1,2,1)\
             if x+i>=0 and y+j>=0]
def bigink(x,y):
    return [(x+i,y+j) for i in range(-2,3,1) for j in range(-2,3,1)\
            if abs(i)+abs(j)<=2 and x+i>=0 and y+j>=0]

for dataset in sys.stdin:
    x,y,size=map(int,dataset.split(","))
    if size==1:
        L=smallink(x,y)
    elif size==2:
        L=ink(x,y)
    else:
        L=bigink(x,y)
    while len(L)!=0:
        point=L.pop(0)
        p[point[0]][point[1]]+=1

count=0
max=0
for i in range(10):
    for j in range(10):
        if(p[i][j]>max):
            max=p[i][j]
        if(p[i][j]==0):
            count+=1
print count
print max

Submission status: Runtime Error

Solution code:
import sys
p = [[0 for a in range(10)] for b in range(10)]
def smallink(x,y):
    return [(x+i,y+j) for i in range(-1,2,1) for j in range(-1,2,1)\
            if abs(i)+abs(j)<=1 and x+i>=0 and y+j>=0]
def ink(x,y):
    return [(x+i,y+j) for i in range(-1,2,1) for j in range(-1,2,1)\
            if x+i>=0 and y+j>=0]
def bigink(x,y):
    return [(x+i,y+j) for i in range(-2,3,1) for j in range(-2,3,1)\
            if abs(i)+abs(j)<=2 and x+i>=0 and y+j>=0]

for dataset in sys.stdin:
    x,y,size=map(int,dataset.split(","))
    if size==1:
        L=smallink(x,y)
    elif size==2:
        L=ink(x,y)
    else:
        L=bigink(x,y)
    while len(L)!=0:
        point=L.pop(0)
        p[point[0]][point[1]]+=1

count=0
max=0
for i in range(10):
    for j in range(10):
        if(p[i][j]>max):
            max=p[i][j]
        if(p[i][j]==0):
            count+=1
print count
print max

Submission status: Runtime Error

Solution code:
import sys
mat=[[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,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,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,0,0,0,0,0,0,0,0,0],
         [0,0,0,0,0,0,0,0,0,0]]
for line in sys.stdin.readlines():

    y, x, s=map(int,line.split(','))
    c=0
    max=0

    if(s==1):
        mat[x][y]=mat[x][y]+1
        mat[x][y+1]=mat[x][y+1]+1
        mat[x-1][y]=mat[x-1][y]+1
        mat[x][y-1]=mat[x][y-1]+1
        mat[x+1][y]=mat[x+1][y]+1
    elif(s==2):
        mat[x][y]=mat[x][y]+1
        mat[x][y+1]=mat[x][y+1]+1
        mat[x-1][y]=mat[x-1][y]+1
        mat[x][y-1]=mat[x][y-1]+1
        mat[x+1][y]=mat[x+1][y]+1
        mat[x-1][y+1]=mat[x-1][y+1]+1
        mat[x-1][y-1]=mat[x-1][y-1]+1
        mat[x+1][y+1]=mat[x+1][y+1]+1
        mat[x+1][y-1]=mat[x+1][y-1]+1
    elif(s==3):
        mat[x][y]=mat[x][y]+1
        mat[x][y+1]=mat[x][y+1]+1
        mat[x-1][y]=mat[x-1][y]+1
        mat[x][y-1]=mat[x][y-1]+1
        mat[x+1][y]=mat[x+1][y]+1
        mat[x-1][y+1]=mat[x-1][y+1]+1
        mat[x-1][y-1]=mat[x-1][y-1]+1
        mat[x+1][y+1]=mat[x+1][y+1]+1
        mat[x+1][y-1]=mat[x+1][y-1]+1
        mat[x-2][y]=mat[x-2][y]+1
        mat[x+2][y]=mat[x+2][y]+1
        mat[x][y+2]=mat[x][y+2]+1
        mat[x][y-2]=mat[x][y-2]+1
print (mat)
for i in range(10):
    for j in range(10):
        if(mat[i][j]==0):
            c=c+1
        if(mat[i][j]>max):
            max=mat[i][j]
print(c)
print(max)

Submission status: Runtime Error

Solution code:
import sys
mat=[[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,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,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,0,0,0,0,0,0,0,0,0],
         [0,0,0,0,0,0,0,0,0,0]]
for line in sys.stdin.readlines():

    y, x, s=map(int,line.split(','))
    c=0
    max=0

    if(s==1):
        mat[x][y]=mat[x][y]+1
        mat[x][y+1]=mat[x][y+1]+1
        mat[x-1][y]=mat[x-1][y]+1
        mat[x][y-1]=mat[x][y-1]+1
        mat[x+1][y]=mat[x+1][y]+1
    elif(s==2):
        mat[x][y]=mat[x][y]+1
        mat[x][y+1]=mat[x][y+1]+1
        mat[x-1][y]=mat[x-1][y]+1
        mat[x][y-1]=mat[x][y-1]+1
        mat[x+1][y]=mat[x+1][y]+1
        mat[x-1][y+1]=mat[x-1][y+1]+1
        mat[x-1][y-1]=mat[x-1][y-1]+1
        mat[x+1][y+1]=mat[x+1][y+1]+1
        mat[x+1][y-1]=mat[x+1][y-1]+1
    elif(s==3):
        mat[x][y]=mat[x][y]+1
        mat[x][y+1]=mat[x][y+1]+1
        mat[x-1][y]=mat[x-1][y]+1
        mat[x][y-1]=mat[x][y-1]+1
        mat[x+1][y]=mat[x+1][y]+1
        mat[x-1][y+1]=mat[x-1][y+1]+1
        mat[x-1][y-1]=mat[x-1][y-1]+1
        mat[x+1][y+1]=mat[x+1][y+1]+1
        mat[x+1][y-1]=mat[x+1][y-1]+1
        mat[x-2][y]=mat[x-2][y]+1
        mat[x+2][y]=mat[x+2][y]+1
        mat[x][y+2]=mat[x][y+2]+1
        mat[x][y-2]=mat[x][y-2]+1
for i in range(10):
    for j in range(10):
        if(mat[i][j]==0):
            c=c+1
        if(mat[i][j]>max):
            max=mat[i][j]
print(c)
print(max)

Submission status: Runtime Error

Solution code:
import sys
mat=[[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,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,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,0,0,0,0,0,0,0,0,0],
     [0,0,0,0,0,0,0,0,0,0]]
c=0
max=0

for line in sys.stdin.readlines():

    y, x, s=map(int,line.split(','))
    if(s==1):
        mat[x][y]=mat[x][y]+1
        mat[x][y+1]=mat[x][y+1]+1
        mat[x-1][y]=mat[x-1][y]+1
        mat[x][y-1]=mat[x][y-1]+1
        mat[x+1][y]=mat[x+1][y]+1
    elif(s==2):
        mat[x][y]=mat[x][y]+1
        mat[x][y+1]=mat[x][y+1]+1
        mat[x-1][y]=mat[x-1][y]+1
        mat[x][y-1]=mat[x][y-1]+1
        mat[x+1][y]=mat[x+1][y]+1
        mat[x-1][y+1]=mat[x-1][y+1]+1
        mat[x-1][y-1]=mat[x-1][y-1]+1
        mat[x+1][y+1]=mat[x+1][y+1]+1
        mat[x+1][y-1]=mat[x+1][y-1]+1
    elif(s==3):
        mat[x][y]=mat[x][y]+1
        mat[x][y+1]=mat[x][y+1]+1
        mat[x-1][y]=mat[x-1][y]+1
        mat[x][y-1]=mat[x][y-1]+1
        mat[x+1][y]=mat[x+1][y]+1
        mat[x-1][y+1]=mat[x-1][y+1]+1
        mat[x-1][y-1]=mat[x-1][y-1]+1
        mat[x+1][y+1]=mat[x+1][y+1]+1
        mat[x+1][y-1]=mat[x+1][y-1]+1
        mat[x-2][y]=mat[x-2][y]+1
        mat[x+2][y]=mat[x+2][y]+1
        mat[x][y+2]=mat[x][y+2]+1
        mat[x][y-2]=mat[x][y-2]+1
for i in range(10):
    for j in range(10):
        if(mat[i][j]==0):
            c=c+1
        if(mat[i][j]>max):
            max=mat[i][j]
print(c)
print(max)

Submission status: Runtime Error

Solution code:
import sys

drops = [None,
         [(-1,0),(1,0),(0,-1),(0,1)],
         [(-1,0),(1,0),(0,-1),(0,1),(-1,1),(-1,-1),(1,-1),(1,1)],
         [(-1,0),(1,0),(0,-1),(0,1),(-1,1),(-1,-1),(1,-1),(1,1),(-2,0),(2,0),(0,-2),(0,2)]]

B = [[0 for j in xrange(10)] for i in xrange(10)]

for line in sys.stdin:
    x, y, s = map(int, line.rstrip().split(','))
    for dx, dy in drops[s]:
        nx, ny = x+dx, y+dy
        if (0 <= nx <= 9 or 0 <= ny <= 9):
            B[ny][nx] += 1

emp, m = 0, 0
for i in xrange(10):
    for j in xrange(10):
        if B[i][j] == 0:
            emp += 1
        m = max(m, B[i][j])
print emp
print m

Submission status: Runtime Error

Solution code:
import sys

drops = [None,
         [(-1,0),(1,0),(0,-1),(0,1)],
         [(-1,0),(1,0),(0,-1),(0,1),(-1,1),(-1,-1),(1,-1),(1,1)],
         [(-1,0),(1,0),(0,-1),(0,1),(-1,1),(-1,-1),(1,-1),(1,1),(-2,0),(2,0),(0,-2),(0,2)]]

B = [[0 for j in xrange(10)] for i in xrange(10)]

for line in sys.stdin:
    x, y, s = map(int, line.rstrip().split(','))
    B[x][y] += 1
    for dx, dy in drops[s]:
        nx, ny = x+dx, y+dy
        if (0 <= nx <= 9 or 0 <= ny <= 9):
            B[ny][nx] += 1

emp, m = 0, 0
for i in xrange(10):
    for j in xrange(10):
        if B[i][j] == 0:
            emp += 1
        m = max(m, B[i][j])
print emp
print m

Submission status: Runtime Error

Solution code:
import sys

drops = [None,
         [(0,0),(-1,0),(1,0),(0,-1),(0,1)],
         [(0,0),(-1,0),(1,0),(0,-1),(0,1),(-1,1),(-1,-1),(1,-1),(1,1)],
         [(0,0),(-1,0),(1,0),(0,-1),(0,1),(-1,1),(-1,-1),(1,-1),(1,1),(-2,0),(2,0),(0,-2),(0,2)]]

B = [[0 for j in xrange(10)] for i in xrange(10)]

for line in sys.stdin:
    x, y, s = map(int, line.rstrip().split(','))
    for dx, dy in drops[s]:
        nx, ny = x+dx, y+dy
        if (0 <= nx <= 9 or 0 <= ny <= 9):
            B[ny][nx] += 1

emp, m = 0, 0
for i in xrange(10):
    for j in xrange(10):
        if B[i][j] == 0:
            emp += 1
        m = max(m, B[i][j])
print emp
print m

Submission status: Runtime Error

Solution code:
Masu = []
def access(x,y):
    if x < 0 or y < 0:
        return
    Masu[y][x] += 1

for i in range(10):
    Masu.append([0,0,0,0,0,0,0,0,0,0])
kosu = 0
komax = 0
while True:
    try:
        
        x,y,s = map(int,input().split(","))
        if s == 1:
            for j in range(3):
                access(y +1 - j,x)
            access(y,x - 1)
            access(y,x + 1)

        elif s == 2:
            for k in range(3):
                for l in range(3):
                    access(y + 1 - k,x + 1 -l)
        elif s == 3:
            for k in range(3):
                for l in range(3):
                    access(y + 1 - k,x + 1 -l)
            access(y - 2,x)
            access(y + 2,x)
            access(y,x + 2)
            access(y,x - 2)
               
    except (EOFError,ValueError):
        for i in range(10):
            kosu += Masu[i].count(0)
        for j in range(10):
            if komax < max(Masu[j]):
                komax = max(Masu[j])
        print(kosu)
        print(komax)
        break

Submission status: Runtime Error

Solution code:
Masu = []
def access(x,y):
    if x < 0 or y < 0:
        return
    Masu[y][x] += 1

for i in range(10):
    Masu.append([0,0,0,0,0,0,0,0,0,0])
kosu = 0
komax = 0
while True:
    try:
        
        x,y,s = map(int,input().split(","))
        if s == 1:
            for j in range(3):
                access(y +1 - j,x)
            access(y,x - 1)
            access(y,x + 1)

        elif s == 2:
            for k in range(3):
                for l in range(3):
                    access(y + 1 - k,x + 1 -l)
        elif s == 3:
            for k in range(3):
                for l in range(3):
                    access(y + 1 - k,x + 1 -l)
            access(y - 2,x)
            access(y + 2,x)
            access(y,x + 2)
            access(y,x - 2)
               
    except EOFError:
        for i in range(10):
            kosu += Masu[i].count(0)
        for j in range(10):
            if komax < max(Masu[j]):
                komax = max(Masu[j])
        print(kosu)
        print(komax)
        break

Submission status: Runtime Error

Solution code:
t = [[0 for i in range(10)] for j in range(10)]
case1 = [(0, 0), (0, -1), (1, 0), (0, 1), (-1, 0)]
case2 = [(1, -1), (1, 1), (-1, 1), (-1, -1)]
case3 = [(0, -2), (2, 0), (0, 2), (-2, 0)]
while True:
    try:
        x, y, s = map(int, input().split(','))
    except:
        break
    for c in [case1, case2, case3][:s]:
        for _x, _y in c:
            if y+_y < 0 or x+_x < 0:
                continue
            t[y+_y][x+_x] += 1
            
print(sum(1 for l in t for v in l if not v))
print(max(v for l in t for v in l))

Submission status: Runtime Error

Solution code:
paper = [[0 for _ in range(14)] for _ in range(14)]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

while True:
    try:
        x, y, s = map(int, input().split())
    except EOFError:
        break
    x += 2
    y += 2
    paper[x][y] += 1
    for i in range(4):
        paper[x + dx[i]][y + dy[i]] += 1
    if s >= 2:
        for i in range(4):
            paper[x + dx[i] + dx[(i + 1) % 4]][y + dy[i] + dy[(i + 1) % 4]] += 1
    if s >= 3:
        for i in range(4):
            paper[x + 2 * dx[i]][y + 2 * dy[i]] += 1

paper = paper[2:12]
for i in range(10):
    paper[i] = paper[i][2:12]
print(sum(paper[i].count(0) for i in range(10)))
print(max(paper[i][j] for i in range(10) for j in range(10)))

Submission status: Runtime Error

Solution code:
import sys
paper = [[0 for i in range(10)] for j in range(10)]
for line in sys.stdin:
    if line == "\n":
        break
    x, y, size = map(int, line.split(","))
    if size == 1:
        paper[y][x] += 1
        paper[y-1][x] += 1
        paper[y+1][x] += 1
        paper[y][x-1] += 1
        paper[y][x+1] += 1
    elif size == 2:
        for i in range(y-1, y+2):
            for j in range(x-1, x+2):
                paper[i][j] += 1
    else:
        for i in range(y-1, y+2):
            for j in range(x-1, x+2):
                paper[i][j] += 1
        paper[y-2][x] += 1
        paper[y+2][x] += 1
        paper[y][x-2] += 1
        paper[y][x+2] += 1
    #for i in range(10):
        #for j in range(10):
            #if j == 10 - 1:
                #print(paper[i][j])
            #else:
                #print(paper[i][j], end=" ")
cnt = 0
max_n = 0
for i in range(10):
    for j in range(10):
        if paper[i][j] == 0:
            cnt += 1
        if max_n < paper[i][j]:
            max_n = paper[i][j]
print(cnt)
print(max_n)