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=[int(i) for i in input().split()]
a1=[0]
a2=[w]
a3=[0]
a4=[h]
for i in range(n):
    x,y,a=[int(j) for j in input().split()]
    if a==1:
        a1.append(x)
    elif a==2:
        a2.append(x)
    elif a==3:
        a3.append(y)
    else:
        a4.append(y)
a1.sort()
a2.sort()
a3.sort()
a4.sort()
ans=(a2[0]-a1[-1])*(a4[0]-a3[-1])
print(ans if ans>=0 else 0)

Submission status: Wrong Answer

Solution code:
w,h,n=[int(i) for i in input().split()]
a1=[0]
a2=[w]
a3=[0]
a4=[h]
for i in range(n):
    x,y,a=[int(i) for i in input().split()]
    if a==1:
        a1.append(x)
    elif a==2:
        a2.append(x)
    elif a==3:
        a3.append(y)
    else:
        a4.append(y)
ans=(sorted(a1)[-1]-sorted(a2)[0])*(sorted(a3)[-1]-sorted(a4)[0])
print(ans if ans>=0 else 0)

Submission status: Wrong Answer

Solution code:
w,h,n=[int(i) for i in input().split()]
a1=[0]
a2=[w]
a3=[0]
a4=[w]
for i in range(n):
    x,y,a=[int(i) for i in input().split()]
    if a==1:
        a1.append(x)
    elif a==2:
        a2.append(x)
    elif a==3:
        a3.append(y)
    else:
        a4.append(y)
ans=(sorted(a1)[-1]-sorted(a2)[0])*(sorted(a3)[-1]-sorted(a4)[0])
print(ans if ans>=0 else 0)

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

Submission status: Wrong Answer

Solution code:
right, top, n = map(int, input().split())
list = [list(map(int, input().split())) for i in range(n)]
bottom, left = 0, 0

for i in range(n):
    if list[i][2] == 1:
        left = max(list[i][0], left)
    elif list[i][2] == 2:
        right = min(list[i][0], right)
    elif list[i][2] == 3:
        bottom = max(list[i][1], bottom)
    else:
        top = min(list[i][1], top)

area = (top - bottom) * (right - left)

print(area if area > 0 else 0)

Submission status: Wrong Answer

Solution code:
w,h,n = map(int,input().split())
pos_list = [map(int,input().split()) for _ in range(n)]
s = [0,0]
f = [w,h]
for x,y,a in pos_list:
    if a == 1:
        s[0] = max(s[0],x)
    elif a == 2:
        f[0] = min(f[0],x)
    elif a == 3:
        s[1] = max(s[1],y)
    elif a == 4:
        f[1] = min(f[1],y)

ans = (f[0]-s[0])*(f[1]-s[1])
if ans <= 0:
    print(0)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
w,h,n = map(int,input().split())
pos_list = [map(int,input().split()) for _ in range(n)]
s = [0,0]
f = [w,h]
for x,y,a in pos_list:
    if a == 1:
        if s[0] < x: s[0] = x
    elif a == 2:
        if f[0] > x: f[0] = x
    elif a == 3:
        if s[1] < y: s[1] = y
    elif a == 4:
        if f[0] > y: f[1] = y

if f[0]-s[0] <= 0 or f[1] - s[1] <= 0:
    print(0)
else:
    print((f[0]-s[0])*(f[1]-s[1]))

Submission status: Wrong Answer

Solution code:
w,h,n = map(int,input().split())
pos_list = [map(int,input().split()) for _ in range(n)]
s = [0,0]
f = [w,h]
for x,y,a in pos_list:
    if a == 1:
        if s[0] < x: s[0] = x
    elif a == 2:
        if f[0] > x: f[0] = x
    elif a == 3:
        if s[1] < y: s[1] = y
    elif a == 4:
        if f[0] > y: f[1] = y

ans = (f[0]-s[0])*(f[1]-s[1])
if ans <= 0:
    print(0)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
w,h,n = map(int,input().split())
pos_list = [map(int,input().split()) for _ in range(n)]
s = [0,0]
f = [w,h]
for x,y,a in pos_list:
    if a == 1:
        if s[0] < x: s[0] = x
    elif a == 2:
        if f[0] > x: f[0] = x
    elif a == 3:
        if s[1] < y: s[1] = y
    elif a == 4:
        if f[0] > y: f[1] = y

ans = (f[0]-s[0])*(f[1]-s[1])
if ans < 0:
    print(0)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
w,h,n = map(int,input().split())
pos_list = [map(int,input().split()) for _ in range(n)]
s = [0,0]
f = [w,h]
for x,y,a in pos_list:
    if a == 1:
        s[0] = x
    elif a == 2:
        f[0] = x
    elif a == 3:
        s[1] = y
    elif a == 4:
        f[1] = y

ans = (f[0]-s[0])*(f[1]-s[1])
if ans < 0:
    print(0)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
W,H,N=map(int,input().split())
wide=[0,W]
height=[0,H]
# white sphere calculate
for i in range(N):
    x,y,a=map(int,input().split())
    if a==1:
        wide[0]=max(wide[0],x)
    elif a==2:
        wide[1]=min(wide[1],x)
    elif a==3:
        height[0]=max(height[0],y)
    elif a==4:
        height[1]=min(height[1],y)
w_len=wide[1]-wide[0]
h_len=height[1]-height[0]
s=w_len*h_len
if s>=0:
    print(s)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
w,h,n = (int(i) for i in input().split())
sq = [0,0,w,h]
#x1,y1 x2,y2
for j in range(n):
  x,y,a = (int(k) for k in input().split())
  if a == 1 and sq[0] < x:
    sq[0] = x
  elif a == 2 and sq[2] > x:
    sq[2] = x
  elif a == 3 and sq[1] < y:
    sq[1] = y
  elif a == 4 and sq[3] > y:
    sq[3] = y
answer = (sq[2]-sq[0])*(sq[3]-sq[1])
print(answer if answer > 0 else 0)

Submission status: Wrong Answer

Solution code:
w,h,n = (int(i) for i in input().split())
sq = [0,0,w,h]
#x1,y1 x2,y2
for j in range(n):
  x,y,a = (int(k) for k in input().split())
  if a == 1:
    sq[0] = x
  elif a == 2:
    sq[2] = x
  elif a == 3:
    sq[1] = y
  else:
    sq[3] = y
answer = (sq[2]-sq[0])*(sq[3]-sq[1])
print(answer if answer > 0 else 0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#import pprint
w,h,n=map(int,input().split())
x=[]
y=[]
a=[]
for i in range(n):
    xi,yi,ai=map(int,input().split())
    x.append(xi)
    y.append(yi)
    a.append(ai)

dot = [[0] * w for i in range(h)]
#pprint.pprint(dot,width=60)

for i in range(n):
    if a[i] == 1:
        for j in range(x[i]):
            for k in range(h):
                print(k,j)
                dot[k][j]=1
    if a[i] == 2:
        for j in range(x[i],w):
            for k in range(h):
                dot[k][j]=1
    if a[i] == 3:
        for j in range(y[i]):
            for k in range(w):
                dot[j][k]=1
    if a[i] == 4:
        for j in range(y[i],h):
            for k in range(w):
                print(j,k)
                dot[j][k]=1
    #pprint.pprint(dot,width=60)

print(sum(dot,[]).count(0))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
W,H,N = map(int,input().split())
xl = yd = 0
xr = W
yu = H
for _ in range(N):
    X,Y,A = map(int,input().split())
    if A == 1:xl = max(X,xl)
    elif A == 2:xr = min(X,xr)
    elif A == 3:yd = max(Y,yd)
    elif A == 4:zyu = min(Y,yu)
print(max(0,((xr-xl) * (yu-yd))))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
w,h,n=input().split()
W=int(w)
H=int(h)
N=int(n)
x=[]
y=[]
a=[]
for i in range(N):
  s=input().split()
  x.append(int(s[0]))
  y.append(int(s[1]))
  a.append(int(s[2]))
w=[0,0,0,0]
for i in range(N):
  if a[i]==1:
    w[0]=max(w[0],x[i])
  elif a[i]==2:
    w[1]=min(w[1],x[i])
  elif a[i]==3:
    w[2]=max(w[2],y[i])
  else:
    w[3]=min(w[3],y[i])
if w[1]-w[0]<=0 or w[3]-w[2]<=0:
  S=0
else:
  S=(w[1]-w[0])*(w[3]-w[2])
print(S)

Submission status: Wrong Answer

Solution code:
w,h,n=input().split()
W=int(w)
H=int(h)
N=int(n)
x=[]
y=[]
a=[]
for i in range(N):
  s=input().split()
  x.append(int(s[0]))
  y.append(int(s[1]))
  a.append(int(s[2]))
w=[0,0,0,0]
for i in range(N):
  if a[i]==1:
    w[0]=max(w[0],x[i])
  elif a[i]==2:
    w[1]=min(w[1],x[i])
  elif a[i]==3:
    w[2]=max(w[2],y[i])
  else:
    w[3]=min(w[3],y[i])
if w[1]-w[0]<=0 or w[3]-w[2]<=0:
  S=0
else:
  S=(w[0]-w[1])*(w[2]-w[3])
print(S)

Submission status: Wrong Answer

Solution code:
w,h,n=input().split()
W=int(w)
H=int(h)
N=int(n)
x=[]
y=[]
a=[]
S=W*H
for i in range(N):
  s=input().split()
  x.append(int(s[0]))
  y.append(int(s[1]))
  a.append(int(s[2]))
w=[0,0,0,0]
for i in range(N):
  if a[i]==1:
    w[0]=min(w[0],x[i])
  elif a[i]==2:
    w[1]=max(w[1],x[i])
  elif a[i]==3:
    w[2]=min(w[2],y[i])
  else:
    w[3]=max(w[3],y[i])
if w[0]-w[1]<=0 or w[2]-w[3]<=0:
  S=0
else:
  S=(w[0]-w[1])*(w[2]-w[3])
print(S)

Submission status: Wrong Answer

Solution code:
w,h,n=input().split()
W=int(w)
H=int(h)
N=int(n)
x=[]
y=[]
a=[]
S=W*H
for i in range(N):
  s=input().split()
  x.append(int(s[0]))
  y.append(int(s[1]))
  a.append(int(s[2]))
for i in range(N):
  if a[i]==1:
    W-=x[i]
    for j in range(N):
      x[j]-=x[i]
  elif a[i]==2:
    W=x[i]
  elif a[i]==3:
    H-=y[i]
    for j in range(N):
      y[j]-=y[i]
  else:
    H=y[i]
  S=W*H
  if S<=0:
    S=0
    break
print(S)

Submission status: Wrong Answer

Solution code:
w,h,n=input().split()
W=int(w)
H=int(h)
N=int(n)
x=[]
y=[]
a=[]
S=W*H
for i in range(N):
  s=input().split()
  x.append(int(s[0]))
  y.append(int(s[1]))
  a.append(int(s[2]))
for i in range(N):
  if a[i]==1:
    W-=x[i]
  elif a[i]==2:
    W=x[i]
  elif a[i]==3:
    H-=y[i]
  else:
    H=y[i]
  S=W*H
  if S<=0:
    S=0
    break
print(S)

Submission status: Wrong Answer

Solution code:
w,h,n=input().split()
W=int(w)
H=int(h)
N=int(n)
x=[]
y=[]
a=[]
S=W*H
for i in range(N):
  s=input().split()
  x.append(int(s[0]))
  y.append(int(s[1]))
  a.append(int(s[2]))
for i in range(N):
  if a[i]==1:
    W-=x[i]
  elif a[i]==2:
    W=x[i]
  elif a[i]==3:
    H-=y[i]
  else:
    H=y[i]
  S=W*H
  if S<=0:
    break
if H<=0 or W<=0:
    S=0
print(S)

Submission status: Wrong Answer

Solution code:
w,h,n=input().split()
W=int(w)
H=int(h)
N=int(n)
x=[]
y=[]
a=[]
S=W*H
for i in range(N):
  s=input().split()
  x.append(int(s[0]))
  y.append(int(s[1]))
  a.append(int(s[2]))
for i in range(N):
  if a[i]==1:
    W-=x[i]
  elif a[i]==2:
    W=x[i]
  elif a[i]==3:
    H-=y[i]
  else:
    H=y[i]
  S=W*H
if H<=0 or W<=0:
    S=0
print(S)

Submission status: Wrong Answer

Solution code:
w,h,n=input().split()
W=int(w)
H=int(h)
N=int(n)
x=[]
y=[]
a=[]
S=W*H
for i in range(N):
  s=input().split()
  x.append(int(s[0]))
  y.append(int(s[1]))
  a.append(int(s[2]))
for i in range(N):
  if a[i]==1:
    S-=x[i]*H
    W-=x[i]
  elif a[i]==2:
    S-=(W-x[i])*H
    W=x[i]
  elif a[i]==3:
    S-=y[i]*W
    H-=y[i]
  else:
    S-=(H-y[i])*W
    H=y[i]
if H<=0 or W<=0:
    S=0
print(S)

Submission status: Wrong Answer

Solution code:
w,h,n=input().split()
W=int(w)
H=int(h)
N=int(n)
x=[]
y=[]
a=[]
S=W*H
for i in range(N):
  s=input().split()
  x.append(int(s[0]))
  y.append(int(s[1]))
  a.append(int(s[2]))
for i in range(N):
  if H<=0 or W<=0:
    S=0
    break
  if a[i]==1:
    S-=x[i]*H
    W-=x[i]
  elif a[i]==2:
    S-=(W-x[i])*H
    W=x[i]
  elif a[i]==3:
    S-=y[i]*W
    H-=y[i]
  else:
    S-=(H-y[i])*W
    H=y[i]
print(S)

Submission status: Wrong Answer

Solution code:
w,h,n=input().split()
W=int(w)
H=int(h)
N=int(n)
x=[]
y=[]
a=[]
S=W*H
for i in range(N):
  s=input().split()
  x.append(int(s[0]))
  y.append(int(s[1]))
  a.append(int(s[2]))
for i in range(N):
  if H<=0 or W<=0:
    S=0
    break
  if a[i]==1:
    S-=x[i]*H
    W-=x[i]
  elif a[i]==2:
    S-=(W-x[i])*H
    W=x[i]
  elif a[i]==2:
    S-=y[i]*W
    H-=y[i]
  else:
    S-=(H-y[i])*W
    H=y[i]
print(S)

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)

    ans = (maxx - minx) * (maxy - miny)

print(0 if ans < 0 else ans)

Submission status: Wrong Answer

Solution code:
whn = list (map(int, input().split()))
x = 0
y = 0
flag = 0

for i in range(whn[2]):
    xya = list(map(int,input().split()))
    if xya[2] == 1:
        x = max(x, xya[0])
        #print('x=',x)
    elif xya[2] == 2:
        whn[0] = min(whn[0], xya[0])
        #print('w=',whn[0])
    elif xya[2] == 3:
        y = max(y, xya[0])
        #print('y=',y)
    else:
        whn[1] = min(whn[1], xya[1])
        #print('h=', whn[1])
    if x >= whn[0] or y >= whn[1]:
        print(0)
        flag += 1
        break
        
if flag == 0:
    print((whn[0]-x)*(whn[1]-y))

Submission status: Wrong Answer

Solution code:
whn = list (map(int, input().split()))
x = 0
y = 0

for i in range(whn[2]):
    if x >= whn[0] or y >= whn[1]:
        print(0)
        break
    xya = list(map(int,input().split()))
    if xya[2] == 1:
        x = max(x, xya[0])
    elif xya[2] == 2:
        whn[0] = min(whn[0], xya[0])
    elif xya[2] == 3:
        y = max(y, xya[0])
    else:
        whn[1] = min(whn[1], xya[1])

print((whn[0]-x)*(whn[1]-y))

Submission status: Wrong Answer

Solution code:
whn = list (map(int, input().split()))
x = 0
y = 0

for i in range(whn[2]):
    xya = list(map(int,input().split()))
    if xya[2] == 1:
        x = max(x, xya[0])
    elif xya[2] == 2:
        whn[0] = min(whn[0], xya[0])
    elif xya[2] == 3:
        y = max(y, xya[0])
    else:
        whn[1] = min(whn[1], xya[1])

print((whn[0]-x)*(whn[1]-y))

Submission status: Wrong Answer

Solution code:
import numpy as np
H,W,N = map(int,input().split())
arr = np.zeros((H,W))
for i in range(N):
    x,y,a = map(int,input().split())
    if a == 1 :
        arr[:,:x] = 1
    elif a == 2:
        arr[:,x:] = 1
    elif a == 3 :
        y = H-y
        arr[y:,:] = 1
    else :
        y = H-y
        arr[:y,:] = 1
    
print(int(H*W - arr.sum()))

Submission status: Wrong Answer

Solution code:
from numpy import*;I=lambda:map(int,input().split());W,H,N=I();m=zeros((H,W))
for i in range(N):x,y,a=I();m[y*(a>3):y*(a==3)or H,x*(a==2):x*(a<2)or W]=1
print(W*H-int(sum(m)))

Submission status: Wrong Answer

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

for _ in range(n):
    *a, = map(int, input().split())
    b[a[2]-1] = a[int(a[2]/3)]
print(max((b[1]-b[0]), 0)*max((b[3]-b[2]), 0))

Submission status: Wrong Answer

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

for _ in range(n):
    *a, = map(int, input().split())
    b[a[2]-1] = a[a[2]//3]
print(max((b[1]-b[0]), 0)*max((b[3]-b[2]), 0))

Submission status: Wrong Answer

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

for _ in range(n):
    *a, = map(int, input().split())
    b[a[2]-1] = a[a[2]//3]
print((b[1]-b[0])*(b[3]-b[2]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print((w - x0) * (h - y0))

Submission status: Wrong Answer

Solution code:
w, h, n = map(int, input().split())
startX, startY = 0, 0
index=0
while index < n:
    x, y, a=map(int, input().split())
    if a == 1:
        if startX < x:
            startX = x
    elif a == 2:
        if w > x:
            w=x
    elif a == 3:
        if startY < y:
            startY = y
    else:
        if h > y:
            h=y
    index+=1
if (w-startX)*(h-startY) > 0:
    print((w-startX)*(h-startY))
else:
    print(0)

Submission status: Wrong Answer

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

ld = [0,0]
ru = [W,H]

flag = True
for x,y,a in xya:
    if a == 1:
        ld[0] = x
    if a == 2:
        ru[0] = x
    if a == 3:
        ld[1] = y
    if a == 4:
        ru[1] = y
    tate = ru[1] - ld[1]
    yoko = ru[0] - ld[0]
    if tate <= 0 or yoko <= 0:
        flag = False
        break

if flag:
    print(tate*yoko)
else:
    print(0)

Submission status: Wrong Answer

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

ld = [0,0]
lu = [0,H]
ru = [W,H]
rd = [W,0]

flag = True
for x, y, a in xya:
    if a == 1:
        lu[0] = ld[0] = x
    elif a == 2:
        ru[0] = rd[0] = x
    elif a == 3:
        ld[1] = rd[1] = y
    else:
        lu[1] = ru[1] = y
    tate = lu[1]-ld[1]
    yoko = rd[0]-ld[0]
    if tate <= 0 or yoko <= 0:
        flag = False
        break

if flag:
    print(tate*yoko)
else:
    print(0)

Submission status: Wrong Answer

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

ld = [0,0]
lu = [0,H]
ru = [W,H]
rd = [W,0]

flag = True
for x, y, a in xya:
    if a == 1:
        lu[0] = ld[0] = x
    elif a == 2:
        ru[0] = rd[0] = x
    elif a == 3:
        ld[1] = rd[1] = y
    else:
        lu[1] = ru[1] = y
    tate = lu[1]-ld[1]
    yoko = rd[0]-ld[0]
    if tate < 0 or yoko < 0:
        flag = False

if flag:
    print(tate*yoko)
else:
    print(0)

Submission status: Wrong Answer

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

ld = [0,0]
lu = [0,H]
ru = [W,H]
rd = [W,0]

for x, y, a in xya:
    if a == 1:
        lu[0] = ld[0] = x
    elif a == 2:
        ru[0] = rd[0] = x
    elif a == 3:
        ld[1] = rd[1] = y
    else:
        lu[1] = ru[1] = y

tate = lu[1]-ld[1]
yoko = rd[0]-ld[0]
if tate > 0 and yoko > 0:
    print(tate*yoko)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
w,h,n=map(int,input().split())
l=[[int(j) for j in input().split()] for i in range(n)]
b=c=0
d=w
e=h
for i in range(n):
    a=l[i][2]
    if a==1:b=max(b,l[i][0])
    if a==2:d=min(d,l[i][0])
    if a==3:c=max(c,l[i][1])
    if a==4:e=min(e,l[i][1])
print(max((d-b)*(e-c),0))

Submission status: Wrong Answer

Solution code:
w,h,n=map(int,input().split())
l=[[int(j) for j in input().split()] for i in range(n)]
b=c=0
d=w
e=h
for i in range(n):
    a=l[i][2]
    if a==1:b=max(b,l[i][0])
    if a==2:d=min(d,l[i][0])
    if a==3:c=max(c,l[i][1])
    if a==4:e=min(e,l[i][1])
print(max((b-d)*(c-e),0))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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)
x0,x1,y0,y1 = 0,W,0,H
for i in range(N):
    if A[i]==1:
        x0 = max(x0,X[i])
    elif A[i]==2:
        x1 = min(x1,X[i])
    elif A[i]==3:
        y0 = max(y0,Y[i])
    else:
        y1 = min(y1,Y[i])

print(max(0,(x1-x0)*(y1-y0)))

Submission status: Wrong Answer

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

x1 = 0
y1 = 0
x2 = a
y2 = 0
x3 = a
y3 = b
x4 = 0
y4 = b

count=0

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

    if(n == 1):
        x1 = x
        x4 = x
    elif(n == 2):
        x2 = x
        x3 = x
    elif(n == 3):
        y1 = y
        y2 = y
    else:
        y3 = y
        y4 = y

    area = (x2 - x1)*(y3 - y2)
    if(area<=0 or x2 - x1<=0 or y3 - y2 <= 0):
        print(0)
        count+=1
        break
if(count!=1):
    print(area)

Submission status: Wrong Answer

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

x1 = 0
y1 = 0
x2 = a
y2 = 0
x3 = a
y3 = b
x4 = 0
y4 = b

count=0

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

    if(n == 1):
        x1 = x
        x4 = x
    elif(n == 2):
        x2 = x
        x3 = x
    elif(n == 3):
        y1 = y
        y2 = y
    else:
        y3 = y
        y4 = y

    area = (x2 - x1)*(y3 - y2)
    if(area<=0):
        print(0)
        count+=1
        break
if(count!=1):
    print(area)

Submission status: Wrong Answer

Solution code:
def inpl(): return list(map(int, input().split()))

W, H, N = inpl()
l, r, d, u = 0, W, 0, H

for _ in range(N):
    x, y, a = inpl()
    if a == 1:
        l = max(l, x)
    elif a == 2:
        r = min(r, x)
    elif a == 3:
        d = max(d, y)
    else:
        assert a == 4
        u = min(u, y)
print((r-l)*(u-d))

Submission status: Wrong Answer

Solution code:
def inpl(): return list(map(int, input().split()))

W, H, N = inpl()
l, r, d, u = 0, W, 0, H

for _ in range(N):
    x, y, a = inpl()
    if a == 1:
        l = max(l, a)
    elif a == 2:
        r = min(r, a)
    elif a == 3:
        d = max(d, a)
    else:
        assert a == 4
        u = min(u, a)
print((r-l)*(u-d))

Submission status: Wrong Answer

Solution code:
x,y,n = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(n)]
a,b,c,d = [0,0],[x,0],[x,y],[0,y]

for i in range(n):
    if A[i][2] == 1:
        if A[i][0] >= b[0]:
            print(0)
            break
        else:
            a[0] = max(A[i][0],a[0])
            d[0] = a[0]
    if A[i][2] == 2:
        if A[i][0] <= a[0]:
            print(0)
            break
        else:
            b[0] = min(A[i][0],b[0])
            c[0] = b[0]
    if A[i][2] == 3:
        if A[i][1] >= d[1]:
            print(0)
            break
        else:
            a[1] = max(A[i][1],a[1])
            b[1] = a[1]
    if A[i][2] == 4:
        if A[i][1] <= a[1]:
            print(0)
            break
        else:
            c[1] = min(A[i][1],c[1])
            d[1] = c[1]

print((b[0]-a[0])*(d[1]-a[1]))

Submission status: Wrong Answer

Solution code:
x,y,n = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(n)]
a,b,c,d = [0,0],[x,0],[x,y],[0,y]
flag = 0
for i in range(n):
    if A[i][2] == 1:
        if A[i][0] >= b[0]:
            print(0)
            flag = 1
            break
        else:
            a[0] = A[i][0]
            d[0] = A[i][0]
    if A[i][2] == 2:
        if A[i][0] <= a[0]:
            print(0)
            flag = 1
            break
        else:
            b[0] = A[i][0]
            c[0] = A[i][0]
    if A[i][2] == 3:
        if A[i][1] >= d[1]:
            print(0)
            flag = 1
            break
        else:
            a[1] = A[i][1]
            b[1] = A[i][1]
    if A[i][2] == 4:
        if A[i][1] <= a[1]:
            print(0)
            flag = 1
            break
        else:
            c[1] = A[i][1]
            d[1] = A[i][1]
if flag == 0:
    print((b[0]-a[0])*(d[1]-a[1]))

Submission status: Wrong Answer

Solution code:
x,y,n = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(n)]
a,b,c,d = [0,0],[x,0],[x,y],[0,y]
flag = 0
for i in range(n):
    if A[i][2] == 1:
        if A[i][0] >= b[0]:
            print(0)
            flag = 1
            break
        else:
            a[0] = A[i][0]
            d[0] = A[i][0]
    if A[i][2] == 2:
        if A[i][0] <= a[0]:
            print(0)
            flag = 1
            break
        else:
            b[0] = A[i][0]
            c[0] = A[i][0]
    if A[i][2] == 3:
        if A[i][1] >= d[1]:
            print(0)
            flag = 1
            break
        else:
            a[1] = A[i][1]
            b[1] = A[i][1]
    if A[i][2] == 4:
        if A[i][1] <= a[1]:
            print(0)
            flag = 1
            break
        else:
            c[1] = A[i][1]
            d[1] = A[i][1]
print((b[0]-a[0])*(d[1]-a[1]))

Submission status: Wrong Answer

Solution code:
x,y,n = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(n)]
a,b,c,d = [0,0],[x,0],[x,y],[0,y]
for i in range(n):
    if A[i][2] == 1:
        if A[i][0] >= b[0]:
            print(0)
            exit()
        else:
            a[0] = A[i][0]
            d[0] = A[i][0]
    if A[i][2] == 2:
        if A[i][0] <= a[0]:
            print(0)
            exit()
        else:
            b[0] = A[i][0]
            c[0] = A[i][0]
    if A[i][2] == 3:
        if A[i][1] >= d[1]:
            print(0)
            exit()
        else:
            a[1] = A[i][1]
            b[1] = A[i][1]
    if A[i][2] == 4:
        if A[i][1] <= a[1]:
            print(0)
            exit()
        else:
            c[1] = A[i][1]
            d[1] = A[i][1]
print((b[0]-a[0])*(d[1]-a[1]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
w,h,n = map(int,input().split())
s = [[1]*w]*h
for i in range(n):
    x,y,a = map(int,input().split())
    if a == 1:
        for j in range(h):
            for k in range(x):
                s[j][k-1] = 0
    elif a == 2:
        for j in range(h):
            for k in range(x,w):
                s[j][k-1] = 0
    elif a == 3:
        for j in range(y):
            for k in range(w):
                s[j-1][k] = 0
    elif a == 4:
        for j in range(y,h):
            for k in range(w):
                s[j-1][k] = 0
c = 0
for i in range(h):
    c += sum(s[i])
print(c)

Submission status: Wrong Answer

Solution code:
w,h,n = map(int,input().split())
s = [[1]*w]*h
for i in range(n):
    x,y,a = map(int,input().split())
    if a == 1:
        for j in range(h):
            for k in range(x):
                s[j-1][k-1] = 0
    elif a == 2:
        for j in range(h):
            for k in range(x,w):
                s[j-1][k-1] = 0
    elif a == 3:
        for j in range(y):
            for k in range(w):
                s[j-1][k-1] = 0
    elif a == 4:
        for j in range(y,h):
            for k in range(w):
                s[j-1][k-1] = 0
c = 0
for i in range(h):
    c += sum(s[i])
print(c)

Submission status: Wrong Answer

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