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())
xya = []
for _ in range(n):
    x, y, a = map(int, input().split())
    xya.append((x, y, a))
l = 0
r = w
t = h
b = 0
for x, y, a in xya:
    if a==1:
        l = max(l, x)
    elif a==2:
        r = min(r, x)
    elif a==3:
        b = max(b, y)
    else:
        t = min(t, y)

print(max(0, (r-l)*(t-b)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.buffer.readline
    W, H, N = (int(i) for i in input().split())
    XYA = [[int(i) for i in input().split()] for j in range(N)]
    xle = 0
    xri = W
    ylow = 0
    yupp = H
    for x, y, a in XYA:
        if a == 1:
            xle = x
        elif a == 2:
            xri = x
        elif a == 3:
            ylow = y
        elif a == 4:
            yupp = y
    print(max((xri-xle)*(yupp-ylow), 0))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    w, h, n = map(int, input().split())
    a = [0, 0]
    b = [w, h]
    for _ in range(n):
        x, y, t = map(int, input().split())
        if t == 1:
            a[0] = x
        elif t == 2:
            b[0] = x
        elif t == 3:
            a[1] = y
        else:
            b[1] = y
    print(max(b[0] - a[0], 0) * max(b[1] - a[1], 0))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.readline
W, H, N = map(int, readline().split())
lb = [0, 0]
rt = [W, H]
for _ in range(N):
    x, y, a = map(int, readline().split())
    if a == 1 and lb[0] < x:
        lb[0] = x
    elif a == 2 and rt[0] > x:
        rt[0] = x
    elif a == 3 and lb[1] < y:
        lb[1] = y
    elif a == 4 and rt[1] > y:
        rt[1] = y

print(max((rt[0]-lb[0])*(rt[1]-lb[1]), 0))

Submission status: Wrong Answer

Solution code:
w,h,n=map(int,input().split())
x=[]
y=[]
a=[]
for i in range(n):
    a1,b,c=map(int,input().split())
    x.append(a1)
    y.append(b)
    a.append(c)

w1=0#左の削り
w2=0#右の削り
h1=0#下の削り
h2=0#上の削り
for i in range(n):
    if a[i]==1:
        w1=max(w1,x[i])
    if a[i]==2:
        w2=max(w2,w-x[i])
    if a[i]==3:
        h1=max(h1,y[i])
    if a[i]==4:
        h2=max(h2,h-y[i])
print(max(0,(w-w1-w2)*(h-h1-h2)))

Submission status: Wrong Answer

Solution code:
W,H,N = map(int,input().split())
X0 = 0
X = W
Y0 = 0
Y = H
for _ in range(N):
    x,y,a = map(int,input().split())
    if a == 1:
        X0 = x
    elif a == 2:
        X = x
    elif a == 3:
        Y0 = y
    else: # a == 4
        Y = y

#print (X0,X,Y0,Y)
if X0 >= X or Y0 >= Y:
    print (0)
else:
    print ((X-X0)*(Y-Y0))

Submission status: Wrong Answer

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

XYA = [tuple(map(int, input().split())) for _ in range(N)]

x = (0, W)
y = (0, H)
for xya in XYA:
    a = xya[2]
    if a == 1:
        if x[0] < xya[0]:
            x = (xya[0], x[1])
    elif a == 2:
        if xya[0] < x[1]:
            x = (x[0], xya[0])
    elif a == 3:
        if y[0] < xya[1]:
            y = (xya[1], y[1])
    else:
        if xya[1] < y[1]:
            y = (y[0], xya[1])

res = (x[1] - x[0]) * (y[1] - y[0])
if res < 0:
    res = 0
print(res)

Submission status: Wrong Answer

Solution code:
left = 0 
down = 0
right , up , n =map(int,input().split())
for _ in range(n):
	x,y,a = map(int,input().split())
	if a==1:
		left = x

	elif a==2:
		right = x

	elif a==3:
		down = y

	elif a==4:
		up = y
if right>=left and up>=down:
	h = abs(up)-abs(down)
	w = abs(right)-abs(left)
	print(h*w)
else:
	print(0)

Submission status: Wrong Answer

Solution code:
left = 0 
down = 0
right , up , n =map(int,input().split())
for _ in range(n):
	x,y,a = map(int,input().split())
	if a==1:
		left = x

	elif a==2:
		right = x

	elif a==3:
		down = y

	elif a==4:
		up = y
if ((up-down)*(right-left))>0:
	print(((up-down)*(right-left)))
else:
	print(0)

Submission status: Wrong Answer

Solution code:


w, h, n = map(int,input().split())
x0, y0, x1, y1 = 0, 0, w, h

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        x0 = max(x0, x)
    elif a == 2:
        x1 = min(x1, x)
    elif a == 3:
        y0 = max(y0, y)
    else:
        y1 = min(y1, y)

s = (x1 - x0) * (y1 - y0)
print(s if s > 0 else 0)

Submission status: Wrong Answer

Solution code:
w, h, n = map(int,input().split())
a_1 = 0
a_2 = w
a_3 = 0
a_4 = h
for i in range(n):
    x, y, a = map(int,input().split())
    if a == 1:
        a_1 = max(a_1,x)
    elif a == 2:
        a_2 = min(a_2,x)
    elif a == 3:
        a_3 = max(a_3,y)
    else:
        a_4 = min(a_4,y)

if a_1 < a_2:
    if a_3 < a_4:
        print((a_2-a_1)*(a_4-a_3))

else:
    print(0)

Submission status: Wrong Answer

Solution code:
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())

start, end  = [0, 0], [w, h]

for i in range(n):
    if a[i] == 1 and x[i] > start[0]:
        start[0] = x[i]
    elif a[i] == 2 and x[i] < end[0]:
        end[0] = x[i]
    elif a[i] == 3 and start[1] < y[i]:
        start[1] = y[i]
    elif a[i] == 4 and end[1] > y[i]:
        end[1] = y[i]
    

print(max(0, (end[0] - start[0]) * (end[1] - start[1])))

Submission status: Wrong Answer

Solution code:
#Beginner 047 B
W, H, N = map(int, input().split())

s = [input() for i in range(N)]
S = []
for i in range(N):
    S.append(list(map(int, s[i].split())))

lst = [[1 for i in range(W)] for j in range(H)]
print(lst)

for i in range(N):
    if S[i][2] == 1:
        for j in range(0,S[i][0]):
            for k in range(H):
                lst[k][j] = 0
    if S[i][2] == 2:
        for j in range(S[i][0],W):
            for k in range(H):
                lst[k][j] = 0
    if S[i][2] == 3:
        for j in range(0,S[i][1]):
            for k in range(W):
                lst[j][k] = 0
    if S[i][2] == 4:
        for j in range(S[i][1],H):
            for k in range(W):
                lst[j][k] = 0

print(sum(lst,[]).count(1))

Submission status: Wrong Answer

Solution code:
W,H,N = map(int,input().split())
for i in range(1,N+1):
    xi,yi,ai = map(int,input().split())
    if xi > W or yi > H or ai > 4:
        continue
    if ai == 1:
        S = (W - xi) * H
        W -= xi
    elif ai == 2:
        S = xi * H
        W = xi
    elif ai == 3:
        S = W * (H - yi)
        H -= yi
    else:
        S = W * yi
        H = yi
print(S)

Submission status: Wrong Answer

Solution code:
w,h,n=map(int,input().split())
w0,h0=0,0
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        if w0<x:
            w0=x
    elif a==2:
        if w>x:
            w=x
    elif a==3:
        if h0<y:
            h0=y
    elif a==4:
        if h>y:
            h=y
print((w-w0)*(h-h0) if (w-w0)*(h-h0)>0 else 0 )

Submission status: Wrong Answer

Solution code:
W,H,N = map(int,input().split())
x_max = W
x_min = 0
y_max = H
y_min = 0
for i in range(N):
    x,y,a = map(int,input().split())
    if a == 1 and x>x_min:
        x_min = x
    elif a==2 and x<x_max:
        x_max = x
    elif a==3 and y>y_min:
        y_min = y
    elif a==4 and y<y_max:
        y_max = y
print((x_max-x_min)*(y_max-y_min) if (x_max-x_min)*(y_max-y_min)>=0 else 0)

Submission status: Wrong Answer

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

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

for _ in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        min_x = x
    elif a == 2:
        max_x = x
    elif a == 3:
        min_y = y
    else:
        max_y = y

print((max_x - min_x) * (max_y - min_y) if max_x > min_x and max_y > min_y else 0)

Submission status: Wrong Answer

Solution code:
W,H,N = map(int, input().split())
abc = [list(map(int, input().split())) for _ in range(N)]
w1=0
h1=0
w2=W
h2=H

for i in range(0,N):
    if abc[i][2] ==1:
        w1 = max(w1,abc[i][0])
    elif abc[i][2] ==2:
        w2 = min(w2,abc[i][0])
    elif abc[i][2] ==3:
        h1 = max(h1,abc[i][0])
    elif abc[i][2] ==4:
        h2 = min(h2,abc[i][0])

res = max((w2-w1),0)*max((h2-h1),0)
print(res)

Submission status: Wrong Answer

Solution code:
w, h, n = map(int, input().split())
w1 = 0
w2 = w
h1 = 0
h2 = h
for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        w1 = max(w1, x)
    elif a == 2:
        w2 = min(w2, x)
    elif a == 3:
        h1 = max(h1, y)
    elif a == 4:
        h2 = min(h2, y)
print(max((h2 - h1) * (w2 - w1), 0))

Submission status: Wrong Answer

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

def view(now):
    s = ''
    now = list(reversed(now))
    for i in range(h):
        for j in range(w):
            s += str(now[i][j])
        else:
            s += '\n'
    return s
mapp = [[1]*(w)] * (h)
#print(mapp)
for i in range(n):
    for j in range(xy[i][1]):
        if xy[i][2] == 1:
            mapp[j][:xy[i][0]] = [0]*xy[i][0]

        elif xy[i][2] == 2:
            mapp[j][xy[i][0]:] = [0]*(w-xy[i][0])

        elif xy[i][2] == 3:
            for s in range(xy[i][1]):
                mapp[s] = [0] * w
            break

        elif xy[i][2] == 4:
            for s in range(xy[i][1],h):
                mapp[s] = [0] * w
            break
    #print(view(mapp))
ans = 0
for i in range(h):
    ans += mapp[i].count(1)
print(ans)

Submission status: Wrong Answer

Solution code:
w, h, n = map(int,input().split())
xy = [list(map(int,input().split())) for _ in range(n)]
print(0)

Submission status: Wrong Answer

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

def view(now):
    s = ''
    now = list(reversed(now))
    for i in range(h):
        for j in range(w):
            s += str(now[i][j])
        else:
            s += '\n'
    return s
mapp = [[1]*(w)] * (h)
#print(mapp)
for i in range(n):
    for j in range(xy[i][1]):
        if xy[i][2] == 1:
            mapp[j][:xy[i][0]] = [0]*xy[i][0]
        elif xy[i][2] == 2:
            mapp[j][xy[i][0]:] = [0]*(w-xy[i][0])
        elif xy[i][2] == 3:
            for s in range(xy[i][1]):
                mapp[s] = [0] * w
        elif xy[i][2] == 4:
            for t in range(xy[i][1],h):
                mapp[t] = [0] * w
    #print(view(mapp))
ans = 0
for i in range(h):
    ans += mapp[i].count(1)
print(ans)

Submission status: Wrong Answer

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

def view(now):
    s = ''
    now = list(reversed(now))
    for i in range(h):
        for j in range(w):
            s += str(now[i][j])
        else:
            s += '\n'
    return s
mapp = [[1]*(w)] * (h)
#print(mapp)
for i in range(n):
    for j in range(xy[i][1]):
        #print(xy[i][2])
        if xy[i][2] == 1:
            mapp[j][:xy[i][0]] = [0]*xy[i][0]
            #print('a')
        elif xy[i][2] == 2:
            mapp[j][xy[i][0]:] = [0]*(w-xy[i][0])
            #print('b')
        elif xy[i][2] == 3:
            for s in range(xy[i][1]):
                mapp[s] = [0] * w
            break
            #print('c')
        elif xy[i][2] == 4:
            for t in range(xy[i][1],h):
                mapp[t] = [0] * w
            break
            #print('d')
    #print(view(mapp))
#print(mapp)
ans = 0
for i in range(h):
    ans += mapp[i].count(1)
print(ans)

Submission status: Wrong Answer

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

mapp = [[1]*(w)] * (h)
#print(mapp)
for i in range(n):
    for j in range(xy[i][1]):
        #print(xy[i][2])
        if xy[i][2] == 1:
            mapp[j][:xy[i][0]] = [0]*xy[i][0]
            #print('a')
        elif xy[i][2] == 2:
            mapp[j][xy[i][0]:] = [0]*(w-xy[i][0])
            #print('b')
        elif xy[i][2] == 3:
            for s in range(xy[i][1]):
                mapp[s] = [0] * w
            #print('c')
        elif xy[i][2] == 4:
            for t in range(xy[i][1],h):
                mapp[t] = [0] * w
            #print('d')
#print(mapp)
ans = 0
for i in range(h):
    ans += mapp[i].count(1)
print(ans)

Submission status: Wrong Answer

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

def main():
    w, h, n = map(int, input().split())
    left = 0
    right = w
    top = 0
    bottom = h
    for i in range(n):
        x, y, a = map(int, input().split())
        if a == 1:
            left = x
        elif a == 2:
            right = x
        elif a == 3:
            top = y
        else:
            bottom = y
    res = max(0, right - left) * max(0, bottom - top)
    print(res)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
W,H,N=map(int,input().split())
S=[0]*N; p=0
for i in range(N):
  x,y,a=map(int,input().split())
  S[i]=[x,y,a]
#print("x,y,a",S)
e=101;w=-1;n=101;s=-1
for i in range(N):
  if S[i][2]==1:
    w=max(w,S[i][0])
  elif S[i][2]==2:
    e=min(e,S[i][0])
  elif S[i][2]==3:
    s=max(s,S[i][1])
  elif S[i][2]==4:
    n=min(n,S[i][1])

#print("w,e,s,n",w,e,s,n)
for i in range(1,H+1):
  for j in range(1,W+1):
    if (j<=w and w>0) or (j>=e and e<101) or (i>=n and n<101) or (i<=s and s>0):
      p=p+1

print(W*H-p)

Submission status: Wrong Answer

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

A=[0,w,0,h]
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        A[0]=max(A[0],x)
    elif a==2:
        A[1]=min(A[1],x)
    elif a==3:
        A[2]=max(A[2],y)
    else:
        A[3]=min(A[3],y)

squ=(A[1]-A[0])*(A[3]-A[2])

print(squ if squ>0 else 0)

Submission status: Wrong Answer

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

A=[0,w,0,h]
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        A[0]=max(A[0],x)
    elif a==2:
        A[1]=min(A[1],x)
    elif a==3:
        A[2]=max(A[2],y)
    else:
        A[3]=min(A[3],y)

squ=(A[1]-A[0])*(A[3]-A[2])

print(squ if squ>=0 else 0)

Submission status: Wrong Answer

Solution code:
W,H,N=map(int,input().split())
S=[0]*N; p=0
for i in range(N):
  x,y,a=map(int,input().split())
  S[i]=[x,y,a]
print("x,y,a",S)
e=101;w=-1;n=101;s=-1
for i in range(N):
  if S[i][2]==1:
    w=max(w,S[i][0])
  elif S[i][2]==2:
    e=min(e,S[i][0])
  elif S[i][2]==3:
    s=max(s,S[i][1])
  elif S[i][2]==4:
    n=min(n,S[i][1])

print("w,e,s,n",w,e,s,n)
for i in range(1,H+1):
  for j in range(1,W+1):
    if (j<=w and w>0) or (j>=e and e<101) or (i>=n and n<101) or (i<=s and s>0):
      p=p+1

print(W*H-p)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys

[W, H, N] = list(map(int, stdin.readline().rstrip().split()))


Ws = 0
We = W

Hs = 0
He = H


A = []
for i in range(N):
    A.append(list(map(int, stdin.readline().rstrip().split())))

for i in range(N):
    [x, y, a] = A[i]
    if a == 1:
        Ws = x
    elif a == 2:
        We = x
    elif a == 3:
        Hs = y
    elif a == 4:
        He = y

if (We - Ws) <= 0 or (He - Hs) <=0:
    print(0)
else:
    print((We - Ws) * (He - Hs))

Submission status: Wrong Answer

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

white = [0, W, 0, H]

points = [[int(i) for i in input().split()] for j in range(N)]

for point in points:
    if point[2] == 1:
        if point[0] > white[0]:
            white[0] = point[0]
    if point[2] == 2:
        if point[0] < white[1]:
            white[1] = point[0]
    if point[2] == 3:
        if point[1] > white[2]:
            white[2] = point[1]
    if point[2] == 4:
        if point[1] < white[3]:
            white[3] = point[1]

result = (white[1] - white[0]) * (white[3] - white[2])

if result > 0:
    print(result)
else:
    print(0)

Submission status: Wrong Answer

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

white = [0, W, 0, H]

points = [[int(i) for i in input().split()] for j in range(N)]

for point in points:
    if point[2] == 1:
        if point[0] > white[0]:
            white[0] = point[0]
    if point[2] == 2:
        if point[0] < white[1]:
            white[1] = point[0]
    if point[2] == 3:
        if point[1] > white[2]:
            white[0] = point[1]
    if point[2] == 4:
        if point[1] < white[3]:
            white[3] = point[1]

result = (white[1] - white[0]) * (white[3] - white[2])

if result > 0:
    print(result)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
w, h, n = map(int, input().split())
li = [list(map(int, input().split())) for i in range(n)]
xy = []
a = []
for i in range(n):
    xy.append([li[i][0], li[i][1]])
    a.append(li[i][2])

left, right = [0, 0], [w, h]

for i in range(n):
    if a[i] == 1:
        if left[0] < xy[i][0]:
            left[0] = xy[i][0]
    elif a[i] == 2:
        if right[0] > xy[i][0]:
            right[0] = xy[i][0]
    elif a[i] == 3:
        if left[1] < xy[i][1]:
            left[1] = xy[i][1]
    else:
        if right[1] > xy[i][1]:
            right[1] = xy[i][1]

ans = (right[0]-left[0]) * (right[1]-left[1])
if ans < 0:
    ans = 0
print(str(ans))

Submission status: Wrong Answer

Solution code:
w, h, n = map(int, input().split())
li = [list(map(int, input().split())) for i in range(n)]
xy = []
a = []
for i in range(n):
    xy.append([li[i][0], li[i][1]])
    a.append(li[i][2])

left, right = [0, 0], [w, h]

for i in range(n):
    if a[i] == 1:
        left[0] = xy[i][0]
    elif a[i] == 2:
        right[0] = xy[i][0]
    elif a[i] == 3:
        left[1] = xy[i][1]
    else:
        right[1] = xy[i][1]

ans = (right[0]-left[0]) * (right[1]-left[1])
if ans < 0:
    ans = 0
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

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

X1 = 0
X2 = 0
Y1 = 0
Y2 = 0

x1, x2, y1, y2 = 0, 0, 0, 0

X = 0
Y = 0

entire = W * H

for i in range(N):
    if a[i]==1 and X1<x[i]:
        x1 = x[i] * H
        X1 = x[i]
    elif a[i]==2 and X2<(W-x[i]):
        x2 = (W-x[i]) * H
        X2 = W - x[i]
    elif a[i]==3 and Y1<y[i]:
        y1 = y[i] * W
        Y1 = y[i]
    elif a[i]==4 and Y2<(H-y[i]):
        y2 = (H-y[i]) * W
        Y2 = H - y[i]

entire = entire - (x1 + x2 + y1 + y2) + ((X1+X2) * (Y1+Y2))

if entire<=0:
    print('0')
else:
    print(entire)

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

X1 = 0
X2 = 0
Y1 = 0
Y2 = 0

x1, x2, y1, y2 = 0, 0, 0, 0

X = 0
Y = 0

entire = W * H

for i in range(N):
    if a[i]==1 and X1<x[i]:
        x1 = x[i] * H
        X1 += x[i]
    elif a[i]==2 and X2<(W-x[i]):
        x2 = (W-x[i]) * H
        X2 += W - x[i]
    elif a[i]==3 and Y1<y[i]:
        y1 = y[i] * W
        Y1 += y[i]
    elif a[i]==4 and Y2<(H-y[i]):
        y2 = (H-y[i]) * W
        Y2 += H - y[i]

entire = entire - (x1 + x2 + y1 + y2) + ((X1+X2) * (Y1+Y2))

if entire<=0:
    print('0')
else:
    print(entire)

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

X1 = 0
X2 = 0
Y1 = 0
Y2 = 0

x1, x2, y1, y2 = 0, 0, 0, 0

X = 0
Y = 0

entire = W * H

for i in range(N):
    if a[i]==1 and X1<x[i]:
        x1 = x[i] * H
        X1 = x[i]
    elif a[i]==2 and X2<(W-x[i]):
        x2 = (W-x[i]) * H
        X2 = W - x[i]
    elif a[i]==3 and Y1<y[i]:
        y1 = y[i] * W
        Y1 = y[i]
    elif a[i]==4 and Y2<(H-y[i]):
        y2 = (H-y[i]) * W
        Y2 = H - y[i]

#if 
#entire = entire - (x1 + x2 + y1 + y2) + ((X1+X2) * (Y1+Y2))#
#
#if entire<=0:
#    print('0')
#else:
#    print(entire)

if X1 >= X2 or Y1 >= Y2:
    print('0')
else:
    entire = entire - (x1 + x2 + y1 + y2) + ((X1+X2) * (Y1+Y2))
    print(entire)

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

X1 = 0
X2 = 0
Y1 = 0
Y2 = 0

x1, x2, y1, y2 = 0, 0, 0, 0

X = 0
Y = 0

entire = W * H

for i in range(N):
    if a[i]==1 and X1<x[i]:
        x1 = x[i] * H
        X1 += x[i]
    elif a[i]==2 and X2<(W-x[i]):
        x2 = (W-x[i]) * H
        X2 += W - x[i]
    elif a[i]==3 and Y1<y[i]:
        y1 = y[i] * W
        Y1 += y[i]
    elif a[i]==4 and Y2<(H-y[i]):
        y2 = (H-y[i]) * W
        Y2 += H - y[i]

#if 
#entire = entire - (x1 + x2 + y1 + y2) + ((X1+X2) * (Y1+Y2))#
#
#if entire<=0:
#    print('0')
#else:
#    print(entire)

if X1 >= X2 or Y1 >= Y2:
    print('0')
else:
    entire = entire - (x1 + x2 + y1 + y2) + ((X1+X2) * (Y1+Y2))
    print(entire)

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

X1 = 0
X2 = 0
Y1 = 0
Y2 = 0

x1, x2, y1, y2 = 0, 0, 0, 0

X = 0
Y = 0

entire = W * H

for i in range(N):
    if a[i]==1 and X1<x[i]:
        x1 = x[i] * H
        X1 += x[i]
    elif a[i]==2 and X2<(W-x[i]):
        x2 = (W-x[i]) * H
        X2 += (W - x[i])
    elif a[i]==3 and Y1<y[i]:
        y1 = y[i] * W
        Y1 += y[i]
    elif a[i]==4 and Y2<(H-y[i]):
        y2 = (H-y[i]) * W
        Y2 += (H - y[i])

entire = entire - (x1 + x2 + y1 + y2) + ((X1+X2) * (Y1+Y2))

if entire<=0:
    print('0')
else:
    print(entire)

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

X1 = 0
X2 = W
Y1 = 0
Y2 = H

entire = W * H

for i in range(N):
    if a[i] == 1:
        X1 = max(X1, x[i])
    if a[i] == 2:
        X2 = min(X2, x[i])
    if a[i] == 3:
        Y1 = max(Y1, y[i])
    if a[i] == 4:
        Y2 = min(Y2, y[i])

if X1 >= X2 or Y1 >= Y2:
    print('0')
else:
    entire = entire - (Y2-Y1) * (X2-X1)
    print(entire)

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

X1 = 0
X2 = 0
Y1 = 0
Y2 = 0

x1, x2, y1, y2 = 0, 0, 0, 0

X = 0
Y = 0

entire = W * H

for i in range(N):
    if a[i]==1 and X1<x[i]:
        x1 = x[i] * H
        X1 += x[i]
    elif a[i]==2 and X2<(W-x[i]):
        x2 = (W-x[i]) * H
        X2 += W - x[i]
    elif a[i]==3 and Y1<y[i]:
        y1 = y[i] * W
        Y1 += y[i]
    elif a[i]==4 and Y2<(H-y[i]):
        y2 = (H-y[i]) * W
        Y2 += H - y[i]

entire = entire - (x1 + x2 + y1 + y2) + ((X1+X2) * (Y1+Y2))

print(entire)

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 = 0
Y = 0

entire = W * H

for i in range(N):
    if a[i]==1:
        entire -= x[i] * H
        X += x[i]
    elif a[i]==2:
        entire -= (W-x[i]) * H
        X += W - x[i]
    elif a[i]==3:
        entire -= y[i] * W
        Y += y[i]
    else:
        entire -= (H-y[i]) * W
        Y += H - y[i]

entire += X * Y

print(entire)

Submission status: Wrong Answer

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

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

one = 0
two = w
three = 0
four = h


for xl in xlist:
    if xl[2] == 1:
        one = xl[0]
    elif xl[2] == 2:
        two = xl[0]
    elif xl[2] == 3:
        three = xl[1]
    elif xl[2] == 4:
        four = xl[1]
if one > two:
    x = 0
else:
    x = two - one
if three > four:
    y = 0
else:
    y = four - three

if (x*y) < 0:
    print(0)
else:
    print(x*y)

Submission status: Wrong Answer

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

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

one = 0
two = w
three = 0
four = h


for xl in xlist:
    if xl[2] == 1:
        one = xl[0]
    elif xl[2] == 2:
        two = xl[0]
    elif xl[2] == 3:
        three = xl[1]
    elif xl[2] == 4:
        four = xl[1]

x = two - one
y = four - three

if (x*y) < 0:
    print(0)
else:
    print(x*y)

Submission status: Wrong Answer

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

x_left = 0
x_right = w
y_upper = h
y_lower = 0
t = 0
for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        x_left = x
    elif a == 2:
        x_right = x
    elif a == 3:
        y_lower = y
    else:
        y_upper = y
    if x_left < x_right and y_lower < y_upper:
        continue
    else:
        t = 1
        break
if t == 1:
    print(0)
else:
    print((x_right - x_left) * (y_upper - y_lower))

Submission status: Wrong Answer

Solution code:
w,h,n = map(int,input().split())
w_min = 0
w_max = w
h_min = 0
h_max = w
for i in range(n):
    x,y,a = map(int,input().split())
    if a == 1:
        if w_min < x:
            w_min = x
            
    if a == 2:
        if w_max > x:
            w_max = x
            
    if a == 3:
        if h_min < y:
            h_min = y
            
    if a == 4:
        if h_max > y:
            h_max = y

print(x*y)

Submission status: Wrong Answer

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

X = [0] * N
Y = [0] * N
A = [0] * N
p1X, p1Y = 0, 0
p2X, p2Y = W, H

for i in range(N):
    xx, yy, aa = map(int, input().split())
    X[i], Y[i], A[i] = xx, yy, aa

for ii in range(N):
    if A[ii] <3:
        if A[ii] == 1 and p1X < X[ii]:
            p1X = X[ii]
        elif A[ii] == 2 and p2X > X[ii]:
            p2X = X[ii]
        else:
            pass

    else:
        if A[ii] == 3 and p1Y < Y[ii]:
            p1Y = Y[ii]
        elif A[ii] == 4 and p2Y > Y[ii]:
            p2Y = Y[ii]
        else:
            pass

        

wharea = (p2X - p1X) * (p2Y - p1Y)

if wharea >= 0:
    print(wharea)
else:
    print(0)

Submission status: Wrong Answer

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

for i in range(N):
  A = list(map(int, input().split()))
  a.append(A)

for j in a:
  if j[2] == 1:
    x[0] = j[0]
  elif j[2] == 2:
    x[1] = j[0]
  elif j[2] == 3:
    y[0] = j[1]
  else:
    y[1] = j[1]
    
if x[0] >= x[1] or y[0] >= y[1]:
  print('0')
else:
  ans = (x[1] - x[0]) * (y[1] - y[0])
  print(int(ans))

Submission status: Wrong Answer

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

for i in range(N):
  A = list(map(int, input().split()))
  a.append(A)

for j in a:
  if j[2] == 1:
    x[0] = j[0]
  elif j[2] == 2:
    x[1] = j[0]
  elif j[2] == 3:
    y[0] = j[1]
  else:
    y[1] = j[1]
    
if x[0] >= x[1] or y[0] >= y[1]:
  print('0')
else:
  ans = (x[1] - x[0]) * (y[1] - y[0])
  print(ans)

Submission status: Wrong Answer

Solution code:
w,h,n=map(int,input().split())
xa=0
xb=w
ya=0
yb=h
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        xa=max(x,xa)
    if a==2:
        xb=min(x,xb)
    if a==3:
        ya=max(y,ya)
    if a==4:
        yb=min(y,yb)
print(max((xb-xa)*(yb-ya),0))

Submission status: Wrong Answer

Solution code:
import sys
W, H, N = map(int, sys.stdin.readline().split(" "))
Map = [list(map(int,sys.stdin.readline().split(" "))) for i in range(N)]
L = 0
R = W
B = 0
T = H
 
for i in Map:
  if i[2] == 1:
    l = i[0]
    L = max(L, l)
  if i[2] == 2:
    r = i[0]
    R = min(R, r)
  if i[2] == 3:
    b = i[1]
    B = max(B, b)
  if i[2] == 4:
    t = i[1]
    T = min(T, t)
    
if (R - L) * (T - B) > 0:
  print((R - L) * (T - B))
else:
  print(0)

Submission status: Wrong Answer

Solution code:
import sys
W, H, N = map(int, sys.stdin.readline().split(" "))
Map = [list(map(int,sys.stdin.readline().split(" "))) for i in range(N)]
L = 0
R = W
B = 0
T = H
 
for i in Map:
  if i[2] == 1:
    l = i[0]
    L = max(L, l)
  if i[2] == 2:
    r = i[0]
    R = min(R, r)
  if i[2] == 3:
    b = i[1]
    B = max(B, b)
  if i[2] == 4:
    t = i[1]
    T = min(T, t)
    
print((R - L) * (T - B))

Submission status: Wrong Answer

Solution code:
import sys
W, H, N = map(int, sys.stdin.readline().split(" "))
Map = [list(map(int,sys.stdin.readline().split(" "))) for i in range(N)]
L = 0
R = W
B = 0
T = H

for i in Map:
  if i[2] == 1:
    l = i[0]
    L = max(L, l)
  if i[2] == 2:
    r = i[0]
    R = min(R, r)
  if i[2] == 3:
    b = i[0]
    B = max(B, b)
  if i[2] == 4:
    t = i[0]
    T = min(T, t)
    
print((R - L) * (T - B))

Submission status: Wrong Answer

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

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

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

if max_x > min_x and max_y > min_y:
    print(max(0, (max_x - min_x) * (max_y - min_y)))
else:
    print(0)

Submission status: Wrong Answer

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

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

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

print(max(0, (max_x - min_x) * (max_y - min_y)))