Problem:


Score : 400 points

Problem Statement

We have a grid with H rows and W columns. At first, all cells were painted white.

Snuke painted N of these cells. The i-th ( 1 \leq i \leq N ) cell he painted is the cell at the a_i-th row and b_i-th column.

Compute the following:

For each integer j ( 0 \leq j \leq 9 ), how many subrectangles of size 3×3 of the grid contains exactly j black cells, after Snuke painted N cells?

Constraints

3 \leq H \leq 10^9

3 \leq W \leq 10^9

0 \leq N \leq min(10^5,H×W)

1 \leq a_i \leq H (1 \leq i \leq N)

1 \leq b_i \leq W (1 \leq i \leq N)

(a_i, b_i) \neq (a_j, b_j) (i \neq j)

Input

The input is given from Standard Input in the following format:

H W N
a_1 b_1
:
a_N b_N

Output

Print 10 lines.
The (j+1)-th ( 0 \leq j \leq 9 ) line should contain the number of the subrectangles of size 3×3 of the grid that contains exactly j black cells.

Sample Input 1

4 5 8
1 1
1 4
1 5
2 3
3 1
3 2
3 4
4 4

Sample Output 1

0
0
0
2
4
0
0
0
0
0

There are six subrectangles of size 3×3. Two of them contain three black cells each, and the remaining four contain four black cells each.

Sample Input 2

10 10 20
1 1
1 4
1 9
2 5
3 10
4 2
4 7
5 9
6 4
6 6
6 7
7 1
7 3
7 7
8 1
8 5
8 10
9 2
10 4
10 9

Sample Output 2

4
26
22
10
2
0
0
0
0
0

Sample Input 3

1000000000 1000000000 0

Sample Output 3

999999996000000004
0
0
0
0
0
0
0
0
0



Sample input:
4 5 8
1 1
1 4
1 5
2 3
3 1
3 2
3 4
4 4


Sample output:
0
0
0
2
4
0
0
0
0
0

Submission status: Wrong Answer

Solution code:
h,w,n = map(int,input().split())
s = []
for i in range(n):
    arr = list(map(int,input().split()))
    s.append(arr)

for i in range(10):
    a=0
    b=0
    for j in range(h-2):
        for k in range(w-2):
            sq=[]
            sq.append([j+1,k+1])
            sq.append([j+1,k+2])
            sq.append([j+1,k+3])
            sq.append([j+2,k+1])
            sq.append([j+2,k+2])
            sq.append([j+2,k+3])
            sq.append([j+3,k+1])
            sq.append([j+3,k+2])
            sq.append([j+3,k+3])
            for l in s:
                if l in sq:
                    a += 1
            if a == i:
                b += 1
    print(b)

Submission status: Wrong Answer

Solution code:
h, w, n = map(int,input().split())

xy_pos = dict()

for i in range(n):
    a, b = map(int, input().split())
    for k in range(-2,1):
        for l in range(-2,1):
            x = (a-1) + k
            y = (b-1) + l
            if (0 <= x <=(h-1)-2) and (0 <= y <=(w-1)-2):
                xy = str(x) + "x" + str(y)
                if xy in xy_pos:
                    xy_pos[xy] += 1
                else:
                    xy_pos[xy] = 1

ans = [0]*10                    
for v in xy_pos.values():
    ans[v] += 1
ans[0] = (h-2)*(w-2) - sum(ans)
print(ans)

Submission status: Wrong Answer

Solution code:
h,w,n = map(int,input().split())
s = [[0 for j in range(w+2)] for i in range(h+2)]
#print(s)
for i in range(0,n):
    x,y = map(int,input().split())
    s[x-1][y-1] += 1
    s[x-1][y] += 1
    s[x-1][y+1] += 1
    s[x][y-1] += 1
    s[x][y] += 1
    s[x][y+1] += 1
    s[x+1][y-1] += 1
    s[x+1][y] += 1
    s[x+1][y+1] += 1

print(s)
ans = [0] * 10
for i in range(2,h):
    for j in range(2,w):
        ans[s[i][j]] += 1
for i in range(0,10):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
import collections
from itertools import product

H, W, N = map(int,input().split())
PaintList = []
pat = list(product((-2,-1,0),repeat=2))
for i in range(N):
  x,y = map(int, input().split())
  for p in pat:
    xw = x + p[0]
    yw = y + p[1]
    #print(xw,yw)
    if 1 <= xw <= H-2 and 1 <= yw <= W-2:
      PaintList.append((xw,yw))

c = collections.Counter(PaintList)
#print(c)
ans = [0] * 10
for k,v in c.items():
  if k[0] <= H-2 and k[1] <= W-2:
    ans[v] += 1
  
ans[0] = (H-2)*(W-2) - sum(ans[1:9])

for i in range(10):
  print(ans[i])

Submission status: Wrong Answer

Solution code:
h, w, n = map(int, input().split())
from collections import defaultdict
d = defaultdict(int)
surround = [(0, 0), (1,1), (1, 0), (1, -1), (0, -1), (-1, -1), (-1, 0), (-1, 1), (0, 1)]
for _ in range(n):
    x, y  = map(int, input().split())
    x -= 1
    y -= 1
    for i in surround:
        if x + i[0] >= w or x + i[0] < 0 or y + i[1] < 0 or y + i[1] >= h:
            continue
        else:
            d[(x+i[0], y + i[1])] += 1
num = [0]*10
for key in d:
    if key[0] >= 1 and key[0] < h -1 and key[1] >= 1 and key[1] < w-1:
        num[d[key]] += 1

num[0] = (h-2)*(w-2) - sum(num)

for ans in num:
    print(ans)

Submission status: Wrong Answer

Solution code:
"""
参考(神様)
https://atcoder.jp/contests/abc045/submissions/6046010
"""

###かぶるやつを考える.例えばあるマスのかぶり値が9だとしたら,
###周囲はすべて黒->j=9のが1つとカウントしてよい,他の値についても同様.

import sys
from collections import defaultdict,Counter

def input():
    return sys.stdin.readline().strip()

H,W,N = map(int,input().split())

covered = defaultdict(int)
vector = [(0,0),(0,1),(0,-1),(1,0),(-1,0),(1,1),(-1,-1),(1,-1),(-1,1)]

for _ in range(N):
    a,b = map(int,input().split())

    for i,j in vector:
        x = a+i-1
        y = b+j-1

        if 0 < x < H-1 and 0 < y < W-1:
            covered[(x,y)] += 1

num = Counter(covered.values())
print(num)
num[0] = (H-2)*(W-2)-sum(num.values())

for i in range(10):
    print(num[i])

Submission status: Wrong Answer

Solution code:
H, W, N = [int(v) for v in input().split()]
points = (map(int, input().split()) for _ in range(N))
memory = {}

for ai, bi in points:
    for i in range(max(2, ai - 1), min(H - 1, ai + 1) + 1):
        for j in range(max(2, bi - 1), min(W - 1, bi + 1) + 1):
            key = (i, j)
            if not key in memory:
                memory[key] = 0
            memory[key] += 1

counter = {i: 0 for i in range(1, 9 + 1)}
for v in memory.values():
    counter[v] += 1

for i in range(1, 9 + 1):
    print(counter[i])

Submission status: Wrong Answer

Solution code:
H,W,N = map(int,input().split())

A = {}
for i in range(N):
  a,b = map(int,input().split())
  a-=1;b-=1
  for t in range(3):
    for s in range(3):
      if 0<=a-t<H-2 and 0<=b-s<W-2:
        if (a-t,b-s) not in A:
          A[(a-t,b-s)]  = 1
        else:
          A[(a-t,b-s)]  += 1
#print(A)
ans = [-1]
temp = list(A.values())
total = 0
for i in range(1,9):
  c = temp.count(i)
  total += c
  ans.append(c)
ans[0] = (H-2)*(W-2)-total
print(*ans, sep="\n")

Submission status: Wrong Answer

Solution code:
H, W , N = map(int,input().split())
from bisect import bisect_left
from bisect import bisect_right
matrix = []
for _ in range(N):
    x,y = map(int,input().split())
    matrix.append([x-1,y-1])
ans = [0 for _ in range(10)]
cand = {}
for l in matrix:
    for x_r in [-2, -1 , 0]:
        for y_r in [-2, -1 , 0]:
            nowx = l[0] + x_r
            nowy = l[1] + y_r
            if nowx < 0 or nowy < 0 or nowx + 2>= H or nowy+ 2 >= W:
                continue
            #ここで起点(左上)nowx, nowy として　 9マスに着目する
            name = str(nowx) + ' '  +str(nowy)
            if name in cand : cand[name] += 1
            else: cand[name] = 1
tmp = ((H - 2) * (W - 2))
for x in cand.values():
  ans[x] +=1
ans[0] -= len(cand)
for x in ans:
    print(x)

Submission status: Wrong Answer

Solution code:
H, W , N = map(int,input().split())
from bisect import bisect_left
from bisect import bisect_right
matrix = []
for _ in range(N):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    matrix.append([x,y])
matrix.sort()
ans = [0 for _ in range(10)]
from bisect import bisect_left
cand = {}
for l in matrix:
    for x_r in [-2, -1 , 0]:
        for y_r in [-2, -1 , 0]:
            nowx = l[0] + x_r
            nowy = l[1] + y_r
            if nowx < 0 or nowy < 0 or nowx + 2>= H or nowy+ 2 >= W:
                continue
            #ここで起点(左上)nowx, nowy として　 9マスに着目する
            name = str(nowx) + str(nowy)
            try: cand[name] += 1
            except: cand[name] = 1
tmp = ((H - 2) * (W - 2))
for x in cand.values():
    try:
        ans[x] += 1
    except:pass
    tmp -= 1
ans[0] = tmp
for x in ans:
    print(x)

Submission status: Wrong Answer

Solution code:
H, W , N = map(int,input().split())
from bisect import bisect_left
from bisect import bisect_right
matrix = []
for _ in range(N):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    matrix.append([x,y])
matrix.sort()
ans = [0 for _ in range(10)]
from bisect import bisect_left
cand = {}
for l in matrix:
    for x_r in [-2, -1 , 0]:
        for y_r in [-2, -1 , 0]:
            nowx = l[0] + x_r
            nowy = l[1] + y_r
            if nowx < 0 or nowy < 0 or nowx + 2>= H or nowy+ 2 >= W:
                continue
            #ここで起点(左上)nowx, nowy として　 9マスに着目する
            name = str(nowx) + str(nowy)
            try: cand[name] += 1
            except: cand[name] = 1
tmp = ((H - 2) * (W - 2))
print(cand)
try:
    for x in cand.values():
        print(x)
        ans[x] += 1
        tmp -= 1
except: pass
ans[0] = tmp
for x in ans:
    print(x)

Submission status: Wrong Answer

Solution code:
H, W , N = map(int,input().split())
from bisect import bisect_left
from bisect import bisect_right
matrix = []
for _ in range(N):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    matrix.append([x,y])
matrix.sort()
ans = [0 for _ in range(10)]
from bisect import bisect_left
cand = {}
try:
    for l in matrix:
        for x_r in [-2, -1 , 0]:
            for y_r in [-2, -1 , 0]:
                nowx = l[0] + x_r
                nowy = l[1] + y_r
                if nowx < 0 or nowy < 0 or nowx + 2>= H or nowy+ 2 >= W:
                    continue
                #ここで起点(左上)nowx, nowy として　 9マスに着目する
                name = str(nowx) + str(nowy)
                try: cand[name] += 1
                except: cand[name] = 1
    tmp = ((H - 2) * (W - 2))
    for x in cand.values():
        ans[x] += 1
        tmp -= 1
    ans[0] = tmp
    for x in ans:
        print(x)

except: pass

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

H, W, N = map(int, input().split())
xy = []
dot = defaultdict(bool)
seen = defaultdict(bool)
for _ in range(N):
    a, b = map(int, input().split())
    xy.append((a, b))
    dot[(a, b)] = True

ans = [0] * 10
for x, y in xy:
    for dx in [-2, -1, 0]:
        for dy in [-2, -1, 0]:
            nx = x + dx
            ny = y + dy
            if seen[(nx, ny)] or nx <= 0 or nx + 2 > H or ny <= 0 or ny + 2 > W:
                continue
            seen[(nx, ny)] = True
            cnt = 0
            for i in range(3):
                for j in range(3):
                    cnt += int(dot[(nx + i, ny + j)])
            ans[cnt] += 1
            print(nx, ny, cnt)

zero = (H - 2) * (W - 2) - sum(ans)
ans[0] = zero
print(*ans, sep="\n")

Submission status: Wrong Answer

Solution code:
#in1 = '10 10 20'
#in2 = ['1 1', '1 4', '1 9', '2 5', '3 10', '4 2', '4 7', '5 9', '6 4', '6 6', '6 7', '7 1', '7 3', '7 7', '8 1', '8 5', '8 10', '9 2', '10 4', '10 9']
#in1 = '1000000000 1000000000 0'
#h, w, n = map(int, in1.split())
h, w, n = map(int, input().split())

idx1 = 0
ab = [[0 for i in range(2)] for j in range(n)]

black_cnt = [0] * 10
black_cnt[0] = (h - 2) * (w - 2)

if n != 0:
    while idx1 < n:
        x = input().split()
        #x = in2[idx1].split()
        ab[idx1][0] = int(x[0])
        ab[idx1][1] = int(x[1])
        idx1 += 1
    for idx1 in range(len(ab)):
        if ab[idx1][0] < 3:
            s = 0
        else:
            s = ab[idx1][0] - 3
        if ab[idx1][0] > h - 2:
            l = h - 2
        else:
            l = ab[idx1][0]
        Rrange = range(s, l)
        if ab[idx1][1] < 3:
            s = 0
        else:
            s = ab[idx1][1] - 3
        if ab[idx1][1] > w - 2:
            l = h - 2
        else:
            l = ab[idx1][1]
        Crange = range(s, l)
        for nowRow in Rrange:
            for nowCol in Crange:
                w_black = 0
                for idx2 in range(idx1):
                    if nowRow < ab[idx2][0] <= nowRow + 3 and nowCol < ab[idx2][1] <= nowCol + 3:
                        w_black += 1
                black_cnt[w_black]     -= 1
                black_cnt[w_black + 1] += 1
for idx1 in range(len(black_cnt)):
    print(black_cnt[idx1])

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def main():
    h,w,n = map(int,input().split())
    dg = 10**10
    d = dict()

    def f(x,y):
        if 2 <= x <= h-1 and 2 <= y <= w-1:
            return True
        else:
            False

    for i in range(n):
        a,b = map(int,input().split())
        
        if f((a-1),b-1):
            if (a-1)*dg + b-1 in d:
                d[(a-1)*dg + b-1] += 1
            else:
                d[(a-1)*dg + b-1] = 1
        
        if f((a-1),b):
            if (a-1)*dg + b in d:
                d[(a-1)*dg + b] += 1
            else:
                d[(a-1)*dg + b] = 1
        
        if f((a-1),b+1):
            if (a-1)*dg + b+1 in d:
                d[(a-1)*dg + b+1] += 1
            else:
                d[(a-1)*dg + b+1] = 1

        if f((a),b-1):
            if (a)*dg + b-1 in d:
                d[(a)*dg + b-1] += 1
            else:
                d[(a)*dg + b-1] = 1
        
        if f(a,b):
            if a*dg + b in d:
                d[a*dg + b] += 1
            else:
                d[a*dg + b] = 1
        
        if f((a),b+1):
            if (a)*dg + b+1 in d:
                d[(a)*dg + b+1] += 1
            else:
                d[(a)*dg + b+1] = 1
        

        
        
        
        
    res = [0]*10
 
    for e in d:
        res[d[e]] += 1
 
    res[0] = (h-2)*(w-2)-sum(res)
 
    for e in res:
        print(e)
 
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def main():
    h,w,n = map(int,input().split())
    dg = 10**10
    d = dict()

    def f(x,y):
        if 2 <= x <= h-1 and 2 <= y <= w-1:
            return True
        else:
            False

    for i in range(n):
        a,b = map(int,input().split())
        
        if f((a-1),b-1):
            if (a-1)*dg + b-1 in d:
                d[(a-1)*dg + b-1] += 1
            else:
                d[(a-1)*dg + b-1] = 1
        
        if f((a-1),b):
            if (a-1)*dg + b in d:
                d[(a-1)*dg + b] += 1
            else:
                d[(a-1)*dg + b] = 1
        
        if f((a-1),b+1):
            if (a-1)*dg + b+1 in d:
                d[(a-1)*dg + b+1] += 1
            else:
                d[(a-1)*dg + b+1] = 1

        if f((a),b-1):
            if (a)*dg + b-1 in d:
                d[(a)*dg + b-1] += 1
            else:
                d[(a)*dg + b-1] = 1
        
        if f(a,b):
            if a*dg + b in d:
                d[a*dg + b] += 1
            else:
                d[a*dg + b] = 1
        

 
 
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def main():
    h,w,n = map(int,input().split())
    dg = 10**10
    d = dict()

    def f(x,y):
        if 2 <= x <= h-1 and 2 <= y <= w-1:
            return True
        else:
            False

    for i in range(n):
        a,b = map(int,input().split())
        
        if f((a-1),b-1):
            if (a-1)*dg + b-1 in d:
                d[(a-1)*dg + b-1] += 1
            else:
                d[(a-1)*dg + b-1] = 1



 
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def main():
    h,w,n = map(int,input().split())
    dg = 10**10
    d = dict()

    def f(x,y):
        if 2 <= x <= h-1 and 2 <= y <= w-1:
            return True
        else:
            False

    for i in range(n):
        a,b = map(int,input().split())
        
        if f((a-1),b-1):
            if (a-1)*dg + b-1 in d:
                d[(a-1)*dg + b-1] += 1
            else:
                d[(a-1)*dg + b-1] = 1
        
        if f((a-1),b):
            if (a-1)*dg + b in d:
                d[(a-1)*dg + b] += 1
            else:
                d[(a-1)*dg + b] = 1
        
        if f((a-1),b+1):
            if (a-1)*dg + b+1 in d:
                d[(a-1)*dg + b+1] += 1
            else:
                d[(a-1)*dg + b+1] = 1

        if f((a),b-1):
            if (a)*dg + b-1 in d:
                d[(a)*dg + b-1] += 1
            else:
                d[(a)*dg + b-1] = 1
        
        if f(a,b):
            if a*dg + b in d:
                d[a*dg + b] += 1
            else:
                d[a*dg + b] = 1
        
        if f((a),b+1):
            if (a)*dg + b+1 in d:
                d[(a)*dg + b+1] += 1
            else:
                d[(a)*dg + b+1] = 1
        
        if f((a+1),b+1):
            if (a+1)*dg + b+1 in d:
                d[(a+1)*dg + b+1] += 1
            else:
                d[(a+1)*dg + b+1] = 1
        
        if f((a+1),b):
            if (a+1)*dg + b in d:
                d[(a+1)*dg + b] += 1
            else:
                d[(a+1)*dg + b] = 1
        
        if f((a+1),b-1):
            if (a+1)*dg + b-1 in d:
                d[(a+1)*dg + b-1] += 1
            else:
                d[(a+1)*dg + b-1] = 1
        

 
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def main():
    h,w,n = map(int,input().split())
    dg = 10**10
    d = dict()

    def f(z):
        x,y = divmod(z,dg)
        if 2 <= x <= h-1 and 2 <= y <= w-1:
            return True
        else:
            False

    for i in range(n):
        a,b = map(int,input().split())
        
        if f((a-1)*dg + b-1):
            if (a-1)*dg + b-1 in d:
                d[(a-1)*dg + b-1] += 1
            else:
                d[(a-1)*dg + b-1] = 1
        
        if f((a-1)*dg + b):
            if (a-1)*dg + b in d:
                d[(a-1)*dg + b] += 1
            else:
                d[(a-1)*dg + b] = 1
        
        if f((a-1)*dg + b+1):
            if (a-1)*dg + b+1 in d:
                d[(a-1)*dg + b+1] += 1
            else:
                d[(a-1)*dg + b+1] = 1

        if f((a)*dg + b-1):
            if (a)*dg + b-1 in d:
                d[(a)*dg + b-1] += 1
            else:
                d[(a)*dg + b-1] = 1
        
        if f(a*dg + b):
            if a*dg + b in d:
                d[a*dg + b] += 1
            else:
                d[a*dg + b] = 1
        
        if f((a)*dg + b+1):
            if (a)*dg + b+1 in d:
                d[(a)*dg + b+1] += 1
            else:
                d[(a)*dg + b+1] = 1
        
        if f((a+1)*dg + b+1):
            if (a+1)*dg + b+1 in d:
                d[(a+1)*dg + b+1] += 1
            else:
                d[(a+1)*dg + b+1] = 1
        
        if f((a+1)*dg + b):
            if (a+1)*dg + b in d:
                d[(a+1)*dg + b] += 1
            else:
                d[(a+1)*dg + b] = 1
        
        if f((a+1)*dg + b-1):
            if (a+1)*dg + b-1 in d:
                d[(a+1)*dg + b-1] += 1
            else:
                d[(a+1)*dg + b-1] = 1
        
        
        
        
    res = [0]*10
    cnt = 0
    for e in d:
        cnt += 1
    
    if cnt > 65535:
        d[-1] = 1
        

    else:
        print(10)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#すぬけくんの塗り絵
h,w,n=map(int,input().split())
dic={}
for  _ in range(n):
    a,b=map(int,input().split())
    for i in range(a-1,a+2):
        for j in range(b-1,b+2):
            if (i,j) in dic.keys():
                dic[(i,j)]+=1
            else:
                dic[(i,j)]=1
              
howmany=[0 for i in range(10)]
for some in dic.keys():
    a,b=some[0],some[1]
    if 2<=a<=h-1 and 2<=b<=w-1:
        howmany[dic[some]]+=1
for i in range(10):
    print(howmany[i])

Submission status: Wrong Answer

Solution code:
H,W,N = map(int,input().split())
Nli=[0 for j in range(9*N)]
q=0
for k in range(N):
    a,b=map(int,input().split())
    for n in range(-1,2):
        for m in range(-1,2):
            if 0<=a-2-m<H-2 and 0<=b-2-n<W-2:
                Nli[q]=(b-n)*(H)+(a-m)
                q+=1
print(Nli)
del Nli[q:]
print(Nli)
import collections
s = collections.Counter(Nli)
v = list(s.values())
print((H-2)*(W-2)-len(set(Nli)))
for k in range(1,10):
    print(v.count(k))

Submission status: Wrong Answer

Solution code:
from collections import *
h,w,n = map(int,input().split())
dic = defaultdict(int)
for _ in range(n):
  a,b = map(int,input().split())
  for i in range(9):
    dic[a + i //3,b + i % 3] += 1
ans =[0]*10
for i, j in dic:
  ans[dic[i,j]] += h-1 > i > 0 < j < w -1
ans[0] = (h -2)*(w-2) - sum(ans)
for item in ans:
  print(item)

Submission status: Wrong Answer

Solution code:
from collections import *
h,w,n = map(int,input().split())
dic = defaultdict(int)
for _ in range(n):
  a,b = map(int,input().split())
  for i in range(9):
    dic[a - i //3,b - i % 3] += 1
ans =[0]*(n+1)
for i, j in dic:
  ans[dic[i,j]] += h-1 > i > 0 < j < w -1
ans[0] = (h -2)*(w-2) - sum(ans)
print(*ans)

Submission status: Wrong Answer

Solution code:
from collections import *
h,w,n = map(int,input().split())
dic = defaultdict(int)
for _ in range(n):
  a,b = map(int,input().split())
  for i in range(9):
    dic[a + i //3,b + i % 3] += 1
ans =[0]*(n+1)
for i, j in dic:
  ans[dic[i,j]] += h-1 > i > 0 < j < w -1
ans[0] = (h -2)*(w-2) - sum(ans)
for item in ans:
  print(item)

Submission status: Wrong Answer

Solution code:
from collections import *
h,w,n = map(int,input().split())
dic = defaultdict(int)
for _ in range(n):
  a,b = map(int,input().split())
  for i in range(9):
    dic[a - i //3,b - i % 3] += 1
ans =[0]*(n+1)
for i, j in dic:
  ans[dic[i,j]] += h-1 > i > 0 < j < w -1
ans[0] = (h -2)*(w-2) - sum(ans)
for item in ans:
  print(item)

Submission status: Wrong Answer

Solution code:
h, w, n = map(int, input().split())

hako = [[0 for i in range(w)] for j in range(h)]
ans = [0]*10

#print("hako1 = {0}".format(hako))

if n != 0:
    print('a')
    for i in range(n):
        s, t = map(int, input().split())
        hako[s-1][t-1] = 1

#print("hako2 = {0}".format(hako))

for i in range(h-2):
    for j in range(w-2):
        s = 0
        for p in range(3):
            for q in range(3):
                if hako[i+p][j+q] == 1:
                    s += 1
        ans[s] += 1

for i in range(10):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from collections import Counter
h,w,n=map(int,input().split())
c=Counter()
for _ in range(n):
    a,b=map(int,input().split())
    for i in [-1,0,1]:
        for j in [-1,0,1]:
            if 2<=a+i<w and 2<=b+j<h:
                c[a+i,b+j]+=1
#print(c.items())
c2=Counter(c.values())
print((h-2)*(w-2)-sum(c2.values()))
for i in range(1,10):
    print(c2[i])

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

H,W,N = map(int,input().split())
D = defaultdict(bool)
B = []

for _ in range(N):
    a,b = map(lambda x: int(x)-1,input().split())
    D[(a,b)] = True
    B.append((a,b))

ans = [0 for _ in range(10)]

for a,b in B:
    for i in range(9):
        ix,iy = divmod(i,3)
        if a-ix<0 or b-iy<0:
            continue
        black_count = 0
        for j in range(9):
            jx,jy = divmod(j,3)
            if H<=a-ix+jx or W<=b-iy+jy:
                break
            if D[(a-ix+jx,b-iy+jy)]:
                if -ix+jx<0 or (-ix+jx==0 and -iy+jy<0):
                    print(a,b,ix,iy,jx,jy,-ix+jx,-iy+jy)
                    break
                black_count += 1
        else:
            ans[black_count] += 1

ans[0] = (H-2)*(W-2)-sum(ans)
print(*ans,sep='\n')

Submission status: Wrong Answer

Solution code:
def main():
    from sys import stdin
    input = stdin.readline

    h, w, n = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in [0]*n]
    ab_d = {(a, b) for a, b in ab}

    ans = [set() for _ in range(9)]
    for a, b in ab:
        temp = [None]*25
        for i in range(max(0, 3-a), min(5, h-a+3)):
            for j in range(max(0, 3-b), min(5, w-b+3)):
                if (a+i-2, b+j-2) in ab_d:
                    temp[i*5+j] = 1
                else:
                    temp[i*5+j] = 0

main()

Submission status: Wrong Answer

Solution code:
H, W, N = list(map(int, input().split()))
ans = {}
for i in range(N):
  a, b = list(map(int, input().split()))
  for j in range(-1, 2):
    for k in range(-1, 2):
      if a+j>=2 and b+k>=2 and a+j<=H-1 and b+k<=W-1:
        key = str(a+j) + "_" + str(b+k)
        ans[key] = ans.get(key, 0) + 1
ans_value = list(ans.values())
for i in range(10):
  print(ans_value.count(i))

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left
h,w,n=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
cnt=[0]*10

def find(x):
    z=bisect_left(ab,x)
    if z==n:
        return False
    elif x==ab[z]:
        return True
    else:
        return False

for i in range(n):
    a,b=ab[i]
    l,r,d,u=max(1,a-2),min(h,a+2),max(1,b-2),min(w,b+2)
    data=[[0]*(u-d+2) for i in range(r-l+2)]
    for i in range(l,r+1):
        for j in range(d,u+1):
            if find([i, j]):
                data[i-l+1][j-d+1]=1
            if i>l and j>d:
                data[i-l+1][j-d+1]+=data[i-l+1][j-d]+data[i-l][j-d+1]-data[i-l][j-d]
            elif j>d:
                data[i-l+1][j-d+1]+=data[i-l+1][j-d]
            elif i>l:
                data[i-l+1][j-d+1]+=data[i-l][j-d+1]
    for i in range(1,r-l):
        for j in range(1,u-d):
            k=data[i+2][j+2]-data[i+2][j-1]-data[i-1][j+2]+data[i-1][j-1]
            cnt[k]+=1
for i in range(1,10):
    cnt[i]//=i
print((h-2)*(w-2)-sum(cnt))
for i in range(1,10):
    print(cnt[i])

Submission status: Wrong Answer

Solution code:
H, W, N = map(int, input().split())
A = []
L = 0
ans = [0] * 10

for i in range(N):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    for i in range(max(0, a - 2), min(a + 1,H-2)):
        for j in range(max(0, b - 2), min(b + 1,W-2)):
            A.append((i, j))
            L += 1

A.sort()
print(A)
count = 1
for i in range(L - 1):
    if A[i] == A[i + 1]:
        count += 1
    else:
        ans[count] += 1
        count = 1
if L >= 1:
    ans[count] += 1

ans[0] = (H - 2) * (W - 2) - sum(ans)

for i in range(10):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
H,W,N = map(int,input().split())
count = []
L = 0
for i in range(N):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    for i in range(max(0,a-2),min(a+1,H-2)):
        for j in range(max(0,b-2),min(b+1,W-2)):
            count.append((i,j))
            L += 1
count.sort()
ans = [0]*10
tmp = 1
for i in range(L-1):
    if count[i] == count[i+1]:
        tmp += 1
    else:
        ans[tmp] += 1
        tmp = 1
ans[tmp] += 1
ans[0] = (H-2)*(W-2)-sum(ans)
for i in range(10):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
H,W,N = map(int,input().split())
count = []
L = 0
for i in range(N):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    for i in range(max(0,a-2),min(a+1,H-2)):
        for j in range(max(0,b-2),min(b+1,W-2)):
            count.append((i,j))
            L += 1
count.sort()
ans = [0]*10
tmp = 0
for i in range(L-1):
    if count[i] == count[i+1]:
        tmp += 1
    else:
        ans[tmp] += 1
        tmp = 1
ans[tmp] += 1
ans[0] = (H-2)*(W-2)-sum(ans)
for i in range(10):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
H,W,N = map(int,input().split())
dic={}
for _ in range(N):
  a,b = [int(x)-1 for x in input().split()]
  for h in range(a,a+3):
    for w in range(b,b+3):
      if h<H and w<W:
        dic[10**10*h+w] = dic.get(10**10*h+w,0)+1
ans = [0]*10
for x in dic.values():
  ans[x] += 1
ans[0] = (H-2)*(W-2)-sum(ans[1:])
for x in ans:
  print(x)

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
input = sys.stdin.readline
H, W, N = map(int, input().split())

board = defaultdict(int)
black = []
for _ in range(N):
    a, b = map(int, input().split())
    black.append((a - 1, b - 1))
    board[(a-1) * W + (b - 1)] = 1

print(board)

num = [0] * 10
for p in black:
    for ch in range(max(p[0] - 1, 1), min(p[0] + 2, H - 1)):
        for cw in range(max(p[1] - 1, 1), min(p[1] + 2, W - 1)):
            count = 0
            for h in range(ch - 1, ch + 2):
                for w in range(cw - 1, cw + 2):
                    if board[h * W + w] == 1:
                        count += 1
            num[count] += 1
for i in range(1, 10):
    num[i] //= i
print((H - 2) * (W - 2) - sum(num))
for i in range(1, 10):
    print(num[i])

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
input = sys.stdin.readline
H, W, N = map(int, input().split())

board = defaultdict(int)
black = []
for _ in range(N):
    a, b = map(int, input().split())
    black.append((a - 1, b - 1))
    board[(a-1) * 10 ** 10 + (b - 1)] = 1

num = [0] * 10
for p in black:
    for ch in range(max(p[0] - 1, 1), min(p[0] + 2, H - 1)):
        for cw in range(max(p[1] - 1, 1), min(p[1] + 2, W - 1)):
            count = 0
            for h in range(ch - 1, ch + 2):
                for w in range(cw - 1, cw + 2):
                    if board[h * 10 ** 10 + w] == 1:
                        count += 1
            if count == 2:
                print(ch, cw)
            num[count] += 1
for i in range(1, 10):
    num[i] //= i
print((H - 2) * (W - 2) - sum(num))
for i in range(1, 10):
    print(num[i])

Submission status: Wrong Answer

Solution code:

def main():
    input = open(0).readline
    H, W, N = map(int, input().split())
    grid = {}
    AB = [0]*N
    for i in range(N):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        AB[i] = a, b
        grid[(a,b)]=1

    total = ((H-3)+1)*((W-3)+1)
    count = [0] * 10
    offset = [-2, -1, 0]
    for a, b in AB:
      pass

    for i in range(1, 10):
        count[i] //= i

    print(total-sum(count))
    for i in range(1, 10):
        #print(i, len(count[i])//i)#, count[i])
        print(count[i])#, count[i])
main()

Submission status: Wrong Answer

Solution code:
from collections import Counter, defaultdict

ans = defaultdict(lambda: 0)
h, w, n = map(int, input().split())
for _ in range(n):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    for a_i in range(a - 2, a + 1):
        for b_i in range(b - 2, b + 1):
            if (0 <= a_i < h - 2) & (0 <= b_i < w - 2):
                ans[(a_i, b_i)] += 1

k = Counter(ans.values())
ans_0 = (h - 2) * (w - 2) - sum(k.values())
for i in range(10):
    if i in k.keys():
        print(k[i])
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter, defaultdict

ans = defaultdict(lambda: 0)
h, w, n = map(int, input().split())
for _ in range(n):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    for a_i in range(a - 2, a + 1):
        for b_i in range(b - 2, b + 1):
            if (0 <= a_i < h - 2) & (0 <= b_i < w - 2):
                ans[(a_i, b_i)] += 1

k = Counter(ans.values())
for i in range(10):
    if i in k.keys():
        print(k[i])
    else:
        print(0)