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:
#!/usr/bin/python

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:
        if not 0 <= p[0] * 10 + p[1] <= 99: continue
        paper[p[0] * 10 + p[1]] += 1

Submission status: Wrong Answer

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[1] * 10 + p[0] <= 99: continue
        paper[p[1] * 10 + p[0]] += 1

Submission status: Wrong Answer

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:
    try:
        x,y,size = map(int,raw_input().split(","))
        input_list.append((x,y,size))
    except:
        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)]

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

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[cell_num][2] += 1

array = [[i,j,0] for i in range(10)
    for j in range(10)]   
input_list = []
while True:
    try:
        x,y,size = map(int,raw_input().split(","))
        input_list.append((x,y,size))
    except:
        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)]

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

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[cell_num][2] += 1
    return array

array = [[i,j,0] for i in range(10)
    for j in range(10)]   
input_list = []
while True:
    try:
        x,y,size = map(int,raw_input().split(","))
        input_list.append((x,y,size))
    except:
        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)]

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

Solution code:
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]

while True:
    try:
        x,y,size=map(int,raw_input().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
    except:
        break

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

Solution code:
#encoding=utf-8

import sys
ans = 0
par, num = [], []
for i in sys.stdin:
    num.append(map(int, i.split(",")))

for i in xrange(10):
    par.append([0,0,0,0,0,0,0,0,0,0])
for i in xrange(len(num)):
    try:
        par[num[i][1]][num[i][0]] += 1
        par[num[i][1] - 1][num[i][0]] += 1
        par[num[i][1] + 1][num[i][0]] += 1
        par[num[i][1]][num[i][0] - 1] += 1
        par[num[i][1]][num[i][0] + 1] += 1
    except:
        pass

    if num[i][2] == 2 or num[i][2] == 3:
        try:
            par[num[i][1] - 1][num[i][0] - 1] += 1
            par[num[i][1] - 1][num[i][0] + 1] += 1
            par[num[i][1] + 1][num[i][0] - 1] += 1
            par[num[i][1] + 1][num[i][0] + 1] += 1
        except:
            pass
        if num[i][2] == 3:
            try:
                par[num[i][1] - 2][num[i][0]] += 1
                par[num[i][1]    ][num[i][0] - 2] += 1
                par[num[i][1] + 2][num[i][0]] += 1
                par[num[i][1]    ][num[i][0] + 2] += 1
            except:
                pass
for i in xrange(10):
    for j in xrange(10):
        if par[i][j] == 0:
            ans += 1

print ans
print max(max(par))

Submission status: Wrong Answer

Solution code:
#encoding=utf-8

import sys
ans = 0
par, num = [], []
for i in sys.stdin:
    num.append(map(int, i.split(",")))

for i in xrange(10):
    par.append([0,0,0,0,0,0,0,0,0,0])
for i in xrange(len(num)):
    try: par[num[i][1]][num[i][0]] += 1
    except: pass
    try: par[num[i][1] - 1][num[i][0]] += 1
    except: pass
    try: par[num[i][1] + 1][num[i][0]] += 1
    except: pass
    try: par[num[i][1]][num[i][0] - 1] += 1
    except: pass
    try: par[num[i][1]][num[i][0] + 1] += 1
    except: pass
    if num[i][2] == 2 or num[i][2] == 3:
        try:par[num[i][1] - 1][num[i][0] - 1] += 1
        except: pass
        try: par[num[i][1] - 1][num[i][0] + 1] += 1
        except: pass
        try: par[num[i][1] + 1][num[i][0] - 1] += 1
        except: pass
        try: par[num[i][1] + 1][num[i][0] + 1] += 1
        except: pass
        if num[i][2] == 3:
            try: par[num[i][1] - 2][num[i][0]] += 1
            except: pass
            try: par[num[i][1]    ][num[i][0] - 2] += 1
            except: pass
            try: par[num[i][1] + 2][num[i][0]] += 1
            except: pass
            try: par[num[i][1]    ][num[i][0] + 2] += 1
            except: pass

for i in xrange(10):
    for j in xrange(10):
        if par[i][j] == 0:
            ans += 1

print ans
print max(max(par))

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:
            return True
        else:
            return 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:
# -*- coding: utf-8 -*-

import sys

def small_inc(x, y, cells):
    cells[x][y] += 1
    if y > 0:
        cells[x][y-1] += 1
    if x > 0:
        cells[x-1][y] += 1
    if x < MAPSIZE-1:
        cells[x+1][y] += 1
    if y < MAPSIZE-1:
        cells[x][y+1] += 1

def medium_inc(x, y, cells):
    if y > 0:
        cells[x][y-1] += 1
        if x > 0:
            cells[x-1][y-1] += 1
        if x < MAPSIZE-1:
            cells[x+1][y-1] += 1
    cells[x][y] += 1
    if x > 0:
        cells[x-1][y] += 1
    if x < MAPSIZE-1:
        cells[x+1][y] += 1
    if y < MAPSIZE-1:
        cells[x][y-1] += 1
        if x > 0:
            cells[x-1][y+1] += 1
        if x < MAPSIZE-1:
            cells[x+1][y+1] += 1

def large_inc(x, y, cells):
    if y > 1:
        cells[x][y-2] += 1
    if y > 0:
        cells[x][y-1] += 1
        if x > 0:
            cells[x-1][y-1] += 1
        if x < MAPSIZE-1:
            cells[x+1][y-1] += 1
    cells[x][y] += 1
    if x > 1:
        cells[x-2][y] += 1
    if x > 0:
        cells[x-1][y] += 1
    if x < MAPSIZE-1:
        cells[x+1][y] += 1
    if x < MAPSIZE-2:
        cells[x+2][y] += 1
    if y < MAPSIZE-1:
        cells[x][y-1] += 1
        if x > 0:
            cells[x-1][y+1] += 1
        if x < MAPSIZE-1:
            cells[x+1][y+1] += 1
    if y < MAPSIZE-2:
        cells[x][y+2] += 1

SMALL = 1
MEDIUM = 2
LARGE = 3
MAPSIZE = 10

cells = [[0 for i in range(MAPSIZE)] for j in range(MAPSIZE)]
for line in sys.stdin:
    x , y, size = map(int, line.split(','))
    if size == SMALL:
        small_inc(x, y, cells)
    elif size == MEDIUM:
        medium_inc(x, y, cells)
    elif size == LARGE:
        large_inc(x, y, cells)
count = max_d = 0
for i in range(MAPSIZE):
    for j in range(MAPSIZE):
        if cells[i][j] == 0:
            count += 1
        else:
            max_d = max(max_d, cells[i][j])
print count
print max_d

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys

def small_inc(x, y, cells):
    cells[x][y] += 1
    if y > 0:
        cells[x][y-1] += 1
    if x > 0:
        cells[x-1][y] += 1
    if x < MAPSIZE-1:
        cells[x+1][y] += 1
    if y < MAPSIZE-1:
        cells[x][y+1] += 1

def medium_inc(x, y, cells):
    if y > 0:
        cells[x][y-1] += 1
        if x > 0:
            cells[x-1][y-1] += 1
        if x < MAPSIZE-1:
            cells[x+1][y-1] += 1
    cells[x][y] += 1
    if x > 0:
        cells[x-1][y] += 1
    if x < MAPSIZE-1:
        cells[x+1][y] += 1
    if y < MAPSIZE-1:
        cells[x][y+1] += 1
        if x > 0:
            cells[x-1][y+1] += 1
        if x < MAPSIZE-1:
            cells[x+1][y+1] += 1

def large_inc(x, y, cells):
    if y > 1:
        cells[x][y-2] += 1
    if y > 0:
        cells[x][y-1] += 1
        if x > 0:
            cells[x-1][y-1] += 1
        if x < MAPSIZE-1:
            cells[x+1][y-1] += 1
    cells[x][y] += 1
    if x > 1:
        cells[x-2][y] += 1
    if x > 0:
        cells[x-1][y] += 1
    if x < MAPSIZE-1:
        cells[x+1][y] += 1
    if x < MAPSIZE-2:
        cells[x+2][y] += 1
    if y < MAPSIZE-1:
        cells[x][y+1] += 1
        if x > 0:
            cells[x-1][y+1] += 1
        if x < MAPSIZE-1:
            cells[x+1][y+1] += 1
    if y < MAPSIZE-2:
        cells[x][y+2] += 1

SMALL = 1
MEDIUM = 2
LARGE = 3
MAPSIZE = 10

cells = [[0 for i in range(MAPSIZE)] for j in range(MAPSIZE)]
for line in sys.stdin:
    x , y, size = map(int, line.split(','))
    if size == SMALL:
        small_inc(x, y, cells)
    elif size == MEDIUM:
        medium_inc(x, y, cells)
    elif size == LARGE:
        large_inc(x, y, cells)
count = max_d = 0
for i in range(MAPSIZE):
    for j in range(MAPSIZE):
        if cells[i][j] == 0:
            count += 1
        else:
            max_d = max(max_d, cells[i][j])
for i in range(MAPSIZE):
    print " ".join(map(str, cells[i]))
print count
print max_d

Submission status: Wrong Answer

Solution code:
d = [[0] * 10 for i in range(10)]

def b(x, y):
    for i in range(x - 2, x + 3):
        a = 3 - abs(x - i)
        for a in range(y - a + 1, y + a):
            if 0 <= i < 10 and 0 <= a < 10:
                d[a][i] += 1


def m(x, y):
    for i in range(x - 1, x + 2):
        for j in range(y - 1, y + 2):
            if 0 <= i < 10 and 0 <= j < 10:
                d[j][i] += 1


def s(x, y):
    r = (1, 0)
    for i in range(x - 1, x + 2):
        a = abs(x - i)
        for j in range(y - r[a], y + r[a] + 1):
            if 0 <= i < 10 and 0 <= j < 10:
                d[j][i] += 1

while 1:
    try:
        f = (None, s, m, b)
        x, y, size = list(map(int, input().split(',')))
        f[size](x, y)

    except:
        break


r1 = r2 = 0
for i in range(10):
    for j in range(10):
        r1 += 1 if d[i][j] == 0 else 0
        r2 = max(r2, d[i][j])

print(r1, r2)

Submission status: Wrong Answer

Solution code:
a = [[0] * 14 for _ in range(14)]
while True:
    try:
        x, y, s = map(int, input().split(','))
    except:
        break
    x += 2
    y += 2
    for d in [(0, 0), (0, -1), (0, 1), (-1, 0), (1, 0)]:
        a[x + d[0]][y + d[1]] += 1
    if s >= 2:
        for d in [(1, 1), (1, -1), (-1, 1), (-1, -1)]:
            a[x + d[0]][y + d[1]] += 1
    if s == 3:
        for d in [(0, 2), (0, -2), (2, 0), (-2, 0)]:
            a[x + d[0]][y + d[1]] += 1
print(sum(a[i][2:12].count(0) for i in range(2, 12)))
print(max(max(a[i]) for i in range(14)))
print(a)

Submission status: Wrong Answer

Solution code:
a = [[0] * 14 for _ in range(14)]
while True:
    try:
        x, y, s = map(int, input().split(','))
    except:
        break
    x += 2
    y += 2
    for d in [(0, 0), (0, -1), (0, 1), (-1, 0), (1, 0)]:
        a[x + d[0]][y + d[1]] += 1
    if s >= 2:
        for d in [(1, 1), (1, -1), (-1, 1), (-1, -1)]:
            a[x + d[0]][y + d[1]] += 1
    if s == 3:
        for d in [(0, 2), (0, -2), (2, 0), (-2, 0)]:
            a[x + d[0]][y + d[1]] += 1
print(sum(a[i][2:12].count(0) for i in range(2, 12)))
print(max(max(a[i][2:12]) for i in range(2, 12)))
print(a)

Submission status: Wrong Answer

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 (nx < 0 or nx > 9 or ny < 0 or ny > 9):
            continue
        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: Wrong Answer

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

Solution code:
import sys

paper = [[0] * 10 for i in range(10)]

for line in sys.stdin:
    x,y,s = map(int,line.split(','))
    for i in range(10):
        for j in range(10):
            if s == 1:
                if abs(i - y) + abs(j - x) <= 1:
                    paper [i] [j] += 1
            if s == 2:
                if abs(i - y) <= 1 and abs(j - x) <= 1:
                    paper [i] [j] += 1
            if s == 3:
                if abs(i - y) + abs(j - x) <= 2:
                    paper [i] [j] += 1

ans = [0,0]
for i in range(10):
    for j in range(10):
        if paper [i] [j] == 0:
            ans [0] += 1
        if paper [i] [j] > ans [1]:
            ans [1] = paper [i] [j]

print(ans [0],ans [1])

Submission status: Wrong Answer

Solution code:
Masu = []
def access(x,y):
    if x < 0 or y < 0 or x > 9 or y > 9:
        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)
        print(Masu)
               
    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: Wrong Answer

Solution code:

board=[[0]*10 for i in range(10)]
ink=[[[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]],
[[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]],
[[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 True:
    try:
        x,y,s=map(int,input().split(","))
    except:
        break
    for i in range(5):
        for j in range(5):
            if 0<=i+y-2<=9 and 0<=j+x-2<=9:
                board[i+y-2][j+x-2]+=ink[s-1][i][j]

flat=sum(board,[])
print(flat.count(0))
print(flat.count(max(flat)))

Submission status: Wrong Answer

Solution code:
paper = [0 for x in range(10) for y in range(10)]

while True :
    try:
        x, y, ink = [int(_) for _ in input().split(',')]
        temp = (x - 1) + y * 10
        spot = [temp]
        for _ in 1, 10 :
            if temp + _ > 0 : spot.append(temp + _)
            if temp - _ > 0 : spot.append(temp - _)
        if ink == 2 or ink == 3 :
            for _ in 9, 11 :
                if temp + _ > 0 : spot.append(temp + _)
                if temp - _ > 0 : spot.append(temp - _)
            if ink == 3 :
                for _ in 2, 20 :
                    if temp + _ > 0 : spot.append(temp + _)
                    if temp - _ > 0 : spot.append(temp - _)
        for _ in spot : paper[_] += 1
    except : break

none = 0
for _ in paper : 
    if _ == 0 : none += 1
print(none, max(paper))

Submission status: Wrong Answer

Solution code:
paper = [0 for x in range(10) for y in range(10)]

while True :
    try:
        x, y, ink = [int(_) for _ in input().split(',')]
        temp = (x - 1) + y * 10
        spot = [temp]
        for _ in 1, 10 :
            if temp + _ > 0 : spot.append(temp + _)
            if temp - _ > 0 : spot.append(temp - _)
        if ink == 2 or ink == 3 :
            for _ in 9, 11 :
                if temp + _ > 0 : spot.append(temp + _)
                if temp - _ > 0 : spot.append(temp - _)
            if ink == 3 :
                for _ in 2, 20 :
                    if temp + _ > 0 : spot.append(temp + _)
                    if temp - _ > 0 : spot.append(temp - _)
        for _ in spot : paper[_] += 1
    except : break

none = 0
for _ in paper : 
    if _ == 0 : none += 1
print(none)
print(max(paper))

Submission status: Wrong Answer

Solution code:
import sys
n1 = [[0, 1], [1, 0], [-1, 0], [0, -1]]
n2 = n1 + [[a, b] for a in [-1,1] for b in [-1, 1]]
n3 = n2 + [[a*2, b*2] for a, b in n1]
mas = [[0]*10 for i in range(10)]
for i in sys.stdin:
    try:
        x, y, a = list(map(int,i.split(",")))
        mas[y][x] += 1
        for j in eval("n"+str(a)):
            try:
                mas[y+j[1]][x+j[0]] += 1
            except IndexError:
                continue
    except:
        break
print(len([i for x in mas for i in x if not i]))
print(max([max(v) for v in mas]))

Submission status: Wrong Answer

Solution code:
import sys
n1 = [[0, 1], [1, 0], [-1, 0], [0, -1]]
n2 = n1 + [[a, b] for a in [-1, 1] for b in [-1, 1]]
n3 = n2 + [[a*2, b*2] for a, b in n1]
mas = [[0]*10 for i in range(10)]
for i in sys.stdin:
    try:
        x, y, a = list(map(int, i.split(",")))
        mas[y][x] += 1
        for j in eval("n"+str(a)):
            try:
                mas[y+j[1]][x+j[0]] += 1
            except IndexError:
                continue
    except:
        break
print(len([i for x in mas for i in x if not i]))
print(max([max(v) for v in mas]))

Submission status: Wrong Answer

Solution code:
import sys
n1 = [[0, 1], [1, 0], [-1, 0], [0, -1]]
n2 = n1 + [[a, b] for a in [-1, 1] for b in [-1, 1]]
n3 = n2 + [[a*2, b*2] for a, b in n1]
mas = [[0]*10 for i in range(10)]
for i in sys.stdin:
    try:
        x, y, a = list(map(int, i.split(",")))
        mas[y][x] += 1
        for k,l in eval("n"+str(a)):
            try:
                if y+l>= 0 and x+k >= 0:
                    mas[y+l][x+k] += 1
            except IndexError:
                continue
    except ValueError:
        break
print(mas)
print(len([i for x in mas for i in x if not i]))
print(max([max(v) for v in mas]))

Submission status: Wrong Answer

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:
            try:
                t[x+_x][y+_y] += 1
            except IndexError:
                continue
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: Wrong Answer

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:
            try:
                t[y+_y][x+_x] += 1
            except IndexError:
                continue
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: Wrong Answer

Solution code:
A=[[int(0) for i in range(10)]for j in range(10)]
count=0
while 1:
    try:
        x,y,s = map(int, input().split(','))
        if s==1:
            for i in range(x-1,x+1):
                if i>=0 and i<=9:
                    A[i][y]=A[i][y]+1
            for i in range(y-1,y+1):
                if i>=0 and i<=9:
                    A[x][i]=A[x][i]+1
            A[x][y]=A[x][y]-1                    
        elif s==2:
            for i in range(x-1,x+1):
                for j in range(y-1,y+1):
                    if i>=0 and i<=9 and j>=0 and j<=9:
                        A[i][j]=A[i][j]+1
        else:
            for i in range(x-2,x+2):
                if i>=0 and i<=9:
                    A[i][y]=A[i][y]+1
            for i in range(y-2,y+2):
                if i>=0 and i<=9:
                    A[x][i]=A[x][i]+1
            for i in range(x-1,x+1):
                if i>=0 and i<=9:
                    A[i][y]=A[i][y]-1
            for i in range(y-1,y+1):
                if i>=0 and i<=9:
                    A[x][i]=A[x][i]-1
            for i in range(x-1,x+1):
                for j in range(y-1,y+1):
                    if i>=0 and i<=9 and j>=0 and j<=9:
                        A[i][j]=A[i][j]+1
    except EOFError:
        break
        
for i in range(10):
    for j in range(10):
        if A[i][j]==0:
            count=count+1
print(count)
print(max(A))

Submission status: Wrong Answer

Solution code:
area = [[0 for i in range(10)] for j in range(10)]

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(area)

max = 0
cnt = 0

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

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)]

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

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

drop(1,1,1)