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 (j) for j in input().split())

w1=0
w2=w
h3=0
h4=h

for i in range(n):
    x,y,a=(int (j) for j in input().split())
    if a==1 and x>w1:
        w1=x
    elif a==2 and x<w2:
        w2=x
    elif a==3 and y>h3:
        h3=y
    elif a==4 and y<h4:
        h4=y

s=(w-w1-(w-w2))*(h-h3-(h-h4))

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

Submission status: Wrong Answer

Solution code:
w,h,n=(int (x) for x in input().split())

w1=0
w2=w
h3=0
h4=h

for i in range(n):
    x,y,a=(int (x) for x in input().split())
    if a==1 and x>w1:
        w1=x
    elif a==2 and x<w2:
        w2=x
    elif a==3 and y>h3:
        h3=y
    elif a==4 and y<h4:
        h4=y

s=(w-w1-(w-w2))*(h-h3-(h-h4))

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

Submission status: Wrong Answer

Solution code:
w, h, n = map(int, input().split())
wmin = 0
hmin = 0
wmax = w
hmax = h
for i in range(n):
    x, y, a = map(int, input().split())
    if a==1:
        wmax = max(wmax,x)
    elif a==2:
        wmin = min(wmin,x)
    elif a==3:
        hmax = max(hmax,y)
    elif a==4:
        hmin = min(hmin,y)
if wmax-wmin<0 or hmax-hmin<0:
    print(0)
else:
    print((wmax-wmin)*(hmax-hmin))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

w,h,n = map(int, input().split())
print(w,h)

area = [[0 for i in range(w)] for j in range(h)]

for i in range(n):
    a,b,c = map(int, input().split())
    if(c == 1):
        for j in range(h):
            for k in range(a):
                area[j][k] = 1
    if (c == 2):
        for j in range(h):
            for k in range(a,w):
                area[j][k] = 1
    if(c == 3):
        for j in range(b):
            for k in range(w):
                area[j][k] = 1
    if (c == 4):
        for j in range(b,h):
            for k in range(w):
                area[j][k] = 1

counter = 0

for i in range(h):
    for j in range(w):
        if(area[i][j] == 0):
            counter += 1

print(counter)

Submission status: Wrong Answer

Solution code:
W,H,N=map(int,input().split())
xM=W
xm=0
yM=H
ym=0
for i in range(N):
    a=list(map(int,input().split()))
    if a[2]==1:
        if a[0]>xm:
            xm=a[0]
        else:
            continue
    elif a[2]==2:
        if a[0]<xM:
            xM=a[0]
        else:
            continue
    elif a[2]==3:
        if a[1]>ym:
            ym=a[1]
        else:
            continue
    else:
        if a[1]<yM:
            yM=a[1]
        else: 
            continue
xl=xM-xm
yl=yM-ym
print(xl*yl)

Submission status: Wrong Answer

Solution code:
W,H,N=map(int,input().split())
xM=W
xm=0
yM=H
ym=0
for i in range(N):
    a=list(map(int,input().split()))
    if a[2]==1:
        if a[0]>xm:
            xm=a[0]
        else:
            xm=xm
    elif a[2]==2:
        if a[0]<xM:
            xM=a[0]
        else:
            xM=xM
    elif a[2]==3:
        if a[1]>ym:
            ym=a[1]
        else:
            ym=ym
    else:
        if a[1]<yM:
            yM=a[1]
        else: 
            yM=yM
xl=xM-xm
yl=yM-ym
print(xl*yl)

Submission status: Wrong Answer

Solution code:
W,H,N=map(int,input().split())
xM=W
xm=0
yM=H
ym=0
for i in range(N):
    a=list(map(int,input().split()))
    if a[2]==1:
        if a[0]>xm:
            xm=a[0]
        else:
            break
    elif a[2]==2:
        if a[0]<xM:
            xM=a[0]
        else:
            break
    elif a[2]==3:
        if a[1]>ym:
            ym=a[1]
        else:
            break
    else:
        if a[1]<yM:
            yM=a[1]
        else: 
            break
xl=xM-xm
yl=yM-ym
print(xl*yl)

Submission status: Wrong Answer

Solution code:
W,H,N=map(int,input().split())
xM=W
xm=0
yM=H
ym=0
for i in range(N):
    a=list(map(int,input().split()))
    if a[2]==1:
        if a[0]>xm:
            xm=a[0]
        else:
            continue
    elif a[2]==2:
        if a[0]<xM:
            xM=a[0]
        else:
            continue
    elif a[2]==3:
        if a[0]>ym:
            ym=a[0]
        else:
            continue
    else:
        if a[0]<yM:
            yM=a[0]
        else: 
            continue
xl=xM-xm
yl=yM-ym
print(xl*yl)

Submission status: Wrong Answer

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

for _ in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        # 黒の領域(x軸)を塗りつぶす
        w = max(w, x)
    elif a == 2:
        # 白の領域(x軸)を削る
        W = min(W, x)
    elif a == 3:
        # 黒の領域(y軸)を塗りつぶす
        h = max(h, y)
    else:
        # 白の領域(y軸)を削る
        H = min(H, y)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().rstrip().split())
xya = [list(map(int, input().rstrip().split())) for _ in range(N)]
xy = [[0]*H for _ in range(W)]
for i in xya:
    x_y = i[:2]
    a = i[2]
    if a == 1:
        for j in range(x_y[0]):
            xy[j] = list(map(lambda x: x+1, xy[j]))
    elif a == 2:
        for j in range(x_y[0],W):
            xy[j] = list(map(lambda x: x+1, xy[j]))
    elif a == 3:
        y = x_y[1]
        for j in range(W):
            for k in range(H):
                xy[j][k] += 1 if k <= y else 0  
    else:
        y = x_y[1]
        for j in range(W):
            for k in range(H):
                xy[j][k] += 1 if k >= y else 0
area = 0
for i in xy:
    area += i.count(0)
print(area)

Submission status: Wrong Answer

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

x=[0]*n
y=[0]*n
a=[0]*n
white=[0,h,w,0]
for i in range(n):
    line = list(map(int, input().split()))
    x[i] = line[0]
    y[i] = line[1]
    a[i] = line[2]

    if a[i] == 1:
        white[0] = max(white[0],x[i])
    elif a[i] == 2:
        white[2] = min(white[2], x[i])
    elif a[i] == 3:
        white[3] = max(white[3], y[i])
    elif a[i] == 4:
        white[1] = min(white[1], y[i])
        
print(max((white[2]-white[0]) * (white[1]-white[3]),0))

Submission status: Wrong Answer

Solution code:
w,h,n = map(int,input().split())
lo = [0,0]
hi = [w,h]
for i in range(n):
    a,b,x = map(int,input().split())
    if x == 1:
        if a >= lo[0]:
            lo[0] = a
    if x == 2:
        if a <= hi[0]:
            hi[0] = a

    if x == 3:
        if b >= lo[1]:
            lo[1] = b

    if x == 4:
        if b <= hi[1]:
            hi[1] = b
print(max(0,(hi[0]-lo[0])*(hi[1]-lo[1]) ))

Submission status: Wrong Answer

Solution code:
w,h,n = map(int,input().split())
lo = [0,0]
hi = [w,h]
for i in range(n):
    a,b,x = map(int,input().split())
    if x == 1:
        if a > lo[0]:
            lo[0] = a
    if x == 2:
        if a < hi[0]:
            hi[0] = a

    if x == 3:
        if b > lo[1]:
            lo[1] = b

    if x == 4:
        if b < hi[1]:
            hi[1] = b
print(max(0,(hi[0]-lo[0])*(hi[1]-lo[1]) ))

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

W, H, N = MAP()
xya = [LIST() for _ in range(N)]

right = W
left = 0
top = H
bottom = 0

for x, y, a in xya:
	if a == 1 and left < x < right:
		left = x
	elif a == 2 and left < x < right:
		right = x
	elif a == 3 and bottom < y < top:
		bottom = y
	elif a == 4 and bottom < y < top:
		top = y
	else:
		pass
S = (right-left)*(top-bottom)
if S <= 0:
	S = 0
print(S)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

W, H, N = MAP()
xya = [LIST() for _ in range(N)]

right = W
left = 0
top = H
bottom = 0

for x, y, a in xya:
	if a == 1:
		left = x
	elif a == 2:
		right = x
	elif a == 3:
		bottom = y
	else:
		top = y
S = (right-left)*(top-bottom)
if S <= 0:
	S = 0
print(S)

Submission status: Wrong Answer

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

x0, y0, x1, y1 = 0, 0, W, H
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        x0 = x
    elif a == 2:
        x1 = x
    elif a == 3:
        y0 = y
    else:
        y1 = y

if x1-x0<0 or y1-y0<0:
    print(0)
else:
    print((x1-x0)*(y1-y0))

Submission status: Wrong Answer

Solution code:
from functools import reduce

def main():
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10

    # 1文字のみを読み込み
    # s = input().rstrip()
    
    # スペース区切りで標準入力を配列として読み込み
    # s = input().rstrip().split(' ')

    # 1文字ずつ標準入力を文字列として読み込み
    # s = list(input().rstrip())
    
    # 1文字ずつ標準入力を数値配列として読み込み
    # X = [int(_) for _ in input().split()]
    s = input().rstrip().split(' ')
    W = int(s[0])
    W_S = 0
    H = int(s[1])
    H_S = 0
    N = int(s[2])
    x = []
    y = []
    a = []
    for i in range(N):
        s = input().rstrip().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 and x[i]>W_S ):
            W_S = x[i]
        elif(a[i]==2 and x[i]<W ):
            W = x[i]
        elif(a[i]==3 and y[i]>H_S ):
            H_S = y[i]
        elif(a[i]==4 and y[i]<H ):
            H = y[i]        
    ans = (W-W_S) * (H-H_S)
    if ans < 0:
        ans = 0
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
x_1 = 0
y_1 = 0
x_2, y_2, N = map(int, input().split(" "))
for l in sys.stdin:
  x_i, y_i, a = map(int, l.split(" "))
  if a == 1:
    x_1 = x_i
    if x_2 == x_i:
      S = 0
      break
  elif a == 2:
    x_2 = x_i
    if x_1 == x_i:
      S = 0
      break
  elif a == 3:
    y_1 = y_i
    if y_2 == y_i:
      S = 0
      break
  elif a == 4:
    y_2 = y_i
    if y_2 == y_i:
      S = 0
      break
else:
	S = (x_2 - x_1) * (y_2 - y_1)
print(S)

Submission status: Wrong Answer

Solution code:
import sys
x_1 = 0
y_1 = 0
x_2, y_2, N = map(int, input().split(" "))
for l in sys.stdin:
  x_i, y_i, a = map(int, l.split(" "))
  if a == 1:
  	x_1 = x_i
  elif a == 2:
    x_2 = x_i
  elif a == 3:
    y_1 = y_i
  elif a == 4:
    y_2 = y_i
S = (x_2 - x_1) * (y_2 - y_1)
if S < 0:
  S = 0
print(S)

Submission status: Wrong Answer

Solution code:
w,h,n=map(int,input().split())
x_a=0
x_b=w
y_a=0
y_b=h

for i in range(n):
  x,y,z=map(int,input().split())
  if(z==1):
    x_a=max(x_a,x)
  elif(z==2):
    x_b=min(x_a,x)
  elif(z==3):
    y_a=max(y_a,y)
  elif(z==4):
    y_b=min(y_a,y)

if(x_b-x_a>0 and y_b-y_a>0):
  print((x_b-x_a)*(y_b-y_a))
else:
  print(0)

Submission status: Wrong Answer

Solution code:
w,h,n=map(int,input().split())
x_a=0
x_b=w
y_a=0
y_b=h

for i in range(n):
  x,y,z=map(int,input().split())
  if(z==1):
    x_a=max(x_a,x)
  elif(z==2):
    x_b=min(x_a,x)
  elif(z==3):
    y_a=max(y_a,y)
  elif(z==4):
    y_b=min(y_a,y)
    
print((x_b-x_a)*(y_b-y_a))

Submission status: Wrong Answer

Solution code:
p1=[0,0]
*p2,N=map(int,input().split())
for _ in range(N):
	x,y,a=map(int,input().split())
	if a==1 and p2[0] > x:
		p1[0]=x
	elif a==2 and p1[0] < x:
		p2[0]=x
	elif a==3 and p2[1] > y:
		p1[1]=y
	elif a==4 and p1[1] < y:
		p2[1]=y
	else:
		print(0)
		break
else:
	print((p2[0]-p1[0])*(p2[1]-p1[1]))

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
L = 0
R = W
D = 0
U = H

for i in range(N):
  x, y, a = map(int, input().split())
  if a == 1:
    L = max(L, x)
  if a == 2:
    R = min(R, x)
  if a == 3:
    D = max(D, y)
  if a == 4:
    U = min(U, y)
print(max((R-L)*(U-D), 0))

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    s = LI()
    if sum(s) ==  2*max(s):
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    w,h,n = LI()
    l,r = 0,w
    d,u = 0,h
    for i in range(n):
        x,y,a = LI()
        if a == 1:
            l = x
        elif a == 2:
            r = x
        elif a == 3:
            d = y
        else:
            u = y
    print(max(r-l,0)*max(u-d,0))
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    B()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
W, H, N = map(int, input().split())
x, y, a = [0] * N, [0] * N, [0] * N
for i in range(N):
    x[i], y[i], a[i] = map(int, input().split())
    
RU = [W, H]
LD = [0, 0]

i = 0
while i < N:
    if a[i] == 1:
        LD[0] = max(x[i], LD[0])
    elif a[i] == 2:
        RU[0] = min(x[i], RU[0])
    elif a[i] == 3:
        LD[1] = max(y[i], LD[1])
    else:
        RU[1] = min(y[i], RU[1])
    i += 1
        
    if RU[0] <= LD[0] or RU[1] <= LD[0]:
        print(0)
        break
if i == N:
    print((RU[0] - LD[0]) * (RU[1] - LD[1]))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
W, H, N = map(int, input().split())
x, y, a = [0] * N, [0] * N, [0] * N
for i in range(N):
    x[i], y[i], a[i] = map(int, input().split())
    
RU = [W, H]
LD = [0, 0]

while i < N:
    if a[i] == 1:
        LD[0] = max(x[i], LD[0])
    elif a[i] == 2:
        RU[0] = min(x[i], RU[0])
    elif a[i] == 3:
        LD[1] = max(y[i], LD[1])
    else:
        RU[1] = min(y[i], RU[1])
    i += 1
        
    if RU[0] <= LD[0] or RU[1] <= LD[0]:
        print(0)
        break
if i == N:
    print((RU[0] - LD[0]) * (RU[1] - LD[1]))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
W, H, N = map(int, input().split())
x, y, a = [0] * N, [0] * N, [0] * N
for i in range(N):
    x[i], y[i], a[i] = map(int, input().split())
    
RU = [W, H]
LD = [0, 0]

for i in range(N):
    if a[i] == 1:
        LD[0] = max(x[i], LD[0])
    elif a[i] == 2:
        RU[0] = min(x[i], RU[0])
    elif a[i] == 3:
        LD[1] = max(y[i], LD[1])
    else:
        RU[1] = min(y[i], RU[1])
        
if RU[0] <= LD[0] or RU[1] <= LD[0]:
    print(0)
else:
    print((RU[0] - LD[0]) * (RU[1] - LD[1]))

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
L = 0
D = 0
R = W
U = H

for i in range(N):
  x, y, a = map(int, input().split())
  if a == 1:
    L = max(L, x)
  if a == 2:
    R = min(R, x)
  if a == 3:
    D = max(D, y)
  if a == 4:
    U = min(U, y)
print(max((R-L)*(U-D), 0))

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
L, D = 0, 0
R = W
U = H

for i in range(N):
  x, y, a = map(int, input().split())
  if a == 1 :
    L = max(L, x)
  if a == 2:
    R = min(R, x)
  if a == 3:
    D = max(D, y)
  if a == 4:
    U = min(U, y)
print(max((R -L)*(U-D), 0))

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
L, D = 0, 0
R = W
U = H

for i in range(N):
  x, y, a = map(int, input().split())
  if a == 1:
    if L < x:
      L = x
  if a == 2:
    if R > x:
      R = x
  if a == 3:
    if D < y:
      D = y
  if a == 4:
    if U > y:
      U == y
print(max((R -L)*(U-D), 0))

Submission status: Wrong Answer

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

top, bottom, left, right = H, 0, 0, W
#print(top, bottom, left, right)
for x, y, a in I:
	if a == 1:
		if 0 <= x <= W:
			left = max(left, x)
	if a == 2:
		if 0 <= x <= W:
			right = min(right, x)
	if a == 3:
		if 0 <= y <= H:
			bottom = max(bottom, y)
	if a == 4:
		if 0 <= y <= H:
			top = min(top, y)
	#print(top, bottom, left, right)

print(max((top - bottom)*(right-left), 0))

Submission status: Wrong Answer

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

top, bottom, left, right = H, 0, 0, W
#print(top, bottom, left, right)
for x, y, a in I:
	if a == 1:
		left = max(left, x)
	if a == 2:
		right = min(right, x)
	if a == 3:
		bottom = max(bottom, y)
	if a == 4:
		top = min(top, y)
	#print(top, bottom, left, right)

print(max((top - bottom)*(right-left), 0))

Submission status: Wrong Answer

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

sx = 0
sy = 0
ex = w
ey = h
for x,y,a in xya:
    if a == 1:
        sx = max(sx,x)
    if a == 2:
        ex = min(ex,x)
    if a == 3:
        sy = max(sy,y)
    if a == 4:
        ey = min(ey,y)

print(max((ex-sx)*(ey-sy),0))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
W,H,N=list(map(int,input().split()))
ten=[list(map(int,input().split())) for _ in range(N)]
base=[[0,0,1],[0,0,3],[W,H,2],[W,H,4]]
ten.extend(base)
onemax=max(i[0] for i in ten if i[2]==1)
twomin=min(i[0] for i in ten if i[2]==2)
thrmax=max(i[1] for i in ten if i[2]==3)
foumin=min(i[1] for i in ten if i[2]==4)
if (twomin-onemax)>0 and (foumin-thrmax) >0:
    print((twomin-onemax)*(foumin-thrmax))
else:print()

Submission status: Wrong Answer

Solution code:
W,H,N=list(map(int,input().split()))
ten=[list(map(int,input().split())) for _ in range(N)]
base=[[0,0,1],[0,0,3],[W,H,2],[W,H,4]]
ten.extend(base)
onemax=max(i[0] for i in ten if i[2]==1)
twomin=min(i[0] for i in ten if i[2]==2)
thrmax=max(i[1] for i in ten if i[2]==3)
foumin=min(i[1] for i in ten if i[2]==4)
print(max((twomin-onemax)*(foumin-thrmax),0))

Submission status: Wrong Answer

Solution code:
W,H,N=list(map(int,input().split()))
ten=[list(map(int,input().split())) for _ in range(N)]
base=[[0,0,1],[0,0,3],[W,H,2],[W,H,4]]
ten.extend(base)
onemax=max(i[0] for i in ten if i[2]==1)
twomin=min(i[0] for i in ten if i[2]==2)
thrmax=max(i[1] for i in ten if i[2]==3)
foumin=min(i[1] for i in ten if i[2]==4)
print((twomin-onemax)*(foumin-thrmax))

Submission status: Wrong Answer

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

L, R = 0, W
D, T = 0, H

for i in range(N):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        if L < x:
            L = x
    elif a == 2:
        if x < R:
            R = x
    elif a == 3:
        if D < y:
            D = y
    elif a == 4:
        if y < T:
            T = y

if (R-L) * (T-D) > 0:
    print((R-L)*(T-D))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
W, H, N = list(map(int, input().split()))
input_list = []
for i in range(N):
    input_list.append(list(map(int, input().split())))
    
# 左下を原点とする座標をモデル化
C = [[0] * W] * H

# 塗りつぶしの座標を１とする
for col in input_list:
    if col[2] == 1:
        for w in range(len(C)):
            for h in range(len(C[w])):
                if W - w < col[0]:
                    C[w][h] = 1
    elif col[2] == 2:
        for w in range(len(C)):
            for h in range(len(C[w])):
                if W - w > col[0]:
                    C[w][h] = 1
    elif col[2] == 3:
        for w in range(len(C)):
            for h in range(len(C[w])):
                if h < col[1]:
                    C[w][h] = 1
    elif col[2] == 4:
        for w in range(len(C)):
            for h in range(len(C[w])):
                if h > col[1]:
                    C[w][h] = 1

# 2次元配列の1の要素の個数
cnt = 0
for col in C:
    cnt += col.count(0)
print(cnt)

Submission status: Wrong Answer

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

# 全ての座標を0とする二次元配列
C = [[0] * W] * H

# 塗りつぶしの座標を１とする
for col in input_list:
    if col[2] == 1:
        for w in range(len(C)):
            for h in range(len(C[w])):
                if w <= col[0]:
                    C[w][h] = 1
    elif col[2] == 2:
        for w in range(len(C)):
            for h in range(len(C[w])):
                if w >= col[0]:
                    C[w][h] = 1
    elif col[2] == 3:
        for w in range(len(C)):
            for h in range(len(C[w])):
                if h <= col[1]:
                    C[w][h] = 1
    elif col[2] == 4:
        for w in range(len(C)):
            for h in range(len(C[w])):
                if h >= col[1]:
                    C[w][h] = 1

# 2次元配列の1の要素の個数
cnt = 0
for col in C:
    cnt += col.count(1)
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

x1,x2,y1,y2=w,0,h,0

for i in range(n):
    if s[i][2] == 1:
        x2 = s[i][0]
    elif s[i][2] == 2:
        x1 = s[i][0]
    elif s[i][2] == 3:
        y2 = s[i][1]
    else:
        y1 = s[i][1]

if (x1 > x2) and (y1 > y2):
    print((x1-x2)*(y1-y2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import numpy as np

W, H, N = map(int, input().split())
xlist = np.zeros(N,dtype=int)
ylist = np.zeros(N,dtype=int)
alist = np.zeros(N,dtype=int)
for i in range(N):
    xlist[i], ylist[i], alist[i] = map(int, input().split())
rectangular = np.zeros((H, W))
for i in range(N):
    if alist[i] == 1:
        rectangular[:,:xlist[i]] = 1
    if alist[i] == 2:
        rectangular[:,xlist[i]:] = 1
    if alist[i] == 3:
        rectangular[:ylist[i],:] = 1
    if alist[i] == 4:
        rectangular[ylist[i]:,:] = 1
sum(sum(rectangular < 1))

Submission status: Wrong Answer

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

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

for x,y,a in p:
    if a == 1:
        xmin = x
    elif a == 2:
        xmax = x
    elif a == 3:
        ymin = y
    elif a == 4:
        ymax = y

result = (xmax-xmin) * (ymax-ymin)
if result < 0:
    result = 0

print(result)

Submission status: Wrong Answer

Solution code:
W, H, N = [int(x) for x in input().split()]
L = [[int(y) for y in input().split()] for _ in range(N)]
xmin = 0
xmax = W
ymin = 0
ymax = H

for i in range(N):
    if L[i][2] == 1 and L[i][0] > xmin:
        xmin = L[i][0]
    elif L[i][2] == 2 and L[i][0] < xmax:
        xmax = L[i][0]
    elif L[i][2] == 3 and L[i][1] > ymin:
        ymin = L[i][1]
    elif L[i][2] == 4 and L[i][1] < ymax:
        ymax = L[i][1]
print(max((xmax-xmin)*(ymax-ymin), 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)]

xl, xr, yl, yh = 0, W, 0, H

for xi, yi, ai in p:
  if ai == 1:
    if xl > xi:
      xl = xi
  if ai == 2:
    if xr < xi:
      xr = xi
  if ai == 3:
    if yl > yi:
      yl = yi
  if ai == 4:
    if yh < yi:
      yh = yi

if xr -xl < 0 or yh - yl < 0:
  ans = 0
else:
  ans = (xr - xl) * (yh - yl)
print(ans)

Submission status: Wrong Answer

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

xl, xr, yl, yh = 0, W, 0, H

for xi, yi, ai in p:
  if ai == 1:
    xl = xi
  if ai == 2:
    xr = xi
  if ai == 3:
    yl = yi
  if ai == 4:
    yh = yi

if xr -xl < 0 or yh - yl < 0:
  ans = 0
else:
  ans = (xr - xl) * (yh - yl)
print(ans)

Submission status: Wrong Answer

Solution code:
""" AtCoder """

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

w = 0
h = 0

for i in range(N):
    if xya[i][2] == 1:
        if w < xya[i][0]:
            w = xya[i][0]
    elif xya[i][2] == 2:
        if W > xya[i][0]:
            W = xya[i][0]
    elif xya[i][2] == 3:
        if h < xya[i][1]:
            h = xya[i][1]
    else:
        if H > xya[i][1]:
            H = xya[i][1]

ans = (H - h) * (W - w)

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

Submission status: Wrong Answer

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

sx, sy, ex, ey = 0, 0, W, H

for x, y, a in XYA:
    if a == 1:
        sx = x
    elif a == 2:
        ex = x
    elif a == 3:
        sy = y
    elif a == 4:
        ey = y
    
result = max(ex - sx, 0) * max(ey - sy, 0)
print(result)

Submission status: Wrong Answer

Solution code:
w,h,n = map(int,input().split())
paint = [list(map(int,input().split())) for _ in range(n)]
x1,x2,y1,y2 = 0,w,0,h
for p in paint:
    if p[2] == 1:
        x1 = max(x1,p[0])
    elif p[2] == 2:
        x2 = min(x2,p[0])
    elif p[2] == 3:
        y1 = max(y1,p[1])
    else:
        y2 = min(y2,p[1])
print( max(0,(x2-x1)*(y2-y1)))

Submission status: Wrong Answer

Solution code:
w,h,n = map(int,input().split())
paint = [list(map(int,input().split())) for _ in range(n)]
x1,x2,y1,y2 = 0,w,0,h
for p in paint:
    if p[2] == 1:
        x1 = p[0]
    elif p[2] == 2:
        x2 = p[0]
    elif p[2] == 3:
        y1 = p[1]
    else:
        y2 = p[1]
print( max(0,(x2-x1)*(y2-y1)))

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
x_l, x_r, y_b, y_u = 0, W, 0, H
for _ in range(N):
  x, y, a = map(int, input().split())
  if a == 1:
    x_l = max(x_l, x)
  elif a == 2:
    x_r = min(x_r, x)
  elif a == 3:
    y_b = max(y_b, y)
  else:
    y_u = min(y_u, y)
print(max((x_r - x_l) * (y_u - y_b), 0))

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
x_l, x_r, y_b, y_u = 0, W, 0, H
for _ in range(N):
  x, y, a = map(int, input().split())
  if a == 1:
    x_l = max(x_l, x)
  elif a == 2:
    x_r = min(x_r, x)
  elif a == 3:
    y_b = max(y_b, y)
  else:
    y_u = min(y_u, y)
print((x_r - x_l) * (y_u - y_b))

Submission status: Wrong Answer

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

left = 0
right = w
down = 0
up = h

for xya in xya_s:
    if xya[2] == 1:
        if left < xya[0]:
            left = xya[0]
    elif xya[2] == 2:
        if xya[0] < right:
            right = xya[0]
    elif xya[2] == 3:
        if xya[1] > down:
            down = xya[1]
    else:
        if xya[1] < up:
            up = xya[1]
s = (right-left)*(up-down)
if s < 0:
    print(0)
else:
    print(s)