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

import fileinput
import math

def main():
    offiHouse = [[[0 for i3 in range(10)] for i2 in range(3)] for i1 in range(4)]   #y, x, z

    n = int(input())

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

        offiHouse[a-1][b-1][c-1] += d

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
R=range
I=input
p=print
l=[[[0 for i in R(10)]for j in R(3)]for s in R(4)]
for i in R(int(I())):b,f,r,v=map(int,I().split());l[b-1][f-1][r-1]+=v
for i in R(4):
 for k in l[i]:p("",*k)
 if i!=3:p("#"*20)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
n=int(input())
a=[[[0 for i in range(10)] for i in range(3)] for i in range(4)]
for i in range(n):
    w=input().split()
    b=(int(w[0]))
    f=(int(w[1]))
    r=(int(w[2]))
    v=(int(w[3]))
    a[b-1][f-1][r-1]+=v
for i in range(4):
    for j in range(3):
        for k in range(10):
            sys.stdout.write(" {0}".format(a[i][j][k]))
        sys.stdout.write("\n")
    if (i!=3):
        for x in range(20):
            sys.stdout.write("#")
        sys.stdout.write("\n")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    n_b = 4
    n_f = 3
    n_r = 10

    from collections import defaultdict
    state = defaultdict(int)

    for _ in range(n):
        # b?£?f??????r???????????¨?±?
        # v??????????????§??\?±????????????¨???????????????
        # v?????????????????´??????v????????????????????¨??????????????????
        b, f, r, v = map(int, input().split())
        state[(b, f, r)] += v

    for b in range(1, n_b + 1):
        for f in range(1, n_f + 1):
            room_state = []
            for r in range(1, n_r + 1):
                room_state.append(state[(b, f, r)])
            print(" " + " ".join(map(str, room_state)))
        if b != n_b:
            print("#" * 20)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a=[[[0]*10 for _ in range(3)] for _ in range(4)]
for _ in range(int(input())):
 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):
  print(' ',end='')
  print(*a[i][j])
 if i!=3:print('#'*20)

Submission status: Accepted

Solution code:
a=[[10*[0]for _ in range(3)]for _ in range(4)]
for _ in range(int(input())):
 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):
  print('',*a[i][j])
 if i!=3:print('#'*20)

Submission status: Accepted

Solution code:
a=[[10*[0]for _ in range(3)]for _ in range(4)]
for _ in range(int(input())):
 b,f,r,v=map(int,input().split())
 a[b-1][f-1][r-1]+=v
for i in range(4):
 [print('',*a[i][j])for j in range(3)]
 if i!=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):
    b,f,r,v = map(int,input().split())
    A[b-1][f-1][r-1] += v

for b in range(4):
    for f in range(3):
        for r in range(10):
            print('',A[b][f][r],end='')
        print()
    if b != 3:
        print('#'*20)

Submission status: Accepted

Solution code:
n = int(input())

a = []
for i in range(n):
    a.append(list(map(int, input().split())))

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

for i in range(n):
    b[a[i][0] - 1][a[i][1] - 1][a[i][2] - 1] += a[i][3]

for i in range(4):
    for j in range(3):
        b[i][j].insert(0, "")
        print(*b[i][j])
    if i == 3:
        break
    print("####################")

Submission status: Accepted

Solution code:
buildings=[[[0 for i in range(10)]for m in range(3)]for k in range(4)]
x=int(input())
for i in range(x):
    a,b,c,d=map(int,input().split())
    buildings[a-1][b-1][c-1]+=d
for i in range(4):
    for j in range(3):
        for k in range(10):
            print("",buildings[i][j][k],end="")
        print()
    if i!=3:
        print("#"*20)

Submission status: Accepted

Solution code:
n = int(input())
list = [[0 for i in range(10)] for j in range(12)]
for i in range(n):
    b,f,r,v = map(int,input().split())
    list[3*(b - 1)+(f - 1)][r - 1] += v
for i in range(12):
    if i % 3 == 0 and i != 0:
        print('####################')
    for j in range(10):
        print(' {}'.format(list[i][j]),end = "")
        if j == 9:
            print('')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding:utf-8
import sys
n = input()
array = []
for i in range(n):
    array.append(map(int, raw_input().split()))
array.sort()
result = [[0 for i in range(4)] for j in range(n)]
index = 0
result[index] = array[0][0:4]
for i in range(1,n):
    if result[index][0:3] == array[i][0:3]:
        result[index][3] += array[i][3]
    elif result[index][0:3] != array[i][0:3]:
        index += 1
        result[index] = array[i][0:]
index = 0
for i in range(4):
    for j in range(3):
        for k in range(10):
            sys.stdout.write(' ')
            if(i == result[index][0] - 1 and j == result[index][1] - 1 and k == result[index][2] - 1):
                print result[index][3],
                if index != len(result) - 1:
                    index += 1
            else:
                print 0,
        else:
            print
    else:
        if(i != 3):
            print "####################"

Submission status: Accepted

Solution code:
n = int(input())

a = [[[0 for iii in range(10)] for ii in range(3)] for i in range(4)]

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

for i in range(4):
    for ii in range(3):
        for iii in range(10):
            print(" " + str(a[i][ii][iii]), end="")
        print()
    if i == 3: break
    print("####################")

Submission status: Accepted

Solution code:
n = int(input())

ab = 4
af = 3
ar = 10

data = [[[0 for i in range(ar)] for j in range(af)] for k in range(ab)]

for i in range(n):
    instr = input().split()
    b = int(instr[0])
    f = int(instr[1])
    r = int(instr[2])
    v = int(instr[3])

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

for i in range(ab):
    if i != 0:
        print('#' * 20)
    for j in range(af):
        print("", *data[i][j])

Submission status: Accepted

Solution code:
from collections import defaultdict
m = defaultdict(int)
n = int(input())
for _ in range(n):
    b, f, r, v = map(int, input().split())
    m[(b, f, r)] += v
for b in range(1, 5):
    for f in range(1, 4):
        for r in range(1, 11):
            print("", m[(b, f, r)], end="")
        print("")
    if b < 4:
        print("####################")

Submission status: Accepted

Solution code:
'''
いちばん簡単なのは建物とフロアごとにリスト作って、足し引き
'''


#部屋、フロア、建物をクラスで定義。まあ、クラスにしなくてもいいんだけど

a = int(input())

n = 10
m = 3
o = 4
h = [
        [
            [0 for i in range(n)] 
         for j in range(m)] 
    for k in range(o)]


#w, x, y, z = 3, 1, 8, 4
for i in range(a):
    w,x,y,z = map(int, input().split())
    h[w-1][x-1][y-1] += z

#print(h[1][1])
#建物と建物仕切り
def makeFence():
    fence = '#' * 20
    print(fence)

#部屋を表示する関数
def showRoom(f):
    for k in range(len(f)-1):
        print(' ' + str(f[k]), end='')
    print(' ' + str(f[len(f)-1]))

#フロアを表示する関数
def showFloor(b):
    j = 0
    while j < len(b):
        f = b[j]
        showRoom(f)
        j += 1

def statusShow(h):
    for i in range(len(h)-1):
        b = h[i]
        showFloor(b)
        makeFence()
    showFloor(h[len(h)-1])

statusShow(h) 

   
#b = statusShow(h)
#makeFence()
#print(b)

Submission status: Accepted

Solution code:
import sys 

buildings = tuple(i for i in range(4)) 
floors = tuple(i for i in range(3)) 
rooms = tuple(i for i in range(10)) 
occupant = [[[0 for r in rooms] for f in floors] for b in buildings] 

n = input()  

for line in sys.stdin: 
	b, f, r, v = map(int, line.split()) 
	occupant[b - 1][f - 1][r - 1] += v 

for b in buildings: 
	if b: 
		print('####################') 
	for f in floors: 
		print("", *occupant[b][f])

Submission status: Accepted

Solution code:
a=[[10*[0]for _ in range(3)]for _ in range(4)]
for _ in range(int(input())):
 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):print('',*a[i][j])
 if i!=3:print('#'*20)

Submission status: Accepted

Solution code:
from __future__ import print_function
n = int(raw_input())
bilding1 = [[" 0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0"],
           [" 0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0"],
           [" 0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0"]
           ]
bilding2 = [[" 0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0"],#35~44
           [" 0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0"],#46~55
           [" 0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0"]
           ]
bilding3 = [[" 0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0"],#69~78
           [" 0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0"],#80~89
           [" 0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0"]
           ]
bilding4 = [[" 0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0"],#103~112
           [" 0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0"],#114~123
           [" 0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0"]
           ]
bilding = []
bilding.append(bilding1)
bilding.append(bilding2)
bilding.append(bilding3)
bilding.append(bilding4)

for i in range(0,n):
    inf = raw_input()
    inf= inf.split(" ")
    b = int(inf[0]) -1
    f = int(inf[1]) -1
    r = int(inf[2]) -1
    v = int(inf[3])
    bilding[b][f][r] = int(bilding[b][f][r]) + v
    if(r == 0):
        bilding[b][f][r] = " " + str(bilding[b][f][r]) + " "
    elif(r < 9):
        bilding[b][f][r] = str(bilding[b][f][r]) + " "
    else:
        bilding[b][f][r] = str(bilding[b][f][r])

count = 0
for j in range(0,4):
    for k in range(0,3):
        for l in range(0,10):
            print((bilding[j][k][l]),end="")
        print("")
    if(count < 3):
        print("####################")
        count += 1

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_6_C&lang=jp

"""
import sys
from sys import stdin
input = stdin.readline


def solve(n):
    # ビルをつくる(どの部屋も入居者は0)
    buildings = []
    for _ in range(4):          #  ビルは4棟
        buildings.append([[0]*10 for _ in range(3)]) #  1フロア10部屋で3階建

    # 入居者の増減処理 (ビル番号、フロア番号、部屋番号が0起算になっているので、-1する)
    for _ in range(n):
        b, f, r, v = map(int, input().split())
        buildings[b-1][f-1][r-1] += v

    res = []
    for b in buildings:
        for f in b:
            f_stat = ' '.join(map(str, f))
            res.append(' ' + f_stat)
        res.append('#'*20)
    res = res[:-1]
    print(*res, sep='\n')


def main(args):
    n = int(input())
    solve(n)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

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

N = int(input())
moves = [[int(i)-1 for i in input().split()] for _ in range(N)]

for m in moves:
    b,f,r,v = m
    v += 1
    A_college[b][f][r] += v

for b,building in enumerate(A_college):
    if 0 != b: print('#'*20)
    for flr in building:
        print('',*flr)

Submission status: Accepted

Solution code:
a=[[10*[0]for _ in range(3)]for _ in range(4)]
for _ in[0]*int(input()):
 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):print('',*a[i][j])
 if i!=3:print('#'*20)

Submission status: Accepted

Solution code:
n = int(input())
a = [[[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())
  a[b-1][f-1][r-1] += v
 
for i in range(4):
  for j in range(3):
    print(' '+' '.join(map(str, a[i][j])))
 
  if i != 3:
    print('#'*20)

Submission status: Accepted

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

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

for b in range(4):
    for f in range(3):
        out = ""
        for r in range(10):
            out += " " + str(l[b][f][r])
        print(out)
    if 3 != b:
        print("####################")

Submission status: Accepted

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

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

for b in range(4):
    for f in range(3):
        out = ""
        for r in range(10):
            out += " " + str(l[b][f][r])
        print(out)
    if 3 != b:
        print("####################")

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 = [int(i) for i in input().split()]
    l[b-1][f-1][r-1] += v

for b in range(4):
    for f in range(3):
        out = ""
        for r in range(10):
            out += " " + str(l[b][f][r])
        print(out)
    if 3 != b:
        print("####################")

Submission status: Accepted

Solution code:
n = int(input())
info = []
for _ in range(n):
    temp = [int(x) for x in input().split( )]
    info.append(temp)
state = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for a in info:
    state[a[0]-1][a[1]-1][a[2]-1] += a[3]
for b in range(4):
    for f in range(3):
        string = ''
        for k in range(10):
            string += ' ' + str(state[b][f][k])
        print(string)
    if b < 3:
        print('#'*20)

Submission status: Accepted

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

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

ans = ('\n' + '#' * 20 + '\n').join([ '\n'.join([' ' + ' '.join(map(str, floor)) for floor in building]) for building in record])
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
buffer = []
i = 0
while i<n:
    b,f,r,v = map(int,input().split())
    buffer.append([b,f,r,v])
    i = i + 1

room = []
for h in range(15):
    if h == 3 or h == 7 or h == 11:
        room.append(['**']*10)
    else:
        room.append([0]*10)
            
for y in range(n):
    if buffer[y][0] == 1:
        room[buffer[y][1]-1][buffer[y][2]-1] = buffer[y][3] + room[buffer[y][1]-1][buffer[y][2]-1]
    elif buffer[y][0] == 2:
        room[buffer[y][1]-1+4][buffer[y][2]-1] = buffer[y][3] + room[buffer[y][1]-1+4][buffer[y][2]-1]
    elif buffer[y][0] == 3:
        room[buffer[y][1]-1+8][buffer[y][2]-1] = buffer[y][3] + room[buffer[y][1]-1+8][buffer[y][2]-1]
    elif buffer[y][0] == 4:
        room[buffer[y][1]-1+12][buffer[y][2]-1] = buffer[y][3] + room[buffer[y][1]-1+12][buffer[y][2]-1]
        
for x in range(15):
    if x == 3 or x == 7 or x == 11:
        print("####################")
    else:
        for y in range(10):
            print(" "+str(room[x][y]), end = "")   
        print()

Submission status: Accepted

Solution code:
n = int(input())
count = [[[0 for x in range(10)] for x in range(3)] for x 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 i in range(4):
    for j in range(3):
        print(" " + " ".join(map(str, count[i][j])))

    if i != 3:
        print("#"*20)

Submission status: Accepted

Solution code:
n = {}
for b in range(1,5):
    for f in range(1,4):
        for r in range(1,11):
            n[(b,f,r)] = 0

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

for b in range(1, 5):
    for f in range(1, 4):
        for r in range(1, 11):
            print (" " + str(n[(b,f,r)]), end ="")
        print("")
    if b <= 3:
        print("#"*20)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding: utf-8

n = int(input())

x = [[[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 = (int(j) for j in input().split())
    x[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" " + str(x[i][j][k]), end = '' if k != 9 else '\n')

    print("#"*20 if i != 3 else '', end='\n'if i != 3 else '')

Submission status: Accepted

Solution code:
arr = [[[0 for i3 in range(10)] for i2 in range(3)] for i1 in range(4)]
for _ in range(int(input())):
    a,b,c,d = map(int,input().split())
    arr[a-1][b-1][c-1] += d
for j1 in range(4):
    for j2 in range(3):
        u = arr[j1][j2]
        print("",u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],u[8],u[9])
    if j1 == 3:
        break
    print("####################")

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

tenant = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]

n = int(sys.stdin.readline())
for i in range(n):
    b, f, r, v = map(int, sys.stdin.readline().split())
    tenant[b-1][f-1][r-1] += v

separator = '#' * 20
for b in range(4):
    for f in range(3):
        for r in range(10):
            print(' ', tenant[b][f][r], sep='', end='')
        print()
    if b != 3:
        print(separator)

Submission status: Accepted

Solution code:
SEPARATE = "####################"

tower = [
		[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
		[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
		[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
		[[0, 0, 0, 0, 0, 0, 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())
i = 0
while i < n:
	b, f, r, v = map(int, input().split())
	tower[b - 1][f - 1][r - 1] += v
	i += 1

i = 0
j = 0
k =  0
while k < 4:	
	while j < 3:
		while i < 10:
			print(" " + str(tower[k][j][i]), end = "")
			i += 1
		print()
		j += 1
		i = 0
	if k != 3:
		print(SEPARATE)
	j = 0
	k += 1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = [[[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 = [int(x) for x in input().split()]
    a[b-1][f-1][r-1] += v
for i, b in enumerate(a) :
    for f in b :
        for r in f :
            print(' %d' % r, end = '')
        print()
    if i < 3 :
        print('#'*20)

Submission status: Accepted

Solution code:
# リスト内包表記
a = [[0 for i in range(10)] for k in range(3 * 4)]
for i in range(int(input())):
    b, f, r, v = map(int, input().split())
    a[(b-1)*3 + (f-1)][r-1] += v
for idx, i in enumerate(a):
    if idx % 3 == 0 and idx != 0:
        for k in range(20):
            print("#", end = "")
        print("")
    print(" ", end = "")
    print(" ".join(map(str, i)))

Submission status: Accepted

Solution code:
L=[0]*120
n = int(input())
i = 0
while i < n:
    b, f, r, v = map(int, input().split(' '))
    p = (r - 1) + (f - 1) * 10 + (b - 1) * 30
    L[p] += v
    i += 1
ans = ''
ans += ' ' + ' '.join(map(str, L[0:10].copy())) + '\n'
q = 1
while q < 12:
    if q % 3 == 0:
        ans += '#' * 20 + '\n'
    ans += ' ' + ' '.join(map(str, L[q*10:(q+1)*10].copy())) + '\n'
    q += 1
print(ans[:-1])

Submission status: Accepted

Solution code:
#!/usr/bin/env python

if __name__ == '__main__':
    man = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]

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

    print ' '+('\n%s\n ' % ('#'*20)).join(map(lambda x : '\n '.join(map(lambda y : ' '.join(map(str, y)), x)), man))

Submission status: Accepted

Solution code:
import sys

n = int(sys.stdin.readline())
values =[ [ int(val) for val in num[:-1].split() ] for num in sys.stdin.readlines() ]

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

for value in values:
    nyukyo[value[0]-1][value[1]-1][value[2]-1] += value[3]
    if nyukyo[value[0] - 1][value[1] - 1][value[2] - 1] < 0:
        nyukyo[value[0] - 1][value[1] - 1][value[2] - 1] = 0
    elif nyukyo[value[0]-1][value[1]-1][value[2]-1] > 9:
        nyukyo[value[0] - 1][value[1] - 1][value[2] - 1] = 9

for j in range(4):
    for n in range(3):
        for m in range(10):
            print( ' ' + str(nyukyo[j][n][m]), end='')
        print('')
    if j < 3:
        print('#' * 20)

Submission status: Accepted

Solution code:
n = int(input())
move = []
first = []
second = []
third = []
forth = []

for p in range(3):
    first.append([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])

for q in range(3):
    second.append([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
    
for r in range(3):
    third.append([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
    
for s in range(3):
    forth.append([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])

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

for j in move:
    f = j[1] - 1
    r = j[2] - 1
    if j[0] == 1:
        first[f][r] += j[3]
    elif j[0] == 2:
        second[f][r] += j[3]
    elif j[0] == 3:
        third[f][r] += j[3]
    else:
        forth[f][r] += j[3]

for i in range(3):
    print(' ' + ' '.join(map(str, first[i])))

print("#" * 20)

for i in range(3):
    print(' ' + ' '.join(map(str, second[i])))
    
print("#" * 20)

for i in range(3):
    print(' ' + ' '.join(map(str, third[i])))
    
print("#" * 20)

for i in range(3):
    print(' ' + ' '.join(map(str, forth[i])))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
build,story,room,people=[],[],[],[]
for i in range(n):
    date=list(map(int,input().split(' ')))
    build.append(date[0])
    story.append(date[1])
    room.append(date[2])
    people.append(date[3])
build1=[[0 for i in range(10)] for j in range(3)]
build2=[[0 for i in range(10)] for j in range(3)]
build3=[[0 for i in range(10)] for j in range(3)]
build4=[[0 for i in range(10)] for j in range(3)]
for i in range(n):
    m=int(i)
    if(build[m]==1):
        build1[story[m]-1][room[m]-1]=build1[story[m]-1][room[m]-1]+people[m]
    elif(build[m]==2):
        build2[story[m]-1][room[m]-1]=build2[story[m]-1][room[m]-1]+people[m]
    elif(build[m]==3):
        build3[story[m]-1][room[m]-1]=build3[story[m]-1][room[m]-1]+people[m]
    else:
        build4[story[m]-1][room[m]-1]=build4[story[m]-1][room[m]-1]+people[m]

for i in range(3):
    print(' '+' '.join(list(map( lambda x: str(x),build1[i]))))
print('#'*20)
for i in range(3):
    print(' '+' '.join(list(map( lambda x: str(x),build2[i]))) )
print('#'*20)
for i in range(3):
    print(' '+' '.join(list(map( lambda x: str(x),build3[i]))) )
print('#'*20)
for i in range(3):
    print(' '+' '.join(list(map( lambda x: str(x),build4[i]))) )

Submission status: Accepted

Solution code:
n = int(input())
l = [[[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())
  l[b - 1][f - 1][r - 1] += v
for b in range(4):
  for f in range(3):
    for r in range(10):
      print(" %d" % l[b][f][r], end = "")
    print("")
  if b != 3:
    print("#" * 20)

Submission status: Accepted

Solution code:
from collections import defaultdict

tower = defaultdict(lambda: defaultdict(list))
for x in range(1, 5):
    for y in range(1, 4):
        for z in range(1, 11):
            tower[x][y].append(0)

count = int(input())

for x in range(count):
    b, f, r, v = map(int, input().split())
    if v > 0:
        tower[b][f][r-1] += v
    else:
        tower[b][f][r-1] -= -v


for key, value in tower.items():
    for layer, value in value.items():
        print(' ', end='')
        print(' '.join(map(str, value)))
    if key != 4:
        print('#' * 20)

Submission status: Accepted

Solution code:
house = [[ 0 for i in range(10)],
        [ 0 for i in range(10)],
        [ 0 for i in range(10)],
        [ "#" for i in range(20)],
        [ 0 for i in range(10)],
        [ 0 for i in range(10)],
        [ 0 for i in range(10)],
        [ "#" for i in range(20)],
        [ 0 for i in range(10)],
        [ 0 for i in range(10)],
        [ 0 for i in range(10)],
        [ "#" for i in range(20)],
        [ 0 for i in range(10)],
        [ 0 for i in range(10)],
        [ 0 for i in range(10)]]
n = int(input())
for i in range(n):
    b,f,r,v = map(int,input().split())
    if b==1:
        house[f-1+(b-1)*4][r-1] += v
    elif b==2:
        house[f-1+(b-1)*4][r-1] += v
    elif b==3:
        house[f-1+(b-1)*4][r-1] += v
    else:
        house[f-1+(b-1)*4][r-1] += v
for i in range(len(house)):
    if (i+1)%4 ==0:
        print(''.join(str(i) for i in house[i]))
    else:
        print('',' '.join(str(i) for i in house[i]))

Submission status: Accepted

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

for i in range(len(house)):
    if (i+1)%4 ==0:
        print(''.join(str(i) for i in house[i]))
    else:
        print('',' '.join(str(i) for i in house[i]))