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

person = [[[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())
    person[b - 1][f - 1][r - 1] += v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" %d" % (person[i][j][k]), end="")
        print("")
    if i != 3:
        print("####################")

Submission status: Accepted

Solution code:
n = int(input())

table = [[[0]*10 for i in range (0,3)] for k in range (0,4)]

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

for b in range(4):
    for f in range(3):
        print(' '+ ' '.join(map(str,table[b][f])))
    if b < 3:
        print('#'*20)

Submission status: Accepted

Solution code:
a = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for i in range(n):
    sc = input().split()
    a[int(sc[0]) - 1][int(sc[1]) - 1][int(sc[2]) - 1] += int(sc[3])
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(' {}'.format(a[i][j][k]), end = '')
        print('')
    if i != 3:
        print('####################')

Submission status: Accepted

Solution code:
n = int(input())
L = []
for i in range(n):
    b,f,r,v = map(int, input().split())
    L.append([b,f,r,v])

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

      [ [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0] ],

      [ [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0] ],

      [ [0,0,0,0,0,0,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 j in range(len(L)):
    A[L[j][0]-1][L[j][1]-1][L[j][2]-1] += L[j][3]
for a in range(3):
    for b in range(3):
        print('',*A[a][b])
    print('#'*20)
for b in range(3):
    print('',*A[3][b])

Submission status: Accepted

Solution code:
L = [[[ 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())
         L[b-1][f-1][r-1] += v
for i in range(4):
         for j in range(3):
                  for k in range(10):
                           print(" {}".format(L[i][j][k]), end = "")
                  print()
         if i + 1 != 4:
                  print("#" * 20)

Submission status: Accepted

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

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

for bill in kosha:
    if flag==1: 
        print("####################")
    for floor in bill:
        print(" ",end="")
        print(*floor,)
    flag=1

Submission status: Accepted

Solution code:
import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

tower = [[[0] * 10 for i in range(3)] for j in range(4)]

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

for i, h in enumerate(tower):
    if i:
        print("#" * 20)
    for r in h:
        print("", *r)

Submission status: Accepted

Solution code:
def main(inputs):
    outputs = ''
    table = [[[0]*10 for i in range(3)] for i in range(4)]
    for input in inputs:
        b, f, r, v = map(int, input.split())
        table[b-1][f-1][r-1] += v
    for i in range(len(table)):
        if i != 0:
            outputs += '#'*20 + '\n'
        for j in range(len(table[i])):
            for r in range(len(table[i][j])):
                outputs += ' {}'.format(str(table[i][j][r]))
            outputs += '\n'
    return outputs


if __name__ == "__main__":
    n = int(input())
    inputs = [input() for i in range(n)]
    print(main(inputs), end='')

Submission status: Accepted

Solution code:
n = int(input())
info = []
t1 = [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]]
t2 = [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]]
t3 = [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]]
t4 = [[0,0,0,0,0,0,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(n):
  info.append(list(input().split()))
  info[i] = [int(n) for n in info[i]]

for j in range(len(info)):
  if info[j][0] == 1:
    if info[j][1] == 1:
      t1[0][info[j][2]-1] += info[j][3]
    if info[j][1] == 2:
      t1[1][info[j][2]-1] += info[j][3]
    if info[j][1] == 3:
      t1[2][info[j][2]-1] += info[j][3]
  if info[j][0] == 2:
    if info[j][1] == 1:
      t2[0][info[j][2]-1] += info[j][3]
    if info[j][1] == 2:
      t2[1][info[j][2]-1] += info[j][3]
    if info[j][1] == 3:
      t2[2][info[j][2]-1] += info[j][3]
  if info[j][0] == 3:
    if info[j][1] == 1:
      t3[0][info[j][2]-1] += info[j][3]
    if info[j][1] == 2:
      t3[1][info[j][2]-1] += info[j][3]
    if info[j][1] == 3:
      t3[2][info[j][2]-1] += info[j][3]
  if info[j][0] == 4:
    if info[j][1] == 1:
      t4[0][info[j][2]-1] += info[j][3]
    if info[j][1] == 2:
      t4[1][info[j][2]-1] += info[j][3]
    if info[j][1] == 3:
      t4[2][info[j][2]-1] += info[j][3]
  
for k in range(0,3):
  [print(" %d"%i, end="")for i in t1[k]]
  print()
print("####################")
for k in range(0,3):
  [print(" %d"%i, end="")for i in t2[k]]
  print()
print("####################")
for k in range(0,3):
  [print(" %d"%i, end="")for i in t3[k]]
  print()
print("####################")
for k in range(0,3):
  [print(" %d"%i, end="")for i in t4[k]]
  print()

Submission status: Accepted

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

counter = [[[0] * 10 for i in range(4)] for k in range(5)]
# counter = [[[0] * 10] * 3] * 4

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

x = 0
for i in range(4):
    if x != 0:
        print("#" * 20)
    x += 1

    for a in range(3):
        for b in range(10):
            print(" {}".format(counter[i][a][b]), end="")
        print()

Submission status: Accepted

Solution code:
rooms = [[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
         [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
         [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
         [[0, 0, 0, 0, 0, 0, 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())
for i in range(n):
    b, f, r, v = map(lambda x: int(x), input().split(" "))
    B, F, R = b - 1, f - 1, r - 1
    new = rooms[B][F][R] + v
    rooms[B][F][R] = new < 0 if 0 else new
for i in range(4):
    if 0 < i:
        print("####################")
    for j in range(3):
        print(" " + " ".join(map(lambda x: str(x), rooms[i][j])))

Submission status: Accepted

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

n=int(input())

for c in range(n):
    house,floor,room,add=map(int, input().split())
    table[house-1][floor-1][room-1] += add

for d in range(4):
    if d != 0:
        print("#"*20)
    for e in range(3):
        for f in range(10):
            print(" %d" %(table[d][e][f]), end="")
        print()

Submission status: Accepted

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

n= int(input())
#tmp= float(input())

data=[]


for i in range(12):
    tmp=[]
    for j in range(10):
        tmp.append(0)
    data.append(tmp)

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




for i in range(4):
    for j in range(3):
        tmp=""
        for k in range(10):
            tmp+=" "
            tmp+=str(data[i*3+j][k])
#            if(k!=9):
#                tmp+=" "
        print(tmp)
    if(i!=3):
        print("####################")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for i in range(n)]
d = {}

for i in range(4):
  for j in range(3):
    d.setdefault(i, []).append(j)
    if type(d[i][j]) == int:
      d[i][j] = []
    for k in range(10):
      d[i][j].append(0)

for i in range(len(s)):
  d[int(s[i].split()[0])-1][int(s[i].split()[1])-1][int(s[i].split()[2])-1] += int(s[i].split()[3])

for k,v in d.items():
	if k > 0:
		print('#'*20)
	for i in v:
		print(' '+' '.join(map(str,i)), end='')
		print()

Submission status: Accepted

Solution code:
N = int(input())
resid = [[[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())
    resid[b - 1][f - 1][r - 1] += v

for k in range(4) :
    for j in range(3) :
        line = ""
        for i in range(10) :
            line += " " + str(resid[k][j][i])
        print(line)
    if k == 3 and j == 2 :
        break
    print("#" * 20)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
house = [[[0 for r in range(10)]for f in range(3)]for b in range(4)]
for i in range(n):
  b,f,r,v = map(int,input().split())
  house[b-1][f-1][r-1]+=v

for b in range(4):
  for f in house[b]:
    print("",*f)
  if b != 3:
    print("#"*20)

Submission status: Accepted

Solution code:
# init
ROOMS=10
FLOORS=3
BUILDINGS=4
rooms = [[[0 for i in range(ROOMS)] for j in range(FLOORS)] for k in range(BUILDINGS)]

# input
n = int(input())

# check inputs
for loop in range(n):
    b, f, r, v = map(int, input().split())
    
    rooms[b-1][f-1][r-1] += v
    
    if rooms[b-1][f-1][r-1] < 0:
        rooms[b-1][f-1][r-1] = 0

for i in range(BUILDINGS):
    for j in range(FLOORS):
        for k in range(ROOMS):
            print(" {0}".format(rooms[i][j][k]), end="")
        print()
    if i<BUILDINGS-1:
        print('#'*20)

Submission status: Accepted

Solution code:
from collections import defaultdict
n = int(input())
info = defaultdict(int)

def drawbuilding(n):
    for room_num in range(1,4):
        for floor_num in range(1,11):
            print(' '+str(info[f'{[n,room_num,floor_num]}']),end='')
        print()

for _ in range(n):
    tmp = list(map(int,input().split()))
    info[f'{tmp[:3]}'] += tmp[3]
    if info[f'{tmp[:3]}'] < 0:
        info[f'{tmp[:3]}'] = 0

for i in range(1,5):
    drawbuilding(i)
    if i < 4:
        print('#'*20)

Submission status: Accepted

Solution code:
t_num = 4
f_num = 3
r_num = 10
m_dict = dict()
for i in range(t_num):
    m_dict.setdefault(i+1,list())
    for j in range(f_num):
        m_dict[i+1].append([0]*r_num)
n = input()

for i in range(int(n)):
    a = input()
    IOinfo = a.split()
    b,f,r,v = IOinfo
    tou = int(b)
    flo = int(f)
    rnm = int(r)
    vis = int(v)
    m_dict[tou][flo-1][rnm-1] = m_dict[tou][flo-1][rnm-1] + vis
else:
    for t in range(t_num):
        for f in range(f_num):
            out_c = ''
            for r in range(r_num):
                v = m_dict[t+1][f][r]
                out_c = '{} {}'.format(out_c,v)
            else:
                print(out_c)
        else:
            if t < t_num-1:
                out_m = '#'*20
                print(out_m)

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):
            print(" %d" %count[i][j][k], end="")
        print()
    if i < 3:
        print("#"*20)

Submission status: Accepted

Solution code:
n = int(input())

house = [[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
         
         [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
         
         [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
        
         [[0, 0, 0, 0, 0, 0, 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(n):
    b, f, r, v = [int(x) for x in input().split()]
    if house[b-1][f-1][r-1] == 0:
        house[b-1][f-1][r-1] = v
    else:
        house[b-1][f-1][r-1] += v
        
for b in range(4):
    for f in range(3):
        for r in range(10):
            print(' ', end='')
            print(house[b][f][r], end='')
        print()
    if b != 3: print('#'*20)

Submission status: Accepted

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

n = int(input())

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

for b in range(4):
    for f in houses[b]:
        print("", *f)
    if b != 3:
        print("#" * 20)

Submission status: Accepted

Solution code:
s = [[[0]*10 for i in range (3)] for j in range (4)]
n = int(input())
k = 0
for i in range(n):
    t = list(map(int,input().split()))
    s[t[0]-1][t[1]-1][t[2]-1] = s[t[0]-1][t[1]-1][t[2]-1] + t[3]
for u in s:
    if k == 1:
        print("#"*20)
    else:
        k = 1
    for v in u:
        for w in v:
            print(" " + str(w),end ="")
        print()

Submission status: Accepted

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

rooms = [[[0]*10, [0]*10, [0]*10],
        [[0]*10, [0]*10, [0]*10],
        [[0]*10, [0]*10, [0]*10],
        [[0]*10, [0]*10, [0]*10]]

for info in info_l:
    b = info[0]
    f = info[1]
    r = info[2]
    v = info[3]
    rooms[b-1][f-1][r-1] += v

cnt = 0
for room in rooms:
    cnt += 1
    for i in room:
        print(' ' + ' '.join(map(str, i)))
    if cnt != 4:
        print('#'*20)

Submission status: Accepted

Solution code:
n = int(input())
builds = [[[0]*10 for _ in range(3)] for _ in range(4)]
for _ in range(n):
    b, f, r, v = map(int, input().split())
    builds[b-1][f-1][r-1] += v

for i, b in enumerate(builds):
    for _b in b:
        print(" ", end="")
        print(*_b)

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

Submission status: Accepted

Solution code:
x = int(input())
bs = [list(map(int, input().split())) for i in range(x)]
box = [[[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]],
       [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]],
       [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]],
       [[0,0,0,0,0,0,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 b in bs:
    box[b[0]-1][b[1]-1][b[2]-1] += b[3]
for i, b in enumerate(box):
    for bb in b:
        print(" ",end="")
        print(" ".join(map(str,bb)))
    if(i != 3):
        print("####################")

Submission status: Accepted

Solution code:
rooms = [[[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())
    rooms[b-1][f-1][r-1] += v

for i in range(len(rooms)):
    for j in range(len(rooms[0])):
        for k in range(len(rooms[0][0])):
            print(f' {rooms[i][j][k]}', end='')
        if j!= len(rooms[0])-1:print()
    print()
    if i!=len(rooms)-1:
        print('####################')

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

def print_floor(b):
    for i in range(3):
        for j in range(10):
            print(" "+str(resident[b][i][j]),end="")
        print()


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

for i in range(4):
    print_floor(i)
    if i!=3:
        for j in range(20):
            print("#",end='')
        print()

Submission status: Accepted

Solution code:
n = int(input())

rooms = {}

for i in range(1, 5):
    rooms[i] = {}
    for j in range(1, 4):
        rooms[i][j] = {}
        for k in range(1, 11):
            rooms[i][j][k] = 0

for i in range(n):
    b, f, r, v = map(int, input().split())
    rooms[b][f][r] += v
    
for i in range(1, 5):
    for j in range(1, 4):
        for k in range(1, 11):
            #print('', end=' ')
            print(f' {rooms[i][j][k]}', end='')
        print()

    if i < 4:
        print('####################')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
p = [[[0 for z in range(10)] for y in range(3)] for x in range(4)]

num = int(input())

for i in range(num):
    b,f,r,v = [ int(x) for x in input().split()]
    p[b-1][f-1][r-1] += v
    
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" ",end="")
            print(p[i][j][k],end="")
        print()
    if i < 3:
        print("####################")

Submission status: Accepted

Solution code:
n = int(input())
houseInfo = [[0] * 10 for _ in range(12)]

for i in range(n):
    b, f, r, v = list(map(int, input().split()))
    # list上の基準(行)を計算
    base = ((b - 1) * 3) + (f - 1)

    houseInfo[base][r - 1] += v

count = 1
index = 0
while index < len(houseInfo):
    if count % 4 == 0:
        print("#" * 20)
    else:
        print(" ", end="")
        print(*houseInfo[index])
        index += 1

    count += 1

Submission status: Accepted

Solution code:
n=int(input())
b=[0]*n
f=[0]*n
r=[0]*n
v=[0]*n
for i in range(0,n):
    b[i],f[i],r[i],v[i]=(int(x) for x in input().split())
for i in range(1,5):
    for j in range(1,4):
        for k in range(1,11):
            sum=0
            for l in range(n):
                if b[l]==i and f[l]==j and r[l]==k:
                    sum+=v[l]
            if k!=10:
                print(" %d"%sum,end="")
            else:
                print(" %d"%sum)
    if i!=4:
        print("#"*20)

Submission status: Accepted

Solution code:
n = int(input())

bldg = [[[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())
	#print(b,f,r,v)
	bldg[b-1][f-1][r-1] = bldg[b-1][f-1][r-1] + v

#print(bldg)

for a in range(4):
		for b in range(3):
			for c in range(10):
					print(" " + str(bldg[a][b][c]), end = "")
			print()
		if a != 3:
			for i in range(20):
				print("#", end="")
			print()

Submission status: Accepted

Solution code:
tower1 = [[0]*10 for i in range(3)]
tower2 = [[0]*10 for i in range(3)]
tower3 = [[0]*10 for i in range(3)]
tower4 = [[0]*10 for i in range(3)]

n = int(input())

for _ in range(n):
	b,f,r,v = map(int,input().split())
	
	if b == 1:
		tower1[f-1][r-1] += v
	elif b == 2:
		tower2[f-1][r-1] += v
	elif b == 3:
		tower3[f-1][r-1] += v
	elif b == 4:
		tower4[f-1][r-1] += v
		
for i in tower1:
	print(str.format(" {} {} {} {} {} {} {} {} {} {}",i[0],i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8],i[9]))

print("#"*20)

for i in tower2:
	print(str.format(" {} {} {} {} {} {} {} {} {} {}",i[0],i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8],i[9]))

print("#"*20)

for i in tower3:
	print(str.format(" {} {} {} {} {} {} {} {} {} {}",i[0],i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8],i[9]))
	
print("#"*20)

for i in tower4:
	print(str.format(" {} {} {} {} {} {} {} {} {} {}",i[0],i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8],i[9]))

Submission status: Accepted

Solution code:
class town:
    def __init__(self,room,height):
        # self.a,self.b,self.c,self.d = [[0] * room]*height,[[0] * room]*height,[[0] * room]*height,[[0] * room]*height
        self.a = [[0] * room for i in range(height)]
        self.b = [[0] * room for i in range(height)]
        self.c = [[0] * room for i in range(height)]
        self.d = [[0] * room for i in range(height)]
    def in_out(self,b,f,r,v):
        str_h = self.check(b)
        str_h[f][r] += v
    def check(self,b):
        if b == 1:
            return self.a
        if b == 2:
            return self.b
        if b == 3:
            return self.c
        if b == 4:
            return self.d
    def open_house(self):
        for a in self.a:
            print(end=' ')
            print(*a)
        print('####################')
        for b in self.b:
            print(end=' ')
            print(*b)
        print('####################')
        for c in self.c:
            print(end=' ')
            print(*c)
        print('####################')
        for d in self.d:
            print(end=' ')
            print(*d)
counts = int(input())
mytown = town(10,3)
for c in range(counts):
    b,f,r,v = map(int,input().split(' '))
    mytown.in_out(b,f-1,r-1,v)
mytown.open_house()

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(' {0}' .format(building[i][j][k]), end='')
        print()
    if i < 3:
        print('#'*20)

Submission status: Accepted

Solution code:
wall = "#" * 20
n = int(input())
dat = []
for _ in range(12):
    dat.append([0] * 10)

for _ in range(n):
    b,f,r,v = map(int, input().split())
    dat[3 * (b - 1) + ( f-1)][r - 1] += v
for i in range(12):
    print(" ",end="")
    print(" ".join(map(str, dat[i])))
    if i % 3 == 2 and i!=11:
        print(wall)

Submission status: Accepted

Solution code:
#初期値の準備
fidge_number = 4
floor_number = 3
room_number = 10
residents_data = list()

#リストの初期化
for x in range(fidge_number):
    residents_data_temp = list()
    for y in range(floor_number):
        residents_data_temp.append([0]*10)
    residents_data.append(residents_data_temp)

#インプットdataの反映
data_number = int(input())
for i in range(data_number):
    #入力データの格納
    input_data = list(map(int, input().split()))
    fidge_input = input_data[0]
    floor_input = input_data[1]
    room_input = input_data[2]
    number_input = input_data[3]
    
    #入力データのエラーチェック
    if 0 <= fidge_input <= fidge_number and 0<= floor_input <= floor_number and 0<= room_input <= room_number:
        if residents_data[fidge_input-1][floor_input-1][room_input-1] + number_input >= 0:

    #入力データの反映
            residents_data[fidge_input-1][floor_input-1][room_input-1] += number_input

#結果の表示
for x in range(fidge_number):
    for y in range(floor_number):
        print(" " + " ".join(map(str,residents_data[x][y])))
    if x != fidge_number-1:
        print("####################")

Submission status: Accepted

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

def main():
    N = int(input())

    check = [[[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())
        check[b-1][f-1][r-1] += v
    
    for i in range(4):
        for j in range(3):
            for k in range(10):
                print("", check[i][j][k], end="")
            print()
        if i != 3:
            print("#"*20)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
H = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
for i in range(n):
    b, f, r, v = map(int, input().split())
    H[b-1][f-1][r-1] += v
for b in range(4):
    for f in range(3):
        A = map(str, H[b][f])
        a = ' '+' '.join(A)
        print(a)
    if b == 3:
        exit()
    print('#'*20)

Submission status: Accepted

Solution code:
house = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n=int(input())
for x in range(n):
    a,b,c,d=map(int,input().split())
    house[a-1][b-1][c-1]+=d
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(f' {house[i][j][k]}',end="")
        print()
    if int(i)<3: print("#"*20)

Submission status: Accepted

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

rep = int(input())

for i in range(rep):
    lst = list(map(int,input().split()))
    b = lst[0] - 1
    f = lst[1] - 1
    r = lst[2] - 1
    v = lst[3]
    apart[b][f][r] += v

for i,building in enumerate(apart):
    for floor in building:
        for room in floor:
            print(f" {room}",end='')
        print()

    #最後以外は末尾に区切り用の'#'を入れる
    if i < 3:
        print("####################")

Submission status: Accepted

Solution code:
n=int(input())

A=[[[0 for k in range(11)] for j in range(4)] for i in range(5)]

for i in range(n):
	a,b,c,d = map(int,input().split())
	A[a][b][c] += d

for a in range(1,5):
	for b in range(1,4):
		for c in range(1,11):
			print(f" {A[a][b][c]}", end="")
		print()
	if a != 4: print("#"*20)

Submission status: Accepted

Solution code:
house= [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
n = int(input())

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

for b in range(4):
 for f in range(3):
  for r in range(10):
   print(f" {house[b][f][r]}",end="")
  print()
 if b<3:
  print("####################")

Submission status: Accepted

Solution code:
n = int(input())
people = [[[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())
    people[b-1][f-1][r-1] += v
    if people[b-1][f-1][r-1] < 0:
        people[b-1][f-1][r-1] = 0
    if people[b-1][f-1][r-1] > 9:
        people[b-1][f-1][r-1] = 9
for B in people:
    for F in B:
        for R in F:
            print(' ' + str(R), end='')
        print('')
    if not B is people[-1]:
        print('####################')

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

for b in range(4):
    for f in range(3):
        print(" " + " ".join(map(str, count[b][f])))
    if b != 3:
        print("####################")

Submission status: Accepted

Solution code:
rperf = 10
fperb = 3
buildings = 4

n = int(input())

rooms = [[[0 for i in range(rperf)] for j in range(fperb)] for k in range(buildings)]
for i in range(n):
    b, f, r, v = map(int, input().split())
    b, f, r = b-1, f-1, r-1 
    if rooms[b][f][r]+v < 0:
        rooms[b][f][r] = 0
    else:
        rooms[b][f][r] += v

for i in range(buildings):
    if i>0:
        print("####################")
    for j in range(fperb):
        floor = ""
        for k in range(rperf):
            floor += " " + str(rooms[i][j][k])
        print(floor)

Submission status: Accepted

Solution code:
test = input().split()
n = int(test[0])
building = []
count2 = 0
for i in range(120):
    building.append(0)
for a in range(n):
    actual_room_no = 0
    count = 10 
    b, f, r, v = map(int, input().split())
    if b == 4:
        actual_room_no += 90
    elif b == 3:
        actual_room_no += 60
    elif b == 2:
        actual_room_no += 30
    if f == 3:
        actual_room_no += 20
    elif f == 2:
        actual_room_no += 10
    for j in range(10):
        if r == int(count):
            actual_room_no += count
            count -= 1
        else:
            count -= 1
    actual_room_no -= 1
    building[actual_room_no] += v
for g in range(3):
    for c in range(3):
        for d in range(10):
            print(' ',end='')
            if building[int(count2)] < 0:
                print(0,end='')
                count2 += 1
            else:
                print(int(building[int(count2)]),end='')
                count2 += 1
        print('')
    for e in range(20):
        print('#',end='')
    print('')
for h in range(3):
        for d in range(10):
            print(' ',end='')
            print(building[int(count2)],end='')
            count2 += 1
        print('')

Submission status: Accepted

Solution code:
n=int(input())
mat=[[0 for i in range(20)] for j in range(15)]
for i in range(n):
    b,f,r,v=list(map(int,input().split()))
    h=(b-1)*4+f-1
    w=2*r-1
    n=v
    mat[h][w]+=n
for x in range(15):
    for y in range(20):
        if x%4==3:
            mat[x][y]="#"
        elif y%2==0:
            mat[x][y]=" "
        print(mat[x][y],end="")
    print()

Submission status: Accepted

Solution code:
# データの数を受け取る
n = int(input())

# データを受け取る
input_list = [input() for i in range(n)]

# 3 * 4 * 10 の0を用意
count = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

# インプットデータを基にリスト内の要素を更新
for l in input_list:
    tou, kai, banme, nin = map(int, l.split())
    count[tou - 1][kai - 1][banme - 1] = count[tou - 1][kai - 1][banme - 1] + nin

# 結果を出力
for m in range(4):
    for o in range(3):
        print(" " + " ".join(map(str, count[m][o])))
    if m != 3:
        print("#" * 20)