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:
W, H, N = map(int, input().split())
zahyo = [list(map(int, input().split())) for i in range(N)]
x_min = y_min = 0
x_max = W
y_max = H
for i in range(N):
    if zahyo[i][2] == 1:
        if x_min < zahyo[i][0]:
            x_min = zahyo[i][0]
    
    elif zahyo[i][2] == 2:
        if zahyo[i][0] < x_max:
            x_max = zahyo[i][0]
            
    elif zahyo[i][2] == 3:
        if y_min < zahyo[i][1]:
            y_min = zahyo[i][1]
            
    elif zahyo[i][2] == 4:
        if zahyo[i][1] < y_max:
            y_max = zahyo[i][1]
    
print((x_max - x_min) * (y_max - y_min))

Submission status: Wrong Answer

Solution code:
W,H,N = map(int, input().split())
a = [0] * N
x = [0] * N
y = [0] * N

xl = 0
xr = W
yt = H
yb = 0

for i in range(N):
    x,y,a = map(int, input().split())
    if a == 1:
        xl = max(x,xl)

    elif a == 2:
        xr = min(x,xr)
    
    elif a == 3:
        yb = max(y,yb)    

    else :
        yt = min(y, yt)

# print(xr)
# print(xl)
# print(yt)
# print(yb)

ans = (xr - xl) * (yt - yb)
if ans <= 0 and (xr - xl < 0 )and (yt - yb < 0):
    ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:
W,H,N = map(int, input().split())
a = [0] * N
x = [0] * N
y = [0] * N

xl = 0
xr = W
yt = H
yb = 0

for i in range(N):
    x,y,a = map(int, input().split())
    if a == 1:
        xl = max(x,xl)

    elif a == 2:
        xr = min(x,xr)
    
    elif a == 3:
        yb = max(y,yb)    

    else :
        yt = min(y, yt)

# print(xr)
# print(xl)
# print(yt)
# print(yb)

ans = (xr - xl) * (yt - yb)
if ans <= 0 and xr - xl > 0 and yt - yb:
    ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:
W,H,N = map(int, input().split())
a = [0] * N
x = [0] * N
y = [0] * N

xl = 0
xr = W
yt = H
yb = 0

for i in range(N):
    x,y,a = map(int, input().split())
    if a == 1:
        xl = max(x,xl)

    elif a == 2:
        xr = min(x,xr)
    
    elif a == 3:
        yb = max(y,yb)    

    else :
        yt = min(y, yt)

# print(xr)
# print(xl)
# print(yt)
# print(yb)
ans = (xr - xl) * (yt - yb)
if ans <= 0 :
    ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:
W,H,N = map(int, input().split())
a = [0] * N
x = [0] * N
y = [0] * N

xl = 0
xr = W
yt = H
yb = 0

for i in range(N):
    x,y,a = map(int, input().split())
    if a == 1:
        xl = max(x,xl)

    elif a == 2:
        xr = min(x,xr)
    
    elif a == 3:
        yb = max(y,yb)    

    else :
        yt = min(y, yt)

print(xr)
print(xl)
print(yt)
print(yb)
ans = (xr - xl) * (yt - yb)
if ans < 0 :
    ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:
W,H,N=map(int,input().split())
rec=[[0,0],[W,H]]

for i in range(N):
    x,y,a=map(int,input().split())
    if a==1:
        rec[0][0]=max(rec[0][0],x)
    elif a==2:
        rec[1][0]=min(rec[1][0],x)
    elif a==3:
        rec[0][1]=max(rec[0][1],y)
    elif a==4:
        rec[1][1]=min(rec[1][1],y)
        
ans=(rec[1][0]-rec[0][0])*(rec[1][1]-rec[0][1])
print(ans if ans>=0 else 0)

Submission status: Wrong Answer

Solution code:
w, h, n = map(int, input().split())
nums_list=[list(map(int, input().split())) for i in range(n)]
minX = 0
maxX = w
minY = 0
maxY = h
for nums in nums_list:
	x, y, a = map(int, nums)
	if a == 1:
		minX = minX if (minX > x) else x
	elif a == 2:
		maxX = maxX if (maxX < x) else x
	elif a == 3:
		minY = minY if (minY > y) else y
	elif a == 4:
		maxY = maxY if (maxY < y) else y
v = (maxX-minX)*(maxY-minY)
print(v if (v > 0) else 0)

Submission status: Wrong Answer

Solution code:
w,h,n = map(int,input().split())
Mx = w ; My = h
mx = 0 ; my = 0

for i in range(n):
    x,y,a = map(int,input().split())
    
    if a == 1:
        mx = max(mx,x)
    elif a == 2:
        Mx = min(Mx,x)
    elif a == 3:
        my = max(my,y)
    else:
        My = min(My,y)
        
s = (Mx - mx)*(My - my)
print(s if s >= 0 else 0)

Submission status: Wrong Answer

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

xr = w
xl = 0
yu = h
yl = 0

for i in range(n):
    if T[i][2] == 2:
        xr = min(xr, T[i][0])
    elif T[i][2] == 1:
        xl = max(xl, T[i][0])
    elif T[i][2] == 4:
        yu = min(yu, T[i][1])
    else:
        yl = max(yl, T[i][1])

print(max((xr - xl) * (yu - yl), 0))

Submission status: Wrong Answer

Solution code:
w, h, n = map(int, input().split())
xya = []

left = 0
right = w
under = 0
upper = h

for _ in range(n):
    x, y, a = map(int, input().split())

    if a==1:
        left = max(x, left)
    elif a==2:
        right = min(x, right)
    elif a==3:
        under = max(y, under)
    else:
        upper = min(y, upper)

ans = (upper-under)*(right-left)
print(max(ans, 0))

Submission status: Wrong Answer

Solution code:
w, h, n = map(int, input().split())
xya = []

left = 0
right = w
under = 0
upper = h

for _ in range(n):
    x, y, a = map(int, input().split())

    if a==1:
        left = x
    elif a==2:
        right = x
    elif a==3:
        under = y
    else:
        upper = y

ans = (upper-under)*(right-left)
print(max(ans, 0))

Submission status: Wrong Answer

Solution code:
#abc047 b
w,h,n=map(int,input().split())
zahyo=[]
a=[]
for i in range(n):
    x,y,z=map(int,input().split())
    zahyo.append([x,y])
    a.append(z)
l=[0,0]
r=[w,h]

def white(i):
    if a[i]==1:
        l[0]=zahyo[i][0]
    elif a[i]==2:
        r[0]=zahyo[i][0]
    elif a[i]==3:
        l[1]=zahyo[i][1]
    else:
        r[1]=zahyo[i][1]

for i in range(n):
    white(i)

yoko=r[0]-l[0]
tate=r[1]-l[1]
ans=0
if yoko>=0 and tate>=0:# マイナスxマイナスを含めない
    ans=yoko*tate
print(ans)

Submission status: Wrong Answer

Solution code:
#abc047 b
w,h,n=map(int,input().split())
zahyo=[]
a=[]
for i in range(n):
    x,y,z=map(int,input().split())
    zahyo.append([x,y])
    a.append(z)
l=[0,0]
r=[w,h]

def white(i):
    if a[i]==1:
        l[0]=zahyo[i][0]
    elif a[i]==2:
        r[0]=zahyo[i][0]
    elif a[i]==3:
        l[1]=zahyo[i][1]
    else:
        r[1]=zahyo[i][1]

for i in range(n):
    white(i)
ans=(r[0]-l[0])*(r[1]-l[1])
ans=max(ans,0)
print(ans)

Submission status: Wrong Answer

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

c1 = [0, 0] # corner 1
c2 = [W, H] # corner 2

while(N):
    x, y, a = map(int, input().split())
    if a == 1:
        if c1[0] < x:
            c1[0] = x
    elif a == 2:
        if c2[0] > x:
            c2[0] = x
    elif a == 3:
        if c1[1] < y:
            c1[1] = y
    else:
        if c2[1] > y:
            c2[1] = y
            
    N = N - 1

S = (c2[0] - c1[0]) * (c2[1] - c1[1])
print(S)

Submission status: Wrong Answer

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

stage = ['1' * w] * h
p = [list(map(int, input().split())) for i in range(n)]

for i, hh in enumerate(p):
    ans = []
    x = hh[0]
    y = hh[1]
    f = hh[2]
    if f == 1:
        for s in stage:
            ans.append('0' * x + s[x:])
    elif f == 2:
        for s in stage:
            ans.append(s[:x] + '0' * (w - x))
    elif f == 3:
        for j, hs in enumerate(stage):
            if j <= y:
                ans.append('0' * w)
            else:
                ans.append(stage[j])
        ans = list(reversed(ans))
    elif f == 4:
        for j, hs in enumerate(stage):
            if j <= y - 1:
                ans.append(stage[j])
            else:
                ans.append('0' * w)
        ans = list(reversed(ans))
    stage = ans

sm = 0
for i in stage:
    sm = sm + i.count('1')

print(sm)

Submission status: Wrong Answer

Solution code:
w, h, n = map(int, input().split())
u, d = 0, h
l, r = 0, w

for _ in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        l = max(l, x)
    if a == 2:
        r = min(r, x)
    if a == 3:
        u = max(u, y)
    if a == 4:
        d = min(d, y)
print(u, d, l, r)
print(max(0, (d-u)) * max(0, (r-l)))

Submission status: Wrong Answer

Solution code:
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    W,H,N=map(int,input().split())
    x, y,a = [0] * N, [0] * N,[0]*N
    for i in range(N):
        x[i], y[i],a[i] = map(int, input().split())


    w,h=0,0
    for i in range(N):
        if a[i]==1:
            w=max(w,x[i])
        elif a[i]==2:
            W=min(W,x[i])
        elif a[i]==3:
            h = max(h, y[i])
        elif a[i] == 4:
            H = min(H, y[i])

    print((W-w)*(H-h) if (W-w)*(H-h)>=0 else 0)




resolve()

Submission status: Wrong Answer

Solution code:
W,H,N=map(int,input().split())
w=[0]*2
h=[0]*2
w[1]=W
h[1]=H
for _ in range(N):
    x,y,a,=map(int,input().split())
    if a==1:
        if w[0]<=x:
            w[0]=x
    if a==2:
        if w[1]>=x:
            w[1]=x
    if a==3:
        if h[0]<=y:
            h[0]=y
    if a==4:
        if h[1]>=y:
            h[1]=y
S=(w[1]-w[0])*(h[1]-h[0])
print(max(S,0))

Submission status: Wrong Answer

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

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

lst1 = [0,w,0,h] #←x,x→,y↓,y↑
for i in range(n):
    x,y,a = map(int,readline().split())
    if a==1 or a==3: #max
        if a==1: #x
            lst1[a-1] = max(lst1[a-1],x)
        else: #y
            lst1[a-1] = max(lst1[a-1],y)
    
    else:
        if a==2: #x
            lst1[a-1] = min(lst1[a-1],x)
        else: #y
            lst1[a-1] = min(lst1[a-1],y)

print(w*h
    - lst1[0]*h
    - (w-lst1[1])*h
    - lst1[2]*w
    - (h-lst1[3])*w
    + lst1[0]*lst1[2]
    + lst1[0]*(h-lst1[3])
    + (w-lst1[1])*lst1[2]
    + (w-lst1[1])*(h-lst1[3]))

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
plot_infos = [list(map(int, input().split())) for _ in range(N)]

def calcArea(M, H, N, plot_infos):
  pointA = [M, H]
  pointB = [0, 0]
  for i in range(N):
    plot_info = plot_infos[i]
    if plot_info[2] == 1:
      pointB[0] = plot_info[0]
    elif plot_info[2] == 2:
      pointA[0] = plot_info[0]
    elif plot_info[2] == 3:
      pointB[1] = plot_info[1]
    elif plot_info[2] == 4:
      pointA[1] = plot_info[1]
      
  if pointA[0] < pointB[0] or pointA[1] < pointB[1]:
      return 0
      
  return (pointA[0] - pointB[0]) * (pointA[1] - pointB[1])

print(calcArea(W, H, N, plot_infos))

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
xmin, xmax = 0, W
ymin, ymax = 0, H
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        xmin = max(xmin, x)
    elif a == 2:
        xmax = min(xmax, x)
    elif a == 3:
        ymin = max(ymin, y)
    else:
        ymax = min(ymax, y)

print(xmin, xmax, ymin, ymax)

if xmin >= xmax or ymin >= ymax:
    print(0)
else:
    print((xmax-xmin) * (ymax-ymin))

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
xmin, xmax = 0, W
ymin, ymax = 0, H
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        xmin = min(xmin, x)
    elif a == 2:
        xmax = max(xmax, x)
    elif a == 3:
        ymin = min(ymin, y)
    else:
        ymax = max(ymax, y)

if xmin >= xmax or ymin >= ymax:
    print(0)
else:
    print((xmax-xmin) * (ymax-ymin))

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
xmin, xmax = 0, W
ymin, ymax = 0, H
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        xmin = min(xmin, x)
    elif a == 2:
        xmax = max(xmax, x)
    elif a == 3:
        ymin = min(ymin, y)
    else:
        ymax = max(ymax, y)
print((xmax-xmin) * (ymax-ymin))

Submission status: Wrong Answer

Solution code:
W,H,N = map(int,input().split())
grid = []
for i in range(N):
	array = list(map(int,input().split()))
	grid.append(array)
x1 = 0
xW = W
y1 = 0
yH = H
for i in grid:
	if i[2] == 1 and x1 < i[0]:
		x1 = i[0]
	elif i[2] == 2 and xW > i[0]:
		xW = i[0]
	elif i[2] == 3 and y1 < i[1]:
		y1 == i[1]
	elif i[2] == 4 and yH > i[1]:
		yH == i[1]
print(max(0,xW-x1)*max(0,yH-y1))

Submission status: Wrong Answer

Solution code:
W,H,N = map(int,input().split())
grid = []
for i in range(N):
	array = list(map(int,input().split()))
	grid.append(array)
x1 = 0
xW = W
y1 = 0
yH = H
for i in grid:
	if i[2] == 1 and x1 < i[0]:
		x1 = i[0]
	elif i[2] == 2 and xW > i[0]:
		xH = i[0]
	elif i[2] == 3 and y1 < i[1]:
		y1 == i[1]
	elif i[2] == 4 and yH > i[1]:
		yH == i[1]
	else:
		continue
print(max(0,xW-x1)*max(0,yH-y1))

Submission status: Wrong Answer

Solution code:
w, h, n = map(int, input().split())
l = 0
r = w
u = h
d = 0
for i 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)
print(max(0, (r - l) * (u - d)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
w,h,n=map(int,input().split())
a=[[int(i) for i in input().split()] for i in range(n)]

x,y=0,0
for s,t,u in a:
    if u==1:
        x=max(x,s)
    elif u==2:
        w=min(w,s)
    elif u==3:
        y=max(y,t)
    else:
        h=min(h,t)
ans=max(0,(h-y)*(w-x))
print(ans)

Submission status: Wrong Answer

Solution code:
w,h,n=map(int,input().split())
min_x,max_x=0,w
min_y,max_y=0,h
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        min_x=max(min_x,x)
    elif a==2:
        max_x=min(max_x,x)
    elif a==3:
        min_y=max(min_y,y)
    elif a==4:
        max_y=min(max_y,y)
ans=(max_x-min_x)*(max_y-min_y)
print(max(ans,0))

Submission status: Wrong Answer

Solution code:
#B - すぬけ君の塗り絵 2 イージー
W, H,N = map(int, input().split())
a = [input().split() for l in range(N)]
tmpx = W
tmpx1 = 0
tmpx2 = 0
tmpy = H
tmpy1 = 0
tmpy2 = 0
for i in range(N):
    if a[i][2] == "1":
        tmpx1 = int(a[i][0])
    elif a[i][2] == "2" :
        tmpx = int(a[i][0])
    elif a[i][2] == "3" :
        tmpy1 = int(a[i][1])
    elif a[i][2] == "4" :
        tmpy = int(a[i][1])
    else:
        print(0)
        exit()

if tmpx-tmpx1 <= 0 or tmpy - tmpy1 <=0:
    print(0)
else:
    print(abs(tmpx-tmpx1)*abs(tmpy-tmpy1))

Submission status: Wrong Answer

Solution code:
##!/usr/bin/env python3
w,h,n = map(int,input().split())
hl = 0
hu = 100
wl = 0
wu = 100
for i in range(n):
  x,y,a = map(int,input().split())
  if a == 1: hl = max(x,hl)
  if a == 2: hu = min(x,hu)
  if a == 3: wl = max(y,wl)
  if a == 4: wl = min(y,wu)
print(max(0,(hu-hl))*max(0,wu-wl))

Submission status: Wrong Answer

Solution code:
W,H,N = map(int,input().split())
XYA = [tuple(map(int,input().split())) for i in range(N)]

l,r,d,u = 0,W,0,H
for x,y,a in XYA:
    if a==1:
        l = x
    elif a==2:
        r = x
    elif a==3:
        d = y
    else:
        u = y
w = max(0,r-l)
h = max(0,u-d)
print(w*h)

Submission status: Wrong Answer

Solution code:
w, h, n = map(int, input().split())
xu = w
xl = 0
yu = h
yl = 0
for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        xl = x
    elif a == 2:
        xu = x
    elif a == 3:
        yl = y
    else:
        yu = y
print(max(0, (xu-xl))*max(0, (yu-yl)))

Submission status: Wrong Answer

Solution code:
W,H,N=map(int,input().split())
xya=[list(map(int,input().split())) for i in range(N)]
X=[0,W]
Y=[0,H]
for i in range(N):
    if xya[i][2]==1:
        X[0]=xya[i][0]
    if xya[i][2]==2:
        X[1]=xya[i][0]
    if xya[i][2]==3:
        Y[0]=xya[i][1]
    if xya[i][2]==4:
        Y[1]=xya[i][1]
if X[0] >= X[1] or Y[0] >= Y[1]:
    print(0)
else:
    print((X[1]-X[0]) * (Y[1]-Y[0]))

Submission status: Wrong Answer

Solution code:
w,h,n = map(int,input().split())
x0,y0 = 0,0

for i in range(n):
    x,y,a = map(int,input().split())
    if a==1:
        x0=x
    elif a==2:
        w=x
    elif a==3:
        y0=y
    else:
        h=y
print(0 if w-x0<=0 or h-y0<=0 else (w-x0)*(h-y0))

Submission status: Wrong Answer

Solution code:
W,H,N = map(int, input().split())
l = []
for i in range (N):
    x,y,a = map(int,input().split())
    l.append([x,y,a])
t1 = 0
t2 = H
s1 = 0
s2 = W
while (s2 > s1 and t2 > t1):
    for j in range (N):
        if l[j][2] == 1:
            s1 = l[j][0]
        elif l[j][2] == 2:
            s2 = l[j][0]
        elif l[j][2] == 3:
            t1 = l[j][1]
        elif l[j][2] == 4:
            t2 = l[j][1]
S = (s2 - s1)*(t2 - t1)
if (S > 0):
    print(S)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
W,H,N = map(int, input().split())
l = []
for i in range (N):
    x,y,a = map(int,input().split())
    l.append([x,y,a])
t1 = 0
t2 = H
s1 = 0
s2 = W
for j in range (N):
    if l[j][2] == 1:
        s1 = l[j][0]
    elif l[j][2] == 2:
        s2 = l[j][0]
    elif l[j][2] == 3:
        t1 = l[j][1]
    elif l[j][2] == 4:
        t2 = l[j][1]
S = (s2 - s1)*(t2 - t1)
if (s2 > s1 and t2 > t1):
    print(S)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
W,H,N = map(int, input().split())
l = []
for i in range (N):
    x,y,a = map(int,input().split())
    l.append([x,y,a])
tate1 = 0
tate2 = H
yoko1 = 0
yoko2 = W
S = W*H
for j in range (N):
    if l[j][2] == 1:
        yoko1 = l[j][0]
        S = (yoko2 - yoko1)*(tate2 - tate1)
    elif l[j][2] == 2:
        yoko2 = l[j][0]
        S = (yoko2 - yoko1)*(tate2 - tate1)
    elif l[j][2] == 3:
        tate1 = l[j][1]
        S = (yoko2 - yoko1)*(tate2 - tate1)
    elif l[j][2] == 4:
        tate2 = l[j][1]
        S = (yoko2 - yoko1)*(tate2 - tate1)
if S > 0:
    print(S)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
W, H, N = map(int,input().split())
x_raw = []
y_raw = []
a_raw = []
x_o = 0
y_o = 0
for i in range(0, N):
    x, y, a = map(int,input().split())
    x_raw.append(x)
    y_raw.append(y)
    a_raw.append(a)

for i in range(0, N):
    if a_raw[i] == 1:
        if x_o < x_raw[i]:
            x_o = x_raw[i]
    elif a_raw[i] == 2:
        if W > x_raw[i]:
            W = x_raw[i]
    elif a_raw[i] == 3:
        if y_o < y_raw[i]:
            y_o = y_raw[i]
    else:
        if H > y_raw[i]:
            H = y_raw[i]

X = W - x_o
Y = H - y_o
ans = X * Y

if ans <= 0:
    print('0')
else:
    print(str(ans))

Submission status: Wrong Answer

Solution code:
W,H,N=map(int,input().split())
x=[0]*N
y=[0]*N
a=[0]*N
minX=0
maxX=W
minY=0
maxY=H
for i in range(N):
  x[i],y[i],a[i]=map(int,input().split())
  if a[i]==1:
    minX=max(minX,x[i])
  if a[i]==2:
    maxX=min(maxX,x[i]) 
  if a[i]==3:
    minY=max(minY,y[i])
  if a[i]==4:
    maxY=min(maxY,y[i])  
print(max(0,(maxX-minX)*(maxY-minY)))

Submission status: Wrong Answer

Solution code:
import numpy as np

w, h, n = map(int, input().split())
num_list = np.array([[1 for _ in range(w)] for _ in range(h)])

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        num_list[:, :x] = 0
    elif a == 2:
        num_list[:, x-1:] = 0
    elif a == 3:
        num_list[:y-1, :] = 0
    else:
        num_list[y:, :] = 0

print(sum(sum(num_list)))

Submission status: Wrong Answer

Solution code:
W, H, N = [int(i) for i in input().split()]
top, bottom, left, right = H, 0, 0, W
for _ in range(N):
    x, y, a = [int(i) for i in input().split()]
    if a == 1:
        left = x
    elif a == 2:
        right = x
    elif a == 3:
        bottom = y
    elif a == 4:
        top = y
print(max(right - left, 0) * max(top - bottom, 0))

Submission status: Wrong Answer

Solution code:
w, h, n = map(int, input().split())
a = [0, 0]
b = [w, 0]
c = [w, h]
d = [0, h]
for _ in range(n):
    x, y, m = map(int, input().split())
    if m == 1:
        a[0] = x
        d[0] = x
    elif m == 2:
        b[0] = x
        c[0] = x
    elif m == 3:
        a[1] = y
        b[1] = y
    else:
        c[1] = y
        d[1] = y

print(max(0, (b[0]-a[0])*(c[1]-b[1])))

Submission status: Wrong Answer

Solution code:
w,h,n=map(int,input().split())
a1,a2,a3,a4=0,w,0,h
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        a1=max(a1,x)
    elif a==2:
        a2=min(a2,x)
    elif a==3:
        a3=max(a3,y)
    else:
        a4=min(a4,y)
print(max((a2-a1)*(a4-a3),0))

Submission status: Wrong Answer

Solution code:
w, h, n = [int(e) for e in input().split()]
x_under, x_lim, y_under, y_lim = 0, w, 0, h
for _ in range(n):
    x, y, a = [int(e) for e in input().split()]
    if a == 1 and x_under < x:
        x_under = x
    elif a == 2 and x < x_lim:
        x_lim = x
    elif a == 3 and y_under < y:
        y_under = y
    elif a == 4 and y < y_lim:
        y_lim = y
area = (x_lim-x_under)*(y_lim-y_under)
if area < 0:
    print('0')
else:
    print(area)

Submission status: Wrong Answer

Solution code:
def main():
    width, height, point_num = map(int, input().split())
    points = [tuple(map(int, input().split())) for _ in range(point_num)]
    white_range = [[0, 0], [width, height]]
    for point in points:
        if point[2] == 1:
            white_range[0][0] = point[0]
        elif point[2] == 2:
            white_range[1][0] = point[0]
        elif point[2] == 3:
            white_range[0][1] = point[1]
        else:
            white_range[1][1] = point[1]
    if white_range[1][0] < white_range[0][0] or white_range[1][0] < white_range[0][0]:
        print(0)
    else:
        print((white_range[1][0] - white_range[0][0]) * (white_range[1][1] - white_range[0][1]))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    width, height, point_num = map(int, input().split())
    points = [tuple(map(int, input().split())) for _ in range(point_num)]
    white_range = [[0, 0], [width, height]]
    for point in points:
        if point[2] == 1:
            white_range[0][0] = point[0]
        elif point[2] == 2:
            white_range[1][0] = point[0]
        elif point[2] == 3:
            white_range[0][1] = point[1]
        else:
            white_range[1][1] = point[1]
    print(max((white_range[1][0] - white_range[0][0]) * (white_range[1][1] - white_range[0][1]), 0))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def change_value(list, limit, type):
    list[(type + 1) % 2] = limit
    return list


def main():
    width, height, point_num = map(int, input().split())
    points = [tuple(map(int, input().split())) for _ in range(point_num)]
    white_width = [0, width]
    white_height = [0, height]
    for point in points:
        if point[2] <= 2:
            white_width = change_value(white_width, point[0], point[2])
        else:
            white_height = change_value(white_height, point[1], point[2])
    print(max((white_height[1] - white_height[0]) * (white_width[1] - white_width[0]), 0))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
x = [0] * N
y = [0] * N
a = [0] * N
for i in range(N):
    x[i], y[i], a[i] = map(int, input().split())

x_min = 0
x_max = W
y_min = 0
y_max = H
for i in range(len(a)):
    if a[i] == 1:
        if x_min < x[i]:
            x_min = x[i]
    elif a[i] == 2:
        if x_max > x[i]:
            x_max = x[i]
    elif a[i] == 3:
        if y_min < y[i]:
            y_min = y[i]
    else:
        if y_max > y[i]:
            y_max = y[i]
        
x_len = x_max-x_min
y_len = y_max-y_min
if (y_len<0)|(x_len<0):
    result = 0

print(x_len*y_len)

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
x = [0] * N
y = [0] * N
a = [0] * N
for i in range(N):
    x[i], y[i], a[i] = map(int, input().split())
    
total = W*H

x_min = 0
x_max = W
y_min = 0
y_max = H
for i in range(len(a)):
    if a[i] == 1:
        if x_min <= x[i]:
            x_min = x[i]
    elif a[i] == 2:
        if x_max >= x[i]:
            x_max = x[i]
    elif a[i] == 3:
        if y_min <= y[i]:
            y_min = y[i]
    else:
        if y_max >= y[i]:
            y_max = y[i]
        
x_len = x_max-x_min
y_len = y_max-y_min
result = x_len*y_len
if result < 0:
    result = 0
else:
    pass
print(result)

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
x = [0] * N
y = [0] * N
a = [0] * N
for i in range(N):
    x[i], y[i], a[i] = map(int, input().split())
    
total = W*H

x_min = 0
x_max = W
y_min = 0
y_max = H
for i in range(len(a)):
    if a[i] == 1:
        if x_min < x[i]:
            x_min = x[i]
    elif a[i] == 2:
        if x_max > x[i]:
            x_max = x[i]
    elif a[i] == 3:
        if y_min < y[i]:
            y_min = y[i]
    else:
        if y_max > y[i]:
            y_max = y[i]
        
x_len = x_max-x_min
y_len = y_max-y_min
result = x_len*y_len
if result < 0:
    result = 0
else:
    pass
print(result)

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
x = [0] * N
y = [0] * N
a = [0] * N
for i in range(N):
    x[i], y[i], a[i] = map(int, input().split())
    
total = W*H

x_min = 0
x_max = W
y_min = 0
y_max = H
for i in range(len(a)):
    if a[i] == 1:
        if x_min < x[i]:
            x_min = x[i]
    elif a[i] == 2:
        if x_max > x[i]:
            x_max = x[i]
    elif a[i] == 3:
        if y_min < y[i]:
            y_min = y[i]
    else:
        if y_max > y[i]:
            y_max = y[i]
        
x_len = x_max-x_min
y_len = y_max-y_min
result = x_len*y_len
if result < 0:
    result = 0
print(result)

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
x = [0] * N
y = [0] * N
a = [0] * N
for i in range(N):
    x[i], y[i], a[i] = map(int, input().split())
    
total = W*H

x_min = 0
x_max = W
y_min = 0
y_max = H
for i in range(len(a)):
    if a[i] == 1:
        if x_min < x[i]:
            x_min = x[i]
    elif a[i] == 2:
        if x_max > x[i]:
            x_max = x[i]
    elif a[i] == 3:
        if y_min < y[i]:
            y_min = y[i]
    else:
        if y_max > y[i]:
            y_max = y[i]
        
x_len = x_max-x_min
y_len = y_max-y_min

print(x_len*y_len)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

ze = np.ones((W, H))

for i in range(N):
    x, y, a = map(int, input().split())

    if a == 1:
        ze[:x, :] = 0
    elif a == 2:
        ze[x+1:, :] = 0
    elif a == 3:
        ze[:, :y] = 0
    elif a == 4:
        ze[:, y+1:] = 0

print(np.sum(ze))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

ze = np.ones((W + 1, H + 1))

for i in range(N):
    x, y, a = map(int, input().split())

    if a == 1:
        ze[:x, :] = 0
    elif a == 2:
        ze[x:, :] = 0
    elif a == 3:
        ze[:, :y] = 0
    elif a == 4:
        ze[:, y:] = 0

print(np.sum(ze))

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
x = [0] * N
y = [0] * N
a = [0] * N
for i in range(N):
    x[i], y[i], a[i] = map(int, input().split())
    
total = W*H

x_min = 0
x_max = W
y_min = 0
y_max = H
for i in range(len(a)):
    if a[i] == 1:
        x_min = x[i]
    elif a[i] == 2:
        x_max = x[i]
    elif a[i] == 3:
        y_min = y[i]
    else:
        y_max = y[i]
        
x_len = x_max-x_min
y_len = y_max-y_min

print(x_len*y_len)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

ze = np.ones((W + 1, H + 1))

for i in range(N):
    x, y, a = map(int, input().split())

    if a == 1:
        ze[:x, :] = 0
    elif a == 2:
        ze[x + 1:, :] = 0
    elif a == 3:
        ze[:, :y] = 0
    elif a == 4:
        ze[:, y + 1:] = 0

print(int(np.sum(ze)))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

ze = np.ones((W + 1, H + 1))

for i in range(N):
    x, y, a = map(int, input().split())

    if a == 1:
        ze[:x, :] = 0
    elif a == 2:
        ze[x + 1:, :] = 0
    elif a == 3:
        ze[:, :y] = 0
    elif a == 4:
        ze[:, y + 1:] = 0

print(np.sum(ze))

Submission status: Wrong Answer

Solution code:
w, h, n = list(map(int, input().split(' ')))

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

mx = 0
my = 0
xx = w
xy = h
    
for point in points:
    if point[2] == 1 and mx < point[0]:
        mx = point[0]
    elif point[2] == 2 and xx > point[0]:
        xx = point[0]
    elif point[2] == 3 and my < point[1]:
        my = point[1]
    elif point[2] == 4 and xy > point[1]:
        xy = point[1]
        
erea = (xx - mx) * (xy - my)
if erea < 0:
    erea = 0
print(erea)

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
min_H = 0
min_W = 0
max_H = H
max_W = W

for _ in range(N):
    x, y, a = map(int, input().split())

    if a == 1:
        min_W = max(x, min_W)
    elif a == 2:
        max_W = min(x, max_W)
    elif a == 3:
        min_H = max(y, min_H)
    else:
        max_H = min(y, max_W)

if min_W > max_W or min_H > max_H:
    print(0)
else:
    print((max_H - min_H) * (max_W - min_W))