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:
#47b
w,h,n = map(int,input().split())
s = w*h

for _ in range(n):
    x,y,a = map(int,input().split())
    if a==1:
        s-=(w-x)*h
    elif a==2:
        s-=x*h
    elif a==3:
        s-=(h-y)*w
    else:
        s-=y*w
print(max(0,s))

Submission status: Wrong Answer

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

min_x, max_x, min_y, max_y = 0, w, 0, h
for x_y_a_i in x_y_a:
    x, y, a = x_y_a_i
    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)

Submission status: Wrong Answer

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

min_x, max_x, min_y, max_y = 0, w, 0, h
for x_y_a_i in x_y_a:
    x, y, a = x_y_a_i
    if a == 1:
        min_x = x
    elif a == 2:
        max_x = x
    elif a == 3:
        min_y = y
    elif a == 4:
        max_y = y

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

Submission status: Wrong Answer

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

min_x, max_x, min_y, max_y = 0, w, 0, h
for x_y_a_i in x_y_a:
    x, y, a = x_y_a_i
    if a == 1:
        min_x = x
    elif a == 2:
        max_x = x
    elif a == 3:
        min_y = y
    elif a == 4:
        max_y = y

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

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
av_x_1, av_x_2, av_y_1, av_y_2 = 0, W, 0, H

for i in range(N) :
    x, y, a = map(int, input().split())
    
    if a == 1 and x > av_x_1 : av_x_1 = x
    elif a == 2 and x < av_x_2 : av_x_2 = x
    elif a == 3 and y > av_y_1 : av_y_1 = y
    elif a == 4 and y < av_y_2 : av_y_2 = y
        
# print(max(0, (av_x_2 - av_x_1) * (av_y_2 - av_y_1)))
print(0)

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
av_x_1, av_x_2, av_y_1, av_y_2 = 0, W, 0, H

for i in range(N) :
    x, y, a = map(int, input().split())
    
    if a == 1 and x > av_x_1 : av_x_1 = x
    elif a == 2 and x < av_x_2 : av_x_2 = x
    elif a == 3 and y > av_y_1 : av_y_1 = y
    elif a == 4 and y < av_y_2 : av_y_2 = y
        
print(max(0, (av_x_2 - av_x_1) * (av_y_2 - av_y_1)))

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
av_x_1, av_x_2, av_y_1, av_y_2 = 0, W, 0, H

for i in range(N) :
    x, y, a = map(int, input().split())
    
    if a == 1 and x >= av_x_1 : av_x_1 = x
    elif a == 2 and x <= av_x_2 : av_x_2 = x
    elif a == 3 and y >= av_y_1 : av_y_1 = y
    elif a == 4 and y <= av_y_2 : av_y_2 = y
        
print(max(0, (av_x_2 - av_x_1) * (av_y_2 - av_y_1)))

Submission status: Wrong Answer

Solution code:
W,H,N = map(int, input().split())
l,t,r,b = 0, H, W, 0
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        l = x
    elif a == 2:
        r = x
    elif a == 3:
        b = y
    elif a == 4:
        t = y
print(max(0, r - l) * max(0, t - b))

Submission status: Wrong Answer

Solution code:
fn = lambda: map(int, input().split())
W, H, N = fn()
min_x, max_x = 0, W
min_y, max_y = 0, H
for i in range(N):
    xi, yi, ai = fn()
    if ai == 1:
        min_x = xi
    elif ai == 2:
        max_x = xi
    elif ai == 3:
        min_y = yi
    elif ai == 4:
        max_y = yi
    else:
        print('Something wrong')

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

x_y_min_max = [0, w, 0, h]
for x_y_a_i in x_y_a:
    x, y, a = x_y_a_i
    if a == 1:
        x_y_min_max[a-1] = max(x, x_y_min_max[a-1])
    elif a == 2:
        x_y_min_max[a-1] = min(x, x_y_min_max[a-1])
    elif a == 3:
        x_y_min_max[a-1] = max(y, x_y_min_max[a-1])
    elif a == 4:
        x_y_min_max[a-1] = min(y, x_y_min_max[a-1])
print(max(0, (x_y_min_max[1]-x_y_min_max[0])*(x_y_min_max[3]-x_y_min_max[2])))

Submission status: Wrong Answer

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

x_y_min_max = [0, w, 0, h]
for x_y_a_i in x_y_a:
    x, y, a = x_y_a_i
    if a == 1:
        x_y_min_max[a-1] = max(x, x_y_min_max[a-1])
    elif a == 2:
        x_y_min_max[a-1] = min(x, x_y_min_max[a-1])
    elif a == 3:
        x_y_min_max[a-1] = max(y, x_y_min_max[a-1])
    elif a == 4:
        x_y_min_max[a-1] = min(y, x_y_min_max[a-1])
    print(x_y_min_max)
print((x_y_min_max[1]-x_y_min_max[0])*(x_y_min_max[3]-x_y_min_max[2]))

Submission status: Wrong Answer

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

x_y_min_max = [0, w, 0, h]
for x_y_a_i in x_y_a:
    x, y, a = x_y_a_i
    x_y_min_max[a-1] = [x, y][(a-1)//2]
    print(x_y_min_max)
print((x_y_min_max[1]-x_y_min_max[0])*(x_y_min_max[3]-x_y_min_max[2]))

Submission status: Wrong Answer

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

ma_x=w
ma_y=h
mi_x=0
mi_y=0

for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        if mi_x<x:
            mi_x=x
    elif a==2:
        if ma_x>x:
            ma_x=x
    elif a==3:
        if mi_y<y:
            mi_y=y
    elif a==4:
        if ma_y>y:
            ma_y=y

ans=(ma_x-mi_x)*(ma_y-mi_y)

if ans<0:
    ans=0

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
w,h,n=map(int,input().split())
y=[0,w]
t=[0,h]
def ct(w0,h0,a0):
  if a0==1:
    v=max(w0,y[0])
    y[0]=v
  if a0==2:
    v=min(w0,y[1])
    y[1]=v
  if a0==3:
    v=max(h0,t[0])
    t[0]=v
  if a0==4:
    v=min(h0,t[1])
    t[1]=v
for i in range(n):
  w1,h1,a1=map(int,input().split())
  ct(w1,h1,a1)

print(max(0,y[0]-y[1])*max(0,t[0]-t[1]))

Submission status: Wrong Answer

Solution code:
w,h,n=map(int,input().split())
y=[0,w]
t=[0,h]
def ct(w0,h0,a0):
  if a0==1:
    v=max(w0,y[0])
    y[0]=v
  if a0==2:
    v=min(w0,y[1])
    y[1]=v
  if a0==3:
    v=max(h0,t[0])
    t[0]=v
  if a0==4:
    v=min(h0,t[1])
    t[1]=v
for i in range(n):
  w1,h1,a1=map(int,input().split())
  ct(w1,h1,a1)

print((max(y)-min(y))*(max(t)-min(t)))

Submission status: Wrong Answer

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

a1 = [0]
a2 = [W]
a3 = [0]
a4 = [H]
for x,y,a in XYA:
    if a==1:
        a1.append(x)
    elif a==2:
        a2.append(x)
    elif a==3:
        a3.append(y)
    elif a==4:
        a4.append(y)
        
x_min = max(a1)
x_max = min(a2)
y_min = max(a3)
y_max = min(a4)

ans = (x_max-x_min) * (y_max-y_min)

print(max(0,ans))

Submission status: Wrong Answer

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

a1 = [0]
a2 = [W]
a3 = [0]
a4 = [H]
for x,y,a in XYA:
    if a==1:
        a1.append(x)
    elif a==2:
        a2.append(x)
    elif a==3:
        a3.append(y)
    elif a==4:
        a4.append(y)
        
x_min = max(a1)
x_max = min(a2)
y_min = max(a3)
y_max = min(a4)

ans = (x_max-x_min) * (y_max-y_min)

print(max(0,ans))

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())    
xya_list = [list(map(int, input().split())) for  _ in range(N)]
x_lower, x_upper, y_lower, y_upper =0, W,  0, H
for i in xya_list:
    if i[2] == 1 and i[0] > x_lower:
        x_lower = i[0]
    elif i[2] == 2 and i[0] < x_upper:
        x_upper = i[0]
    elif i[2] == 3 and i[1] > y_lower:
        y_lower = i[1]
    elif i[2] == 4 and i[1] < y_upper:
        y_upper = i[1]

area = (x_upper - x_lower) * (y_upper - y_lower)
if area >= 0:
    print(area)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())    
xya_list = [list(map(int, input().split())) for  _ in range(N)]
x_lower, x_upper, y_lower, y_upper =0, W,  0, H
for i in xya_list:
    if i[2] == 1:
        x_lower = i[0]
    elif i[2] == 2:
        x_upper = i[0]
    elif i[2] == 3:
        y_lower = i[1]
    else:
        y_upper = i[1]

area = (x_upper - x_lower) * (y_upper - y_lower)
if area >= 0:
    print(area)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

W, H, N = map(int, input().split())
aN = [list(map(int, input().split())) for i in range (N)]

# 1マスずつ塗りつぶさないパターン(こっちのが速い)
minXY = [0, 0]
maxXY = [W, H]
for i in range(N):
    
    if aN[i][2] == 1:
        minXY[0] = max(minXY[0], aN[i][0])

    elif aN[i][2] == 2:
        maxXY[0] = min(maxXY[0], aN[i][0])

    elif aN[i][2] == 3:
        minXY[1] = max(minXY[1], aN[i][1])

    elif aN[i][2] == 4:
        maxXY[1] = min(maxXY[1], aN[i][1])

ans = (maxXY[0] - minXY[0]) * (maxXY[1] - minXY[1])
if ans < 0:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
w,h,n=map(int, input().split())
b=np.ones((w,h))

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

Submission status: Wrong Answer

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

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


left_lim = 0
right_lim = w
bottom_lim = 0
top_lim = h

for i in range(n):
  if points_dir[i][2] == 1:
    left_lim = points_dir[i][0] if points_dir[i][0] > left_lim else left_lim
  elif points_dir[i][2] == 2:
    right_lim = points_dir[i][0] if points_dir[i][0] < right_lim else right_lim
  elif points_dir[i][2] == 3:
    bottom_lim = points_dir[i][1] if points_dir[i][1] > bottom_lim else bottom_lim
  elif points_dir[i][2] == 4:
    top_lim = points_dir[i][1] if points_dir[i][1] < top_lim else top_lim

rectangle = (right_lim - left_lim) * (top_lim - bottom_lim) if (right_lim - left_lim) * (top_lim - bottom_lim) > 0 else 0

print(rectangle)

Submission status: Wrong Answer

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

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


left_lim = 0
right_lim = w
bottom_lim = 0
top_lim = h

for i in range(n):
  if points_dir[i][2] == 1:
    left_lim = points_dir[i][0]
  elif points_dir[i][2] == 2:
    right_lim = points_dir[i][0]
  elif points_dir[i][2] == 3:
    bottom_lim = points_dir[i][1]
  elif points_dir[i][2] == 4:
    top_lim = points_dir[i][1]

rectangle = (right_lim - left_lim) * (top_lim - bottom_lim) if (right_lim - left_lim) * (top_lim - bottom_lim) > 0 else 0

print(rectangle)

Submission status: Wrong Answer

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

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

l_lim = 0
r_lim = w
b_lim = 0
t_lim = h

for i in range(n):
  if points_dir[i][2] == 1:
    l_lim = points_dir[i][0]
  elif points_dir[i][2] == 2:
    r_lim = points_dir[i][0]
  elif points_dir[i][2] == 3:
    b_lim = points_dir[i][1]
  else:
    t_lim = points_dir[i][1]

if r_lim <= l_lim or b_lim >= t_lim:
  print("0")
else:
  print((r_lim - l_lim) * (t_lim - b_lim))

Submission status: Wrong Answer

Solution code:
W,H,N = (int(i) for i in input().split())

upright = [W,H]
downleft = [0,0]

for i in range(N):
    x,y,a = (int(k) for k in input().split())
    if a == 1:
        if x >= downleft[0]:
            downleft[0] = x
    elif a == 2:
        if x <= upright[0]:
            upright[0] = x
    elif a == 3:
        if x >= downleft[1]:
            downleft[1] = y
    else:
        if x <= upright[1]:
            upright[1] = y

height = upright[1]-downleft[1]
width = upright[0]-downleft[0]

if height >= 0 and width >= 0:
    area = height*width
else:
    area = 0

print(area)

Submission status: Wrong Answer

Solution code:
W,H,N = (int(i) for i in input().split())

upright = [W,H]
downleft = [0,0]

for i in range(N):
    x,y,a = (int(k) for k in input().split())
    if a == 1:
        if x > downleft[0]:
            downleft[0] = x
    elif a == 2:
        if x < upright[0]:
            upright[0] = x
    elif a == 3:
        if x > downleft[1]:
            downleft[1] = y
    else:
        if x < upright[1]:
            upright[1] = y

area = (upright[1]-downleft[1])*(upright[0]-downleft[0])

if area <= 0:
    print(0)
else:
    print(area)

Submission status: Wrong Answer

Solution code:
W,H,N = (int(i) for i in input().split())

upright = [W,H]
downleft = [0,0]

for i in range(N):
    x,y,a = (int(k) for k in input().split())
    if a == 1:
        if x >= downleft[0]:
            downleft[0] = x
    elif a == 2:
        if x <= upright[0]:
            upright[0] = x
    elif a == 3:
        if x >= downleft[1]:
            downleft[1] = y
    else:
        if x <= upright[1]:
            upright[1] = y

area = (upright[1]-downleft[1])*(upright[0]-downleft[0])

if area < 0:
    print(0)
else:
    print(area)

Submission status: Wrong Answer

Solution code:
l,d=0,0
w,h,n=map(int,input().split())
for _ in [0]*n:
    x,y,a=map(int,input().split())
    if a==1 and l>x:l=x
    elif a==2 and w<x:w=x
    elif a==3 and d>y:d=y
    elif a==4 and h<y:h=y
if w<=l or h<=d:print(0)
else:print((w-l)*(h-d))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

x = [list(map(int, input().split())) for x in range(n)]
coordinate = [[0,0], [w,0], [h,0], [w,h]]

for i in range(n):
        if x[i][2] == 1:
                coordinate[0][0] = x[i][0]
                coordinate[2][0] = x[i][0]
        elif x[i][2] == 2:
                coordinate[1][0] = x[i][0]
                coordinate[3][0] = x[i][0]
        elif x[i][2] == 3:
                coordinate[0][1] = x[i][1]
                coordinate[1][1] = x[i][1]
        elif x[i][2] == 4:
                coordinate[2][1] = x[i][1]
                coordinate[3][1] = x[i][1]

ans = (coordinate[3][0] - coordinate[2][0]) * (coordinate[3][1] - coordinate[1][1])
print(ans if ans > 0 else 0)

Submission status: Wrong Answer

Solution code:
W, H, N = (int(i) for i in input().split())
points = [[int(i) for i in input().split()] for i in range(N)]
low_left_x = 0
low_left_y = 0
s = 0
j = 0

for j in range(N):
    if(points[j][2] == 1): #blanking left
        if(points[j][0] > low_left_x):
            low_left_x = points[j][0]
    if(points[j][2] == 2): #blanking right
        if(points[j][0] < W):
            W = points[j][0]
    if(points[j][2] == 3): #blanking low
        if(points[j][1] > low_left_y):
            low_left_y = points[j][1]
    if(points[j][2] == 4): #blanking high
        if(points[j][1] < H):
            H = points[j][1]

s = (W - low_left_x) * (H - low_left_y)
if(s < 0):
    s = 0
print(s)

Submission status: Wrong Answer

Solution code:
W,H,N = (int(i) for i in input().split())

dleft = [0,0]
dright = [W,0]
uleft = [0,H]
uright = [W,H]

for i in range(N):
    x,y,a = (int(i) for i in input().split())
    if a == 1:
        if x >= dleft[0]:
            dleft[0] == x
            uleft[0] == x
    elif a == 2:
        if x <= dright[0]:
            dright[0] == x
            uright[0] == x
    elif a == 3:
        if y >= uleft[1]:
            dleft[1] == y
            dright[1] == y
    else:
        if y <= dleft[1]:
            uleft[1] == y
            uright[1] == y

area = (dright[0]-dleft[0])*(uright[1]-dright[1])
print(area)

Submission status: Wrong Answer

Solution code:
W,H,N = (int(i) for i in input().split())

area = H*W

for i in range(N):
    x,y,a = (int(i) for i in input().split())
    if a == 1:
        area = area - H*x
    elif a == 2:
        area = area - H*(W-x)
    elif a == 3:
        area = area - W*y
    else:
        area = area - W*(H-y)

print(area)

Submission status: Wrong Answer

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

print(max(0, (w - p) * (h - q)))

Submission status: Wrong Answer

Solution code:
def main():
    w, h, n = map(int, input().split())
    
    w_min, w_max = [0], [w]
    h_min, h_max = [0], [h]
    
    for i in range(n):
        x, y, a = map(int, input().split())
        if a == 1:
            w_min.append(x)
        elif a == 2:
            w_max.append(x)
        elif a == 3:
            h_min.append(y)
        else:
            h_max.append(y)
            
    w = min(w_max) - max(w_min)
    h = min(h_max) - max(h_min)
    
    if w * h > 0:
        print(w*h)
    else:
        print(0)

        
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

x_min = 0
x_max = w
y_min = 0
y_max = h

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        x_min = min(x, x_min)
    elif a == 2:
        x_max = max(x, x_max)
    elif a == 3:
        y_min = min(y, y_min)
    else:
        y_max = max(y, y_max)
print(max(y_max - y_min, 0) * max(x_max - x_min, 0))

Submission status: Wrong Answer

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

x_min = 0
x_max = w
y_min = 0
y_max = h

for i in range(n):
    x,y,a = map(int, input().split())
    if a == 1:
        x_min = x
    elif a == 2:
        x_max = x
    elif a == 3:
        y_min = y
    else:
        y_max = y
print(max(y_max-y_min, 0) * max(x_max-x_min, 0))

Submission status: Wrong Answer

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

x_min = 0
x_max = w
y_min = 0
y_max = h

for i in range(n):
    x,y,a = map(int, input().split())
    if a == 1:
        x_min = x
    elif a == 2:
        x_max = x
    elif a == 3:
        y_min = y
    else:
        y_max = y
print(y_max, y_min, x_max,x_min)
print(max(y_max-y_min,0) * max(x_max-x_min,0))

Submission status: Wrong Answer

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

x_min = 0
x_max = w
y_min = 0
y_max = h

for i in range(n):
    x,y,a = map(int, input().split())
    if a == 1:
        x_min = x
    elif a == 2:
        x_max = x
    elif a == 3:
        y_min = y
    else:
        y_max = y
print((y_max-y_min) * (x_max-x_min))

Submission status: Wrong Answer

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

x_min = 0
x_max = w
y_min = 0
y_max = h

for i in range(n):
    x,y,a = map(int, input().split())
    if a == 1:
        x_max = x
    elif a == 2:
        x_min = x
    elif a == 3:
        y_max = y
    else:
        y_min = y

print((y_max-y_min) * (x_max-x_min))

Submission status: Wrong Answer

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

l,r,t,b = 0,W,H,0

for i in range(N):
    x,y,a = map(int,input().split())
    if a==1: l=x
    elif a==2: r=x
    elif a==3: b=y
    elif a==4: t=y
        
W = r-l if r-l>=0 else 0
H = t-b if t-b>=0 else 0
        
print(W*H)

Submission status: Wrong Answer

Solution code:
W, H, N = map(int,input().split())
D = [list(map(int,input().split())) for k in range(N)]
mx = 0
my = 0
MX = W
MY = H
for d in D:
    if d[2] == 1:
        mx = max(mx,d[0])
    elif d[2] == 2:
        MX = min(MX,d[0])
    elif d[2] == 3:
        my = max(my,d[1])
    else:
        MY = min(MY,d[1])

print(max(0,(MX-mx)*(MY-my)))

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split(' '))
minx = 0
maxx = W
miny = 0
maxy = H
for i in range(N):
    x, y, a = map(int, input().split(' '))
    if a == 1:
        minx = max(minx, x)
    elif a == 2:
        maxx = min(maxx, x)
    elif a == 3:
        miny = max(miny, y)
    else:
        maxy = min(maxy, y)
if minx <= maxx and miny <= maxy:
    print((maxx-minx) * (maxy-miny))

Submission status: Wrong Answer

Solution code:
W,H,N = map(int,input().split())
X1,X2,Y1,Y2 = 0,W,0,H
for i in range(N):
    x,y,a = map(int,input().split())
    if a == 1:
        X1 = x
    elif a == 2:
        X2 = x
    elif a == 3:
        Y1 = y
    elif a == 4:
        Y2 = y
print(max(0,(X2-X1))*max(0,(Y2-Y1)))

Submission status: Wrong Answer

Solution code:
W,H,N = map(int,input().split())
X1,X2,Y1,Y2 = 0,W,0,H
for i in range(N):
    x,y,a = map(int,input().split())
    if a == 1:
        X1 = x
    elif a == 2:
        X2 = x
    elif a == 3:
        Y1 = y
    elif a == 4:
        Y2 = y
print((X2-X1)*(Y2-Y1))

Submission status: Wrong Answer

Solution code:
a, b, n = list(map(int,input().split()))

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

aa =0
ab =a
ac =0
ad =b

for i in range(n):
    if c[i][2] == 1:
        aa = max(aa,c[i][0])
    elif c[i][2] == 2:
        ab = min(ab,c[i][0])
    elif c[i][2] == 3:
        ac = max(ac,c[i][1])
    else:
        ad = min(ad,c[i][1])

if ab-aa < 0 and ad-ac < 0:
    print((ab-aa)*(ad-ac))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
a, b, n = list(map(int,input().split()))

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

aa =0
ab =a
ac =0
ad =b

for i in range(n):
    if c[i][2] == 1:
        aa = max(aa,c[i][0])
    elif c[i][2] == 2:
        ab = min(ab,c[i][0])
    elif c[i][2] == 3:
        ac = max(ac,c[i][1])
    else:
        ad = min(ad,c[i][1])

print((ab-aa)*(ad-ac))

Submission status: Wrong Answer

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

for i in range(n):
    if l[i][2]==1 and start[0]<l[i][0]:
        start[0] = l[i][0]
    elif l[i][2]==2 and end[0]>l[i][0]:
        end[0] = l[i][0]
    elif l[i][2]==3 and start[1]<l[i][1]:
        start[1] = l[i][1]
    elif l[i][2]==4 and end[1]>l[i][1]:
        end[1] = l[i][1]
ans = (end[0]-start[0])*(end[1]-start[1])
print(ans if ans > 0 else 0)

Submission status: Wrong Answer

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

for i in range(n):
    if l[i][2]==1:
        start[0] = l[i][0]
    elif l[i][2]==2:
        end[0] = l[i][0]
    elif l[i][2]==3:
        start[1] = l[i][1]
    else:
        end[1] = l[i][1]
ans = (end[0]-start[0])*(end[1]-start[1])
print(ans if ans > 0 else 0)

Submission status: Wrong Answer

Solution code:
W,H,N = map(int,input().split())
maxH = H
maxW = W
minH = 0
minW = 0
for i in range(N):
    x,y,a = map(int,input().split())
    if a == 1:
        minW = max(minW,x)
    elif a == 2:
        maxW = min(maxW,x)    
    elif a == 3:
        minH = max(minH,y)
    else:
        maxH = min(maxH,y)
ansW = maxW - minW
ansH = maxH - minH
print(ansW * ansH);

Submission status: Wrong Answer

Solution code:
w,h,n=map(int,input().split())
t=[tuple(map(int,input().split()))for i in range(n)]
A=C=0
B=w
D=h
for i in range(n):
    if t[i][2]==1:
        A=max(A,t[i][0])
    elif t[i][2]==2:
        B=min(B,t[i][0])
    elif t[i][2]==3:
        C=max(C,t[i][1])
    elif t[i][2]==4:
        D=min(D,t[i][1])
if (B-A)*(D-C)<=0:
    print(0)
else:
    print((B-A)*(D-C))

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
y_min = 0
x_max = W
y_max = H
for i in range(N):
    if a[i] == 1:
        x_min = max(x_min,x[i])
    if a[i] == 2:
        x_max = min(x_max,x[i])
    if a[i] == 3:
        y_min = max(y_min,y[i])
    if a[i] == 4:
        y_max = min(y_max,y[i])
print(x_min,x_max,y_min,y_max)
x_sub = x_max-x_min
y_sub = y_max-y_min
print(x_sub*y_sub)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

T=W*H
Ws=0
Hs=0
Wh=W
Hh=H
for i in range(N):
    if A[i]==1:
        T-=(X[i]-Ws)*(Hh-Hs)
        Ws=X[i]
    elif A[i]==2:
        T-=(Wh-X[i])*(Hh-Hs)
        Wh=X[i]
    elif A[i]==3:
        T-=(Y[i]-Hs)*(Wh-Ws)
        Hs=Y[i]
    elif A[i]==4:
        T-=(Hh-Y[i])*(Wh-Ws)
        Hh=Y[i]
    if T<=0:
        T=0
        break

print(T)

Submission status: Wrong Answer

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

xmin, ymin = 0, 0
xmax, ymax = w, 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)
   elif a == 4:
      ymax = min(ymax, y)

print((xmax-xmin)*(ymax-ymin))

Submission status: Wrong Answer

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

xmin, ymin = 0, 0
xmax, ymax = w, h

for i in range(n):
   x, y, a = map(int, input().split())
   if a == 1:
      xmin = x
   elif a == 2:
      xmax = x
   elif a == 3:
      ymin = y
   elif a == 4:
      ymax = y

print((xmax-xmin)*(ymax-ymin))

Submission status: Wrong Answer

Solution code:
w, h, n = [int(x) for x in input().split()]
area = w * h
sx = 0
sy = 0
ex = w
ey = h

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 2 and ex > x:
        ex = x
    elif a == 1 and sx < x:
        sx = x
    elif a == 3 and sy < y:
        sy = y
    elif a == 4 and ey > y:
        ey = y

ans = (ex-sx)*(ey-sy)
print(ans if ex-sx <= 0 or ey-sy <= 0 else 0)

Submission status: Wrong Answer

Solution code:
w, h, n = [int(x) for x in input().split()]
area = w * h
sx = 0
sy = 0
ex = w
ey = h

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 2 and ex > x:
        ex = x
    elif a == 1 and sx < x:
        sx = x
    elif a == 3 and sy < y:
        sy = y
    elif a == 4 and ey > y:
        ey = y

ans = (ex-sx)*(ey-sy)
print(ans if ans > 0 else 0)

Submission status: Wrong Answer

Solution code:
w, h, n = input().split()
lx ,ly ,hx ,hy = 0, 0, int(w), int(h)
for i in range(int(n)):
    S = list(map(int, input().split()))
    if S[2]==1:
        lx = S[0]
    elif S[2]==2:
        hx = S[0]
    elif S[2]==3:
        ly = S[1]
    elif S[2]==4:
        hy = S[1]
ans = int(hx-lx)*int(hy-ly) 
if hx-lx<=0 or hy-ly<=0:
    print(0)
else: print(ans)

Submission status: Wrong Answer

Solution code:
w, h, n = input().split()
lx ,ly ,hx ,hy = 0, 0, int(w), int(h)
for i in range(int(n)):
    S = list(map(int, input().split()))
    if S[2]==1:
        lx = S[0]
    elif S[2]==2:
        hx = S[0]
    elif S[2]==3:
        ly = S[1]
    elif S[2]==4:
        hy = S[1]
ans = int(hx-lx)*int(hy-ly) 
if ans<=0:
    print(0)
else: print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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