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:
l = list(map(int, input().split()))

w = l[0]
h = l[1]
n = l[2]

minx = 0
maxx = w
miny = 0
maxy = h

for i in range(n):
    l = list(map(int, input().split()))
    x = l[0]
    y = l[1]
    a = l[2]
    if a == 1:
        if minx < x:
            minx = x
    elif a == 2:
        if maxx > x:
            maxx = x
    elif a == 3:
        if miny < y:
            miny = y
    elif a == 4:
        if maxy > y:
            maxy = y

cnt = w * h
#print(minx, maxx, miny, maxy)
ans = (maxx-minx) * (maxy-miny)
if ans < 0:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
W, H, N = [int(i) for i in input().split()]
w, h = 0, 0
for i in range(N):
    x, y, a = [int(i) for i in input().split()]
    if a is 1:
        w = max(w, x)
    elif a is 2:
        W = min(W, x)
    elif a is 3:
        h = max(h, y)
    elif a is 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 i in range(N):
    x, y, a = [int(i) for i in input().split()]
    if a is 1:
        w = max(w, x)
    elif a is 2:
        W = min(W, x)
    elif a is 3:
        h = max(h, y)
    else:
        H = min(H, y)

print(max(0, (W - w) * (H - h)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#! /bin/python
# coding:utf-8

(W, H, N) = map(int, raw_input().split())

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

for i in range(0, N):
    (x, y, a) = map(int, raw_input().split())
    if (int(a) == 1):
        if (x > min_x):
            min_x = x
    elif (a == 2):
        if (x < max_x):
            max_x = x
    elif (a == 3):
        if (y > min_y):
            min_y = y
    elif (a == 4):
        if (y < max_y):
            max_y = y

res = (max_x - min_x) * (max_y - min_y)

if (res < 0):
    print "0"
else:
    print res

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)  

yoko1=0
yoko2=W
tate1=0
tate2=H

for j in range(N):
    if A[j]==1:
        if yoko1<X[j]:
            yoko1=X[j]
    
    elif A[j]==2:
        if yoko2>X[j]:
            yoko2=X[j]
        
    elif A[j]==3:
        if tate1<Y[j]:
            tate1=Y[j]

    elif A[j]==4:
        if tate2>Y[j]:
             tate2=Y[j]

ans=(tate2-tate1)*(yoko2-yoko1)

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

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)  

yoko1=0
yoko2=W
tate1=0
tate2=H

for j in range(N):
    if A[j]==1:
        if yoko1<X[j]:
            yoko1=X[j]
    
    elif A[j]==2:
        if yoko2>X[j]:
            yoko2=X[j]
        
    elif A[j]==3:
        if tate1<Y[j]:
            tate1=Y[j]

    elif A[j]==4:
        if tate2>Y[j]:
             tate2=Y[j]

ans=(tate2-tate1)*(yoko2-yoko1)

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

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)  

M=W*H
yoko1=0
yoko2=W
tate1=0
tate2=H

for j in range(N):
    if A[j]==1:
        M=M-(X[j]-yoko1)*(tate2-tate1)
        if yoko1<X[j]:
            yoko1=X[j]
    
    elif A[j]==2:
        M=M-(yoko2-X[j])*(tate2-tate1)
        if yoko2>X[j]:
            yoko2=X[j]
        
    elif A[j]==3:
        M=M-(yoko2-yoko1)*(Y[j]-tate1)
        if tate1<Y[j]:
            tate1=Y[j]

    elif A[j]==4:
        M=M-(yoko2-yoko1)*(tate2-Y[j])
        if tate2>Y[j]:
            tate2=Y[j]

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

Submission status: Wrong Answer

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

d = 0
u = h
r = w
l = 0

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        if l <= x:
            l = x
    elif a == 2:
        r = x
    elif a == 3:
        if d <= y:
            d = y
    elif a == 4:
        u = y
    if u-d <= 0 or r-l <= 0:
        break
ans = (r-l) * (u-d)
if ans <= 0:
    print(0)
else:
    print(ans)

Submission status: Wrong Answer

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

rect = [0, 0, W, H]

ans = -1

XY_a = []

for i in range(N):
    XY_a.append(list(map(int, input().split())))
    
for i in range(N):
    if XY_a[i][2] == 1:
        rect[0] = XY_a[i][0]
    elif XY_a[i][2] == 2:
        rect[2] = XY_a[i][0]
    elif XY_a[i][2] == 3:
        rect[1] = XY_a[i][1]
    elif XY_a[i][2] == 4:
        rect[3] = XY_a[i][1]
        
    if rect[0] >= rect[2] or rect[1] >= rect[3]:
        ans = 0
        break
        
if ans == 0:
    print(ans)
else :
    ans = (rect[2] - rect[0])*(rect[3] - rect[1])
    print(ans)

Submission status: Wrong Answer

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

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

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1 and x > left:
        left = x
    elif a == 2 and x < right:
        right = x
    elif a == 3 and y > down:
        down = y
    elif a == 4 and y < up:
        up = y

wans = up - down
yans = right - left
ans = wans * yans
if ans >= 0:
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

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

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

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1 and x >= left:
        left = x
    elif a == 2 and x <= right:
        right = x
    elif a == 3 and y >= down:
        down = y
    elif a == 4 and y <= up:
        up = y

wans = up - down
yans = right - left
ans = wans * yans
if ans >= 0:
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

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

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

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        left = x
    elif a == 2:
        right = x
    elif a == 3:
        down = y
    elif a == 4:
        up = y

wans = up - down
yans = right - left
ans = wans * yans
if ans >= 0:
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
def main():
    W, H, N = map(int, input().split())
    P = [tuple(map(int, input().split())) for _ in range(N)]

    x = [0, W]
    y = [0, H]
    for p in P:
        if p[2] == 1:
            x[0] = p[0]
        elif p[2] == 2:
            x[1] = p[0]
        elif p[2] == 3:
            y[0] = p[1]
        elif p[2] == 4:
            y[1] = p[1]

    region = [x[1] - x[0], y[1] - y[0]]
    if region[0] <= 0 or region[1] <= 0:
        area = 0
    else:
        area = region[0] * region[1]

    print(area)

main()

Submission status: Wrong Answer

Solution code:
def main():
    W, H, N = map(int, input().split())
    P = [tuple(map(int, input().split())) for _ in range(N)]

    x = [0, W]
    y = [0, H]
    for p in P:
        if p[2] == 1:
            x[0] = p[0]
        elif p[2] == 2:
            x[1] = p[0]
        elif p[2] == 3:
            y[0] = p[1]
        elif p[2] == 4:
            y[1] = p[1]

    region = [x[1] - x[0], y[1] - y[0]]
    if region[0] < 0 or region[1] < 0:
        area = 0
    else:
        area = region[0] * region[1]

    print(area)

main()

Submission status: Wrong Answer

Solution code:
maxw, maxh, N = list(map(int, input().split(' ')))
minw, minh = 0, 0

for n in range(N):
    x, y, a = list(map(int, input().split(' ')))
    if a == 1:
        minw = max(minw, x)
    elif a == 2:
        maxw = min(maxw, x)
    elif a == 3:
        minh = max(minh, y)
    elif a == 4:
        maxh = min(maxh, y)

if maxw-minw < 0 or maxh-minh > 0:
    res = 0
else:
    res = (maxw-minw)*(maxh-minh)
print(res)

Submission status: Wrong Answer

Solution code:
maxw, maxh, N = list(map(int, input().split(' ')))
minw, minh = 0, 0

for n in range(N):
    x, y, a = list(map(int, input().split(' ')))
    if a == 1 and minw < x:
        minw = x
    elif a == 2 and maxw > x:
        maxw = x
    elif a == 3 and minh < y:
        minh = y
    elif a == 4 and maxh > y:
        maxh = y

res = (maxw-minw)*(maxh-minh)
if res < 0:
    res = 0
print(res)

Submission status: Wrong Answer

Solution code:
maxw, maxh, N = list(map(int, input().split(' ')))
minw, minh = 0, 0

for n in range(N):
    x, y, a = list(map(int, input().split(' ')))
    if a == 1 and minw < x:
        minw = x
    elif a == 2 and maxw > x:
        maxw = x
    elif a == 3 and minh < y:
        minh = y
    elif a == 4 and maxh > y:
        maxh = y

print((maxw-minw)*(maxh-minh))

Submission status: Wrong Answer

Solution code:
W,H,N = map(int,input().split())
act = [[0 for j in range(3)] for i in range(N)]
xl = 0 #左端 
xr = W #右端
yd = 0 #上端
yu = H #下端
for i in range(N):
	act[i] = [int(j) for j in input().split()]
for obj in act:
	if(obj[2]==1):
		xl = max(obj[0],xl)
	elif(obj[2]==2):
		xr = min(obj[0],xr)
	elif(obj[2]==3):
		yd = max(obj[1],yd)
	elif(obj[2]==4):
		yu = min(obj[1],yu)
ans = (xr-xl)*(yu-yd)
print(xr,xl,yu,yd)
if(xr < xl or yu < yd):
	print(0)
else:
	print(ans)

Submission status: Wrong Answer

Solution code:
W,H,N = map(int,input().split())
act = [[0 for j in range(3)] for i in range(N)]
xr = 0
xl = W 
yu = 0
yd = H
for i in range(N):
	act[i] = [int(j) for j in input().split()]
for obj in act:
	if(obj[2]==1):
		xr = max(obj[0],xr)
	elif(obj[2]==2):
		xl = min(obj[0],xl)
	elif(obj[2]==3):
		yu = max(obj[1],yu)
	elif(obj[2]==4):
		yd = min(obj[1],yd)
ans = (xr-xl)*(yu-yd)
if(xr < xl or yu < yd):
	print(0)
else:
	print(ans)

Submission status: Wrong Answer

Solution code:
W,H,N = map(int,input().split())
act = [[0 for j in range(3)] for i in range(N)]
xr = 0
xl = W 
yu = 0
yd = H
for i in range(N):
	act[i] = [int(j) for j in input().split()]
for obj in act:
	if(obj[2]==1):
		xr = max(obj[0],xr)
	elif(obj[2]==2):
		xl = min(obj[0],xl)
	elif(obj[2]==3):
		yu = max(obj[1],yu)
	elif(obj[2]==4):
		yd = min(obj[1],yd)
ans = (xr-xl)*(yu-yd)
if(ans<0):
	print(0)
else:
	print(ans)

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, raw_input().split())
xya = [map(int, raw_input().split()) for i in xrange(N)]
lx, hx = 0, W
ly, hy = 0, H
for x, y, a in xya:
    if a == 1: lx = max(lx, x)
    if a == 2: hx = min(hy, x) 
    if a == 3: ly = max(ly, y) 
    if a == 4: hy = min(hy, y) 
print max(0, hx - lx)*max(0, hy - ly)

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, raw_input().split())
xya = [map(int, raw_input().split()) for i in xrange(N)]
lx, hx = 0, W
ly, hy = 0, H
for x, y, a in xya:
    if a == 1: lx = x
    if a == 2: hx = x
    if a == 3: ly = y
    if a == 4: hy = y
print max(0, hx - lx)*max(0, hy - ly)

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, raw_input().split())
xya = [map(int, raw_input().split()) for i in xrange(N)]
lx, hx = 0, W
ly, hy = 0, H
for x, y, a in xya:
    if a == 1: lx = x
    if a == 2: hx = x
    if a == 3: ly = y
    if a == 4: hy = y
print (hx - lx)*(hy - ly)

Submission status: Wrong Answer

Solution code:
W, H, N = map(int,input().split())
x = []
y = []
a = []
x1 = 0
x2 = W
y1 = 0
y2 = H
for i in range(N):
    temp = list(map(int,input().split()))
    x.append(temp[0])
    y.append(temp[1])
    a.append(temp[2])

for i in range(N):
    if a[i] == 1:
        x1 = max(x1,x[i])
    if a[i] == 2:
        x2 = min(x2,x[i])
    if a[i] == 3:
        y1 = max(y1,y[i])
    if a[i] == 4:
        y2 = min(y2,y[i])

print((x2-x1)*(y2-y1))

Submission status: Wrong Answer

Solution code:
w, h, n = map(int, input().split())
sx, sy, ex, ey = 0, 0, w, h
for _ in range(n):
    x, y, a = map(int, input().split())
    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(0, (ex - sx) * (ey - sy)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#prepare
L = []
Q = []

#input
W, H, N, = map(int,raw_input().split())
for i in range(N):
    L.append(map(int,raw_input().split()))
x1=0
x2=W
y1=0
y2=H

#calculate
Q = [row[2] for row in L]
print Q

for k in range(N):
    if Q[k] == 1:
        x1 = max(x1,L[k][0])
    elif Q[k] == 2:
        x2 = min(x2,L[k][0])
    elif Q[k] == 3:
        y1 = max(y1,L[k][1])
    elif Q[k] == 4:
        y2 = min(y2,L[k][1])

print max(0,x2-x1) * max(0,y2-y1)

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
xya = []
l = 0
r = W
u = H
d = 0
for _ in range(N):
	x, y, a = map(int, input().split())
	if a == 1:
		l = x
	elif a == 2:
		r = x
	elif a == 3:
		d = y
	else:
		u = y
print(max(0,(u-d))*max(0,(r-l)))

Submission status: Wrong Answer

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

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

	if a == 1 and w < x:
		w = x
	elif a == 2 and W > x:
		W = x
	elif a == 3 and h < y:
		h = y
	elif a == 4 and H > y:
		H = y

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

Submission status: Wrong Answer

Solution code:
sorce_point = list(map(int, input().split()))
W = sorce_point[0]
H = sorce_point[1]
N = sorce_point[2]

point = []
for i in range(N):
	point.append(list(map(int, input().split())))
point.append(sorce_point)
for i in range(N + 1):
	if (point[i][2] == 1):
		for j in range(N):
			if point[j][0] < point[i][0]:
				point[j][0] = 0
				point[j][1] = 0
	if (point[i][2] == 2):
		for j in range(N + 1):
			if point[j][0] > point[i][0]:
				point[j][0] = 0
				point[j][1] = 0
	if (point[i][2] == 3):
		for j in range(N + 1):
			if point[j][1] < point[i][1]:
				point[j][1] = 0
	if (point[i][2] == 4):
		for j in range(N + 1):
			if point[j][1] > point[i][1]:
				point[j][1] = 0

point.append(sorce_point)
print(point)
mx= 0
my = 0
mix = 100
miy = 100
for i in range(N + 1):
	if mx < point[i][0]:
		mx = point[i][0]
	if my < point[i][1]:
		my = point[i][1]
	if mix > point[i][0] and not(point[i][0] == 0):
		mix = point[i][0]
	if miy > point[i][1] and not(point[i][1] == 0):
		miy = point[i][1]

print((mx - mix) * (my - miy))

Submission status: Wrong Answer

Solution code:
W, H, N = [int(n) for n in raw_input().split(" ")]
a = [[int(x) for x in raw_input().split(" ")] for n in range(N)]
 
x_min = y_min = 0
x_max, y_max = W, H
 
for s in a:
  if s[2] == 1:
    x_min = max(x_min, s[0])
  elif s[2] == 2:
    x_max = min(x_max, s[0])
  elif s[2] == 3:
    y_min = max(y_min, s[1])
  elif s[2] == 4:
    y_max = min(y_min, s[1])
 
 
if (x_max > x_min) and (y_max > y_min):
  print (x_max - x_min) * (y_max - y_min)
else:
  print 0

Submission status: Wrong Answer

Solution code:
W, H, N = [int(n) for n in raw_input().split(" ")]
a = [[int(x) for x in raw_input().split(" ")] for n in range(N)]

x_min = y_min = 0
x_max, y_max = W, H

for s in a:
  if s[2] == 1:
    x_min = s[0]
  elif s[2] == 2:
    x_max = s[0]
  elif s[2] == 3:
    y_min = s[1]
  elif s[2] == 4:
    y_max = s[1]


if (x_max > x_min) and (y_max > y_min):
  print (x_max - x_min) * (y_max - y_min)
else:
  print 0

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:
		w = x
	elif a == 2:
		W = x
	elif a == 3:
		h = y
	elif a == 4:
		H = y

a = (W-w)*(H-h)
if a < 0:
	print(0)
else:
	print(a)

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:
		if w < x:
			w = x
	elif a == 2:
		if W > x:
			W = x
	elif a == 3:
		if h < y:
			h = y
	elif a == 4:
		if H > y:
			H = y

a = (W-w)*(H-h)
if a < 0:
	print(0)
else:
	print(a)

Submission status: Wrong Answer

Solution code:
W, H, N = [int(x) for x in input().strip().split()]
x_min = 0
y_min = 0

for i in range(N):
    x, y, a = [int(x) for x in input().strip().split()]
    result = 0
    if W < x_min or H < y_min:
        W - x_min == 0
        break

    if a == 1 and x_min < x:
        x_min = x
    elif a == 2 and W > x:
        W = x
    elif a == 3 and y_min < y:
        y_min = y
    elif a == 4 and H > y:
        H = y
    
print((W - x_min)*(H - y_min))

Submission status: Wrong Answer

Solution code:
W, H, N = [int(x) for x in input().strip().split()]
x_min = 0
y_min = 0

for i in range(N):
    x, y, a = [int(x) for x in input().strip().split()]
    result = 0
    if W < x_min or H < y_min:
        W - x_min == 0

    if a == 1 and x_min < x:
        x_min = x
    elif a == 2 and W > x:
        W = x
    elif a == 3 and y_min < y:
        y_min = y
    elif a == 4 and H > y:
        H = y
    
print((W - x_min)*(H - y_min))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
"""Snuke's Coloring 2 (ABC Edit)

@author: hijiri.n
@modified: 11-19-2016

"""

def data(): return list(map(int, input().split()))


def solve(init, point):
    w, h, N = init
    rect = [0, w, 0, h]

    for p in point:
        x, y, a = p

        if [1, -1][a % 2] * ([x, y][a > 2] - rect[a - 1]) < 0:
            rect[a - 1] = [x, y][a > 2]

        if ((rect[1] <= rect[0]) if (a < 2) else (rect[3] <= rect[2])):
            return 0
        
    return (rect[1] - rect[0]) * (rect[3] - rect[2])

# Input init & points data
i_in = data()
p_in = [data() for _ in range(i_in[-1])]
print(solve(i_in, p_in))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
"""Snuke's Coloring 2 (ABC Edit)

@author: hijiri.n
@modified: 11-19-2016

"""

def data(): return list(map(int, input().split()))


def solve(init, point):
    w, h, N = init
    rect = [0, w, 0, h]

    for p in point:
        x, y, a = p

        if [1, -1][a % 2] * ([x, y][a > 2] - rect[a - 1]) < 0:
            rect[a - 1] = [x, y][a > 2]

        if (rect[1] <= rect[0]) if a < 2 else (rect[3] <= rect[2]):
            return 0
        
    return (rect[1] - rect[0]) * (rect[3] - rect[2])

# Input init & points data
i_in = data()
p_in = [data() for _ in range(i_in[-1])]
print(solve(i_in, p_in))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
"""Snuke's Coloring 2 (ABC Edit)

@author: hijiri.n
@modified: 11-19-2016

"""

def data(): return list(map(int, input().split()))


def solve():
    w, h, N = data()
    rect = [0, w, 0, h]

    for i in range(N):
        x, y, a = data()
        if [1, -1][a % 2] * ([x, y][a > 2] - rect[a - 1]) < 0:
            rect[a - 1] = [x, y][a > 2]

        if rect[1] <= rect[0] & rect[3] <= rect[2]:
            return 0
        
    return (rect[1] - rect[0]) * (rect[3] - rect[2])

print(solve())

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

W, H, N = list(map(int, input().split()))
minX = 0
maxX = W
minY = 0
maxY = H

def calc():
    print(maxX)
    print(minX)
    print(maxY)
    print(minY)
    if maxX < minX or maxY < minY:
        return 0
    return (maxX - minX) * (maxY - minY)

for i in range(N):
    x, y, a = list(map(int, input().split()))
    if a is 1:
        if minX < x:
            minX = x
    elif a is 2:
        if maxX > x:
            maxX = x
    elif a is 3:
        if minY < y:
            minY = y
    elif a is 4:
        if maxY > y:
            maxY = y

print(calc())

Submission status: Wrong Answer

Solution code:
min_x=0
min_y=0
max_x,max_y,N=[int(x) for x in input().split()]

for i in range(0,N):
    X,Y,a=[int(x) for x in input().split()]
    if a==1:
        min_x=X
    elif a==2:
        max_x=X
    elif a==3:
        min_y=Y
    elif a==4:
        max_y=Y
        

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

Submission status: Wrong Answer

Solution code:
min_x=0
min_y=0
max_x,max_y,N=[int(x) for x in input().split()]

for i in range(0,N):
    X,Y,a=[int(x) for x in input().split()]
    if a==1:
        min_x=X
    elif a==2:
        max_x=X
    elif a==3:
        min_y=Y
    elif a==4:
        max_y=Y

r=(max_y-min_y)*(max_x-min_x)
if r<0:
    print(0)
else:
    print(r)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
W,H,N = map(int,raw_input().split())
arr = []
for i in xrange(N):
    arr.append(map(int,raw_input().split()))

minx=0
miny=0
maxx=W
maxy=H

for r in arr:
    (x,y,a) = r
    if a==1 and x > minx:
        minx = x
    elif a==2 and x < maxx:
        maxx = x
    elif a==3 and y > miny:
        miny = y
    elif a==4 and y < maxy:
        maxy = y

r = (maxx-minx) * (maxy-miny)
r = 0 if r < 0 else r
print(r)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
 
w, h, N = list(map(int, input().split()))
 
rect = [0, w, 0, h]
for i in range(N):
    x, y, a = list(map(int, input().split()))
    if [1, -1][a % 2] * ([x, y][a > 2] - rect[a - 1]) < 0:
        rect[a - 1] = [x, y][a > 2]

print((lambda x: [0, x][x > 0])((rect[1] - rect[0]) * (rect[3] - rect[2])))

Submission status: Wrong Answer

Solution code:
# coding: utf-8

w, h, N = list(map(int, input().split()))

rect = [0, w, 0, h]
for i in range(N):
    x, y, a = list(map(int, input().split()))
    rect[a - 1] = (lambda c, r, p: [r, c][c > r & p])([x, y][a > 2], rect[a - 1], a % 2)

length = lambda x: [x, 0][x < 0]
print(length(rect[1] - rect[0]) * length(rect[3] - rect[2]))

Submission status: Wrong Answer

Solution code:
# coding: utf-8

w, h, N = list(map(int, input().split()))

rect = [0, w, 0, h]
for i in range(N):
    x, y, a = list(map(int, input().split()))
    rect[a - 1] = [x, y][a > 2]

length = lambda x: [x, 0][x < 0]
print(length(rect[1] - rect[0]) * length(rect[3] - rect[2]))

Submission status: Wrong Answer

Solution code:

wo=0
ho=0
w,h,n=map(int, input().split())

for i in range(n):
    x,y,a=map(int, input().split())
    if a==1: wo=x
    if a==2: w=x
    if a==3: ho=y
    if a==4: h=y

ans=(w-wo)*(h-ho)

if wo>=w or ho>=h: print(0)
else: print(ans)

Submission status: Wrong Answer

Solution code:

wo=0
ho=0
w,h,n=map(int, input().split())

for i in range(n):
    x,y,a=map(int, input().split())
    if a==1: wo=x
    if a==2: w=x
    if a==3: ho=y
    if a==4: h=y

ans=(w-wo)*(h-ho)
print(ans)

Submission status: Wrong Answer

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

max_x_1 = 0
min_x_2 = w
max_y_3 = 0
min_y_4 = h
for i in range(n):
    ai = xya[i][2]
    if ai == 1:
        if xya[i][0] > max_x_1:
            max_x_1 = xya[i][0]
    if ai == 2:
        if xya[i][0] < min_x_2:
            min_x_2 = xya[i][0]
    if ai == 3:
        if xya[i][1] < max_y_3:
            max_y_3 = xya[i][1]
    if ai == 4:
        if xya[i][1] < min_y_4:
            min_y_4 = xya[i][1]

x = min_x_2 - max_x_1
if x <= 0:
    print("0")
else:
    y = min_y_4 - max_y_3
    if y <= 0:
        print("0")
    else:
        print(x * y)

Submission status: Wrong Answer

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

max_x_1 = 0
min_x_2 = w
max_y_3 = h
min_y_4 = 0
for i in range(n):
    ai = xya[i][2]
    if ai == 1:
        if xya[i][0] > max_x_1:
            max_x_1 = xya[i][0]
    if ai == 2:
        if xya[i][0] < min_x_2:
            min_x_2 = xya[i][0]
    if ai == 3:
        if xya[i][1] < max_y_3:
            max_y_3 = xya[i][1]
    if ai == 4:
        if xya[i][1] < min_y_4:
            min_y_4 = xya[i][1]

x = min_x_2 - max_x_1
if x <= 0:
    print("0")
else:
    y = min_y_4 - max_y_3
    if y <= 0:
        print("0")
    else:
        print(x * y)

Submission status: Wrong Answer

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

min_x_1 = w
max_x_2 = 0
min_y_3 = h
max_y_4 = 0
for i in range(n):
    ai = xya[i][2]
    if ai == 1:
        if xya[i][0] < min_x_1:
            min_x_1 = xya[i][0]
    if ai == 2:
        if xya[i][0] > max_x_2:
            max_x_2 = xya[i][0]
    if ai == 3:
        if xya[i][1] < min_y_3:
            min_y_3 = xya[i][1]
    if ai == 4:
        if xya[i][1] > max_y_4:
            max_y_4 = xya[i][1]

x = min_x_1 - max_x_2
if x <= 0:
    print("0")
else:
    y = min_y_3 - max_y_4
    if y <= 0:
        print("0")
    else:
        print(str(x * y))

Submission status: Wrong Answer

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

min_x_1 = w
max_x_2 = 0
min_y_3 = h
max_y_4 = 0
for i in range(n):
    ai = xya[i][2]
    if ai == 1:
        if xya[i][0] < min_x_1:
            min_x_1 = xya[i][0]
    if ai == 2:
        if xya[i][0] > max_x_2:
            max_x_2 = xya[i][0]
    if ai == 3:
        if xya[i][1] < min_y_3:
            min_y_3 = xya[i][1]
    if ai == 4:
        if xya[i][1] > max_y_4:
            max_y_4 = xya[i][1]

x = max_x_2 - min_x_1
if x <= 0:
    print("0")
else:
    y = max_y_4 - min_y_3
    if y <= 0:
        print("0")
    else:
        print(x * y)

Submission status: Wrong Answer

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

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        if p[0] < x:
            p[0] = x
    elif a == 2:
        if x < q[0]:
            q[0] = x
    elif a == 3:
        if p[1] < y:
            p[1] = y
    elif a == 4:
        if y < q[1]:
            q[1] = y

s = (q[0] - p[0])*(q[1] - p[1])

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

Submission status: Wrong Answer

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

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

for i in range(n):
    x,y,a = map(int,raw_input().split(" "))
    if a == 1:
        x_min = max(x_min,x)
    if a == 2:
        x_max = min(x_max,x)
    if a == 3:
        y_min = max(y_min,y)
    if a == 4:
        y_max = min(y_max,y)

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

Submission status: Wrong Answer

Solution code:
array = []
l = list(map(int,list(input().split())))
W,H,N = l[0],l[1],l[2]
S = W*H
left_lower = [0,0]
right_upper = [W,H]

for i in range(N):
    l = list(map(int,list(input().split())))
    array.append([l[0],l[1],l[2]])

for i in range(0,len(array)):
    if array[i][2]==1 and array[i][0]>left_lower[0]:
        left_lower = [array[i][0],left_lower[1]]
    elif array[i][2]==2 and array[i][0]<right_upper[0]:
        right_upper = [array[i][0],right_upper[1]]
    elif array[i][2]==3 and array[i][1]>left_lower[1]:
        left_lower = [left_lower[0],array[i][1]]
    elif array[i][2]==4 and array[i][1]<right_upper[1]:
        right_upper = [right_upper[0],array[i][1]]

S = (right_upper[0]-left_lower[0])*(right_upper[1]-left_lower[1])

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

Submission status: Wrong Answer

Solution code:
w,h,n=map(int,raw_input().split())
l=[['.' for i in range(w)] for j in range(h)]
for i in range(n):
    x,y,a=map(int,raw_input().split())
    if a==1:
        for i in range(h):
            for j in range(x):
                l[i][j]='#'
    elif a==2:
        for i in range(h):
            for j in range(x,w):
                l[i][j]='#'
    elif a==3:
        for i in range(y):
            l[i]=['#' for j in range(w)]
    else:
        for i in range(y,h):
            l[i]=['#' for j in range(w)]

ans=chk=0
for i in l:
    ans+=i.count('.')

Submission status: Wrong Answer

Solution code:
w, h, n = [int(i) for i in input().split()]
width = w
height = h
flag = flag1 = True
xmax1 = xmax2 = ymax1 = ymax2 = 0
while(n):
	x, y, a = [int(i) for i in input().split()]
	if a == 1:
		if x > xmax1:
			if flag:
				w = width - x
				xmax1 = x
			else:
				if x < xmax2:
					w = width - x
					xmax1 = x
				else:
					n = 1
					w = 0
	elif a == 2:
		if flag and x > xmax1:
			xmax2 = x
			w = x - xmax1
			flag = False
		else:
			n = 1
			w = 0
		if x < xmax2:
			if x > xmax1:
				w = x - xmax1
				xmax2 = x
			else:
				n = 1
				w = 0
	elif a == 3:
		if y > ymax1:
			if flag1:
				h = height - y
				ymax1 = y
			else:
				if y < ymax2:
					h = height - y
					ymax1 = y
				else:
					n = 1
					h = 0
	elif a == 4:
		if flag1 and y > ymax1:
			ymax2 = y
			h = y - ymax1
			flag1 = False
		else:
			n = 1
			h = 0
		if y < ymax2:
			if y > ymax1:
				h = y - ymax1
				ymax2 = y
			else:
				n = 1
				h = 0
	n -= 1
 
print(w*h)