Problem:

Official House

You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room.

  For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that &minus;v persons left.

Assume that initially no person lives in the building. 

Input

  In the first line, the number of notices n is given. In the following n lines, a set of four integers b, f, r and v which represents ith notice is given in a line. 

Output

For each building, print the information of 1st, 2nd and 3rd floor in this order. For each floor information, print the number of tenants of 1st, 2nd, .. and 10th room in this order. Print a single space character before the number of tenants. Print "####################" (20 '#') between buildings.

Constraints

No incorrect building, floor and room numbers are given.

0 ≤ the number of tenants during the management ≤ 9

Sample Input

3
1 1 3 8
3 2 2 7
4 3 8 1

Sample Output

 0 0 8 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
####################
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
####################
 0 0 0 0 0 0 0 0 0 0
 0 7 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
####################
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 1 0 0



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


Sample output:
 0 0 8 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
####################
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
####################
 0 0 0 0 0 0 0 0 0 0
 0 7 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
####################
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 1 0 0

Submission status: Accepted

Solution code:
n = int(input())
room = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for _ in range(n):
    b,f,r,v = map(int,input().split())
    room[b-1][f-1][r-1] += v

for c in range(4):
    for d in range(3):
        print('',*room[c][d])
    if c != 3:
        print('#' *20)

Submission status: Accepted

Solution code:
N = int(input())
bfr = [[[0]*10 for i in range(3)] for j in range(4)]
for i in range(N):
    b, f, r, v = [int(n) for n in input().split()]
    bfr[b-1][f-1][r-1] += v
c = 0
for B in bfr:
    for F in B:
        print('{:>20}'.format(' '.join([str(c) for c in F])))
    c += 1
    if c < 4:
        print('####################')

Submission status: Accepted

Solution code:
people = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().split())
    people[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(f" {people[i][j][k]}", end="")
        print()
    if i != 3:
        print("####################")

Submission status: Accepted

Solution code:
n = int(input())
arr = [ [ [0]*10 for j in range(3) ] for i in range(4) ]
i = 0
while i < n:
    a, b, c, d = map(int,input().split())
    arr[a-1][b-1][c-1] += d
    i += 1
for i in range(4):
    if i > 0:
        print('#'*20)
    for j in range(3):
        print('', *arr[i][j])

Submission status: Accepted

Solution code:
targets = [[[0 for i in range(10)] for i in range(3)] for i in range(4)]
n = int(input())
for i in range(n):
	b, f, r, v = map(int, input().split())
	targets[b - 1][f - 1][r - 1] += v
s = '#' * 20
index = 0
for target in targets:
	for t in target:
		print(' ' + ' '.join(list(map(str, t))))
	if index < 3: 
		print(s)
	index += 1

Submission status: Accepted

Solution code:
n = int(input())
x = [[int(x) for x in input().split()] for _ in range(n)]

house0 = [[0 for _ in range(10)] for _ in range(3)]
house1 = [[0 for _ in range(10)] for _ in range(3)]
house2 = [[0 for _ in range(10)] for _ in range(3)]
house3 = [[0 for _ in range(10)] for _ in range(3)]
house = [house0, house1, house2, house3]

for b, f, r, v in x:
    house[b-1][f-1][r-1] += v

for i, item in enumerate(house):
    for row in item:
        print(' ', end='')
        print(*row)
    if i < 3:
        print('#'*20)

Submission status: Accepted

Solution code:
Rooms = [[[0 for i in range(10)] for ii in range(3)] for iii in range (4)]
num = int(input())
for i in range(num):
    b, f, r, v = map(int, input().split())
    Rooms[b-1][f-1][r-1] += v
    
for i in range(15):
    if i % 4 == 3: 
        print("####################")
    else:
        b = i // 4
        f = i % 4
        print(" " + " ".join(map(str, Rooms[b][f])))

Submission status: Accepted

Solution code:
def output(A):
    for i in range(3):
        print(" ",end="")
        print(*A[i])

a = [[0 for i in range(10)] for j in range(3)]
b = [[0 for i in range(10)] for j in range(3)]
c = [[0 for i in range(10)] for j in range(3)]
d = [[0 for i in range(10)] for j in range(3)]

N = int(input())
for _ in range(N):
    bb,f,r,v = map(int,input().split())
    r -= 1
    f -= 1
    if bb == 1:
        a[f][r] += v
    elif bb == 2:
        b[f][r] += v
    elif bb == 3:
        c[f][r] += v
    else:
        d[f][r] += v

output(a)
print("####################")
output(b)
print("####################")
output(c)
print("####################")
output(d)

Submission status: Accepted

Solution code:
n = int(input())
listA = [list(map(int, input().split(" "))) for i in range(n)]

b = []
f = []
r = []
v = []
for building in range(4):
    for floor in range(3):
        for room in range(10):
            r.append(0)
        f.append(r)
        r = []
    b.append(f)
    f = []

for i in listA:
    b[i[0]-1][i[1]-1][i[2]-1] += i[3]

for idx, building in enumerate(b):
    for floor in building:
        print(" " + " ".join(map(str, floor)))
    if idx < 3:
        print("#" * 20)

Submission status: Accepted

Solution code:
# 公舎の入居者数

# input
N = int(input())

# initialization
room_info = [[[0]*10 for i in range(3)] for j in range(4)]

# insert
for i in range(N):
    b, f, r, v = map(int, input().split())
    room_info[b-1][f-1][r-1] += v

# output
for b in range(4):
    for f in range(3):
        print(" ", end="")
        rooms = room_info[b][f]
        rooms = list(map(str, rooms))
        print(" ".join(rooms))
    if not b==3:
        print("####################")

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    l = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]
    
    for _ in range(n):
        b,f,r,v = map(int,input().split())
        b -= 1
        f -= 1
        r -= 1
        l[b][f][r] += v
    
    for i,b in enumerate(l):
        for f in b:
            s = ""
            for r in f:
                s += " " + str(r)
            print(s)
        if i != 3:print("#"*20)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
x=0
i=0
building=[[[0 for i in range(10)] for i in range(3)] for i in range(4)]
while x<n:
    b,f,r,v = map(int, input().split())
    building[b-1][f-1][r-1]+=v
    x += 1
for build in building:
    for floor in build:
        print("",*floor)
    if i<3:
        print("#"*20)
        i+=1
    else:
        i+=1

Submission status: Accepted

Solution code:
n = int(input())
count = [[[0 for i in range(10)]for j in range(3)]for k in range(4)]
for i in range(n):
    b,f,r,v = map(int,input().split())
    count[b-1][f-1][r-1] += v
i = 0
for floor in count:
    i+=1
    for room in floor:
        for visitor in room:
            print("",visitor,end ="")
        print("")
    if(i!=4):
        print("####################")

Submission status: Accepted

Solution code:
count = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for i in range(n):
    b,f,r,v = map(int, input().split())
    count[b-1][f-1][r-1] += v
for i in range(4):
    for j in range(3):
        for k in range(10):
            if k == 9:
                print(f' {count[i][j][k]}')
            else:
                print(f' {count[i][j][k]}', end='')
    if i != 3:
        print('####################')

Submission status: Accepted

Solution code:
n = int(input())
l = [0] * 10*12

for _ in range(n):
    b,f,r,v = map(int,input().split())
    k = 3*10*(b-1) + 10*(f-1) + (r-1)
    l[k] = l[k] + v

k = 0
for i in range(15):
    if (i+1)%4 == 0:
        print ('####################')
        k += 1
    else:
        for j in range(10):
            print (' ' + str(l[((0+i-k)*10)+j]), end='')
        print ()

Submission status: Accepted

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

n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().split())
    a[3 * b + f - 4][r - 1] += v
    
for i, j in enumerate(a):
    if i % 3 == 0 and i != 0:
        print('#' * 20)
    print("", *j)

Submission status: Accepted

Solution code:
h = [[[0]*10 for i in range(3)] for j in range(4)]
for i in range(int(input())):
    b,f,r,k = map(int,input().split())
    h[b-1][f-1][r-1]+=k
for i in range(4):
    for j in h[i]: print('',*j)
    if i<3: print('#'*20)

Submission status: Accepted

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

check = [[0]*10 for _ in range(12)]

for i in range(n):
    b = li[i][0]
    f = li[i][1]
    r = li[i][2] - 1
    check[(b-1)*3 + f-1][r] += li[i][3]
    
for i in range(12):
    for j in range(10):
        if j == 9:
            print(" " + str(check[i][j]))
        else:
            print(" " + str(check[i][j]), end="")
    else:
        if i == 2 or i == 5 or i == 8:
            print("#"*20)

Submission status: Accepted

Solution code:
info = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())

for i in range(n):
    b,f,r,v = (int(x) for x in input().split())
    info[b-1][f-1][r-1] += v

for b in range(4):
    for f in range(3):
        for r in range(10):
            print(" " + str(info[b][f][r]), end="")
        print()
    if b == 3:
        break
    print("####################")

Submission status: Accepted

Solution code:
n=int(input())
list_=[[[0 for x in range(10)] for y in range(3)] for z in range(4)]
for i in range(n):
    b,f,r,v=map(int,input().split())
    list_[b-1][f-1][r-1]+=v
count=0
for a in list_:
    for c in a:
        print(" ",end="")
        #join()はstr型にしないといけない
        print(" ".join(map(str,c)))
    if count!=3:
        print("####################")
    count+=1

Submission status: Accepted

Solution code:

f = [[[0]*10 for _ in range (3)] for _ in range (4)]

n = int(input())
for _ in range(n):
    a,b,c,d = map(int,input().split())
    f[a-1][b-1][c-1] += d

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" %d"%(f[i][j][k]),end='')
        print()
    if i<3:print ('#'*20)

Submission status: Accepted

Solution code:
def construct_floor(num_rooms):
    return [0] * num_rooms


def construct_building(num_floors, num_rooms):
    building = []

    for i in range(num_floors):
        building.append(construct_floor(num_rooms))

    return building


def construct_buildings(num_buildings, num_floors, num_rooms):
    buildings = []

    for i in range(num_buildings):
        buildings.append(construct_building(num_floors, num_rooms))

    return buildings


def floor_to_string(floor):
    room_strings = list(map(str, floor))

    return ' ' + ' '.join(room_strings)


def building_to_string(building):
    floor_strings = list(map(floor_to_string, building))

    return '\n'.join(floor_strings)


def show_buildings(buildings):
    building_strings = list(map(building_to_string, buildings))

    separator = ''.join(['#'] * 20)

    separator = '\n' + separator + '\n'

    buildings_string = separator.join(building_strings)

    print(buildings_string)


if __name__ == "__main__":
    num_inputs = int(input())

    inputs = []

    for i in range(num_inputs):
        inputs.append(input())

    tenant_leaver_notices = list(
        map(lambda input_value: list(map(int, input_value.split())), inputs)
    )

    official_house = construct_buildings(4, 3, 10)

    for tenant_leaver_notice in tenant_leaver_notices:
        building = tenant_leaver_notice[0] - 1
        floor = tenant_leaver_notice[1] - 1
        room = tenant_leaver_notice[2] - 1
        num_people = tenant_leaver_notice[3]

        official_house[building][floor][room] += num_people

    show_buildings(official_house)

Submission status: Accepted

Solution code:
Tatemono = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

n = int(input())
#b棟(4)f階(3)のr番目の部屋(10)にv人が追加

for _ in range(n):
    b,f,r,v=map(int,input().split())
    Tatemono[b-1][f-1][r-1] = v+Tatemono[b-1][f-1][r-1]
    


for building_no, no in zip(Tatemono, range(len(Tatemono))):
    for floor_no in building_no:
        for room_no in floor_no:
            print(" ",end ="")
            print(room_no,end="")

        print("")

    if len(Tatemono) == no+1:
        break

    print("####################")

Submission status: Accepted

Solution code:
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
sys.setrecursionlimit(100001)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = int(input())

d = getSomeInputListInt(n)

buildings = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for b, f, r, v in d:
    buildings[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        print("",*buildings[i][j], sep=" ")

    if i!=3:
        for k in range(20):
            print("#", end="")
        print()

Submission status: Accepted

Solution code:
num = int(input())
a = [[0] * 10 for i in range(3)]
b = [[0] * 10 for i in range(3)]
c = [[0] * 10 for i in range(3)]
d = [[0] * 10 for i in range(3)]
for i in range(num):
  s = input().rstrip().split(' ')
  bild = int(s[0])
  floor = int(s[1])
  room = int(s[2])
  member = int(s[3])
  if bild == 1:
    a[floor-1][room-1] += member
  elif bild == 2:
    b[floor-1][room-1] += member
  elif bild == 3:
    c[floor-1][room-1] += member
  elif bild == 4:
    d[floor-1][room-1] += member

for j in range(3):
  ans = " "
  for k in range(9):
    ans = ans + str(a[j][k]) + " "
  ans += str(a[j][9])
  print(ans)
print("####################")
for l in range(3):
  ans = " "
  for m in range(9):
    ans = ans + str(b[l][m]) + " "
  ans += str(b[l][9])
  print(ans)
print("####################")
for n in range(3):
  ans = " "
  for o in range(9):
    ans = ans + str(c[n][o]) + " "
  ans += str(c[n][9])
  print(ans)
print("####################")
for p in range(3):
  ans = " "
  for q in range(9):
    ans = ans + str(d[p][q]) + " "
  ans += str(d[p][9])
  print(ans)

Submission status: Accepted

Solution code:

n = int(input())
a = list()
for i in range(120):
	a.append(0)
for i in range(n):
	b, f, r, v = map(int, input().split())
	a[(b - 1) * 30 + (f - 1) * 10 + (r - 1)] += v
for i in range(4):
	if i >= 1:
		print("#" * 20)
	for j in range(3):
		for k in range(10):
			print(' ', end = '')
			print(a[i * 30 + j * 10 + k], end = '')
		print()

Submission status: Accepted

Solution code:
members = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]

n = int(input())
for _ in range(n):
    b, f, r, v = map(int, input().split())
    members[b-1][f-1][r-1] += v

for b in range(4):
    if b > 0:
        print("####################")
    for f in range(3):
        print(" " + " ".join(map(str, members[b][f])))

Submission status: Accepted

Solution code:
x=[[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n=int(input())
for i in range(n):
	a=list(map(int,input().split()))
	x[a[0]-1][a[1]-1][a[2]-1]+=a[3]

for i in range(4):
	for j in range(3):
		print(' '+' '.join(map(str,x[i][j])))
	if i<3:
		print('####################')

Submission status: Accepted

Solution code:
count=[[[0 for i in range(10)]for j in range(3)]for k in range(4)]
n=int(input())
for i in range(n):
    table=list(map(int, input().split()))
    tou=table[0]
    kai=table[1]
    ban=table[2]
    nin=table[3]
    if count[tou-1][kai-1][ban-1]<10:
        count[tou-1][kai-1][ban-1]+=nin
for k in range(4):
    for j in range(3):
        for i in range(10):
            print("",count[k][j][i], end="")
        print()
    if k<3:
        for l in range(20):
            print("#", end="")
        print()

Submission status: Accepted

Solution code:
#2020-03-19
house = [[[0 for heya in range(10)] for kai in range(3)] for mune in range(4)] 

kensu = int(input())
for i in range(kensu):
    b,f,r,v = map(int,input().split())
    house[b-1][f-1][r-1] += v

for mune in range(4):    
    for kai in range(3):
        for heya in range(10):
            print(f' {house[mune][kai][heya]}',end='')
        print()
    if mune < 3:
        print('#' * 20)

Submission status: Accepted

Solution code:
n = int(input())
build = [[[0] * 10 for i in range(3)] for j in range(4)]

for i in range(n):
    b, f, r, v = map(int, input().split())
    build[b - 1][f - 1][r - 1] = build[b - 1][f - 1][r - 1] + v

for i in range(4):
    for j in range(3):
        print(' ', end='')
        print(' '.join(map(str, (build[i][j]))))
    if i != 3: print('#' * 20)

Submission status: Accepted

Solution code:
A = list([0] * 10 for x in range(3))
B = list([0] * 10 for x in range(3))
C = list([0] * 10 for x in range(3))
D = list([0] * 10 for x in range(3))

official_house = [A, B, C, D]

n = int(input())

for i in range(n):
    b, f, r, v = map(int, input().split())
    official_house[b - 1][f - 1][r- 1] += v

for i, b in enumerate(official_house):
    for f in b:
        print("", " ".join(map(str, f)))
    if i != len(official_house) - 1:
        print("####################")

Submission status: Accepted

Solution code:
count = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for i in range(n):
    b,f,r,v = map(int,input().split())
    count[b-1][f-1][r-1] += v
x = 0
for k in range(4):
    if x != 0:
        print("#"*20)
    x += 1
    for j in range(3):
        for i in range(10):
            print("",count[k][j][i],end="")
        print()

Submission status: Accepted

Solution code:
N = int(input())
bill = []
for _ in range(4):
    bill.append([[0]*10 for _ in range(3)])


for _ in range(N):
    b, f, r, v = map(int, input().split())
    bill[b-1][f-1][r-1] += v

for i, b in enumerate(bill):
    for x in b:
        print("", *x)
    if i < 3:
        print("#"*20)

Submission status: Accepted

Solution code:
import bisect,collections,copy,itertools,math,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def SI(): return list(input().split())
##################################################
def main(N,bfrv):
    ans = [[[0]*10 for _ in range(3)] for _ in range(4)]
    for x in bfrv:
        b,f,r,v = x[0],x[1],x[2],x[3]
        ans[b-1][f-1][r-1] += v
    for i,x in enumerate(ans):
        if i:
            print('#'*20)
        for y in x:
            print(' ',end='')
            print(*y)
    
N = I()
bfrv = [LI() for _ in range(N)]
main(N,bfrv)

Submission status: Accepted

Solution code:
all = [[[0 for _ in range(10)]for _ in range(3)]for _ in range(4)]

n = int(input())
for i in range(n):
    b,f,r,v = map(int, input().split())
    all[b-1][f-1][r-1] += v
for i in range(4):
  for j in range(3):
    for k in range(10):
      print(" {}".format(all[i][j][k]), end='')
    print()
  if i != 3:
    print("####################")

Submission status: Accepted

Solution code:
n = int(input())
build, floors, rooms = (4, 3, 10)

buildings = [[[0 for i in range(rooms)] for j in range(floors)] for k in range(build)]


for k in range(n):
    b, f, r, v = map(int, input().split())
    buildings[b-1][f-1][r-1] = buildings[b-1][f-1][r-1] + v

for i in range(4):

    for o in buildings[i]:
        print("", *o, sep=" ")

    if i < 3:
        print("#" * 20)

Submission status: Accepted

Solution code:
n = int(input())
build, floors, rooms = (4, 3, 10)

buildings = [[[0 for i in range(rooms)] for j in range(floors)] for k in range(build)]


for k in range(n):
    b, f, r, v = map(int, input().split())

    buildings[b-1][f-1][r-1] = buildings[b-1][f-1][r-1] + v


for n in buildings[0]:
    print("", *n, sep=" ")
print("#" * 20)
for o in buildings[1]:
    print("", *o, sep=" ")
print("#" * 20)
for p in buildings[2]:
    print("", *p, sep=" ")
print("#" * 20)
for q in buildings[3]:
    print("", *q, sep=" ")

Submission status: Accepted

Solution code:
n = int(input())

resident = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for i in range(n):
    lst = list(map(int, input().split()))
    resident[lst[0] - 1][lst[1] - 1][lst[2] - 1] += lst[3]

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" {}".format(resident[i][j][k]), end="")
        print()
    if i < 3:
        print("####################")

Submission status: Accepted

Solution code:
build = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
sep = '#'*20
n = int(input())
for _ in range(n):
    b, f, r, v = map(int, input().split())
    build[b-1][f-1][r-1] += v
cnt = 0
for F in build:
    for f in F:
        print(' ', end='')
        f = map(str, f)
        print(' '.join(f))
        cnt += 1
    if cnt <= 10:
        print(sep)

Submission status: Accepted

Solution code:
n = int(input())

board = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for i in range(n):
    b, f, r, v = map(int, input().split())
    board[b - 1][f - 1][r - 1] += v

for i in range(4):
    for j in range(3):
        print("", *board[i][j])
    if i < 3:
        print("#" * 20)

Submission status: Accepted

Solution code:
n = int(input())
info = [list(map(int, input().split())) for i in range(n)]
ans = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
count = 0
for i in info:
  ans[(i[0] - 1)][(i[1] - 1)][(i[2] - 1)] += i[3]
  if ans[(i[0] - 1)][(i[1] - 1)][(i[2] - 1)] > 9:
    ans[(i[0] - 1)][(i[1] - 1)][(i[2] - 1)] = 9
  elif ans[(i[0] - 1)][(i[1] - 1)][(i[2] - 1)] < 0:
        ans[(i[0] - 1)][(i[1] - 1)][(i[2] - 1)] = 0
for j in ans:
  count += 1
  for k in j:
    out = ""
    for l in k:
      out += " " + str(l)
    print(out)
  if count < 4: 
    print("#"*20)

Submission status: Accepted

Solution code:
block_1_floor_1=[0,0,0,0,0,0,0,0,0,0]
block_1_floor_2=[0,0,0,0,0,0,0,0,0,0]
block_1_floor_3=[0,0,0,0,0,0,0,0,0,0]
block_2_floor_1=[0,0,0,0,0,0,0,0,0,0]
block_2_floor_2=[0,0,0,0,0,0,0,0,0,0]
block_2_floor_3=[0,0,0,0,0,0,0,0,0,0]
block_3_floor_1=[0,0,0,0,0,0,0,0,0,0]
block_3_floor_2=[0,0,0,0,0,0,0,0,0,0]
block_3_floor_3=[0,0,0,0,0,0,0,0,0,0]
block_4_floor_1=[0,0,0,0,0,0,0,0,0,0]
block_4_floor_2=[0,0,0,0,0,0,0,0,0,0]
block_4_floor_3=[0,0,0,0,0,0,0,0,0,0]
for i in range(int(input())):
  b,f,r,v=map(int,input().split())
  if b==1:
    if f==1:
      block_1_floor_1[r-1]+=v
    elif f==2:
      block_1_floor_2[r-1]+=v
    else:
      block_1_floor_3[r-1]+=v
  elif b==2:
    if f==1:
      block_2_floor_1[r-1]+=v
    elif f==2:
      block_2_floor_2[r-1]+=v
    else:
      block_2_floor_3[r-1]+=v
  elif b==3:
    if f==1:
      block_3_floor_1[r-1]+=v
    elif f==2:
      block_3_floor_2[r-1]+=v
    else:
      block_3_floor_3[r-1]+=v
  else:
    if f==1:
      block_4_floor_1[r-1]+=v
    elif f==2:
      block_4_floor_2[r-1]+=v
    else:
      block_4_floor_3[r-1]+=v
print(""," ".join(list(map(str,block_1_floor_1))))
print(""," ".join(list(map(str,block_1_floor_2))))
print(""," ".join(list(map(str,block_1_floor_3))))
print("#"*20)
print(""," ".join(list(map(str,block_2_floor_1))))
print(""," ".join(list(map(str,block_2_floor_2))))
print(""," ".join(list(map(str,block_2_floor_3))))
print("#"*20)
print(""," ".join(list(map(str,block_3_floor_1))))
print(""," ".join(list(map(str,block_3_floor_2))))
print(""," ".join(list(map(str,block_3_floor_3))))
print("#"*20)
print(""," ".join(list(map(str,block_4_floor_1))))
print(""," ".join(list(map(str,block_4_floor_2))))
print(""," ".join(list(map(str,block_4_floor_3))))

Submission status: Accepted

Solution code:
t1 = [[0 for i in range(10)] for j in range(3)]
t2 = [[0 for i in range(10)] for j in range(3)]
t3 = [[0 for i in range(10)] for j in range(3)]
t4 = [[0 for i in range(10)] for j in range(3)]

n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().split())
    if b == 1:
        t1[f - 1][r - 1] += v
    elif b == 2:
        t2[f - 1][r - 1] += v
    elif b == 3:
        t3[f - 1][r - 1] += v
    else:
        t4[f - 1][r - 1] += v

for i in range(3):
    for j in range(10):
        print("", t1[i][j], end = "")
    print()
print("#" * 20)
for i in range(3):
    for j in range(10):
        print("", t2[i][j], end = "")
    print()
print("#" * 20)
for i in range(3):
    for j in range(10):
        print("", t3[i][j], end = "")
    print()
print("#" * 20)
for i in range(3):
    for j in range(10):
        print("", t4[i][j], end = "")
    print()

Submission status: Accepted

Solution code:
n = int(input())
w = [[[0]*10 for _ in range(3)] for _ in range(4)]
#[[[0]*10]*3 for i in range(4)]

for i in range(n):
    b, f ,r, v = map(int, input().split())
    w[b - 1][f - 1][r - 1] = w[b - 1][f - 1][r - 1] + v

cnt = 0
for i in w:
    cnt = cnt + 1
    for j in range(3):
        print(" " + " ".join(map(str, i[j])))
    
    if len(w) != cnt:
        print("#" * 20)

Submission status: Accepted

Solution code:
# 直接的な実装

n = int(input())
data_list = list()
for i in range(n):
    data = list(map(int,input().split()))
    data_list.append(data)

apart = [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],'####################',[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],'####################',[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],'####################',[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]]

for data in data_list:
    apart[((data[0]-1)*4)+(data[1]-1)][data[2]-1] = apart[((data[0]-1)*4)+(data[1]-1)][data[2]-1] + data[3]

for ridge in apart:
    if str(ridge[0]).isdigit():
        ridge = [str(i) for i in ridge]
        print('',' '.join(ridge))
    else:
        print(ridge)

Submission status: Accepted

Solution code:
ans1 = []
ans2 = []
ans3 = []
for i in range(4):
    ans1 = []
    ans2 = []
    for j in range(3):
        ans1 = []
        for k in range(10):
            ans1.append(0)
        ans2.append(ans1)
    ans3.append(ans2)

ans4 = []
n = int(input())
for i in range(n):
    ans4 = list(map(int, input().split()))
    ans3[ans4[0]-1][ans4[1]-1][ans4[2]-1] += ans4[3]

for i in range(4):
    for j in range(3):
        print(" ", end="")
        for k in range(9):
            print(ans3[i][j][k], end=" ")
        print(ans3[i][j][9])
    if i < 3:
        print("####################")

Submission status: Accepted

Solution code:
count = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for i in range(n):
    b,f,r,v = map(int,input().split())
    count[b-1][f-1][r-1] += v
fst = 1
for k in count:
    if fst == 1:
        fst = 0
    else:
        print("#"*20)
    for j in k:
        for i in j:
            print(" " + str(i),end = '')
        print()

Submission status: Accepted

Solution code:
houses = [
    [[0]*10,[0]*10,[0]*10],
    [[0]*10,[0]*10,[0]*10],
    [[0]*10,[0]*10,[0]*10],
    [[0]*10,[0]*10,[0]*10]
]
n = int(input())
for a in range(n):
    b,f,r,v = [int(i) for i in input().split()]
    houses[b-1][f-1][r-1] += v

for i,house in enumerate(houses):
    for floor in house:
        print(" "+ " ".join(map(str, floor)))
    if i != len(houses)-1:
        print("#"*20)

Submission status: Accepted

Solution code:
a= [[[0]*10 for i in range(3)] for j in range(4)]

n = int(input())

for i in range(n):
    b,f,r,v = map(int,input().split())
    a[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" " + str(a[i][j][k]),end='')
        print()
    if i != 3:
        print("#"*20)

Submission status: Accepted

Solution code:
a = [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]]
b = [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]]
c = [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]]
d = [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]]

n = int(input())
value = [input() for i in range(n)]

for x in value:
    tower,flore,memo,num = x.split()
    tower = int(tower)
    flore = int(flore)
    memo = int(memo)
    num = int(num)
    if tower == 1:
        a[flore -1][memo -1] += num
    elif tower == 2:
        b[flore -1][memo -1] += num
    elif tower == 3:
        c[flore -1][memo -1] += num
    elif tower == 4:
        d[flore -1][memo -1] += num

for i in a: 
    print(" "+" ".join(map(str,i)))
print("####################")
for i in b:
    print(" "+" ".join(map(str,i)))
print("####################")
for i in c:
    print(" "+" ".join(map(str,i)))
print("####################")
for i in d:
    print(" "+" ".join(map(str,i)))

Submission status: Accepted

Solution code:
count = int(input())
members = list()
buildings = [[[0,0,0,0,0,0,0,0,0,0,],[0,0,0,0,0,0,0,0,0,0,],[0,0,0,0,0,0,0,0,0,0,]],
             [[0,0,0,0,0,0,0,0,0,0,],[0,0,0,0,0,0,0,0,0,0,],[0,0,0,0,0,0,0,0,0,0,]],
             [[0,0,0,0,0,0,0,0,0,0,],[0,0,0,0,0,0,0,0,0,0,],[0,0,0,0,0,0,0,0,0,0,]],
             [[0,0,0,0,0,0,0,0,0,0,],[0,0,0,0,0,0,0,0,0,0,],[0,0,0,0,0,0,0,0,0,0,]]]
for i in range(count):
    e = list(map(int,input().split()))
    members.append(e)

for i in range(count):
    buildings[members[i][0]-1][members[i][1]-1][members[i][2]-1] += members[i][3]
    
    if buildings[members[i][0]-1][members[i][1]-1][members[i][2]-1] > 9:
        buildings[members[i][0]-1][members[i][1]-1][members[i][2]-1] = 9
    
for t in range(4):
    if t >= 1:
        print("#"*20)
    for f in range(3):
        for s in range(10):
            if s <= 8:
                print(" "+str(buildings[t][f][s]),end="")
            else:
                print(" "+str(buildings[t][f][s]))

Submission status: Accepted

Solution code:
n = int(input())
build = [[[0 for i in range(10)]for j in range(3)]for k in range(4)]
for i in range(n):
    b, f, r, v = list(map(int, input().split()))
    build[b-1][f-1][r-1] += v
for b in range(4):
    for f in range(3):
        for r in range(10):
            print("", build[b][f][r], end="")
        print()
    if b != 3: 
        print("####################")

Submission status: Accepted

Solution code:
building = [[[0]*10 for i in range(3)] for j in range(4)]


n = int(input())
for i in range(n):
    b,f,r,v = map(int,input().split())
    building[b-1][f-1][r-1] += v
    
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(' {}'.format(building[i][j][k]),end = '')
        print()
    if i < 3:
        print('#'*20)