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

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

Submission status: Wrong Answer

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    w,h,n = f()

    xmin = 0
    xmax = w

    ymin = 0
    ymax = h
    for i in range(n):
        x,y,a = f()
        if a== 1:
            xmin = max(xmin, x)
        if a == 2:
            xmax = min(xmax, x)
        
        if a== 3:
            ymin = max(ymin, y)
        if a == 4:
            ymax = min(ymax, y)

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


solve()

Submission status: Wrong Answer

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    w,h,n = f()

    xmin = 0
    xmax = w

    ymin = 0
    ymax = h
    for i in range(n):
        x,y,a = f()
        if a== 1:
            xmin = max(xmin, x)
        if a == 2:
            xmax = min(xmax, y)
        
        if a== 3:
            ymin = max(ymin, y)
        if a == 4:
            ymax = min(ymax, y)

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


solve()

Submission status: Wrong Answer

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    w,h,n = f()

    xmin = 0
    ymin = 0
    xmax = w
    ymax = h
    for i in range(n):
        x,y,a = f()
        if a== 1:
            xmin = max(xmin, x)
        if a == 2:
            ymax = min(ymax, y)
        
        if a== 3:
            ymin = max(ymin, y)
        if a == 4:
            ymax = min(ymax, y)

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


solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

white_l = [0]
white_un = [0]
white_r = [W]
white_up = [H]

for x,y,a in XYA:
    if a == 1:
        white_l.append(x)
    elif a == 2:
        white_r.append(x)
    elif a == 3:
        white_un.append(y)
    else:
        white_up.append(y)

print(max(0,(min(white_up)-max(white_un))*(min(white_r)-max(white_l))))

Submission status: Wrong Answer

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

white_l = 0
white_un = 0
white_r = W
white_up = H

for x,y,a in XYA:
    if a == 1:
        white_l = x
    elif a == 2:
        white_r = x
    elif a == 3:
        white_un = y
    else:
        white_up = y

print(max(0,(white_up-white_un)*(white_r-white_l)))

Submission status: Wrong Answer

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

white_l = 0
white_un = 0
white_r = W
white_up = H

for x,y,a in XYA:
    if a == 1:
        white_l = x
    elif a == 2:
        white_r = x
    elif a == 3:
        white_un = y
    else:
        white_up = y

print((white_up-white_un)*(white_r-white_l))

Submission status: Wrong Answer

Solution code:

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

l = 0
r = W
ue = H
sita = 0

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

    if a ==1:
      if l < x:
          l = x
    if a == 2:
        if r > x:
            r = x

    if a == 4:
        if ue > y:
            ue = y
    if a == 3:
        if sita < y:
            sita = y

print(max(0,  (r-l) * (ue-sita)   ))

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
left_under = (0, 0)
right_top = (W, H)
for _ in range(N):
	x, y, a = map(int, input().split())
	if a == 1:
		left_under = (x, left_under[1])
	elif a == 2:
		right_top = (x, right_top[1])
	elif a == 3:
		left_under = (left_under[0], y)
	elif a == 4:
		right_top = (right_top[0], y)

if right_top[0] - left_under[0] <= 0 or right_top[1] - left_under[1] <= 0:
	print(0)
else:
	print((right_top[0] - left_under[0])*(right_top[1] - left_under[1]))

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
left_under = (0, 0)
right_top = (W, H)
for _ in range(N):
	x, y, a = map(int, input().split())
	if a == 1:
		left_under = (x, left_under[1])
	elif a == 2:
		right_top = (x, right_top[1])
	elif a == 3:
		left_under = (left_under[0], y)
	elif a == 4:
		right_top = (right_top[1], y)

if right_top[0] - left_under[0] <= 0 or right_top[1] - left_under[1] <= 0:
	print(0)
else:
	print((right_top[0] - left_under[0])*(right_top[1] - left_under[1]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
wide,height,number = map(int,input().split())
point_list = [list(map(int,input().split())) for i in range(number)]
x_small = [0]
x_large = [wide]
y_small = [0]
y_large = [height]

for i in range(number):
    point = point_list[i]
    if point[2] == 1:
        x_small.append(point[0])
    elif point[2] == 2:
        x_large.append(point[0])
    elif point[2] == 3:
        y_small.append(point[1])
    else:
        y_large.append(point[1])

x_length = min(x_large) - max(x_small)
y_length = min(y_large) - max(y_small)
area = x_length * y_length

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

Submission status: Wrong Answer

Solution code:
w, h, n = list(map(int, input().split()))
xl, xr, yd, yu = 0, w, 0, h
for _ in range(n):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        xl = max(xl, x)
    elif a == 2:
        xr = min(xr, x)
    elif a == 3:
        yd = max(yd, y)
    else:
        yu = min(yu, y)

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

Submission status: Wrong Answer

Solution code:
w, h, n = map(int, input().split())
a = [0, w, 0, h]
for i in range(n):
    xi, yi, ai = map(int, input().split())
    if ai <= 2:
        a[ai - 1] = xi
    else:
        a[ai - 1] = yi
print(max(0, a[1] - a[0]) * max(0,a[3] - a[2]))

Submission status: Wrong Answer

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

try:one = sorted(list(filter(lambda x:x[2]==1, xya)), key=lambda x:x[0])[-1][0]
except: one = 0
try: two = sorted(list(filter(lambda x:x[2]==2, xya)), key=lambda x:x[0])[0][0]
except: two=w
try: three = sorted(list(filter(lambda x:x[2]==3, xya)), key=lambda x:x[1])[-1][1]
except: three = 0
try: four = sorted(list(filter(lambda x:x[2]==4, xya)), key=lambda x:x[1])[0][1]
except: four = h

print(max(0, (two-one) * (four-three)))

Submission status: Wrong Answer

Solution code:
MX,MY,n=map(int,input().split())
s=0
mx=my=0
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:mx=max(x,MX)
    elif a==2: MX=min(x,MX)
    elif a==3: my=max(y,my)
    elif a==4: MY=min(y,my)
print(max(0,MX-mx)*max(0,MY-my))

Submission status: Wrong Answer

Solution code:
MX,MY,n=map(int,input().split())
s=0
mx=my=0
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:mx=max(x,MX)
    elif a==2: MX=min(x,MX)
    elif a==3: my=max(y,my)
    elif a==4: MY=min(y,my)
print((MX-mx)*(MY-my))

Submission status: Wrong Answer

Solution code:
MX,MY,n=map(int,input().split())
s=0
mx=my=0
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:mx=x
    elif a==2: MX=x
    elif a==3: my=y
    elif a==4: MY=y
print(max((MX-mx)*(MY-my),0))

Submission status: Wrong Answer

Solution code:
# ABC047B - すぬけ君の塗り絵 2 イージー / Snuke's Coloring 2 (ABC Edit)
w, h, n = list(map(int, input().rstrip().split()))
lst = [list(map(int, input().rstrip().split())) for _ in range(n)]
ans = [0, 0, w, h]
for i in range(n):
    a = lst[i][2]
    if a == 1:
        ans[0] = max(ans[0], lst[i][0])
    elif a == 2:
        ans[2] = min(ans[2], lst[i][0])
    elif a == 3:
        ans[1] = max(ans[1], lst[i][1])
    else:
        ans[3] = min(ans[3], lst[i][1])
res = (ans[2] - ans[0]) * (ans[3] - ans[1])
print(res if res >= 0 else 0)

Submission status: Wrong Answer

Solution code:
# ABC047B - すぬけ君の塗り絵 2 イージー / Snuke's Coloring 2 (ABC Edit)
w, h, n = list(map(int, input().rstrip().split()))
lst = [list(map(int, input().rstrip().split())) for _ in range(n)]
ans = [0, 0, w, h]
for i in range(n):
    a = lst[i][2]
    if a == 1:
        ans[0] = lst[i][0]
    elif a == 2:
        ans[2] = lst[i][0]
    elif a == 3:
        ans[1] = lst[i][1]
    else:
        ans[3] = lst[i][1]
res = (ans[2] - ans[0]) * (ans[3] - ans[1])
print(res if res >= 0 else 0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
xya = []
for _ in range(N):
  xya.append( list( map(int, input().split() ) ) )
  
W_0 = H_0 = 0
  
for i in range(N):
  
  if xya[i][2] == 1:
        if W_0 < xya[i][0]:
            W_0 =  xya[i][0]
    
  elif xya[i][2] == 2:
        if W > xya[i][0]:
            W = xya[i][0]
    
  elif xya[i][2] == 3:
        if H_0 < xya[i][1]:
            H_0 = xya[i][1]
    
  elif xya[i][2] == 4:
        if H > xya[i][1]:
            H = xya[i][1]
    
  if (W - W_0 == 0) or (H - H_0 == 0):
    break
    
print(max([(W - W_0)*(H - H_0), 0]))

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
xya = []
for _ in range(N):
  xya.append( list( map(int, input().split() ) ) )
  
W_0 = H_0 = 0
  
for i in range(N):
  
  if xya[i][2] == 1:
    W_0 =  xya[i][0]
    
  elif xya[i][2] == 2:
    W = xya[i][0]
    
  elif xya[i][2] == 3:
    H_0 = xya[i][1]
    
  elif xya[i][2] == 4:
    H = xya[i][1]
    
  if (W - W_0 == 0) or (H - H_0 == 0):
    break
    
print(max([(W - W_0)*(H - H_0), 0]))

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
xya = []
for _ in range(N):
  xya.append( list( map(int, input().split() ) ) )
  
W_0 = H_0 = 0
  
for i in range(N):
  
  if xya[i][2] == 1:
    W_0 =  xya[i][0]
    
  if xya[i][2] == 2:
    W = xya[i][0]
    
  if xya[i][2] == 3:
    H_0 = xya[i][1]
    
  if xya[i][2] == 4:
    H = xya[i][1]
    
print(max([(W - W_0)*(H - H_0), 0]))

Submission status: Wrong Answer

Solution code:
w,h,n = map(int,input().split())
x=[]
y=[]
a=[]
for i in range(n):
    x1,y1,a1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
    a.append(a1)
x_max=w
x_min=0
y_max=h
y_min=0
for i in range(n):
    if a[i]==1:
        x_min = max(x_min,x[i])
    elif a[i]==2:
        x_max = min(x_max,x[i])
    elif a[i]==3:
        y_min = max(y_min,y[i])
    elif a[i]==4:
        y_max = min(y_max,y[i])
ans = (x_max-x_min)*(y_max-y_min)
if ans>0:
    print(ans)
else:
    print(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 = max(x_min, x)
  elif a == 2:
    x_max = min(x_max, x)
  elif a == 3:
    y_min = max(y_min, y)
  else:
    y_max = min(y_max, y)
print(max((x_max-x_min)*(y_max-y_min), 0))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

left = max({P[i][0] for i in range(N) if A[i] == 1} | {0})
right = min({P[i][0] for i in range(N) if A[i] == 2} | {W})
bottom = max({P[i][1] for i in range(N) if A[i] == 3} | {0})
top = min({P[i][1] for i in range(N) if A[i] == 4} | {H})
print(max(0, (right - left) * (top - bottom)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
w, h, n = map(int, input().split())
wz = 0
hz = 0
w_max = w
h_max = h
for i in range (n):
    x, y, a = map(int, input().split())
    if a == 1:
        wz = x
    if a == 2:
        if x <= w_max:        
            w = x
            w_max = w
    if a == 3:
        hz = y
    if a == 4:
        if y <= h_max:
            h = y
            h_max = h
if wz < w or hz < h:
    print((w-wz)*(h-hz))
else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

L1 = []
L2 = []
L3 = []
L4 = []
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        L1.append(x)
    if a == 2:
        L2.append(x)      
    if a == 3:
        L3.append(y)
    if a == 4:
        L4.append(y)
# print(L1, L2, L3, L4)

if L1 != []:
    x_min = min(L1)
else:
    x_min = 0
    
if L2 != []:
    x_max = min(L2)
else:
    x_max = W
    
if L3 != []:
    y_min = min(L3)
else:
    y_min = 0
    
if L4 != []:
    y_max = min(L4)
else:
    y_max = H
# print(x_min, x_max, y_min, y_max)

x_len = max(0, x_max-x_min)
y_len = max(0, y_max-y_min)
print(x_len * y_len)

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))
    
x_len = [0, W]
y_len = [0, H]
for l in L:
#     print(l)
    if l[2] == 1:
        x_len[0] = max(l[0],x_len[0])
    if l[2] == 2:
        x_len[1] = min(l[0],x_len[1])
    if l[2] == 3:
        y_len[0] = max(l[1],y_len[0])
    if l[2] == 4:
        y_len[1] = min(l[1],y_len[1])
#     print(x_len, y_len)
    
print(max(0, (x_len[1]-x_len[0]) * (y_len[1]-y_len[0])))

Submission status: Wrong Answer

Solution code:
w,h,n=map(int,input().split())
l=list(list(map(int,input().split()))for _ in range(n))
xl=0
xh=w
yl=0
yh=h
for i in range(n):
    if l[i][2]==1:xl=max(xl,l[i][0])
    if l[i][2]==2:xh=min(xh,l[i][0])
    if l[i][2]==3:yl=max(yl,l[i][1])
    if l[i][2]==4:yh=min(yh,l[i][1])
print((xh-xl)*(yh-yl))

Submission status: Wrong Answer

Solution code:
w,h,n=map(int,input().split())
l=list(list(map(int,input().split()))for _ in range(n))
xl=0
xh=w
yl=0
yh=h
for i in range(n):
    if l[i][2]==1:xl=max(xl,l[i][0])
    if l[i][2]==2:xh=min(xh,l[i][0])
    if l[i][2]==3:yl=max(yl,l[i][1])
    if l[i][2]==4:yh=min(yh,l[i][1])
print(max((xh-xl)*(yh-yl),0))

Submission status: Wrong Answer

Solution code:
w,h,n=map(int,input().split())
List=list(list(map(int,input().split())) for _ in range(n))
x_min=[0]
y_min=[0]
x_max=[w]
y_max=[h]
for i in range(n):
    if List[i][2]==1:
        x_min.append(List[i][0])
    elif List[i][2]==2:
        x_max.append(List[i][0])
    elif List[i][2]==3:
        y_min.append(List[i][1])
    elif List[i][2]==4:
        y_max.append(List[i][1])
print(max((min(x_max)-max(x_min))*(min(y_max)-max(y_min)),0))

Submission status: Wrong Answer

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

xa = [0]
xb = [W]
ya = [0]
yb = [H]


for i in range(N):
    if a[i][2] == 1:
        xa.append(a[i][0])
    elif a[i][2] == 2:
        xb.append(a[i][0])
    elif a[i][2] == 3:
        ya.append(a[i][0])
    elif a[i][2] == 4:
        yb.append(a[i][0])

x1 = max(xa)
x2 = min(xb)
y1 = max(ya)
y2 = min(yb)
if x1 < x2 and y1 < y2:
    print((x2 - x1) * (y2 - y1))
else:
    print("0")

Submission status: Wrong Answer

Solution code:
w,h,n=map(int,input().split())
record=[]
xmin=[]
xmax=[]
ymin=[]
ymax=[]

for i in range(n):
    x,y,a=list(map(int,input().split()))
    record.append([x,y,a])
    
for i in range(n):
    if record[i][2] == 1:
        xmin.append(record[i][0])
    elif record[i][2] == 2:
        xmax.append(record[i][0])
    elif record[i][2] == 3:
        ymin.append(record[i][1])
    else:
        ymax.append(record[i][1])

if xmax==[] and xmin==[]:
    X=w
elif xmax==[]:
    X=w-max(xmin)
elif ymax==[]:
    X=min(xmax)-0
else:
    X=min(xmax)-max(xmin)

if ymax==[] and ymin==[]:
    Y=h
elif ymax==[]:
    Y=h-max(ymin)
elif ymin==[]:
    Y=min(ymax)-0
else:
    Y=min(ymax)-max(ymin)
    
print(X*Y) if (X > 0 and Y > 0) else print(0)

Submission status: Wrong Answer

Solution code:
w,h,n = map(int,input().split())
xya = [list(map(int,input().split())) for _ in range(n)]
wzero,hzero = 0,0
for i in xya:
	if i[2] == 1:
		if wzero <= i[0]:
			wzero = i[0]
	if i[2] == 2:
		if w  >= i[0]:
			w = i[0]
	if i[2] == 3:
		if hzero <= i[1]:
			hzero = i[1]
	if i[2] == 4:
		if h >= i[1]:
			h = i[1]
ans = (h-hzero)*(w-wzero)
print(ans if ans>=0 else 0)

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
WX = [0, W]
HY = [0, H]
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        WX[0] = x
    elif a == 2:
        WX[1] = x
    elif a == 3:
        HY[0] = y
    elif a == 4:
        HY[1] = y
if WX[1]-WX[0] < 0 or HY[1]-HY[0] < 0:
    print(0)
else:
    print((WX[1]-WX[0])*(HY[1]-HY[0]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

init_w, init_h, init_w2, init_h2 = 0,0,w,h
for i in range(n):
  x, y, a = list(map(int,input().split()))
  
  if a ==1:
    init_w = max([x, init_w])
  elif a==2:
    init_w2 = min([x, init_w2])
  elif a==3:
    init_h = max([y, init_h])
  elif a==4:
    init_h2 = min([y, init_h2])

area = (init_w2-init_w)*(init_h2-init_h)
if area<=0:
  area = 0
print(area)

Submission status: Wrong Answer

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

init_w, init_h, init_w2, init_h2 = 0,0,w,h
for i in range(n):
  x, y, a = list(map(int,input().split()))
  
  if a ==1:
    init_w = x
  elif a==2:
    init_w2 = x
  elif a==3:
    init_h = y
  elif a==4:
    init_h2 = y

area = (init_w2-init_w)*(init_h2-init_h)
if area<=0:
  area = 0
print(area)

Submission status: Wrong Answer

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

init_w, init_h, init_w2, init_h2 = 0,0,w,h
for i in range(n):
  x, y, a = list(map(int,input().split()))
  
  if a ==1:
    init_w = x
  elif a==2:
    init_w2 = x
  elif a==3:
    init_h = y
  elif a==4:
    init_h2 = y

area = (init_w2-init_w)*(init_h2-init_h)
    
print(area)

Submission status: Wrong Answer

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

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

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

print(max((xy[0][1]-xy[0][0])*(xy[1][1]-xy[1][0]),0))

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
P = [list(map(int, input().split())) for i in range(N)]
X1, X2, Y1, Y2 = 0, W, 0, H

for i in range(N):
    if P[i][2] == 1:  # ai=1
        X1 = P[i][0]
    elif P[i][2] == 2:  # ai=2
        X2 = P[i][0]
    elif P[i][2] == 3:  # ai=3
        Y1 = P[i][1]
    elif P[i][2] == 4:  # ai=4
        Y2 = P[i][1]

if X1 < X2 and Y1 < Y2:
    S = (X2 - X1) * (Y2 - Y1)
else:
    S = 0
print(S)

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter

bw, bh = 0, 0
w, h, n = map(int, input().split())
xya_array = [list(map(int, input().split())) for _ in range(n)]

for i in xya_array:
    if i[2] == 1:
        if bw < i[0]:
            bw = i[0]
    elif i[2] == 2:
        if w > i[0]:
            w = i[0]
    elif i[2] == 3:
        if bh < i[1]:
            bh = i[1]
    elif i[2] == 4:
        if h > i[1]:
            h = i[1]
    #print(i[1], w-bw, h-bh)

ans = (w-bw)*(h-bh)

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter

bw, bh = 0, 0
w, h, n = map(int, input().split())
xya_array = [list(map(int, input().split())) for _ in range(n)]

for i in xya_array:
    if i[2] == 1:
        if bw < i[0]:
            bw = i[0]
    elif i[2] == 2:
        if w > i[0]:
            w = i[0]
    elif i[2] == 3:
        if bh < i[1]:
            bh = i[1]
    elif i[2] == 4:
        if h > i[1]:
            h = i[1]
    #print(i[1], w-bw, h-bh)

tmp_ans = (w-bw)*(h-bh)

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

Submission status: Wrong Answer

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

x1 = W
x2 = 0
y3 = H
y4 = 0
for x,y,a in xya:
    if a == 1:
        x1 = min(x1, x)
    elif a == 2:
        x2 = max(x2, x)
    elif a == 3:
        y3 = min(y3, y)
    elif a == 4:
        y4 = max(y4, y)
else:
    if x1 <= x2 or y3 <= y4:
        print(0)
    else:
        print((x1-x2) * (y3-y4))

Submission status: Wrong Answer

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

x1 = W
x2 = 0
y3 = H
y4 = 0
for x,y,a in xya:
    if a == 1:
        x1 = min(x1, x)
    elif a == 2:
        x2 = max(x2, x)
    elif a == 3:
        y3 = min(y3, y)
    elif a == 4:
        y4 = max(y4, y)

print((x1-x2) * (y3-y4))

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
xl, xh = (0, W)
yl, yh = (0, H)
for i in range(N):
    x, y, a = map(int, input().split())
    xl = max(xl, x) if (a==1) else xl
    xh = min(xh, x) if (a==2) else xh
    yl = max(yl, y) if (a==3) else yl
    yh = min(yh, y) if (a==4) else yh
print((xh-xl)*(yh-yl))

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] = max(rec[0], x)
    if a == 2:
        rec[2] = min(rec[2], x)
    if a == 3:
        rec[1] = max(rec[1], y)
    if a == 4:
        rec[3] = min(rec[3], y)
print((rec[2]-rec[0])*(rec[3]-rec[1]))

Submission status: Wrong Answer

Solution code:


def read_input():
    w, h, n = map(int, input().split())

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

    return w, h, n, points


def submit():
    w, h, n, points = read_input()

    area_x = [0, w]
    area_y = [0, h]

    for point in points:
        if point[2] == 1:
            if area_x[0] < point[0]:
                area_x[0] = point[0]
            continue

        if point[2] == 2:
            if point[0] < area_x[1]:
                area_x[1] = point[0]
            continue

        if point[2] == 3:
            if area_y[0] < point[1]:
                area_y[0] = point[1]
            continue

        if point[2] == 4:
            if point[1] < area_y[1]:
                area_y[1] = point[1]
            continue

    area = (area_x[1] - area_x[0]) * (area_y[1] - area_y[0])
    if area < 0:
        print(0)
    else:
        print(area)

if __name__ == '__main__':
    submit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
[W,H,N] = list(map(int,input().split()))
minx = 0
maxx = W
miny = 0
maxy = H
for i in range(N):
    [x,y,a] = list(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)
print(max(0,(maxx-minx)*(maxy-miny)))