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())
l=[[[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(lambda x: int(x)-1, input().split())
    l[b][f][r]+=v+1
for j in range(4):
    for k in l[j]:
        print(" "+" ".join(map(str, k)))
    if j < 3:
        print("####################")

Submission status: Accepted

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

for b in range(4):
    for f in range(3):
        print(''.join(' {}'.format(a[b][f][r]) for r in range(10)))
    if b<3:
        print('#'*20)

Submission status: Accepted

Solution code:
rooms = [0] * (4*3*10)
count = int(input())
for i in range(count):
    b, f, r, v = [int(x) for x in input().split()]
    rooms[30*(b-1) + 10*(f-1) + (r-1)] += v
  
for i, room in enumerate(rooms, start=1):
    print('', room, end='')
    if i%10 == 0:
        print()
    if i%30 == 0 and i%120 != 0:
        print('#'*20)

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(4):
    for j in range(3):
        for k in range(10):
            print('', rooms[i][j][k], end='')
        print()
    if i < 3:
        print('#' * 20)

Submission status: Accepted

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

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

for b in range(4):
    for f in range(3):
        print(' ' + ' '.join(map(str, rooms[b][f])))
    if b is not 3:
        print('####################')

Submission status: Accepted

Solution code:


#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
??´?????????
"""

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

number = int(input())

for n in range(number):
    inp = input().split(" ")
    b = int(inp[0]) - 1
    f = int(inp[1]) - 1
    r = int(inp[2]) - 1
    v = int(inp[3])
    rooms[b][f][r] += v

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

Submission status: Accepted

Solution code:
Residents = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for l in range(n):
    b, f, r, v = list(map(int, input().split()))
    Residents[b-1][f-1][r-1] += v
for k in range(4):
    for j in range(3):
        print(' '+' '.join(map(str, Residents[k][j])))
    if k == 3:
        break
    print('####################')

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())
x1=[[int(0) for i in range(10)]for j in range(3)]
x2=[[int(0) for i in range(10)]for j in range(3)]
x3=[[int(0) for i in range(10)]for j in range(3)]
x4=[[int(0) for i in range(10)]for j in range(3)]

for i in range(n):
    b,f,r,v=[int(s) for s in input().split()]
    if b==1:
        x1[f-1][r-1]=x1[f-1][r-1]+v
    elif b==2:
        x2[f-1][r-1]=x2[f-1][r-1]+v
    elif b==3:
        x3[f-1][r-1]=x3[f-1][r-1]+v
    else:
        x4[f-1][r-1]=x4[f-1][r-1]+v
for j in range(3):
    for k in range(10):
        print("",x1[j][k],end="")
    print("")
for n in range(20):
    print('#',end="")
print("")
for j in range(3):
    for k in range(10):
        print("",x2[j][k],end="")
    print("")
for n in range(20):
    print('#',end="")
print("")
for j in range(3):
    for k in range(10):
        print("",x3[j][k],end="")
    print("")
for n in range(20):
    print('#',end="")
print("")
for j in range(3):
    for k in range(10):
        print("",x4[j][k],end="")
    print("")

Submission status: Accepted

Solution code:
n = int(input())
data = [[[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(s) for s in input().split(' ')]
	data[b-1][f-1][r-1] += v

while data:
	building = data.pop(0)
	for floor in building:
		rooms = ' ' + ' '.join([str(room) for room in floor])
		print(rooms)
	if data:
		print('####################')

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
def make_buildings():
    return [[[0 for room in range(10)] for floor in range(3)] for building in range(4)]

def print_building(building):
    return "\n".join(map(lambda floor: " " + " ".join(map(str, floor)),building))
    
line_number = int(input())
regidents_data = [list(map(int, input().split(" "))) for i in range(line_number)]
buildings = make_buildings()

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

print("\n####################\n".join(map(print_building, buildings)))

Submission status: Accepted

Solution code:
# coding: utf-8
def format_building(building):
    return "\n".join(map(lambda floor: " " + " ".join(map(str, floor)),building))
    
line_number = int(input())
regidents_data = [list(map(int, input().split(" "))) for i in range(line_number)]
buildings = [[[0 for room in range(10)] for floor in range(3)] for building in range(4)]

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

print("\n####################\n".join(map(format_building, buildings)))

Submission status: Accepted

Solution code:
n=int(input())
nyukyo=[list(map(int, input().split())) for i in range(n)]
bld=[[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for ny in nyukyo:
    bld[ny[0]-1][ny[1]-1][ny[2]-1]+=ny[3]

for i,b in enumerate(bld):
    for f in b:
        print("",*f)
    if i != 3:
        print("####################")

Submission status: Accepted

Solution code:
num = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
b, f, r, v, v1, n, x, y, z  = 0, 0, 0, 0, 0, 0, 0, 0, 0
n = int(input())
for i in range(n):
	b, f, r, v = list(map(int, input().split()))
	num[b - 1][f - 1][r - 1] += v
for i in range(4):
	if y >= 1:
		z = 0
		y = 0
		x += 1
		print()
		print('####################')
	for i in range(3):
		if z >= 1:
			z = 0
			y += 1
			print('')
		for i in range(10):
			print('', num[x][y][z], end = '')
			z += 1
print()

Submission status: Accepted

Solution code:
data = [[[0 for i in range(10)] for j in range(3)] for h in range(4)]
n = int(input())
for o in range(n):
    a = input().split()
    b = int(a[0])
    f = int(a[1])
    r = int(a[2])
    v = int(a[3])
    data[b - 1][f - 1][r - 1] += v

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

Submission status: Accepted

Solution code:
N = int(input())
residents = [[["0" for rooms in range(10)]for floor in range(3)]for builds in range(4)]

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

for buils_num in range(4):
    for floor_num in range(3):
        print(' '+' '.join(residents[buils_num][floor_num]))
    if buils_num < 3:
        print('#'*20)

Submission status: Accepted

Solution code:
ls = [[[0 for i in range(10)] for j in range(3)]for s in range(4)]
n = int(input())
for g in range(0,n):
    b,f,r,v = map(int,input().split())
    ls[b-1][f-1][r-1] += v
for k in range(0,4):
    if k == 0:
        pass
    else:
        print("####################")
    for z in range(0,3):
        lis = ""
        for s in range(0,10):
            lis += " "+str(ls[k][z][s])
        print(lis)

Submission status: Accepted

Solution code:
idx = int(input())
in_dict = {}

for i in range(idx):
    b, f, r, v = (int(x) for x in input().split())
    b -= 1
    f -= 1
    r -= 1
    in_dict[(b,f,r)] = in_dict.get((b,f,r),0) + v

for b in range(4):
    for f in range(3):
        for r in range(10):
            print(" ",end="")
            print(in_dict.get((b,f,r),0), end="")
        print("\n", end="")
    if b in range(3):print("#"*20)

Submission status: Accepted

Solution code:
def out(bnum):
    print(' '+str(bnum['1f']).replace(',','')[1:10*2])
    print(' '+str(bnum['2f']).replace(',','')[1:10*2])
    print(' '+str(bnum['3f']).replace(',','')[1:10*2])
    
n = int(input())
b1 = {'1f': [0]*10, '2f': [0]*10, '3f': [0]*10}
b2 = {'1f': [0]*10, '2f': [0]*10, '3f': [0]*10}
b3 = {'1f': [0]*10, '2f': [0]*10, '3f': [0]*10}
b4 = {'1f': [0]*10, '2f': [0]*10, '3f': [0]*10}
for i in range(n):
    b, f, r, v = map(int,input().split())
    r -= 1
    if b == 1:
        b1[repr(f)+'f'][r] += v
    elif b == 2:
        b2[repr(f)+'f'][r] += v
    elif b == 3:
        b3[repr(f)+'f'][r] += v
    elif b == 4:
        b4[repr(f)+'f'][r] += v
out(b1)
print('#'*20)
out(b2)
print('#'*20)
out(b3)
print('#'*20)
out(b4)

Submission status: Accepted

Solution code:
class myResi():
    def __init__(self):
        self.val=[[0]*10 for _ in range(3)]
    def __str__(self):
        ret = ''
        for i in range(3):
            ret += ' '+(str(self.val[i]).replace(',','')[1:10*2])+'\n'
        return ret.rstrip("\n")
    def setVal(self,f,r,v):
        self.val[f-1][r-1] += v
        
def fill(allb,b,f,r,v):
    bname=allb[b-1]
    bname.setVal(f,r,v)
    
b1=myResi()
b2=myResi()
b3=myResi()
b4=myResi()
allb=[b1,b2,b3,b4]
n=int(input())
for _ in range(n):
    b,f,r,v = map(int,input().split())
    fill(allb,b,f,r,v)
    
print(b1)
print('#'*20)
print(b2)
print('#'*20)
print(b3)
print('#'*20)
print(b4)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
rooms = []
rooms.append([[0 for i in range(10)] for j in range(3)])
rooms.append([[0 for i in range(10)] for j in range(3)])
rooms.append([[0 for i in range(10)] for j in range(3)])
rooms.append([[0 for i in range(10)] for j in range(3)])

num = int(raw_input())
for i in range(num):
    b,f,r,v = map(int, raw_input().split())
    rooms[b-1][f-1][r-1] += v

for number, room in enumerate(rooms):
    for row in room:
        print " %d %d %d %d %d %d %d %d %d %d" % (row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9])
    if len(rooms) - 1 > number:
        print('####################')

Submission status: Accepted

Solution code:
rooms = []
rooms.append([[0 for i in range(10)] for j in range(3)])
rooms.append([[0 for i in range(10)] for j in range(3)])
rooms.append([[0 for i in range(10)] for j in range(3)])
rooms.append([[0 for i in range(10)] for j in range(3)])

num = int(raw_input())
for i in range(num):
    b,f,r,v = map(int, raw_input().split())
    rooms[b-1][f-1][r-1] += v

for number, room in enumerate(rooms):
    for row in room:
        print ' ' + ' '.join(map(str, row))
    if len(rooms) - 1 > number:
        print('####################')

Submission status: Accepted

Solution code:
a=[int('0') for i in range(10)]
w=["#" for i in range(20)]
z=[]
for i in range(15):
    z+=[a]
    if i == 3 or i== 7 or i== 11:
        z+=[w]
x=[[[0 for i in range(10)] for k in range(3)] for j in range(4)]
n=int(input())
for i in range(n):
    b,f,r,v=map(int,input().split())
    x[b-1][f-1][r-1]+=v

for i in range(4):
    for k in range(3):
        print(" "+" ".join(str(x[i][k][o]) for o in range(10)))
    if i ==0 or i ==1 or i==2:
        print("#"*20)

Submission status: Accepted

Solution code:
# Aizu Problem ITP_1_6_C: Official House
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


building = {b: [[0] * 10, [0] * 10, [0] * 10] for b in range(1, 5)}

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

for b in range(1, 5):
    for level in building[b]:
        print(' ' + ' '.join([str(l) for l in level]))
    if b < 4:
        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 i in range(n):
    b, f, r, v = map(int, input().split())
    house[b-1][f-1][r-1] += v
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" " + str(house[i][j][k]), end="")
        print()
    if j == 3 - 1 and i != 4 - 1:
        print("#" * 20)

Submission status: Accepted

Solution code:
class OfficialHouse:
    def __init__(self):
        self.bill = [[[0,0,0,0,0,0,0,0,0,0],
                      [0,0,0,0,0,0,0,0,0,0],
                      [0,0,0,0,0,0,0,0,0,0]],
                     [[0,0,0,0,0,0,0,0,0,0],
                      [0,0,0,0,0,0,0,0,0,0],
                      [0,0,0,0,0,0,0,0,0,0]],
                     [[0,0,0,0,0,0,0,0,0,0],
                      [0,0,0,0,0,0,0,0,0,0],
                      [0,0,0,0,0,0,0,0,0,0]],
                     [[0,0,0,0,0,0,0,0,0,0],
                      [0,0,0,0,0,0,0,0,0,0],
                      [0,0,0,0,0,0,0,0,0,0]]]


    def input_bfrv(self, b, f, r, v):
        self.bill[b-1][f-1][r-1] += v

    def result(self):
        for i in range(4):
            for j in range(3):
                print("", ' '.join(map(str, self.bill[i][j])))
            if i != 3:
                print("####################")

oh = OfficialHouse()

n = int(input())

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

   oh.input_bfrv(b, f, r, v)

oh.result()

Submission status: Accepted

Solution code:
nyukyo = [[[0 for i in range(10)] for m in range(3)] for n in range(4)]
num = int(input())
for i in range(num):
    handan = input().split()
    handan = list(map(int, handan))
    nyukyo[handan[0]-1][handan[1]-1][handan[2]-1] += handan[3]

for m in nyukyo[0]:
    t = list(map(str, m))
    print(" "+" ".join(t))
print("#"*20)
for m in nyukyo[1]:
    t = list(map(str, m))
    print(" "+" ".join(t))
print("#"*20)
for m in nyukyo[2]:
    t = list(map(str, m))
    print(" "+" ".join(t))
print("#"*20)
for m in nyukyo[3]:
    t = list(map(str, m))
    print(" "+" ".join(t))

Submission status: Accepted

Solution code:
box = [[[0]*10 for i in range(3)] for j in range(4)]
num = int(input())
for i in range(num):
    temp = list(map(int, input().split()))
    box[temp[0]-1][temp[1]-1][temp[2]-1] += temp[3]
    if box[temp[0]-1][temp[1]-1][temp[2]-1] < 0: box[temp[0]-1][temp[1]-1][temp[2]-1] = 0

for i in range(len(box)):
    [print(" "+" ".join( map(str, box[i][j])) ) for j in range(len(box[i]))]
    if i != 3:
        print("####################")

Submission status: Accepted

Solution code:
a = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
e = '#' * 20
n = int(input())
for i in range(n):
    b,f,r,v = [int(i) for i in 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(e)

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-11] += v
	
for i in range(12):
	for j in range(10):
		print(" {}".format(list[i][j]), end="")
	print()	
	if ((i + 1) % 3) == 0 and i != 11:
		print("#"*20)

Submission status: Accepted

Solution code:
def Input(b, f, rn, h):
    A[b][f][rn] += h

def Output():
    for b in range(4):
        for f in range(4):
            for rn in range(10):
                if f < 3:
                    print(' ' + str(A[b][f][rn]), end = '')
                if f == 3 and b != 3:
                    print('##', end = '')
            if b == 3 and f == 3:
                break
            print()

n = int(input())

A = [[[0 for rn in range(10)] for f in range(3)] for b in range(4)]

for idx in range(n):
    R = input().split()
    B = int(R[0]) - 1
    F = int(R[1]) - 1
    RN = int(R[2]) - 1
    H = int(R[3])
    Input(B, F, RN, H)
Output()

Submission status: Accepted

Solution code:
house = {1:[[0 for i in range(10)] for j in range(3)], 2:[[0 for i in range(10)] for j in range(3)],
         3:[[0 for i in range(10)] for j in range(3)], 4:[[0 for i in range(10)] for j in range(3)]}
n = int(input())
for i in range(n):
    building, floor, room, people_numbers = [int(j) for j in input().split()]
    house[building][floor - 1][room - 1] += people_numbers

partition = "#"*20
for i in range(4):
    for j in range(3):
        tmp_list = [str(tmp) for tmp in house[i + 1][j]]
        print(" {}".format(" ".join(tmp_list)))
        if j == 2 and i != 3: print(partition)

Submission status: Accepted

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

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

k = 0
for i in range(4):
    for j in range(3):
        output = " ".join(map(str, table[i][j]))
        print(" %s" % output)
    if k < 3:
        print("####################")
        k += 1

Submission status: Accepted

Solution code:
from collections import OrderedDict
from itertools import cycle, islice
 
d = OrderedDict(("{} {} {}".format(b, f, r), 0) for b in range(1, 5)
                                                for f in range(1, 4)
                                                for r in range(1, 11))
 
n = int(input())
for _ in range(n):
    s = input()
    idx = s.rfind(" ")
    d[s[:idx]] += int(s[idx+1:])

data = d.values()
delim = "#" * 20
for i in range(0, 120, 10):
    print(" " + " ".join(map(str, islice(cycle(data), i, i+10))))
    if i in (20, 50, 80):
        print(delim)

Submission status: Accepted

Solution code:
import sys
write=sys.stdout.write

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

informations=int(input())

for i in range(0,informations):
    information=[]
    information=input().split()
    information[0]=int(information[0])
    information[1]=int(information[1])
    information[2]=int(information[2])
    information[3]=int(information[3])
    buildings[information[0]-1][information[1]-1][information[2]-1]+=information[3]

for i in range(0,4):
    for j in range(0,3):
        for k in range(0,10):
            write(' ')
            write(str(buildings[i][j][k]))
        print()
    if i !=3:
        for j in range(0,20):
            write('#')
        print()

Submission status: Accepted

Solution code:
lst = [[[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,raw_input().split())
    lst[b-1][f-1][r-1] += v
for i in range(4):
    if i != 0:
        print "#"*20
    for j in range(3):
        pri = ""
        for k in range(10):
            pri += " "+ str(lst[i][j][k])
        print pri

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 c in range(4):
    for d in range(3):print('',*a[c][d])
    if c != 3:print('#' *20)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
buildings = [[[0 for V in range(10)] for F in range(3)] for B in range(4)]
for i in range(N):
 b, f, r, num = map(int, input().split())
 buildings[b-1][f-1][r-1] += num

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

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

Submission status: Accepted

Solution code:
# (c) midandfeed
q = []
for i in range(4):
	b = []
	for j in range(3):
		a = [0 for x in range(10)]
		b.append(a)
	q.append(b)

t = int(input())
for _ in range(t):
	b, f, r, v = [int(x) for x in input().split()]
	q[b-1][f-1][r-1] += v

a = 0
for x in q:
	a += 1
	for y in x:
		for z in range(len(y)):
			print(" {}".format(y[z]), end='')
			if (z==(len(y))-1):
				print()
	if (a!=4):	
		print("#"*20)

Submission status: Accepted

Solution code:
A = [[[0 for r in range(10)] for f in range(3)] for b in range(4)] # A[b][f][r]
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(' %d' %(A[b][f][r]), end='')
        print('')
    if b < 3:
        print('#'*20)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(raw_input())
 
info = [[[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, raw_input().split())
    b, f, r = b-1, f-1, r-1
    info[b][f][r] += v
 
sharp = False
for i in info:
    if sharp:
        print "#" * 20
    for j in i:
        print " "+" ".join(map(str, j))
    sharp = True

Submission status: Accepted

Solution code:
x = {}
for i in range(4):
    for j in range(3):
        for k in range(10):
            i,j,k = str(i), str(j), str(k)
            x[i+j+k] = 0

n = int(input())
for i in range(n):
    i,j,k,l = map(int, input().split())
    key = str(i-1)+str(j-1)+str(k-1)
    x[key] = x[key] + int(l)

for i in range(4):
    for j in range(3):
        for k in range(10):
            i,j,k = str(i), str(j), str(k)
            if k != "9":
                print(" " + str(x[i+j+k]), end='')
            else:
                print(" "+ str(x[i+j+k]))
    if int(i) + 1 < 4:
        print("#"*20)

Submission status: Accepted

Solution code:
import itertools
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 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:
room = [0 for i in range(120)]
c = int(input())
for i in range(c):
    b, f, r, v = [int(s) for s in input().split()]
    index = (30 * (b - 1)) + (10 * (f - 1)) + (r - 1)
    room[index] += v

for i in range(12):
    if (i != 0) and (i % 3 == 0):
        print('#' * 20)
    print(' ' + ' '.join([str(v) for v in room[i*10:i*10+10]]))

Submission status: Accepted

Solution code:
import sys

nyuukyosha = []

for tou in range(4):
	nyuukyosha.append([])
	for kai in range(3):
		nyuukyosha[tou].append([])
		for heya in range(10):
			nyuukyosha[tou][kai].append(0)

n = int(raw_input())

for i in range(n):
	data = map(int, raw_input().split())
	a = data[0] - 1
	b = data[1] - 1
	c = data[2] - 1
	nyuukyosha[a][b][c] += data[3]

for tou in range(4):
	for kai in range(3):
		for heya in range(10):
			sys.stdout.write(" {:}".format(nyuukyosha[tou][kai][heya]))
		print("")
	if tou < 3:
		print("####################")

Submission status: Accepted

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

for i in range(n):
    data = [int(j) for j in list(input().split())]
    tower = data[0]-1
    rank = data[1]-1
    room = data[2]-1
    dormitory[tower][rank][room] += data[3]

for i in range(0, 4):
    for j in range(0, 3):
        print(" "+" ".join(map(str, dormitory[i][j])))
    if i == 3:
        break
    else:
        print('#'*20)

Submission status: Accepted

Solution code:
residence=[[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n=int(input())
lines=[input() for i in range(n)]
for l in lines:
    k=list(map(int,l.split()))
    residence[k[0]-1][k[1]-1][k[2]-1]+=k[3]
    if residence[k[0]-1][k[1]-1][k[2]-1]>9: residence[k[0]-1][k[1]-1][k[2]-1]=9

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

Submission status: Accepted

Solution code:
def main():
    
    n = int(input())
    movements = [list(map(int, input().split())) for i in range(n)]
    houses = [[[0 for room in range(10)] for floor in range(3)] for building in range(4)]
    
    for move in movements:
        [b, f, r, v] = move
        houses[b-1][f-1][r-1] += v
    
    for index, building in enumerate(houses):
        for floor in building:
            print(' ' + ' '.join(map(str,floor)))
        if index != 3: print('#'*20)


main()

Submission status: Accepted

Solution code:
n = int(input())

tenant = [
    [ [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 i in range(n):
    b,f,r,nu = map(int, input().split())
    tenant[b-1][f-1][r-1] += nu

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

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 main(args):
    residents = [[[0] * 10 for _ in range(3)] for _ in range(4)]
    n = int(input())
    for _ in range(n):
        b, f, r, v = map(int, input().split())
        residents[b-1][f-1][r-1] += v

    for i in range(4):
        for j in range(3):
            t = ''
            for k in range(10):
                t += '{:2d}'.format(residents[i][j][k])
            print(t)
        if i != 3:
            print('#' * 20)



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

Submission status: Accepted

Solution code:
import sys

def main():
    lines = sys.stdin.readlines()

    # The number of rooms
    rooms = [0] * 10
    floors = [rooms] * 3
    buildings = [floors] * 4

    data_num = 0

    for index, line in enumerate(lines):
        #print(line)
        # rm '\n' from string of a line
        line = line.strip('\n')
        elems = line.split(" ")
        if index == 0:
            data_num = int(elems[0])
        else:
            b = int(elems[0]) - 1   # as index
            f = int(elems[1]) - 1   # as index
            r = int(elems[2]) - 1   # as index
            v = int(elems[3])       # as data
            # print v
            # print buildings[b][f][r]
            ans = []
            for b_i in range(0, 4):
                b_list = []
                for f_i in range(0, 3):
                    f_list = []
                    for r_i in range(0, 10):
                        if b == b_i and f == f_i and r == r_i:
                            f_list.append(buildings[b_i][f_i][r_i] + v)
                        else:
                            f_list.append(buildings[b_i][f_i][r_i])
                    b_list.append(f_list)
                ans.append(b_list)
            # print ans
            buildings = ans

    for b_i in range(0, 4):
        for f_i in range(0, 3):
            for r_i in range(0, 10):
                sys.stdout.write(' %d' % buildings[b_i][f_i][r_i])
            sys.stdout.write('\n')
        if b_i != 3:
            print "####################"



if __name__ == "__main__":
    main()