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: Wrong Answer

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(1,1,1)

Submission status: Wrong Answer

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: Wrong Answer

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(1,1,1)

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: Wrong Answer

Solution code:
#sheet...紙全体、sheet[x][y]は(x, y)のインクの濃さ
sheet = [[0 for _ in range(10)] for _ in range(10)]

#小、中、大のインクの範囲
small_range = ((0, 0), (1, 0), (0, 1), (-1, 0), (0, 1))
middle_range = ((0, 0), (1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1))
large_range = ((0, 0), (1, 0), (2, 0), (1, 1), (0, 1), (0, 2), (-1, 1), (-1, 0), (-2, 0), (-1, -1), (0, -1), (0, -2), (1, -1))

#範囲内か判定してインクを足す
def drop(x, y, drop_range):
  for dx, dy in drop_range:
    newx, newy = x + dx, y + dy
    if 0 <= newx <= 9 and 0 <= newy <= 9:
      sheet[newx][newy] += 1

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

    if s == 1:
      drop(x, y, small_range)
    elif s == 2:
      drop(x, y, middle_range)
    else:
      drop(x, y, large_range)

  except EOFError:
    break

#0の個数
zero_cnt = 0

#インクの最大値
max_ink = 0

for x in range(10):
  for y in range(10):
    ink = sheet[x][y]

    if ink == 0:
      zero_cnt += 1

    if max_ink < ink:
      max_ink = ink

print(zero_cnt)
print(max_ink)

Submission status: Wrong Answer

Solution code:
class Cloth(object):
    cell = None
    def __init__(self, x, y):
        self.cell = list([list([0 for i in range(y)]) for i in range(x)])
    def point(self, x, y):
        try:
            self.cell[x][y] += 1
        except IndexError:
            pass
    def small(self, x, y):
        self.point(x, y + 1)
        self.point(x - 1, y)
        self.point(x, y)
        self.point(x + 1, y)
        self.point(x, y - 1)
    def medium(self, x, y):
        self.small(x, y)
        self.point(x + 1, y + 1)
        self.point(x - 1, y + 1)
        self.point(x + 1, y - 1)
        self.point(x - 1, y - 1)
    def large(self, x, y):
        self.medium(x, y)
        self.point(x, y + 2)
        self.point(x - 2, y)
        self.point(x + 2, y)
        self.point(x, y - 2)
cloth = Cloth(10, 10)
while True:
    try:
        (x, y, s) = map(int, raw_input().split(','))
        if s == 1:
            cloth.small(x, y)
        elif s == 2:
            cloth.medium(x, y)
        elif s == 3:
            cloth.large(x, y)
    except EOFError:
        break
print reduce(lambda x,y:x+y,map(lambda x:x.count(0),cloth.cell))
print max(map(max,cloth.cell))

Submission status: Wrong Answer

Solution code:
class Cloth(object):
    cell = None
    x = 0
    y = 0
    def __init__(self, x, y):
        self.cell = list([list([0 for i in range(y)]) for i in range(x)])
        self.x = x
        self.y = y
    def check(self, x, y):
        try:
            self.cell[x][y] += 0
            return True
        except IndexError:
            return False
    def point(self, x, y):
        try:
            self.cell[x][y] += 1
        except IndexError:
            pass
    def small(self, x, y):
        if not self.check(x, y):
            return
        self.point(x, y + 1)
        self.point(x - 1, y)
        self.point(x, y)
        self.point(x + 1, y)
        self.point(x, y - 1)
    def medium(self, x, y):
        if not self.check(x, y):
            return
        self.small(x, y)
        self.point(x + 1, y + 1)
        self.point(x - 1, y + 1)
        self.point(x + 1, y - 1)
        self.point(x - 1, y - 1)
    def large(self, x, y):
        if not self.check(x, y):
            return
        self.medium(x, y)
        self.point(x, y + 2)
        self.point(x - 2, y)
        self.point(x + 2, y)
        self.point(x, y - 2)
cloth = Cloth(10, 10)
while True:
    print cloth.cell
    try:
        (x, y, s) = map(int, raw_input().split(','))
        if s == 1:
            cloth.small(x, y)
        elif s == 2:
            cloth.medium(x, y)
        elif s == 3:
            cloth.large(x, y)
        else:
            break
    except EOFError:
        break
print reduce(lambda x,y:x+y,map(lambda x:x.count(0),cloth.cell))
print max(map(max,cloth.cell))

Submission status: Wrong Answer

Solution code:
class Cloth(object):
    cell = None
    x = 0
    y = 0
    def __init__(self, x, y):
        self.cell = list([list([0 for i in range(y)]) for i in range(x)])
        self.x = x
        self.y = y
    def check(self, x, y):
        try:
            self.cell[x][y] += 0
            return True
        except IndexError:
            return False
    def point(self, x, y):
        try:
            self.cell[x][y] += 1
        except IndexError:
            pass
    def small(self, x, y):
        if not self.check(x, y):
            return
        self.point(x, y + 1)
        self.point(x - 1, y)
        self.point(x, y)
        self.point(x + 1, y)
        self.point(x, y - 1)
    def medium(self, x, y):
        if not self.check(x, y):
            return
        self.small(x, y)
        self.point(x + 1, y + 1)
        self.point(x - 1, y + 1)
        self.point(x + 1, y - 1)
        self.point(x - 1, y - 1)
    def large(self, x, y):
        if not self.check(x, y):
            return
        self.medium(x, y)
        self.point(x, y + 2)
        self.point(x - 2, y)
        self.point(x + 2, y)
        self.point(x, y - 2)
cloth = Cloth(10, 10)
while True:
    print cloth.cell
    try:
        (x, y, s) = map(lambda x:int(x)-1, raw_input().split(','))
        if s == 0:
            cloth.small(x, y)
        elif s == 1:
            cloth.medium(x, y)
        elif s == 2:
            cloth.large(x, y)
        else:
            break
    except EOFError:
        break
print reduce(lambda x,y:x+y,map(lambda x:x.count(0),cloth.cell))
print max(map(max,cloth.cell))

Submission status: Wrong Answer

Solution code:
class Cloth(object):
    cell = None
    x = 0
    y = 0
    def __init__(self, x, y):
        self.cell = list([list([0 for i in range(y)]) for i in range(x)])
        self.x = x
        self.y = y
    def check(self, x, y):
        try:
            self.cell[x][y] += 0
            return True
        except IndexError:
            return False
    def point(self, x, y):
        try:
            self.cell[x][y] += 1
        except IndexError:
            pass
    def small(self, x, y):
        if not self.check(x, y):
            return
        self.point(x, y + 1)
        self.point(x - 1, y)
        self.point(x, y)
        self.point(x + 1, y)
        self.point(x, y - 1)
    def medium(self, x, y):
        if not self.check(x, y):
            return
        self.small(x, y)
        self.point(x + 1, y + 1)
        self.point(x - 1, y + 1)
        self.point(x + 1, y - 1)
        self.point(x - 1, y - 1)
    def large(self, x, y):
        if not self.check(x, y):
            return
        self.medium(x, y)
        self.point(x, y + 2)
        self.point(x - 2, y)
        self.point(x + 2, y)
        self.point(x, y - 2)
cloth = Cloth(10, 10)
while True:
    try:
        (x, y, s) = map(lambda x:int(x)-1, raw_input().split(','))
        if s == 0:
            cloth.small(x, y)
        elif s == 1:
            cloth.medium(x, y)
        elif s == 2:
            cloth.large(x, y)
        else:
            break
    except EOFError:
        break
print reduce(lambda x,y:x+y,map(lambda x:x.count(0),cloth.cell))
print max(map(max,cloth.cell))

Submission status: Wrong Answer

Solution code:
class Cloth(object):
    cell = None
    x = 0
    y = 0
    def __init__(self, x, y):
        self.cell = list([list([0 for i in range(y)]) for i in range(x)])
        self.x = x
        self.y = y
    def check(self, x, y):
        try:
            self.cell[x][y] += 0
            return True
        except IndexError:
            return False
    def point(self, x, y):
        try:
            self.cell[x][y] += 1
        except IndexError:
            pass
    def small(self, x, y):
        if not self.check(x, y):
            return
        self.point(x, y + 1)
        self.point(x - 1, y)
        self.point(x, y)
        self.point(x + 1, y)
        self.point(x, y - 1)
    def medium(self, x, y):
        if not self.check(x, y):
            return
        self.small(x, y)
        self.point(x + 1, y + 1)
        self.point(x - 1, y + 1)
        self.point(x + 1, y - 1)
        self.point(x - 1, y - 1)
    def large(self, x, y):
        if not self.check(x, y):
            return
        self.medium(x, y)
        self.point(x, y + 2)
        self.point(x - 2, y)
        self.point(x + 2, y)
        self.point(x, y - 2)
cloth = Cloth(10, 10)
while True:
    try:
        (x, y, s) = map(lambda x:int(x)-1, raw_input().split(','))
        if s == 0:
            cloth.small(x, y)
        elif s == 1:
            cloth.medium(x, y)
        elif s == 2:
            cloth.large(x, y)
    except EOFError:
        break
print reduce(lambda x,y:x+y,map(lambda x:x.count(0),cloth.cell))
print max(map(max,cloth.cell))

Submission status: Wrong Answer

Solution code:
cell = [[0] * 10 for i in xrange(10)]

large = [[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]]

medium= [[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]]

small = [[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]]

size = [0,small,medium,large]

while True:
    try:
        x, y, s = [int(i) for i in raw_input().split(',')]
    except EOFError:
        break
    except ValueError:
        break
    p = size[s]
    for i in xrange(5):
        for j in xrange(5):
            try:
                cell[i+x-2][j+y-2] += p[i][j]
            except IndexError:
                pass
print reduce(lambda x,y:x+y,map(lambda x:x.count(0),cell))
print max(map(max,cell))

Submission status: Wrong Answer

Solution code:
cell = [[0] * 10 for i in xrange(10)]

large = [[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]]

medium= [[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]]

small = [[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]]

size = [0,small,medium,large]

while True:
    try:
        x, y, s = [int(i) for i in raw_input().split(',')]
    except EOFError:
        break
    except ValueError:
        break
    p = size[s]
    for i in xrange(5):
        for j in xrange(5):
            try:
                cell[i+x][j+y] += p[i+2][j+2]
            except IndexError:
                pass
print reduce(lambda x,y:x+y,map(lambda x:x.count(0),cell))
print max(map(max,cell))

Submission status: Wrong Answer

Solution code:
cell = [[0] * 10 for i in xrange(10)]

large = [[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]]

medium= [[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]]

small = [[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]]

size = [0,small,medium,large]

while True:
    try:
        x, y, s = [int(i) for i in raw_input().split(',')]
    except EOFError:
        break
    except ValueError:
        break
    p = size[s]
    for i in xrange(5):
        for j in xrange(5):
            try:
                cell[i+y-2][j+x-2] += p[i][j]
            except IndexError:
                pass
    print cell
print reduce(lambda x,y:x+y,map(lambda x:x.count(0),cell))
print max(map(max,cell))

Submission status: Wrong Answer

Solution code:
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)
from sys import stdin
from collections import Counter

NUM = [[0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0],
       [0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0],
       [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]
paper = Counter()
for line in stdin:
    if not line.strip():
        break
    x, y, size = (int(s) for s in line.split(','))

    xidx = [x, x-1, x, x+1, x-2, x-1, x, x+1, x+2, x-1, x, x+1, x]
    yidx = [y-2, y-1, y-1, y-1, y, y, y, y, y, y+1, y+1, y+1, y+2]
    val = iter(NUM[size-1])

    for x, y in zip(xidx, yidx):
        paper[x + y * 10] += next(val)

print(sum(1 for i in xrange(100) if not paper[i]))
print(max(paper[i] for i in xrange(100)))

Submission status: Wrong Answer

Solution code:
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)
from sys import stdin
from collections import Counter

NUM = [[0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0],
       [0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0],
       [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]
paper = Counter()
for line in stdin:
    if not line.strip():
        break
    x, y, size = (int(s) for s in line.split(','))

    xidx = [x, x-1, x, x+1, x-2, x-1, x, x+1, x+2, x-1, x, x+1, x]
    yidx = [y-2, y-1, y-1, y-1, y, y, y, y, y, y+1, y+1, y+1, y+2]
    val = iter(NUM[size-1])

    for a, b in zip(xidx, yidx):
        if a < 0 or 9 < a or b < 0 or 9 < b:
            continue
        paper[a + b * 10] += next(val)

for y in xrange(10):
    for x in xrange(10):
        print('{:02d} '.format(paper[x + y * 10]), end='')
    print()
print(sum(1 for i in xrange(100) if not paper[i]))
print(max(paper[i] for i in xrange(100)))

Submission status: Wrong Answer

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] > max: max = mass[p][q]
print white
print max

Submission status: Wrong Answer

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(','))
		x += 2 ; y += 2
		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] > max: max = mass[p][q]
print white
print max

Submission status: Wrong Answer

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
        try:
            for p in r:
                self.paper[p[0]][p[1]] += 1
        except:
            pass
        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: Wrong Answer

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(self, 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: Wrong Answer

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(self, p):
        if 0 <= p[0] < 10 and 0 <= p[1] < 10:
            True
        else:
            False



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: Wrong Answer

Solution code:
def drop(x,y):
    global paper
    if 0<=x<10 and 0<=y<10: paper[y][x]+=1
    return

def ink(x,y,size):
    drop(x-1,y)
    drop(x+1,y)
    drop(x,y-1)
    drop(x,y+1)
    if size==1: return
    drop(x-1,y-1)
    drop(x-1,y+1)
    drop(x+1,y-1)
    drop(x+1,y+1)
    if size==2: return
    drop(x-2,y)
    drop(x+2,y)
    drop(x,y-2)
    drop(x,y+2)
    return

paper = [[0 for i in range(10)] for j in range(10)]
while True:
    try:
        x,y,size = map(int, raw_input().split(","))
        ink(x,y,size)
    except:
        break

print sum([e.count(0) for e in paper])
print max([max(e) for e in paper])

Submission status: Wrong Answer

Solution code:
import sys

SIZE = 10
paper = []

def main():
    init()

    for line in sys.stdin:
        data = line.strip().split(',')
        i = int(data[0])
        j = int(data[1])
        size = int(data[2])

        if size == 1:
            drop_small(i, j)
        elif size == 2:
            drop_medium(i, j)
        elif size == 3:
            drop_large(i, j)

    print str(count_white()) + " " + str(find_max())

def find_max():
    mx = 0
    for i in xrange(SIZE):
        for j in xrange(SIZE):
            mx = max(mx, paper[i][j])

    return mx

def count_white():
    c = 0
    for i in xrange(SIZE):
        for j in xrange(SIZE):
            if paper[i][j] == 0:
                c += 1

    return c

def init():
    global paper
    for i in xrange(SIZE):
        paper.append([0]*SIZE)


def check(i, j):
    if i < 0 or SIZE <= i:
        return False
    if j < 0 or SIZE <= j:
        return False

    return True


def drop(i, j):
    global paper
    if not check(i, j):
        return False

    paper[i][j] += 1
    return True


def drop_small(i, j):
    drop(i, j)
    drop(i - 1, j)
    drop(i + 1, j)
    drop(i, j - 1)
    drop(i, j + 1)


def drop_medium(i, j):
    drop_small(i, j)
    drop(i - 1, j - 1)
    drop(i - 1, j + 1)
    drop(i + 1, j - 1)
    drop(i + 1, j + 1)


def drop_large(i, j):
    drop_medium(i, j)
    drop(i - 2, j)
    drop(i, j - 2)
    drop(i, j + 2)
    drop(i + 2, j)

main()

Submission status: Wrong Answer

Solution code:
paper =	[[0 for	i	in range(14)] for i in	range(14)]

while True:
    try:
        x, y, s	= map(int, raw_input())
	x += 2
	y += 2
        if s == 1:
            paper[x][y]	+= 1
      	    for i in range(-1,1,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:
            for i in range(-1,2):
                for j in range(-1,2):
                    paper[x+i][y+j] += 1
            paper[x+2][y] += 1; paper[x-2][y] += 1
            paper[x][y+2] += 1; paper[x][y-2] += 1
    except:
	break

white =	0
for i in range(2,11):
    for	j in range(2,11):
	if paper[i][j] == 0:
            white += 1
print white
print max(paper)

Submission status: Wrong Answer

Solution code:
paper =	[[0 for	i	in range(14)] for i in	range(14)]

while True:
    try:
        x, y, s	= map(int, raw_input())
	x += 2
	y += 2
        if s == 1:
            paper[x][y]	+= 1
      	    for i in range(-1,1,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:
            for i in range(-1,2):
                for j in range(-1,2):
                    paper[x+i][y+j] += 1
            paper[x+2][y] += 1; paper[x-2][y] += 1
            paper[x][y+2] += 1; paper[x][y-2] += 1
    except:
	break

white =	0
for i in range(2,13):
    for	j in range(2,13):
	if paper[i][j] == 0:
            white += 1
print white
print max(paper)

Submission status: Wrong Answer

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:
            for i in range(-1,2):
                for j in range(-1,2):
                    paper[x+i][y+j] += 1
            paper[x+2][y] += 1; paper[x-2][y] += 1
            paper[x][y+2] += 1; paper[x][y-2] += 1
    except:
        break

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

print white
print max

Submission status: Wrong Answer

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 white
print max