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: Runtime Error

Solution code:
h, w, n = map(int, input().split())
lst = [tuple(input().split()) for i in range(n)]

ans = [0] * 10
if n == 0:
    ans[0] = 999999996000000004
    ans = map(str, ans)
    print('\n'.join(ans))
    exit(0)

stage = [[0] * w for i in range(h)]

for t in lst:
    stage[int(t[0]) - 1][int(t[1]) - 1] = 1

tmp = []
for col in range(h - 3 + 1):
    for row in range(w - 3 + 1):
        tmp = []
        for cc in range(3):
            tmp.append(stage[col + cc][row:row+3])  
        one_list = sum(tmp, [])
        c = one_list.count(1)
        ans[c] += 1

[print(ans[i]) for i in range(len(ans))]

Submission status: Runtime Error

Solution code:
from collections import defaultdict

h, w, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

d = defaultdict(int)

for a, b in ab:
    for hi in range(a - 2, a + 1):
        for wi in range(b - 2, b + 1):
            if 1 <= hi <= h - 2 and 1 <= wi <= w - 2:
                d[(hi, wi)] += 1

cnt = [0] * 9
for v in d.values():
    cnt[v] += 1

cnt[0] = (h - 2) * (w - 2) - sum(cnt[1:])
print(*cnt, sep="\n")

Submission status: Runtime Error

Solution code:
H,W,N = map(int,input().split())
H,W = H-2,W-2
A = [0]*10
A[0] = W*H
S = [[0]*W for i in range(H)]
for i in range(N):
    a,b = map(lambda x:int(x)-1,input().split())
    for j in [-1,0,1]:
        for k in [-1,0,1]:
            h,w = a+j,b+k
            if min(h,w)<1 or h>H or w>W:continue
            S[h-1][w-1]+=1
            s = S[h-1][w-1]
            A[s]+=1
            A[s-1]-=1
for i in range(10):
    print(A[i])

Submission status: Runtime Error

Solution code:
from collections import Counter
H,W,N = map(int,input().split())
H,W = H-2,W-2
A = [0]*(H*W)
for i in range(N):
    a,b = map(lambda x:int(x)-1,input().split())
    for j in [-1,0,1]:
        for k in [-1,0,1]:
            h,w = a+j,b+k
            if min(h,w)<1 or h>H or w>W:continue
            p = (h-1)*W+(w-1)
            A[p]+=1
C = Counter(A)
for i in range(10):
    print(C[i])

Submission status: Runtime Error

Solution code:
H, W, N, *L = map(int, open('0').read().split())
dic = {}
for a, b in zip(*[iter(L)]*2):
  for i in range(a-2,a+1):
    for j in range(b-2,b+1):
      if 0<i and i+2<=H and 0<j and j+2<=W:
        dic[i*W+j] = dic.get(i*W+j,0)+1
ans = [0]*10
ans[0] = (W-2)*(H-2)
for k in dic.keys():
  ans[dic[k]] += 1
  ans[0] -= 1
print('\n'.join(map(str,ans)))

Submission status: Runtime Error

Solution code:
from collections import defaultdict
H, W, N, *L = map(int, open('0').read().split())
dic = defaultdict(int)
for a, b in zip(*[iter(L)]*2):
  for i in range(a-2,a+1):
    for j in range(b-2,b+1):
      if 0<i and i+2<=H and 0<j and j+2<=W:
        dic[(i,j)] += 1
ans = [0]*10
ans[0] = (W-2)*(H-2)
for k in dic.keys():
  ans[dic[k]] += 1
  ans[0] -= 1
print(*ans,sep='\n')

Submission status: Runtime Error

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
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: Runtime Error

Solution code:
dx = [-1,-1,-1,0,0,1,1,1]
dy = [-1,0,1,-1,1,-1,0,1]
H,W,N = map(int,input().split())
s = []
d = {}
for i in range(N):
    x,y = map(int,input().split())
    if (x,y) not in s:
        d[(x,y)] = 0
        s.append((x,y))
    d[(x,y)] += 1
    for j in range(8):
        X = x + dx[j]
        Y = y + dx[j]
        if (X,Y) not in s:
            d[(x,y)] = 0
            s.append((X,Y))
        d[(X,Y)] += 1
ans = [H*W-len(s),0,0,0,0,0,0,0,0,0]
for (x,y) in s:
    ans[d[(x,y)]] += 1
for i in range(10):
    print(ans[i])

Submission status: Runtime Error

Solution code:
// abc045_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int dx[9]={ 0, 1, 0, -1, 0, -1, 1, -1, 1};
int dy[9]={ 0, 0, 1, 0, -1, -1, -1, 1, 1};

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    ll H, W, N;
    cin >> H >> W >> N;

    if (N == 0){
        print((H-2)*(W-2));
        REP(i, 9) print(0);
        return 0;
    }

    vector<P> AB(N);
    REP(i, N) {
        cin >> AB[i].first >> AB[i].second;
        AB[i].first--; AB[i].second--;
    }

    sort(ALL(AB));
    ll h_margin = min(3ll, H-1 - AB[N-1].first);

    ll prev_x = 0;
    REP(i, N){
        AB[i].first = prev_x + min(3ll, AB[i].first - prev_x);
        prev_x = AB[i].first;
    }
    ll h = AB[N-1].first + 1 + h_margin;

    sort(ALL(AB), [](const P& a, const P& b) {return a.second < b.second;});
    ll w_margin = min(3ll, W-1 - AB[N-1].second);

    ll prev_y = 0;
    REP(i, N){
        AB[i].second = prev_y + min(3ll, AB[i].second - prev_y);
        prev_y = AB[i].second;
    }
    ll w = AB[N-1].second + 1 + w_margin;

//    print(h, w);
//    print(AB);

    vector<vector<int>> S(h, vector<int>(w, 0));
    REP(i, N){
        ll a = AB[i].first;
        ll b = AB[i].second;
        S[a][b] = 1;
    }

//    REP(i, h) print(S[i]);

    vector<ll> ans(10);
    REPN(i, 1, h-1) REPN(j, 1, w-1){

        int cnt=0;
        REP(k, 9) cnt += S[i+dx[k]][j+dy[k]];

        if (cnt > 0) ans[cnt]++;
    }

    ans[0] = (H-2)*(W-2) - accumulate(ALL(ans), 0ll);

    REP(i, 10) print(ans[i]);


    return 0;
}

Submission status: Runtime Error

Solution code:
def main():
    from sys import stdin
    #input = stdin.readline
    import numpy as np
    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 = np.full((5, 5), None, dtype=np.int64)
        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, j] = 1
                else:
                    temp[i, j] = 0
        # print(temp)
        flag_yoko = [0, 5]
        flag_tate = [0, 5]
        if np.all(temp[:, 0] == np.full((1, 5), None, dtype=np.int64)):
            if np.all(temp[:, 1] == np.full((1, 5), None, dtype=np.int64)):
                flag_yoko[0] = 2
            else:
                flag_yoko[0] = 1
        if np.all(temp[:, 4] == np.full((1, 5), None, dtype=np.int64)):
            if np.all(temp[:, 3] == np.full((1, 5), None, dtype=np.int64)):
                flag_yoko[1] = 3
            else:
                flag_yoko[1] = 4
        if np.all(temp[0, :] == np.full(5, None, dtype=np.int64)):
            if np.all(temp[1, :] == np.full(5, None, dtype=np.int64)):
                flag_tate[0] = 2
            else:
                flag_tate[0] = 1
        if np.all(temp[4, :] == np.full(5, None, dtype=np.int64)):
            if np.all(temp[3, :] == np.full(5, None, dtype=np.int64)):
                flag_tate[1] = 3
            else:
                flag_tate[1] = 4
        new_temp = temp[flag_tate[0]:flag_tate[1], flag_yoko[0]:flag_yoko[1]]
        # print(new_temp)
        for i in range(flag_tate[1]-flag_tate[0]-2):
            for j in range(flag_yoko[1]-flag_yoko[0]-2):
                cnt = [new_temp[i+k, j+l] for k in range(3) for l in range(3)]
                if None not in cnt:
                    ans[sum(cnt)-1].add((a+i-2+flag_tate[0], b+j-2+flag_yoko[0]))

    for i in range(9):
        ans[i] = len(ans[i])

    print((h-2)*(w-2)-sum(ans))
    for i in ans:
        print(i)


main()

Submission status: Runtime Error

Solution code:
def main():
    from sys import stdin
    #input = stdin.readline
    import numpy as np
    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 = np.full((5, 5), None, dtype=np.int64)
        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, j] = 1
                else:
                    temp[i, j] = 0
        # print(temp)
        flag_yoko = [0, 5]
        flag_tate = [0, 5]
        if np.all(temp[:, 0] == np.full((1, 5), None), dtype=np.int64):
            if np.all(temp[:, 1] == np.full((1, 5), None), dtype=np.int64):
                flag_yoko[0] = 2
            else:
                flag_yoko[0] = 1
        if np.all(temp[:, 4] == np.full((1, 5), None), dtype=np.int64):
            if np.all(temp[:, 3] == np.full((1, 5), None), dtype=np.int64):
                flag_yoko[1] = 3
            else:
                flag_yoko[1] = 4
        if np.all(temp[0, :] == np.full(5, None), dtype=np.int64):
            if np.all(temp[1, :] == np.full(5, None), dtype=np.int64):
                flag_tate[0] = 2
            else:
                flag_tate[0] = 1
        if np.all(temp[4, :] == np.full(5, None), dtype=np.int64):
            if np.all(temp[3, :] == np.full(5, None), dtype=np.int64):
                flag_tate[1] = 3
            else:
                flag_tate[1] = 4
        new_temp = temp[flag_tate[0]:flag_tate[1], flag_yoko[0]:flag_yoko[1]]
        # print(new_temp)
        for i in range(flag_tate[1]-flag_tate[0]-2):
            for j in range(flag_yoko[1]-flag_yoko[0]-2):
                cnt = [new_temp[i+k, j+l] for k in range(3) for l in range(3)]
                if None not in cnt:
                    ans[sum(cnt)-1].add((a+i-2+flag_tate[0], b+j-2+flag_yoko[0]))

    for i in range(9):
        ans[i] = len(ans[i])

    print((h-2)*(w-2)-sum(ans))
    for i in ans:
        print(i)


main()

Submission status: Runtime Error

Solution code:
def main():
    from sys import stdin
    input = stdin.readline
    import numpy as np
    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 = np.full((5, 5), None)
        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, j] = 1
                else:
                    temp[i, j] = 0
        # print(temp)
        flag_yoko = [0, 5]
        flag_tate = [0, 5]
        if np.all(temp[:, 0] == np.full((1, 5), None)):
            if np.all(temp[:, 1] == np.full((1, 5), None)):
                flag_yoko[0] = 2
            else:
                flag_yoko[0] = 1
        if np.all(temp[:, 4] == np.full((1, 5), None)):
            if np.all(temp[:, 3] == np.full((1, 5), None)):
                flag_yoko[1] = 3
            else:
                flag_yoko[1] = 4
        if np.all(temp[0, :] == np.full(5, None)):
            if np.all(temp[1, :] == np.full(5, None)):
                flag_tate[0] = 2
            else:
                flag_tate[0] = 1
        if np.all(temp[4, :] == np.full(5, None)):
            if np.all(temp[3, :] == np.full(5, None)):
                flag_tate[1] = 3
            else:
                flag_tate[1] = 4
        new_temp = temp[flag_tate[0]:flag_tate[1], flag_yoko[0]:flag_yoko[1]]
        # print(new_temp)
        for i in range(flag_tate[1]-flag_tate[0]-2):
            for j in range(flag_yoko[1]-flag_yoko[0]-2):
                cnt = [new_temp[i+k, j+l] for k in range(3) for l in range(3)]
                if None not in cnt:
                    ans[sum(cnt)-1].add((a+i-2+flag_tate[0], b+j-2+flag_yoko[0]))

    for i in range(9):
        ans[i] = len(ans[i])

    print((h-2)*(w-2)-sum(ans))
    for i in ans:
        print(i)


main()

Submission status: Runtime Error

Solution code:
def main():
    from sys import stdin
    input = stdin.readline
    import numpy as np
    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 = np.full((5, 5), None)
        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, j] = 1
                else:
                    temp[i, j] = 0
        flag_yoko = [0, 5]
        flag_tate = [0, 5]
        if np.all(temp[:, 0] == np.full((1, 5), None)):
            if np.all(temp[:, 1] == np.full((1, 5), None)):
                flag_yoko[0] = 2
            else:
                flag_yoko[0] = 1
        if np.all(temp[:, 4] == np.full((1, 5), None)):
            if np.all(temp[:, 3] == np.full((1, 5), None)):
                flag_yoko[1] = 3
            else:
                flag_yoko[1] = 4
        if np.all(temp[0, :] == np.full(5, None)):
            if np.all(temp[1, :] == np.full(5, None)):
                flag_tate[0] = 2
            else:
                flag_tate[0] = 1
        if np.all(temp[4, :] == np.full(5, None)):
            if np.all(temp[3, :] == np.full(5, None)):
                flag_tate[1] = 3
            else:
                flag_tate[1] = 4
        new_temp = temp[flag_tate[0]:flag_tate[1], flag_yoko[0]:flag_yoko[1]]
        for i in range(flag_tate[1]-flag_tate[0]-2):
            for j in range(flag_yoko[1]-flag_yoko[0]-2):
                cnt = [new_temp[i+k, j+l] for k in range(3) for l in range(3)]
                if None not in cnt:
                    ans[sum(cnt)-1].add((a+i-2+flag_tate[0], b+j-2+flag_yoko[0]))

    for i in range(9):
        ans[i] = len(ans[i])

    print((h-2)*(w-2)-sum(ans))
    for i in ans:
        print(i)


main()

Submission status: Runtime Error

Solution code:
h, w, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

d = dict()
for i in range(len(ab)):
    a = ab[i][0] - 1
    b = ab[i][0] - 1
    d[a] = set()

dp = [0] * 10
dp[0] = (h - 2) * (w - 2)
for i in range(n):
    a = ab[i][0] - 1
    b = ab[i][1] - 1
    for dx in [-1, 0, 1]:
        for dy in [-1, 0, 1]:
            nx, ny = a + dx, b + dy # center
            if nx >= 1 and nx <= h - 2 and ny >= 1 and ny <= w - 2:
                # print(nx, ny)
                tmp = 0
                for dx2 in [-1, 0, 1]:
                    for dy2 in [-1, 0, 1]:
                        if ny + dy2 in d[nx + dx2]:
                            tmp += 1

                dp[tmp] -= 1
                dp[tmp + 1] += 1

    d[a].add(b)

for x in dp:
    print(x)

Submission status: Runtime Error

Solution code:
import numpy as np
H, W, N = map(int, input().split())
table = np.zeros((H, W), dtype='int64')
print(type(table))
for _ in range(N):  # 黒なら1と更新する
    a, b = map(int, input().split())
    table[a-1][b-1] = 1
count_0 = 0
count_1 = 0
count_2 = 0
count_3 = 0
count_4 = 0
count_5 = 0
count_6 = 0
count_7 = 0
count_8 = 0
count_9 = 0

for y in range(H-2):
    for x in range(W-2):
        count = 0
        for i in range(3):    # 1の数を数える
            for j in range(3):
                if table[y + i][x + j] == 1:
                    count += 1
        if count == 0:
            count_0 += 1
        elif count == 1:
            count_1 += 1
        elif count == 2:
            count_2 += 1
        elif count == 3:
            count_3 += 1
        elif count == 4:
            count_4 += 1
        elif count == 5:
            count_5 += 1
        elif count == 6:
            count_6 += 1
        elif count == 7:
            count_7 += 1
        elif count == 8:
            count_8 += 1
        elif count == 9:
            count_9 += 1
        # print('y = {0}, x = {1}, count = {2}'.format(y, x, count))

print(count_0)
print(count_1)
print(count_2)
print(count_3)
print(count_4)
print(count_5)
print(count_6)
print(count_7)
print(count_8)
print(count_9)

Submission status: Runtime Error

Solution code:
import numpy as np
H, W, N = map(int, input().split())
table = np.zeros((H, W), dtype='int64')
for _ in range(N):  # 黒なら1と更新する
    a, b = map(int, input().split())
    table[a-1][b-1] = 1
count_0 = 0
count_1 = 0
count_2 = 0
count_3 = 0
count_4 = 0
count_5 = 0
count_6 = 0
count_7 = 0
count_8 = 0
count_9 = 0

for y in range(H-2):
    for x in range(W-2):
        count = 0
        for i in range(3):    # 1の数を数える
            for j in range(3):
                if table[y + i][x + j] == 1:
                    count += 1
        if count == 0:
            count_0 += 1
        elif count == 1:
            count_1 += 1
        elif count == 2:
            count_2 += 1
        elif count == 3:
            count_3 += 1
        elif count == 4:
            count_4 += 1
        elif count == 5:
            count_5 += 1
        elif count == 6:
            count_6 += 1
        elif count == 7:
            count_7 += 1
        elif count == 8:
            count_8 += 1
        elif count == 9:
            count_9 += 1
        # print('y = {0}, x = {1}, count = {2}'.format(y, x, count))

print(count_0)
print(count_1)
print(count_2)
print(count_3)
print(count_4)
print(count_5)
print(count_6)
print(count_7)
print(count_8)
print(count_9)

Submission status: Runtime Error

Solution code:
import numpy as np
H, W, N = map(int, input().split())
table = np.zeros((H, W))
for _ in range(N):  # 黒なら1と更新する
    a, b = map(int, input().split())
    table[a-1][b-1] = 1
# print(table)
count_0 = 0
count_1 = 0
count_2 = 0
count_3 = 0
count_4 = 0
count_5 = 0
count_6 = 0
count_7 = 0
count_8 = 0
count_9 = 0

for y in range(H-2):
    # print('y = ' + str(y))
    for x in range(W-2):
        # print('x = ' + str(x))
        count = 0
        for i in range(3):    # 1の数を数える
            for j in range(3):
                if table[y + i][x + j] == 1:
                    count += 1
        if count == 0:
            count_0 += 1
        elif count == 1:
            count_1 += 1
        elif count == 2:
            count_2 += 1
        elif count == 3:
            count_3 += 1
        elif count == 4:
            count_4 += 1
        elif count == 5:
            count_5 += 1
        elif count == 6:
            count_6 += 1
        elif count == 7:
            count_7 += 1
        elif count == 8:
            count_8 += 1
        elif count == 9:
            count_9 += 1
        # print('y = {0}, x = {1}, count = {2}'.format(y, x, count))

print(count_0)
print(count_1)
print(count_2)
print(count_3)
print(count_4)
print(count_5)
print(count_6)
print(count_7)
print(count_8)
print(count_9)
# count_0 = 0
# count_1 = 0
# count_2 = 0
# count_3 = 0
# count_4 = 0
# count_5 = 0
# count_6 = 0
# count_7 = 0
# count_8 = 0
# count_9 = 0

# if count == 0:
#     count_0 += 1
# elif count == 1:
#     count_1 += 1
# elif count == 2:
#     count_2 += 1
# elif count == 3:
#     count_3 += 1
# elif count == 4:
#     count_4 += 1
# elif count == 5:
#     count_5 += 1
# elif count == 6:
#     count_6 += 1
# elif count == 7:
#     count_7 += 1
# elif count == 8:
#     count_8 += 1
# elif count == 9:
#     count_9 += 1

Submission status: Runtime Error

Solution code:
import numpy as np
import collections

H, W, N = map(int,input().split())
C = np.zeros((H, W),dtype=int)

for _ in range(N): 
    a, b = map(int, input().split())
    C[a-1,b-1] = 1

ans = []
for i in range(H-2):
    for j in range(W-2):
        ans.append(np.sum(C[i:i+3,j:j+3]))

for j in range(10):
    print(collections.Counter(ans)[j])

Submission status: Runtime Error

Solution code:
import numpy as np
H,W,N = map(int,input().split())
X=np.array([[0]*W]*H)
c=[0]*10
for i in range(N):
  x,y=map(int,input().split())
  X[x-1,y-1]=1
for i in range(H-2):
  for j in range(W-2):
    p=sum(sum(X[i:i+3,j:j+3]))
    c[p] += 1
for i in range(10):
  print(c[i])

Submission status: Runtime Error

Solution code:
H,W,N = map(int,input().split())
count = [[0]*(W-2) for i in range(H-2)]
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[i][j] += 1
ans = [0]*10
for i in range(H-2):
    for j in range(W-2):
        ans[count[i][j]] += 1
for i in range(10):
    print(ans[i])

Submission status: Runtime Error

Solution code:
def main():
    h,w,n=map(int,input().split(' '))
    draw_list=[]
    for i in range(n):
        draw=tuple(map(int,input().split(' ')))
        for j in range(3):
            for k in range(3):
                if 0<draw[0]-j<=h-2 and 0<draw[1]-k<=w-2:
                    draw_list.append((draw[0]-j,draw[1]-k))
    ans = [0]*9
    sorted_draw = sorted(draw_list)
    for n,i in enumerate(sorted_draw):
        if not n:
            ans_num=0
            tmp = i
            continue
        if tmp == i:
            ans_num+=1
        else:
            ans[ans_num] += 1
            tmp = i
            ans_num = 0
    ans[ans_num] += 1
    print((h-2)*(w-2)-sum(ans))
    for i in ans:
        print(i)



if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    h,w,n=map(int,input().split(' '))
    draw_list=[]
    for i in range(n):
        draw=tuple(map(int,input().split(' ')))
        for j in range(3):
            for k in range(3):
                if 0<draw[0]-j<=h-2 and 0<draw[1]-k<=w-2:
                    draw_list.append((draw[0]-j,draw[1]-k))
    ans = [0]*9
    sorted_draw = sorted(draw_list)
    tmp = sorted_draw[0]
    ans_num = 0
    for i in range(len(sorted_draw)-1):
        if sorted_draw[i] == sorted_draw[i+1]:
            ans_num += 1
        else:
            ans[ans_num] += 1
            ans_num = 0
    if ans_num:
        ans[ans_num]+=1

    print((h-2)*(w-2)-sum(ans))
    for i in ans:
        print(i)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    h,w,n=map(int,input().split(' '))
    draw_list=[]
    for i in range(n):
        draw=tuple(map(int,input().split(' ')))
        for j in range(3):
            for k in range(3):
                if 0<draw[0]-j<=h-2 and 0<draw[1]-k<=w-2:
                    draw_list.append((draw[0]-j,draw[1]-k))
    ans = [0]*9
    sorted_draw = sorted(draw_list)
    tmp = sorted_draw[0]
    ans_num = 0
    for i in range(len(sorted_draw)-1):
        if sorted_draw[i] == sorted_draw[i+1]:
            ans_num += 1
        else:
            ans[ans_num] += 1
            ans_num = 0
    if ans_num:
        ans[ans_num]+=1

    print((h-2)*(w-2)-sum(ans))
    for i in ans[1:]:
        print(i)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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-2,a+3):
    for w in range(b-2,b+3):
      if 0<=h<H and 0<=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: Runtime Error

Solution code:
inp=input().split(" ")
H=int(inp[0])
W=int(inp[1])
N=int(inp[2])
square=[]
plot=[]
times=[0 for i in range(10)]
times[0]=(H-2)*(W-2)
from collections import defaultdict
count=defaultdict(lambda:0)
def check(a,b,count):
    for i in range(3):
        for j in range(3):
            if a-i>=0 and b-j>=0 and a+2-i<=H-1 and b+2-j<=W-1:
                count[str([a-i,b-j])]+=1
for i in range(N):
    plot.append(list(map(int,input().split(" "))))
    check(plot[i][0]-1,plot[i][1]-1,square)
for i in count.values():
    times[i]+=1
    times[0]-=1
for i in range(len(times)):
    print(times[i])

Submission status: Runtime Error

Solution code:
from collections import Counter
h,w,n=map(int,input().split())
x=[0 for _ in range((h-2)*(w-2))]
for _ in range(n):
  a,b=map(int,input().split())
  for i in range(max(0,a-3),min(h-2,a)):
    for j in range(max(0,b-3),min(w-2,b)):
      x[i*(h-2)+j]+=1
c=Counter(x)
for i in range(10):
  print(c[i])

Submission status: Runtime Error

Solution code:
import numpy as np
h, w, n = map(int, input().split(" "))
board = np.zeros((h, w))
for i in range(n):
  a, b = map(int, input().split(" "))
  board[a - 1][b - 1] = 1
result = [0 for _ in range(10)]
for start_h in range(h - 2):
  for start_w in range(w - 2):
    sum_black = np.count_nonzero(board[start_h:(start_h+3), start_w:(start_w + 3)] > 0)
    result[sum_black] += 1

for one_result in result:
  print(one_result)

Submission status: Runtime Error

Solution code:

def main():
    import sys
    input = sys.readline
    H, W, N = map(int, input().split())
    grid = set()
    for i in range(N):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        grid.add((a,b))

    total = ((H-3)+1)*((W-3)+1)
    count = [0] * 10
    offset = [-2, -1, 0]
    for a, b in grid:
        for x in offset:
            ax = a+x
            if not (0 <= ax and ax+2 < H):
                continue
            for y in offset:
                by = b + y
                if 0 <= by and by+2 < W:
                    c = sum(1 if (ax+i, by+j) in grid else 0 for i in range(3)
                        for j in range(3))
                    count[c] += 1

    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: Runtime Error

Solution code:
import sys
import numpy as np
import time
input = sys.stdin.readline

H,W,N=map(int,input().split())
ab=[tuple(map(int,input().split())) for i in range(N)]
ab.sort()

r_b=[0]

r_b_app=r_b.append
for i in range(1,N):
  if ab[i][0]!=ab[i-1][0]:
    r_b_app(i)

if N>0:
  r_b_app(N)
rows=tuple(ab[b][0] for b in r_b if b<N)

cols=tuple(tuple(ab[j][1] for j in range(r_b[i],r_b[i+1])) for i in range(len(r_b)-1))

rN=len(cols)


ched_box0=np.zeros(((len(cols[0]) if 0<rN else 0),3,3),dtype=bool)
ched_box1=np.zeros(((len(cols[1]) if 1<rN else 0),3,3),dtype=bool)
ched_box2=np.zeros(((len(cols[2]) if 1<rN else 0),3,3),dtype=bool)

dic_cn0=dict(zip(cols[0],list(range(len(cols[0]))))) if 0<rN else {}
dic_cn1=dict(zip(cols[1],list(range(len(cols[1]))))) if 1<rN else {}
dic_cn2=dict(zip(cols[2],list(range(len(cols[2]))))) if 2<rN else {}

area_n=[0]*9

count=[[1]*3 for i in range(3)]
find_cn=[0]*12

for rn in range(rN):
  cN=len(cols[rn])
  row=rows[rn]

  if rn!=0:
    ched_box0=ched_box1
    dic_cn0=dic_cn1
    ched_box1=ched_box2
    dic_cn1=dic_cn2
    if rn<rN-2:
      cN2_range=range(len(cols[rn+2]))
      ched_box2=np.zeros((len(cols[rn+2]),3,3),dtype=bool)
      dic_cn2=dict(zip(cols[rn+2],list(cN2_range)))

  if (rows[rn+1]==row+1 if rn<rN-1 else False):
    row1=row+1
    if (rows[rn+2]==row+2 if rn<rN-2 else False):
      row2=row+2
    else:
      row2=None
  elif (rows[rn+1]==row+2 if rn<rN-1 else False):
    row1=row+2
    row2=None
  else:
    row1=None
    row2=None
  find_rowcol=np.zeros((5,5),dtype=int)
  for cn in range(cN):
    col=cols[rn][cn]
    ched_box=ched_box0[cn]

    
    for box_row,box_col in zip(*np.where(ched_box==False)):
      if col-2+box_col<1 or col+box_col>W or row-2+box_row<1 or row+box_row>H:
        ched_box[box_row,box_col]=True    

    for ch_row in range(5):
      for ch_col in range(5):
        find_rowcol[ch_row,ch_col]=0
        
    find_cn=[[0]*5 for _ in range(3)]

    find_rowcol[2,2]=1
    find_cn[0][2]=cn
    if (col+1 in dic_cn0 if col+1<=W else False):
      find_rowcol[2,3]=1
      find_cn[0][3]=dic_cn0[col+1]
    if (col+2 in dic_cn0 if col+2<=W else False):
      find_rowcol[2,4]=1
      find_cn[0][4]=dic_cn0[col+2]
    if (row1<=H if row1 is not None else False):
      for ch_col in range(max(col-2,1),min(col+3,W+1)):
        if ch_col in dic_cn1:
          find_rowcol[row1-row+2,ch_col-col+2]=1
          find_cn[row1-row][ch_col-col+2]=dic_cn1[ch_col]
    if (row2<=H if row2 is not None else False):
      for ch_col in range(max(col-2,1),min(col+3,W+1)):
        if ch_col in dic_cn2:
          find_rowcol[row2-row+2,ch_col-col+2]=1
          find_cn[row2-row][ch_col-col+2]=dic_cn2[ch_col]

             
   
    for box_row,box_col in zip(*np.where(ched_box==False)):
      area_n[find_rowcol[box_row:box_row+3,box_col:box_col+3].sum()-1]+=1
    for ch_row,ch_col in zip(*np.where(find_rowcol)):
      for box_row in range(5-ch_row):
        for box_col in range((0 if ch_col>=2 else 2-ch_col),(5-ch_col if ch_col>=2 else 3)):
          if ch_row==2:
            ched_box0[find_cn[ch_row-2][ch_col],box_row,box_col]=True
          elif ch_row==row1-row+2:
            ched_box1[find_cn[ch_row-2][ch_col],box_row,box_col]=True
          elif ch_row==row2-row+2:
            ched_box2[find_cn[ch_row-2][ch_col],box_row,box_col]=True




print((W-2)*(H-2)-sum(area_n))
for i in range(9):
  print(area_n[i])