Problem:


Score : 200 points

Problem Statement

There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.

Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).

Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:

If a_i = 1, he painted the region satisfying x < x_i within the rectangle.

If a_i = 2, he painted the region satisfying x > x_i within the rectangle.

If a_i = 3, he painted the region satisfying y < y_i within the rectangle.

If a_i = 4, he painted the region satisfying y > y_i within the rectangle.

Find the area of the white region within the rectangle after he finished painting.

Constraints

1 ≦ W, H ≦ 100

1 ≦ N ≦ 100

0 ≦ x_i ≦ W (1 ≦ i ≦ N)

0 ≦ y_i ≦ H (1 ≦ i ≦ N)

W, H (21:32, added), x_i and y_i are integers.

a_i (1 ≦ i ≦ N) is 1, 2, 3 or 4.

Input

The input is given from Standard Input in the following format:

W H N
x_1 y_1 a_1
x_2 y_2 a_2
:
x_N y_N a_N

Output

Print the area of the white region within the rectangle after Snuke finished painting.

Sample Input 1

5 4 2
2 1 1
3 3 4

Sample Output 1

9

The figure below shows the rectangle before Snuke starts painting.

First, as (x_1, y_1) = (2, 1) and a_1 = 1, he paints the region satisfying x < 2 within the rectangle:

Then, as (x_2, y_2) = (3, 3) and a_2 = 4, he paints the region satisfying y > 3 within the rectangle:

Now, the area of the white region within the rectangle is 9.

Sample Input 2

5 4 3
2 1 1
3 3 4
1 4 2

Sample Output 2

0

It is possible that the whole region within the rectangle is painted black.

Sample Input 3

10 10 5
1 6 1
4 1 3
6 9 4
9 4 2
3 1 3

Sample Output 3

64



Sample input:
5 4 2
2 1 1
3 3 4


Sample output:
9

Submission status: Wrong Answer

Solution code:
w,h,n = map(int, input().split())
s = [[1 for i in range(w)] for j in range(h)]
b = [[1,2,3,4,5],[6,7,8,9,10]]
print(b[1][0])
print(b)
alist = []
print(s)
for i in range(n):
    x,y,a = map(int, input().split())
    alist.append(a)
    if a == 1:
        for j in range(h):
            for k in range(0,x):
                s[j][k] = 0
    if a == 2:
        for j in range(h):
            for k in range(x,w):
                s[j][k] = 0
    if a == 3:
        for k in range(w):
            for j in range(0,y):
                s[j][k] = 0
    if a == 4:
        for k in range(w):
            for j in range(y,h):
                s[j][k] = 0
ans = 0
for i in range(h):
    ans = ans + s[i].count(1)
print(ans)

Submission status: Wrong Answer

Solution code:
w,h,n = map(int, input().split())
xya = [list(map(int, input().split())) for i in range(n)]
x2 = w
x1 = 0
y2 = h
y1 = 0
for a,b,c in xya:
    if c == 1 and 0 <= a <= w:
        x1 = a
    elif c == 2 and 0 <= a <= w:
        x2 = a
    elif c == 3 and 0 <= b <= h:
        y1 = b
    elif c == 4 and 0 <= b <= h:
        y2 = b
if (0 <= x1 and 0 <= x2 and 0 <= x2-x1) and (0 <= y1 and 0 <= y2 and 0 <= y2-y1):
    print((x2-x1)*(y2-y1))
else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(s)

Submission status: Wrong Answer

Solution code:
w,h,n = map(int, input().split())
xya = [list(map(int, input().split())) for i in range(n)]
x2 = w
x1 = 0
y2 = h
y1 = 0
for a,b,c in xya:
    if c == 1:
        x1 = a
    elif c == 2:
        x2 = a
    elif c == 3:
        y1 = b
    else:
        y2 = b
if (0 <= x1 and 0 <= x2 and 0 <= x2-x1) and (0 <= y1 and 0 <= y2 and 0 <= y2-y1):
    print((x2-x1)*(y2-y1))
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)]
x2 = w
x1 = 0
y2 = h
y1 = 0
for a,b,c in xya:
    if c == 1:
        x1 = a
    elif c == 2:
        x2 = a
    elif c == 3:
        y1 = b
    else:
        y2 = b
if x2 <= x1 or y2 <= y1:
    print(0)
else:
    print((x2-x1)*(y2-y1))

Submission status: Wrong Answer

Solution code:
w,h,n = map(int, input().split())
xya = [list(map(int, input().split())) for i in range(n)]
x2 = w
x1 = 0
y2 = h
y1 = 0
for a,b,c in xya:
    print(x1,x2,y1,y2)
    if c == 1:
        x1 = a
    elif c == 2:
        x2 = a
    elif c == 3:
        y1 = b
    else:
        y2 = b
if x2 <= x1 or y2 <= y1:
    print(0)
else:
    print((x2-x1)*(y2-y1))

Submission status: Wrong Answer

Solution code:
X, Y, N = map(int, input().split())
lst = [[0 for i in range(X)] for j in range(Y)]

for i in (range(N)):
    x, y, a = map(int, input().split())
    if a == 1:
        for j in range(Y):
            for k in range(x):
                lst[j][k] = 1
    elif a == 2:
        for j in range(Y):
            for k in range(X-1, x-1, -1):
                lst[j][k] = 1
    elif a == 3:
        for j in range(y):
            for k in range(X):
                lst[j][k] = 1
    elif a == 4:
        for j in range(Y-1, y-1, -1):
            for k in range(X):
                lst[j][k] = 1
for i in lst:
    print(i)

count = 0
for i in lst:
    count += i.count(0)
print(count)

Submission status: Wrong Answer

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

min_x, min_y, max_x, max_y = 0, 0, w, h
for _ in range(n):
    x, y, a = map(int, input().split())

    if a == 1:
        min_x = x
    elif a == 2:
        max_x = x
    elif a == 3:
        min_y = y
    else:
        max_y = y

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

Submission status: Wrong Answer

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

min_x, max_x, min_y, max_y = 0, w, 0, h
for _ in range(n):
    x, y, a = map(int, input().split())

    if a == 1:
        min_x = x
    elif a == 2:
        max_x = x
    elif a == 3:
        min_y = y
    else:
        max_y = y

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

Submission status: Wrong Answer

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

min_x, max_x, min_y, max_y = 0, w, 0, h
for _ in range(n):
    x, y, a = map(int, input().split())

    if a == 1:
        min_x = x
    elif a == 2:
        max_x = x
    elif a == 3:
        min_y = y
    else:
        max_y = y

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

Submission status: Wrong Answer

Solution code:
def main():
    W,H,N = map(int,input().split())
    x1 = 0 #a=1の初期値
    x2 = 0 #a=2初期値
    y1 = 0 #a=3初期値
    y2 = 0 #a=4初期値
    for _ in range(N):
        a = list(map(int,input().split()))
        if a[2] == 1 and x1 == 0:
            x1 = a[0]
        elif a[2] == 1 and x1 < a[0]:
            x1 = a[0]
        elif a[2] == 2 and x2 == 0:
            x2 = a[0]
        elif a[2] == 2 and x2 > a[0]:
            x2 = a[0]
        elif a[2] == 3 and y1 == 0:
            y1 = a[1]
        elif a[2] == 3 and y1 < a[0]:
            y1 = a[1]
        elif a[2] == 4 and y2 == 0:
            y2 = a[1]
        elif a[2] == 4 and y2 > a[0]:
            y2 = a[1]
    #白塗りのWとHを求める
    if x2 != 0:
        W_new = W - x1 - (W - x2)
    else:
        W_new = W - x1 - x2
    if y2 != 0:
        H_new = H - y1 - (H - y2)
    else:
        H_new = H - y1 - y2

    #面積
    print(W_new * H_new if W_new > 0 and  H_new > 0 else 0)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

    if a==1:
        X=max(X,x)
    elif a==2:
        W=min(W,x)
    elif a==3:
        Y=max(Y,y)
    else:
        H=min(H,y)

S=(W-X)*(H-Y)

print(S)

Submission status: Wrong Answer

Solution code:
W,H,N=list(map(int, input().split()))
wl=[0]
wh=[W]
hl=[0]
hh=[H]
for i in range(N):
  l=list(map(int, input().split()))
  if l[2]==1:
    wl.append(l[0])
  elif l[2]==2:
    wh.append(l[0])
  elif l[2]==3:
    hl.append(l[1])
  else:
    hh.append(l[1])
w=min(wh)-max(wl)
h=min(hh)-max(hl)
print(max(0,w*h))

Submission status: Wrong Answer

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

l, r, b, t = 0, w, 0, h
for x, y, a in xya:
    if a == 1:
        l = x
    elif a == 2:
        r = x
    elif a == 3:
        b = y
    elif a == 4:
        t = y
print(max(0, (r - l) * (t - b)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sx = [0, w]
sy = [0, h]

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        sx[0] = max(sx[0], x)
    if a == 2:
        sx[1] = min(sx[1], x)
    if a == 3:
        sy[0] = max(sy[0], y)
    if a == 4:
        sy[1] = min(sy[1], y)

print(max(0, (sx[1]-sx[0])*(sy[1]-sy[0])))

Submission status: Wrong Answer

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

w_min, w_max, h_min, h_max = 0, w, 0, h

for i in range(n):
    if plots[i][2] == 1:
        w_min = max(w_min, plots[i][0])
    elif plots[i][2] == 2:
        w_max = min(w_max, plots[i][0])
    elif plots[i][2] == 3:
        h_min = max(h_min, plots[i][1])
    else:
        h_max = min(h_max, plots[i][1])

print(max(0, (w_max - w_min) * (h_max - h_min)))

Submission status: Wrong Answer

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

w_min, w_max, h_min, h_max = 0, w, 0, h

for i in range(n):
    if plots[i][2] == 1:
        w_min = max(w_min, plots[i][0])
    elif plots[i][2] == 2:
        w_max = min(w_max, plots[i][0])
    elif plots[i][2] == 3:
        h_min = max(h_min, plots[i][1])
    else:
        h_max = min(h_max, plots[i][1])

print((w_max - w_min) * (h_max - h_min))

Submission status: Wrong Answer

Solution code:
W, H, N  = map(int,input().split()) 
l = 0; r = W; u = H; d = 0 

for i in range(N):
    x, y, a = map(int,input().split()) 
    if a == 1:
        l = max(l,x) 
    elif a == 2:
        r = min(r,x) 
    elif a == 3:
        d = max(d,y) 
    else:
        u = min(u,y) 

print(max(0,(r-l)*(u-d)))

Submission status: Wrong Answer

Solution code:
W, H, N  = map(int,input().split()) 
l = 0; r = W; u = H; d = 0 

for i in range(N):
    x, y, a = map(int,input().split()) 
    if a == 1:
        l = x 
    elif a == 2:
        r = x 
    elif a == 3:
        d = y 
    else:
        u = y 

print(max(0,(r-l)*(u-d)))

Submission status: Wrong Answer

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

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

lx = 0
rx = W
by = 0
ty = H
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        lx = max(lx, x)
    if a == 2:
        rx = min(rx, x)
    if a == 3:
        by = max(by, y)
    if a == 4:
        ty = min(ty, y)
s = (rx - lx) * (ty - by)
if s < 0:
    print(0)
else:
    print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

list = [0, w, 0, h]

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


print((list[0] - list[1]) * (list[2] - list[3]))

Submission status: Wrong Answer

Solution code:
#
# abc047 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5 4 2
2 1 1
3 3 4"""
        output = """9"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """5 4 3
2 1 1
3 3 4
1 4 2"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """10 10 5
1 6 1
4 1 3
6 9 4
9 4 2
3 1 3"""
        output = """64"""
        self.assertIO(input, output)


def resolve():
    W, H, N = map(int, input().split())
    a = []
    ox = 0
    oy = 0
    for _ in range(N):
        a.append(list(map(int, input().split())))
    for i in range(N):
        if a[i][2] == 1:
            ox = max(a[i][0], ox)
        elif a[i][2] == 2:
            W = min(a[i][0], W)
        elif a[i][2] == 3:
            oy = max(a[i][1], oy)
        elif a[i][2] == 4:
            H = min(a[i][1], H)
    print(max((W-ox)*(H-oy), 0))


if __name__ == "__main__":
    # unittest.main()
    resolve()

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],[0,h]]
for i in a:
    if i[2]==1:
        S[0][0]=i[0]

    if i[2]==2:
        S[0][1]=i[0]

    if i[2]==3:
        S[1][0]=i[1]

    if i[2]==4:
        S[1][1]=i[1]

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

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],[0,h]]
for i in a:
    if i[2]==1:
        S[0][0]=i[0]

    if i[2]==2:
        S[0][1]=i[0]

    if i[2]==3:
        S[1][0]=i[1]

    if i[2]==4:
        S[1][1]=i[1]

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

Submission status: Wrong Answer

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

white = [0, w, 0, h]

for i in range(n):
  x, y, a = map(int, input().split())
  if a == 1:
    white[0] = max(x, white[0])
  elif a == 2:
    white[1] = min(x, white[1])
  elif a == 3:
    white[3] = max(y, white[2])
  elif a == 4:
    white[3] = min(y, white[3])
print(abs(white[1] - white[0]) * abs(white[3] - white[2]))

Submission status: Wrong Answer

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

white = [0, w, 0, h]

for i in range(n):
  x, y, a = map(int, input().split())
  if a == 1:
    white[0] = max(x, white[0])
  elif a == 2:
    white[1] = min(x, white[1])
  elif a == 3:
    white[3] = max(y, white[2])
  elif a == 4:
    white[3] = min(y, white[3])
if white[1] - white[0] <= 0 or white[3] - white[2] <= 0:
  print(0)
else:
  print((white[1] - white[0]) * (white[3] - white[2]))

Submission status: Wrong Answer

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

white = [0, w, 0, h]

for i in range(n):
  x, y, a = map(int, input().split())
  if a == 1:
    white[0] = max(x, white[0])
  elif a == 2:
    white[1] = min(x, white[1])
  elif a == 3:
    white[3] = max(y, white[2])
  elif a == 4:
    white[3] = min(y, white[3])
print(abs(white[1] - white[0]) * abs(white[3] - white[2]))

Submission status: Wrong Answer

Solution code:
w,h,n = map(int,input().split())
 
x1 = 0
x2 = w
y1 = 0
y2 = h

for i in range(n):
  x,y,a = map(int,input().split())
  if a == 1:
    x1 = max(x1,x)
  elif a == 2:
    x2 = min(x2,x)
  elif a == 3:
    y1 = max(y1,x) 
  elif a == 4:
    y2 = min(y2,x) 

if x1 >= x2 or y1 >= y2:
    print(0)
else:
    print(abs(x1-x2)*abs(y1-y2))

Submission status: Wrong Answer

Solution code:
w,h,n = map(int,input().split())
 
x1 = 0
x2 = w
y1 = 0
y2 = h

for i in range(n):
  x,y,a = map(int,input().split())
  if a == 1:
    x1 = max(x1,x)
  elif a == 2:
    x2 = min(x2,x)
  elif a == 3:
    y1 = max(y1,x)
  elif a == 4:
    y2 = min(y2,x)

if x1>=x2 or y1>=y2:
  print(0)
else:
  print(abs(x1-x2)*abs(y1-y2))

Submission status: Wrong Answer

Solution code:
w,h,n = map(int,input().split())
#x_list = [int(1) for i in range(w+1)]
#y_list = [int(1) for i in range(h+1)]
#print(x_list)
#print(y_list)
min_x = 0
max_x = w
min_y = 0
max_y = h
for i in range(n):
    x,y,a = map(int,input().split())
    if a==1:
        min_x = x
    elif a==2:
        max_x = x
    elif a==3:
        min_y = y
    else:
        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:
w,h,n = map(int,input().split())
#x_list = [int(1) for i in range(w+1)]
#y_list = [int(1) for i in range(h+1)]
#print(x_list)
#print(y_list)
min_x = 0
max_x = w
min_y = 0
max_y = h
for i in range(n):
    x,y,a = map(int,input().split())
    if a==1:
        min_x = x
    elif a==2:
        max_x = x
    elif a==3:
        min_y = y
    else:
        max_y = y
if min_x > max_x or min_y > max_y:
    print(0)
else:
    print((max_x-min_y)*(max_y-min_y))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
W,H,N=map(int,input().split())
l=[]
for i in range(H+1):
  for k in range(W+1):
    l.append([k,i])
for j in range(N):
  x,y,a=map(int,input().split())
  if a==1:
    for x1 in range(x+1):
      for y1 in range(H+1):
        try:
          l.remove([x1,y1])
        except:
          pass
  elif a==2:
    for x2 in range(x,W+1):
      for y2 in range(H+1):
        try:
          l.remove([x2,y2])
        except:
          pass
  elif a==3:
    for y3 in range(y+1):
      for x3 in range(W+1):
        try:
          l.remove([x3,y3])
        except:
          pass
  else:
    for y4 in range(y,H+1):
      for x4 in range(W+1):
        try:
          l.remove([x4,y4])
        except:
          pass
print(len(l))

Submission status: Wrong Answer

Solution code:
w,h,n =map(int,input().split())
s =[list(map(int,input().split())) for _ in range(n)]
x =0;y =0;
for i in range(n):
  if s[i][2] ==1:
    if x < s[i][0]: x = s[i][0] 
  elif s[i][2] ==2:
    if w > s[i][0]: w = s[i][0]
  elif s[i][2] ==3:
    if y < s[i][1]: y = s[i][1]
  else:
    if h > s[i][1]: h = s[i][1]
print((w-x)*(h-y) if (w-x)*(h-y)>0 else 0)

Submission status: Wrong Answer

Solution code:
whn_list = list(map(int,input().split()))
x_y_list = []
x = [0,whn_list[0]]
y = [0,whn_list[1]]

for i in range(whn_list[2]):
    x_y_list.append(list(map(int,input().split())))

for i in x_y_list:
    if i[2] == 1:
        x[0] = i[0]
    elif i[2] == 2:
        x[1] = i[0]
    elif i[2] == 3:
        y[0] = i[1]
    else:
        y[1] = i[1]

s = (x[1]-x[0])*(y[1]-y[0])

if  ((x[1]-x[0]) < 0) or ((y[1]-y[0]) < 0) or (s <= 0):
    print(0)
else:
    print(s)

Submission status: Wrong Answer

Solution code:
whn_list = list(map(int,input().split()))
x_y_list = []
x = [0,whn_list[0]]
y = [0,whn_list[1]]

for i in range(whn_list[2]):
    x_y_list.append(list(map(int,input().split())))

for i in x_y_list:
    if i[2] == 1:
        x[0] = i[0]
    elif i[2] == 2:
        x[1] = i[0]
    elif i[2] == 3:
        y[0] = i[1]
    else:
        y[1] = i[1]

s = (x[1]-x[0])*(y[1]-y[0])

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

w, h, n = map(int, input().split())
x = [0 for _ in range(n)]
y = [0 for _ in range(n)]
a = [0 for _ in range(n)]
for i in range(n):
    x[i], y[i], a[i] = map(int, input().split())

masu = [['W' for _ in range(w)] for _ in range(h)]

for i in range(n):
    if 1 == a[i]:
        for j in range(h):
            masu[j][:x[i]] = 'B' 
    if 2 == a[i]:
        for j in range(h):
            masu[j][x[i]:] = 'B' 
    if 3 == a[i]:
        for k in range(y[i]):
            masu[k] = ['B' for _ in range(w)]
    if 4 == a[i]:
        for k in range(y[i], h): 
            masu[k] = ['B' for _ in range(w)]

ans = 0 
for i in range(len(masu)):
    ans += masu[i].count('W')
    # print(masu[i])

print(ans)

Submission status: Wrong Answer

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

x1,x2,y1,y2 = 0,0,0,0
for _ in range(n):
  x,y,a = map(int, input().split())
  if a == 1: x1 = max(x1, x)
  if a == 2: x2 = max(x2, w-x)
  if a == 3: y1 = max(y1, y)
  if a == 4: y2 = max(y2, h-y)

w -= x1+x2
h -= y1+y2
if w*h <= 0: print(0)
else: print(w*h)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

for x, y, a in p:
    if a == 1:
        if x > x1:
            x1 = x
    elif a == 2:
        if x < x2:
            x2 = x
    elif a == 3:
        if y > y1:
            y1 = y
    elif a == 4:
        if y < y2:
            y2 = y

ans = (x2-x1)*(y2-y1)
if ans <= 0:
    print(0)
else:
    print(ans)

Submission status: Wrong Answer

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

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

for x, y, a in p:
    if a == 1:
        if x < x2:
            x1 = x
        else:
            x1 = x2
    elif a == 2:
        if x > x1:
            x2 = x
        else:
            x2 = x1
    elif a == 3:
        if y < y2:
            y1 = y
        else:
            y1 = y2
    elif a == 4:
        if y > y1:
            y2 = y
        else:
            y2 = y1
print((x2-x1)*(y2-y1))

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    w, h, n = map(int, readline().split())

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

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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
W,H,N = map(int, input().split(' '))
ls = []
for i in range(N):
  ls.append(input())
  
WA,WZ,HA,HZ = 0,W,0,H

for str_ in ls:
  x,y,a = map(int,str_.split(' '))
  
  if a == 1 and WA < x:
    WA = x
  elif a == 2 and WZ > x:
    WZ = x
  elif a == 3 and HA < y:
    HA = y
  elif a == 4 and HZ > y:
    HZ = y

if (s := (WZ-WA)*(HZ-HA)) > 0:
  print(int(s))
else:
  print(0)

Submission status: Wrong Answer

Solution code:
W,H,N = map(int, input().split(' '))
ls = []
for i in range(N):
  ls.append(input())
  
WA,WZ,HA,HZ = 0,W,0,H

for str_ in ls:
  x,y,a = map(int,str_.split(' '))
  
  if a == 1 and WA < x:
    WA = x
  elif a == 2 and WZ > x:
    WZ = x
  elif a == 3 and HA < y:
    HA = y
  elif a == 4 and HZ > y:
    HZ = y

if (s := (WZ-WA)*(HZ-HA)) > 0:
  print(s)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
W,H,N = map(int, input().split(' '))
ls = []
for i in range(N):
  ls.append(input())
  
WA,WZ,HA,HZ = 0,W,0,H

for str_ in ls:
  x,y,a = map(int,str_.split(' '))
  
  if a == 1:
    WA = x
  elif a == 2:
    WZ = x
  elif a == 3:
    HA = y
  elif a == 4:
    HZ = y

if (s := (WZ-WA)*(HZ-HA)) > 0:
  print(s)
else:
  print(0)

Submission status: Wrong Answer

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

print(max(0, (w - w0) * (h - h0)))

Submission status: Wrong Answer

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

print(max(0, (w - w0) * (h - h0)))

Submission status: Wrong Answer

Solution code:
w, h, n = map(int, input().split())
origin = [0,0]
edge = [w,h]
for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        origin[0] = x
    elif a == 2:
        edge[0] = x
    elif a == 3:
        origin[1] = y
    else:
        edge[1] = y

width = edge[0] - origin[0]
if width < 0:
  width = 0
height = edge[1] - origin[1]
if height < 0:
  height = 0
print(width * height)

Submission status: Wrong Answer

Solution code:
W,H,N=map(int,input().split())
List = []
for i in range (N):
  List.append(list(map(int, input().split())))
WRange = [0,W]
HRange = [0,H]
for i in range(N):
  if List[i][2] == 1:
    WRange[0] = List[i][0]
  elif List[i][2] == 2:
    WRange[1] = List[i][0]
  elif List[i][2] == 3:
    HRange[0] = List[i][1]
  else:
    HRange[1] = List[i][1]
if WRange[1]-WRange[0] >0:
  W = WRange[1]-WRange[0]
else:
  W = 0
if HRange[1]-HRange[0] >0:
  H = HRange[1]-HRange[0]
else:
  H = 0
res = H * W
print(res)

Submission status: Wrong Answer

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

if hmin>=hmax or wmin>=wmax:
  print(0)
else:
  print((hmax-hmin)*(wmax-wmin))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
def main():
    Wr, Hu, N = map(int, input().split())
    C =  [list(map(int, input().split())) for i in range(N)]
    Wl, Hd = 0, 0
    for x, y ,a in C:
        if a == 1:
            Wl = x
        if a == 2:
            Wr = x
        if a == 3:
            Hd = y
        if a == 4:
            Hu = y
        if Wr <= Wl or Hu <= Hd:
            print(0)
            return
    W = Wr - Wl
    H = Hu - Hd
    print(W*H)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
def main():
    Wr, Hu, N = map(int, input().split())
    C =  [list(map(int, input().split())) for i in range(N)]
    Wl, Hd = 0, 0
    for x, y ,a in C:
        if Wr <= Wl or Hu <= Hd:
            print(0)
            return
        if a == 1:
            Wl = x
        if a == 2:
            Wr = x
        if a == 3:
            Hd = y
        if a == 4:
            Hu = y
    W = Wr - Wl
    H = Hu - Hd
    print(W*H if W*H >= 0 else 0)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
def main():
    Wr, Hu, N = map(int, input().split())
    C =  [list(map(int, input().split())) for i in range(N)]
    Wl, Hd = 0, 0
    for x, y ,a in C:
        if Wr <= Wl or Hu <= Hd:
            print(0)
            return
        if a == 1:
            Wl = x
        if a == 2:
            Wr = x
        if a == 3:
            Hd = y
        if a == 4:
            Hu = y
        print(Wr, Wl, Hu, Hd)
    W = Wr - Wl
    H = Hu - Hd
    print(W*H if W*H >= 0 else 0)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

X = [0,W]
Y = [0,H]

for n in range(N):
    x,y,a = list(map(int,input().split()))
    if a == 1:
        X[0] = max(X[0],x)
    elif a == 2:
        X[1] = min(X[1],x)
    elif a == 3:
        Y[0] = max(Y[0],y)
    elif a == 4:
        Y[1] = min(Y[1],y)
    
# print((X[1]-X[0])*(Y[1]-Y[0]))
print(max(0,(X[1]-X[0])*(Y[1]-Y[0])))

Submission status: Wrong Answer

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

X = [0,W]
Y = [0,H]

for n in range(N):
    x,y,a = list(map(int,input().split()))
    if a == 1:
        X[0] = max(X[0],x)
    elif a == 2:
        X[1] = min(X[1],x)
    elif a == 3:
        Y[0] = max(Y[0],y)
    elif a == 4:
        Y[1] = min(Y[1],y)
    
print(max(0,(X[1]-X[0])*(Y[1]-Y[0])))