Problem:


Score : 200 points

Problem Statement

There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.

Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).

Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:

If a_i = 1, he painted the region satisfying x < x_i within the rectangle.

If a_i = 2, he painted the region satisfying x > x_i within the rectangle.

If a_i = 3, he painted the region satisfying y < y_i within the rectangle.

If a_i = 4, he painted the region satisfying y > y_i within the rectangle.

Find the area of the white region within the rectangle after he finished painting.

Constraints

1 ≦ W, H ≦ 100

1 ≦ N ≦ 100

0 ≦ x_i ≦ W (1 ≦ i ≦ N)

0 ≦ y_i ≦ H (1 ≦ i ≦ N)

W, H (21:32, added), x_i and y_i are integers.

a_i (1 ≦ i ≦ N) is 1, 2, 3 or 4.

Input

The input is given from Standard Input in the following format:

W H N
x_1 y_1 a_1
x_2 y_2 a_2
:
x_N y_N a_N

Output

Print the area of the white region within the rectangle after Snuke finished painting.

Sample Input 1

5 4 2
2 1 1
3 3 4

Sample Output 1

9

The figure below shows the rectangle before Snuke starts painting.

First, as (x_1, y_1) = (2, 1) and a_1 = 1, he paints the region satisfying x < 2 within the rectangle:

Then, as (x_2, y_2) = (3, 3) and a_2 = 4, he paints the region satisfying y > 3 within the rectangle:

Now, the area of the white region within the rectangle is 9.

Sample Input 2

5 4 3
2 1 1
3 3 4
1 4 2

Sample Output 2

0

It is possible that the whole region within the rectangle is painted black.

Sample Input 3

10 10 5
1 6 1
4 1 3
6 9 4
9 4 2
3 1 3

Sample Output 3

64



Sample input:
5 4 2
2 1 1
3 3 4


Sample output:
9

Submission status: Wrong Answer

Solution code:
array = []
l = list(map(int,list(input().split())))
W,H,N = l[0],l[1],l[2]
S = W*H
left_lower = [0,0]
right_upper = [W,H]

for i in range(N):
    l = list(map(int,list(input().split())))
    array.append([l[0],l[1],l[2]])

for i in range(0,len(array)):
    if array[i][2]==1:
        left_lower = [array[i][0],left_lower[1]]
    elif array[i][2]==2:
        right_upper = [array[i][0],right_upper[1]]
    elif array[i][2]==3:
        left_lower = [left_lower[0],array[i][1]]
    elif array[i][2]==4:
        right_upper = [right_upper[0],array[i][1]]

S = (right_upper[0]-left_lower[0])*(right_upper[1]-left_lower[1])
if  S< 0:
    print(0)
else:
    print(S)

Submission status: Wrong Answer

Solution code:
array = []
l = list(map(int,list(input().split())))
W,H,N = l[0],l[1],l[2]
S = W*H
left_lower = [0,0]
right_upper = [W,H]

for i in range(N):
    l = list(map(int,list(input().split())))
    array.append([l[0],l[1],l[2]])

for i in range(0,len(array)):
    if array[i][2]==1:
        left_lower = [array[i][0],left_lower[1]]
    elif array[i][2]==2:
        right_upper = [array[i][0],right_upper[1]]
    elif array[i][2]==3:
        left_lower = [left_lower[0],array[i][1]]
    elif array[i][2]==4:
        right_upper = [right_upper[0],array[i][1]]

print((right_upper[0]-left_lower[0])*(right_upper[1]-left_lower[1]))

Submission status: Wrong Answer

Solution code:
# encoding: utf-8

w, h, n = map(int,raw_input().split())

def coloring(w ,h ,n):
    point_a = [0, 0]
    point_b = [w, h]

    for i in range(0, n):
        x, y, a = map(int,raw_input().split())
        if a == 1 and point_a[0] < x: point_a[0] = x
        if a == 2 and point_b[0] > x: point_b[0] = x
        if a == 3 and point_a[1] < y: point_a[1] = y
        if a == 4 and point_b[1] > y: point_b[1] = y

    print max(point_b[0] - point_a[0], 0) * max(point_b[0] - point_a[0], 0)

coloring(w, h, n)

Submission status: Wrong Answer

Solution code:
w, h, n = input().split()        
w, h, n = int(w), int(h), int(n) 
x = []                           
y = []                           
a = []                           
                                 
for _ in range(n):               
    x_, y_, a_ = input().split() 
    x.append(int(x_))            
    y.append(int(y_))            
    a.append(int(a_))            
W = w                            
H = h                            
w_r = w                          
w_l = 0                          
h_u = h                          
h_l = 0                          
for i in range(n):               
    if a[i] is 1 and x[i]>w_l:   
        w_l = x[i]               
    if a[i] is 2 and x[i]<w_r:   
        w_r = x[i]               
    if a[i] is 3 and y[i]>h_l:   
        h_l = y[i]               
    if a[i] is 4 and y[i]<h_u:   
        h_u = y[i]               
                                 
ans = (w_r - w_l)*(h_u - h_l)    
if ans < 0:                      
    ans = 0                      
print(ans)

Submission status: Wrong Answer

Solution code:
w, h, n = input().split()        
w, h, n = int(w), int(h), int(n) 
x = []                           
y = []                           
a = []                           
                                 
for _ in range(n):               
    x_, y_, a_ = input().split() 
    x.append(int(x_))            
    y.append(int(y_))            
    a.append(int(a_))            
W = w                            
H = h                            
w_r = w                          
w_l = 0                          
h_u = h                          
h_l = 0                          
for i in range(n):               
    if a[i] is 1 and x[i]>w_l:   
        w_l = x[i]               
    if a[i] is 2 and x[i]<w_r:   
        w_r = x[i]               
    if a[i] is 3 and y[i]>h_l:   
        h_l = y[i]               
    if a[i] is 4 and y[i]<h_l:   
        h_u = y[i]               
                                 
ans = (w_r - w_l)*(h_u - h_l)    
if ans < 0:                      
    ans = 0                      
print(ans)

Submission status: Wrong Answer

Solution code:
w, h, n = input().split()        
w, h, n = int(w), int(h), int(n) 
x = []                           
y = []                           
a = []                           
                                 
for _ in range(n):               
    x_, y_, a_ = input().split() 
    x.append(int(x_))            
    y.append(int(y_))            
    a.append(int(a_))            
W = w                            
H = h                            
w_r = w                          
w_l = 0                          
h_u = h                          
h_l = 0                          
for i in range(n):               
    if a[i] is 1:                
        w_l = x[i]               
    if a[i] is 2:                
        w_r = x[i]               
    if a[i] is 3:                
        h_l = y[i]               
    if a[i] is 4:                
        h_u = y[i]               
                                 
ans = (w_r - w_l)*(h_u - h_l)    
if ans < 0:                      
    ans = 0                      
print(ans)

Submission status: Wrong Answer

Solution code:
l = []
for i in range(3):
	l.append( map(int, raw_input().split()) )



W = 0
H = 0
maxa_1 = 0
mina_2 = 0
maxa_3 = 0
mina_4 = 0

count = 0
for line in l:
	if count == 0:
		W = line[0]
		H = line[1]
		S = W * H

		maxa_1 = 0
		mina_2 = W
		maxa_3 = 0
		mina_4 = H

	else:
		if line[2] == 1:
			maxa_1 = max(maxa_1, line[0], 0)
		if line[2] == 2:
			mina_2 = min(mina_2, line[0], W)
		if line[2] == 3:
			maxa_3 = max(maxa_3, line[1], 0)
		if line[2] == 4:
			mina_4 = min(mina_4, line[1], H)

	count += 1

print((mina_2-maxa_1) * (mina_4-maxa_3))

Submission status: Wrong Answer

Solution code:
# encoding: utf-8

w, h, n = map(int,raw_input().split())

def coloring(w ,h ,n):
    point_a = [0, 0]
    point_b = [w, h]

    for i in range(0, n):
        x, y, a = map(int,raw_input().split())
        if a == 1 and point_a[0] < x: point_a[0] = x
        if a == 2 and point_b[0] > x: point_b[0] = x
        if a == 3 and point_a[1] < y: point_a[1] = y
        if a == 4 and point_b[1] > y: point_b[1] = y

        if point_b[0] - point_a[0] <= 0:
            print 0
            return

        if point_b[1] - point_a[1] <= 0:
           print 0
           return

    print (point_b[0] - point_a[0]) * (point_b[0] - point_a[0])

coloring(w, h, n)

Submission status: Wrong Answer

Solution code:
# encoding: utf-8

w, h, n = map(int,raw_input().split())

def coloring(w ,h ,n):
    point_a = [0, 0]
    point_b = [w, h]

    for i in range(0, n):
        x, y, a = map(int,raw_input().split())
        if a == 1 and point_a[0] < x: point_a[0] = x
        if a == 2 and point_b[0] > x: point_b[0] = x
        if a == 3 and point_a[1] < y: point_a[1] = y
        if a == 4 and point_b[1] > y: point_b[1] = y

        if point_a[0] and point_b[0]:
            if point_b[0] - point_a[0] <= 0:
                print 0
                return

        if point_a[1] and point_b[1]:
            if point_b[1] - point_a[1] <= 0:
                print 0
                return

    print (point_b[0] - point_a[0]) * (point_b[0] - point_a[0])

coloring(w, h, n)

Submission status: Wrong Answer

Solution code:
# encoding: utf-8

w, h, n = map(int,raw_input().split())

def coloring(w ,h ,n):
    m_lx = 0
    m_rx = 0
    m_ly = 0
    m_uy = 0
    w2 = w
    h2 = h
    for i in range(0, n):
        x, y, a = map(int,raw_input().split())
        if a == 1 and m_lx < x: m_lx = x
        if a == 2 and m_rx < x: m_rx = x
        if a == 3 and m_ly < y: m_ly = y
        if a == 4 and m_ly < y: m_uy = y

    if m_lx != 0 and m_rx != 0:
        print m_lx - m_rx
        if m_rx - m_lx <= 0:
            print 0
            return
    if m_uy != 0 and m_ly != 0:
        if m_uy - m_ly <= 0:
            print 0
            return

    if m_lx: w = w - m_lx
    if m_rx: w = w - (w2 - m_rx)
    if m_ly: h = h - m_ly
    if m_uy: h = h - (h2 - m_uy)
    print w * h

coloring(w, h, n)

Submission status: Wrong Answer

Solution code:
def main():
    W,H,N = map(int , raw_input().split())
    white = {"l_bottom":[0,0],"r_top":[W,H]}
    
    areaZero = False
    
    for i in xrange(N):
        x,y,a = map(int,raw_input().split())
        if a == 1:
            if x > white['r_top'][0]:
                areaZero = True 
                continue
            if x > white['l_bottom'][0]:
                white['l_bottom'][0] = x
                continue
        if a == 2:
            if x <  white['l_bottom'][0]:
                areaZero = True 
                continue
            if x < white['r_top'][0]:
                white['r_top'][0] = x
                continue
        if a ==3 :
            if y > white['r_top'][1]:
                areaZero = True 
                continue
            if y > white['l_bottom'][1]:
                white['l_bottom'][1] = y
                continue
        if a == 4 :
            if y < white['l_bottom'][1]:
                areaZero = True 
                continue
            if y < white['r_top'][1]:
                white['r_top'][1] = y
                continue
    if areaZero == True:
        print 0
    else:
        print (white['r_top'][0]  - white['l_bottom'][0]) * (white['r_top'][1]  - white['l_bottom'][1])

Submission status: Wrong Answer

Solution code:
x1 = 0
y1 = 0
x2, y2, n = list(map(int, input().split()))
for i in range(n):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        x1 = x
    elif a == 2:
        x2 = x
    elif a == 3:
        y1 = y
    elif a == 4:
        y2 = y



w = x2 - x1
h = y2 - y1
if 0 < w and 0 < h:
    S = (x2 - x1) * (y2 - y1)
else:
    S = 0
if 0 < S:
    print(S)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
w, h, n = map(int, raw_input().split())

twl = 0
twr = w
thu = h
thd = 0

for i in range(n):
	x, y, a = map(int, raw_input().split())
	if(a == 1):
		twl = max(twl, x)
	elif(a == 2):
		twr = min(twr, x)
	elif(a == 3):
		thd = max(thd, y)
	elif(a == 4):
		thu = min(thu, y)

ans = (twr-twl)*(thu-thd)
if(ans <= 0):
	print 0
else:
	print ans

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    w, h, n = [int(x) for x in input().split()]
    dots = []
    x_start = 0
    y_start = 0
    x_finish = w
    y_finish = h
    zero_flag = False
    for _ in range(n):
        dots.append([int(x) for x in input().split()])
    for dot in dots:
        if dot[2] == 1:
            x_start = dot[0]
        if dot[2] == 2:
            x_finish = dot[0]
        if dot[2] == 3:
            y_start = dot[1]
        if dot[2] == 4:
            y_finish = dot[1]
        if x_finish <= x_start or y_finish <= y_start:
            zero_flag = True
            break

    if zero_flag:
        ans = 0
    else:
        ans = (x_finish - x_start) * (y_finish - y_start)
    print(ans)

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())

left = 0
right = W
top = 0
bottom = H

for _ in range(N):
    xi, yi, ai = map(int, input().split())
    if ai == 1:
        left = max(left, xi)
    elif ai == 2:
        right = min(right, xi)
    elif ai == 3:
        top = max(top, yi)
    elif ai == 4:
        bottom = min(bottom, yi)

ans = (bottom - top) * (right - left)
print(ans)

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
menseki = W*H
left_x = 0
right_x = W
top_y = H
bottom_y = 0
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        left_x = x
    elif a == 2:
        right_x = x
    elif a == 3:
        bottom_y = y
    else:
        top_y = y
ans = (right_x - left_x) * (top_y - bottom_y)
if right_x <= left_x or top_y <= bottom_y:
    ans = 0
print(int(ans))

Submission status: Wrong Answer

Solution code:
x1 = 0
y1 = 0
x2, y2, n = list(map(int, input().split()))
for i in range(n):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        x1 = x
    elif a == 2:
        x2 = x
    elif a == 3:
        y1 = y
    elif a == 4:
        y2 = y


S = (x2 - x1) * (y2 - y1)
if 0 < S:
    print(S)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
menseki = W*H
left_x = 0
right_x = W
top_y = H
bottom_y = 0
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        left_x = x
    elif a == 2:
        right_x = x
    elif a == 3:
        bottom_y = y
    else:
        top_y = y
ans = (right_x - left_x) * (top_y - bottom_y)
if right_x <= left_x or top_y <= bottom_y:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    w, h, n = [int(x) for x in input().split()]
    dots = []
    x_start = 0
    y_start = 0
    x_finish = w
    y_finish = h
    zero_flag = False
    for _ in range(n):
        dots.append([int(x) for x in input().split()])
    for dot in dots:
        if dot[2] == 1:
            x_start = dot[0]
        if dot[2] == 2:
            x_finish = dot[0]
        if dot[2] == 3:
            y_start = dot[1]
        if dot[2] == 4:
            y_finish = dot[1]
        if x_finish <= x_start or y_finish <= y_start:
            zero_flag = True
            break

    if zero_flag:
        ans = 0
    else:
        ans = abs(x_finish - x_start) * abs(y_finish - y_start)
    print(ans)

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
menseki = W*H
left_x = 0
right_x = W
top_y = H
bottom_y = 0
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        left_x = x
    elif a == 2:
        #delete = (W-x)*H
        right_x = x
    elif a == 3:
        bottom_y = y
        #delete = (H-y)*W - (H-x)*
    else:
        top_y = y
        #delete = y*W
    
ans = (right_x - left_x) * (top_y - bottom_y)
if ans < 0:
    print(0)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
W, H, N = list(map(int, input().split()))

min_x = 0
min_y = 0
max_x = W
max_y = H

for i in range(N):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        min_x = max(min_x, min(max_x, x))
    if a == 2:
        min_y = max(min_y, min(max_y, y))
    if a == 3:
        max_x = min(max_x, max(min_x, x))
    if a == 4:
        max_y = min(max_y, max(min_y, y))

print((max_x - min_x) * (max_y - min_y))

Submission status: Wrong Answer

Solution code:

if __name__ == '__main__':
    whn = list(map(int,input().split()))
    
    a = [0, whn[0], 0, whn[1]]
    for n in range(whn[2]):
        t = list(map(int,input().split()))
        if t[2] == 1:
            a[0] = max(a[0], t[0])
        elif t[2] == 2:
            a[1] = min(a[1], t[0])
        elif t[2] == 3:
            a[2] = max(a[2], t[1])
        elif t[2] == 4:
            a[3] = min(a[3], t[1])
    if a[0] < a[1] or a[2] < a[3]:
        print(0)
    else:
        print((a[1]-a[0])*(a[3]-a[2]))

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    whn = list(map(int,input().split()))
    
    a = [0, whn[0], 0, whn[1]]
    for n in range(whn[2]):
        t = list(map(int,input().split()))
        if t[2] == 1:
            a[0] = max(a[0], t[0])
        elif t[2] == 2:
            a[1] = min(a[1], t[0])
        elif t[2] == 3:
            a[2] = max(a[2], t[1])
        elif t[2] == 4:
            a[3] = min(a[3], t[1])
    if a[0] < a[1] or a[2] < a[3]:
        print(0)
    else:
        print((a[0]-a[1])*(a[2]-a[3]))

Submission status: Wrong Answer

Solution code:
import sys
lines = sys.stdin.readlines()
sizes = lines[0].split(" ")
W=int(sizes[0])
H=int(sizes[1])
N=int(sizes[2])
#print (W,H,N)

calW = W
calH = H
maxX = 0
minX = W
maxY = 0
minY = H
for line in lines[1:]:
    inp = []
    for i in line.split(" "):
        inp.append(int(i))
    #print (inp)
    if inp[2]==1 and inp[0]>maxX:
        calW -= inp[0]
        maxX = inp[0]
    elif inp[2]==2 and inp[0]<minX:
        calW -= W-inp[0]
        minX = inp[0]
    elif inp[2]==3 and inp[1]>maxY:
        calH -= inp[1]
        maxY = inp[1]
    elif inp[2]==4 and inp[1]<minY:
        calH -= H-inp[1]
        minY = inp[1]
    #print (calW,calH)

if calW<0 or calH<0:
    print (0)
else:
    print (calW*calH)

Submission status: Wrong Answer

Solution code:
def main():
    W, H, N = map(int, input().split())
    xya = [tuple(map(int, input().split())) for _ in range(N)]
    minx, miny, maxx, maxy = 0, 0, W, H
    for i in range(N):
        if xya[i][2] == 1:
            minx = max(minx, xya[i][0])
        elif xya[i][2] == 2:
            maxx = min(maxx, xya[i][0])
        elif xya[i][2] == 3:
            miny = max(miny, xya[i][1])
        elif xya[i][2] == 4:
            maxy = min(maxy, xya[i][1])
    print(max(0, (maxx - minx) * (maxy - miny)))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
sx, sy = (0, 0)
ex, ey = (W, H)
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        sx = max([sx, x])
    elif a == 2:
        ex = min([ex, x])
    elif a == 3:
        sy = max([sy, y])
    else:
        ey = min([ey, y])
        
result = (ex - sx) * (ey - sy)
if result < 0:
    print(0)
else:
    print(result)

Submission status: Wrong Answer

Solution code:
sagyou = []
W,H,N = map(int,input().split(' '))
for i in range(0,N):
    sagyou.append(list(map(int,input().split(' '))))
area = [[0,W],[0,H]]
for i in range(0,N):
    if sagyou[i][2] == 1:
        area[0][0] = sagyou[i][0]
    elif sagyou[i][2] == 2:
        area[0][1] = sagyou[i][0]
    elif sagyou[i][2] == 3:
        area[1][0] = sagyou[i][1]
    elif sagyou[i][2] == 4:
        area[1][1] = sagyou[i][1]
    if (area[0][1]-area[0][0])*(area[1][1]-area[1][0]) <= 0:
        print(0)
        break
    if i == N-1 and (area[0][1]-area[0][0])*(area[1][1]-area[1][0]) >= 0:
        print((area[0][1]-area[0][0])*(area[1][1]-area[1][0]))

Submission status: Wrong Answer

Solution code:
list = input().split()
w = int(list[0])
h = int(list[1])
n = int(list[2])
list2 = []
i = 0
while i < n:
   list2.append(input().split())
   i += 1

i = 0
a = int(0)
b = int(w)
c = int(0)
d = int(h)
while i < n:
    list3 = list2[i]
    if int(list3[2]) == 1:
        a = max(a,int(list3[0]))
    elif int(list3[2]) == 2:
        b = min(b,int(list3[0]))
    elif int(list3[2]) == 3:
        c = max(c,int(list3[1]))
    else:
        d = min(d,int(list3[1]))
    i += 1
print (max(0, (b-a)*(d-c)))

Submission status: Wrong Answer

Solution code:
sagyou = []
W,H,N = map(int,input().split(' '))
for i in range(0,N):
    sagyou.append(list(map(int,input().split(' '))))
area = [[0,W],[0,H]]
for i in range(0,N):
    if sagyou[i][2] == 1:
        area[0][0] = sagyou[i][0]
    elif sagyou[i][2] == 2:
        area[0][1] = sagyou[i][0]
    elif sagyou[i][2] == 3:
        area[1][0] = sagyou[i][1]
    elif sagyou[i][2] == 4:
        area[1][1] = sagyou[i][1]
    if (area[0][1]-area[0][0])*(area[1][1]-area[1][0]) <= 0:
        print(0)
        break
    if i == N-1:
        print((area[0][1]-area[0][0])*(area[1][1]-area[1][0]))

Submission status: Wrong Answer

Solution code:
W, H, N =  map(int, raw_input().split())
result = [0, W, 0, H]
for n in range(N):
    x, y, a =  map(int, raw_input().split())
    if a == 1:
        result[0] = max(result[0], x)
    if a == 2:
        result[1] = min(result[1], x)
    if a == 3:
	result[2] = max(result[2], y)
    if a == 4:
	result[3] = min(result[3], y)

print int((result[1]-result[0])*(result[3]-result[2]))

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
x0, y0 = 0, 0
x1, y1 = W, H
for _ in range(N):
    x, y, a = map(int, input().split())
    if a == 1 and x > x0:
        x0 = x
    elif a == 2 and x < x1:
        x1 = x
    elif a == 3 and y > y0:
        y0 = y
    elif a == 4 and y < y1:
        y1 = y
area = (x1 - x0) * (y1 - y0)
if area > 0:
    print(area)
else:
    print(0)

Submission status: Wrong Answer

Solution code:

if __name__ == '__main__':
    whn = list(map(int,input().split()))
    
    a = [0, whn[0], 0, whn[1]]
    for n in range(whn[2]):
        t = list(map(int,input().split()))
        if t[2] == 1:
            a[0] = max(a[0], t[0])
        elif t[2] == 2:
            a[1] = min(a[1], t[0])
        elif t[2] == 3:
            a[2] = max(a[2], t[1])
        elif t[2] == 4:
            a[3] = min(a[3], t[1])
    print(abs((a[0]-a[1])*(a[2]-a[3])))

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    whn = list(map(int,input().split()))
    
    a = [0, whn[0], 0, whn[1]]
    for n in range(whn[2]):
        t = list(map(int,input().split()))
        if t[2] == 1:
            a[0] = max(a[0], t[0])
        elif t[2] == 2:
            a[1] = min(a[1], t[0])
        elif t[2] == 3:
            a[2] = max(a[2], t[1])
        elif t[2] == 4:
            a[3] = min(a[3], t[1])
    print((a[0]-a[1])*(a[2]-a[3]))

Submission status: Wrong Answer

Solution code:
# coding: utf-8

W, H, N = map(int, raw_input().split())
w = [0, W]
h = [0, H]

for i in xrange(N):
    x, y, a = map(int, raw_input().split())
    if a == 1:
        w[0] = x
    elif a == 2:
        w[1] = x
    elif a == 3:
        h[0] = y
    elif a == 4:
        h[1] = y

print max(w[1] - w[0], 0) * max(h[1] - h[0], 0)

Submission status: Time Limit Exceeded

Solution code:
w,h,n = map(int,input().split())
gra = [[1 for i in range(w)] for i in range(h)]
for i in range(n):
    x,y,a = map(int,input().split())
    for j in range(n):
        if a == 1:
            for k in range(h):
                for l in range(x):
                    gra[k][l] = 0
        elif a == 2:
            for k in range(h):
                for l in range(x,w):
                    gra[k][l] = 0
        elif a == 3:
            for k in range(y):
                for l in range(w):
                    gra[k][l] = 0
        else:
            for k in range(y,h):
                for l in range(w):
                    gra[k][l] = 0
print(sum(map(sum, gra)))

Submission status: Time Limit Exceeded

Solution code:
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

W, H, N = map(int, input().split())
X = []
for k in range(N):
  x,y,a = map(int, input().split())
  if a == 1:
    for z in range(1,x+1):
      for j in range(1,H+1):
        X.append([z,j])
        X = get_unique_list(X)
  elif a == 2:
    for z in range(x+1,W+1):
      for j in range(1,H+1):
        X.append([z,j])
        X = get_unique_list(X)
  elif a == 3:
    for z in range(1,y+1):
      for i in range(1,W+1):
        X.append([i,z])
        X = get_unique_list(X)
  else:
    for z in range(y+1,H+1):
      for i in range(1,W+1):
        X.append([i,z])
        X = get_unique_list(X)
print(W*H - len(get_unique_list(X)))

Submission status: Time Limit Exceeded

Solution code:
W, H, N = map(int, input().split())
X = []
for k in range(N):
  x,y,a = map(int, input().split())
  if a == 1:
    for z in range(1,x+1):
      for j in range(1,H+1):
        X.append([z,j])
  elif a == 2:
    for z in range(x+1,W+1):
      for j in range(1,H+1):
        X.append([z,j])
  elif a == 3:
    for z in range(1,y+1):
      for i in range(1,W+1):
        X.append([i,z])
  else:
    for z in range(y+1,H+1):
      for i in range(1,W+1):
        X.append([i,z])
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]
print(W*H - len(get_unique_list(X)))

Submission status: Time Limit Exceeded

Solution code:
W, H, N = map(int, input().split())
X = []
for k in range(N):
  x,y,a = map(int, input().split())
  if a == 1:
    for z in range(1,x+1):
      for j in range(1,H+1):
        if [z,j] not in X:
          X.append([z,j])
  elif a == 2:
    for z in range(x+1,W+1):
      for j in range(1,H+1):
        if [z,j] not in X:
          X.append([z,j])
  elif a == 3:
    for z in range(1,y+1):
      for i in range(1,W+1):
        if [i,z] not in X:
          X.append([i,z])
  else:
    for z in range(y+1,H+1):
      for i in range(1,W+1):
        if [i,z] not in X:
          X.append([i,z])
print(W*H - len(X))

Submission status: Accepted

Solution code:
from collections import deque,defaultdict,Counter
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from bisect import bisect_left,bisect_right
from math import sqrt,gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode
import sys
sys.setrecursionlimit(10 ** 6)

INF = float('inf')
mod = 10**9 + 7

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse=False):
    data.sort(key=lambda x:x[col],reverse=revese)
    return data

def mymax(data):
    M = -1*float('inf')
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float('inf')
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def mydictvaluesort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[1] )

def mydictkeysort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[0] )

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(' ')
        elif type(ls[0])==str:
            print(' '.join(ls))
        elif type(ls[0])==int:
            print(' '.join(map(str,ls)))
        else:
            print('Output Error')
    else:
        if len(ls)==0:
            print('')
        elif type(ls[0])==str:
            print(''.join(ls))
        elif type(ls[0])==int:
            print(''.join(map(str,ls)))
        else:
            print('Output Error')

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())


w,h,n = MI()
xya = LI(n)

xs,xe = 0,w
ys,ye = 0,h

for i in xya:
    x,y,a = i
    if a==1:
        xs = max(xs,x)
    elif a==2:
        xe = min(xe,x)
    elif a==3:
        ys = max(ys,y)
    elif a==4:
        ye = min(ye,y)


if xe<=xs or ye<=ys:
    print(0)
else:
    s = abs(xe-xs)*abs(ye-ys)
    print(s)

Submission status: Accepted

Solution code:
w, h, n = map(int, input().split())
x1 = [0]
x2 = [w]
y1 = [0]
y2 = [h]

for i in range(n):
  x, y, a = map(int, input().split())
  if a == 1:
    x1.append(x)
  elif a == 2:
    x2.append(x)
  elif a == 3:
    y1.append(y)
  elif a == 4:
    y2.append(y)

left = max(x1)
right = min(x2)
bottom = max(y1)
top = min(y2)

ans =max(0, right - left)*max(0, top - bottom)
print(ans)

Submission status: Accepted

Solution code:
w,h,n = map(int, input().split())
x1 = [0] #1 left border of white area
x2 = [w] #2
y1 = [0] #3
y2 = [h] #4
for i in range(n):
  x,y,a = map (int, input().split())
  if a == 1:
    x1.append(x)
  elif a == 2:
    x2.append(x)
  elif a == 3:
    y1.append(y)
  elif a ==4:
    y2.append(y)

left = max(x1)
right = min(x2)
bottom = max(y1)
top = min(y2)


ans =max(0, right - left)*max(0, top - bottom)

print(ans)

Submission status: Accepted

Solution code:
w,h,ｎ = map(int, input().split())
ans = [[0]*(w) for i in range(h)]
for i in range(n):
  x,y,a = map(int, input().split())
  if a == 1:
    for i in range(x):
      for j in range(h):
        ans[j][i] = 1
  elif a == 2:
    for i in range(x,w):
      for j in range(h):
        ans[j][i] = 1
  elif a == 3:
    for i in range(w):
      for j in range(y):
        ans[j][i] = 1
  elif a == 4:
    for i in range(w):
      for j in range(y,h):
        ans[j][i] = 1

cnt = 0
for i in ans:
  cnt += sum(i)
print(h*w - cnt)

Submission status: Accepted

Solution code:
W, H, N = map(int, input().split())
u = H
d = 0
r = W
l = 0
for _ in range(N):
  x, y, a = map(int, input().split())
  if a == 1:
    l = max(l, x)
  elif a == 2:
    r = min(r, x)
  elif a == 3:
    d = max(d, y)
  else:
    u = min(u, y)
dx = max(0, r - l)
dy = max(0, u - d)
print(dx * dy)

Submission status: Accepted

Solution code:
W,H,N = map(int, input().split())
m = [[0]*W]*H
import numpy as np
arr = np.array(m)

for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        arr[:,:x] = 1
    if a == 2:
        arr[:, x:] = 1
    if a == 3:
        arr[H - y:,:] = 1
    if a == 4:
        arr[:H-y,:] = 1
print(np.count_nonzero(arr == 0))

Submission status: Accepted

Solution code:
w,h,n = map(int,input().split())
A = [tuple(map(int,input().split())) for _ in range(n)]
l = 0
r = w
d = 0
u  =h
for x,y,a in A:
    if a==1:
        l = max(x,l)
    elif a ==2:
        r = min(r,x)
    elif a ==3:
        d = max(y,d)
    else:
        u = min(y,u)
if u-d<0 or r-l<0:
    print(0)
else:
    print((u-d)*(r-l))