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

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

x_s,y_s,x_e,y_e = 0,0,W,H
for b in xya:
  if b[2] == 1:
    x_s = min(W, max(x_s, b[0]))
  elif b[2] == 2:
    x_e = max(0, min(x_e, b[0]))
  elif b[2] == 3:
    y_s = min(H, max(y_s, b[1]))
  elif b[2] == 4:
    y_e = max(0, min(y_e, b[1]))

print((x_e - x_s) * (y_e - y_s))

Submission status: Wrong Answer

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

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

x_s,y_s,x_e,y_e = 0,0,W,H
for b in xya:
  if b[2] == 1:
    x_s = max(x_s, b[0])
  elif b[2] == 2:
    x_e = min(x_e, b[0])
  elif b[2] == 3:
    y_s = max(y_s, b[1])
  elif b[2] == 4:
    y_e = min(y_e, b[1])

print(max(0, (x_e - x_s) * (y_e - y_s)))

Submission status: Wrong Answer

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

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

x_s,y_s,x_e,y_e = 0,0,W,H
for b in xya:
  if b[2] == 1:
    x_s = max(x_s, b[0])
  elif b[2] == 2:
    x_e = min(x_e, b[0])
  elif b[2] == 3:
    y_s = max(y_s, b[1])
  elif b[2] == 4:
    y_e = min(y_e, b[1])

print((x_e - x_s) * (y_e - y_s))

Submission status: Wrong Answer

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

x1,x2,y1,y2=0,w,0,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,y)
  else:
      y2=min(y2,y)
        
s=(x2-x1)*(y2-y1)
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)]

x1,x2,y1,y2=0,w,0,h
for x,y,a in XYA:
  if a==1:
    x1=max(x1,x)
  elif a==2:
    x2=min(x2,x)
  elif a==3:
    y1=max(y1,y)
  else:
    y2=min(y2,y)
    
white=(x2-x1)*(y2-y1)
if white<0:
  print(0)
else:
  print(white)

Submission status: Wrong Answer

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

x1,x2,y1,y2=0,w,0,h
for x,y,a in XYA:
  if a==1:
    x1=max(x1,x)
  elif a==2:
    x2=min(x2,x)
  elif a==3:
    y1=max(y1,y)
  elif a==4:
    y2=min(y2,y)
white=(x2-x1)*(y2-y1)
if white<0:
  print(0)
else:
  print(white)

Submission status: Wrong Answer

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

x1,x2,y1,y2=0,w,0,h
for x,y,a in XYA:
  if a==1:
    x1=max(x1,x)
  elif a==2:
    x2=min(x2,x)
  elif a==3:
    y1=max(y1,y)
  elif a==4:
    y2=min(y2,y)
white=(x2-x1)*(y2-y1)
if white<=0:
  print(0)
else:
  print(white)

Submission status: Wrong Answer

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

white=w*h
x1,x2,y1,y2=0,w,0,h
for x,y,a in XYA:
  if a==1:
    x1=max(x1,x)
  elif a==2:
    x2=min(x2,x)
  elif a==3:
    y1=max(y1,y)
  elif a==4:
    y2=min(y2,y)
  white=(x2-x1)*(y2-y1)
if white<=0:
  print(0)
else:
  print(white)

Submission status: Wrong Answer

Solution code:
w,h,n = map(int,input().split())
x1 = 0
x2 = w
y3 = 0
y4 = 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:
        y3 = max(y3,y)
    else:
        y4 = min(y4,y)
X = x2 - x1
Y = y4 - y3
s = X * Y
if x < 0 or Y < 0:
    print(0)
else:
    print(s)

Submission status: Wrong Answer

Solution code:
w,h,n = map(int,input().split())
x1 = 0
x2 = w
y3 = 0
y4 = 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:
        y3 = max(y3,y)
    else:
        y4 = min(y4,y)
X = x2 - x1
Y = y4 - y3
s = X * Y
if s < 0:
    print(0)
else:
    print(s)

Submission status: Wrong Answer

Solution code:
w,h,n = map(int,input().split())
x1 = 0
x2 = w
y3 = 0
y4 = 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:
        y3 = max(y3,y)
    else:
        y4 = min(y4,y)
X = x2 - x1
Y = y4 - y3
print(max(0,X * Y))

Submission status: Wrong Answer

Solution code:
w,h,n = map(int,input().split())
li1 = [0]
li2 = [w]
li3 = [0]
li4 = [h]

for i in range(n):
    x,y,a = map(int,input().split())
    if a == 1:
        li1.append(x)
    elif a == 2:
        li2.append(x)
    elif a == 3:
        li3.append(y)
    else:
        li4.append(y)
X = min(li2) - max(li1)
Y = min(li4) - max(li3)
print(max(0,X * Y))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
w, h, n = map(int, input().split())
max_x = w
min_x = 0
max_y = h
min_y = 0

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        min_x = max(x, min_x)
    elif a == 2:
        max_x = min(x, max_x)
    elif a == 3:
        min_y = max(y, min_y)
    elif a == 4:
        max_y = min(y, max_y)
print(max((max_y - min_y) * (max_x - min_x), 0))

Submission status: Wrong Answer

Solution code:
w,h,n=map(int,input().split())
xmin, xmax, ymin, ymax = 0, w, 0, h
for _ 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
ans = (xmax-xmin) * (ymax-ymin)
if ans < 0:
    print(0)
else:
    print(ans)

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans=[0,0,w,h]
for i in range(n):
    if xya[i][2] == 1:
        if xya[i][0] >= ans[0]:
            ans[0] = xya[i][0]
    elif xya[i][2] == 2:
        if xya[i][0] <= ans[2]:
            ans[2] = xya[i][0]
    elif xya[i][2] == 3:
        if xya[i][1] >= ans[1]:
            ans[1] = xya[i][1]
    elif xya[i][2] == 4:
        if xya[i][1] <= ans[3]:
            ans[3] = xya[i][1]

print(0 if (ans[2]-ans[0])*(ans[3]-ans[1]) <= 0 else (ans[2]-ans[0])*(ans[3]-ans[1]))

Submission status: Wrong Answer

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

ans=[0,0,w,h]
for i in range(n):
    if xya[i][2] == 1:
        if xya[i][0] > ans[0]:
            ans[0] = xya[i][0]
    elif xya[i][2] == 2:
        if xya[i][0] < ans[2]:
            ans[2] = xya[i][0]
    elif xya[i][2] == 3:
        if xya[i][1] > ans[1]:
            ans[1] = xya[i][1]
    elif xya[i][2] == 4:
        if xya[i][1] < ans[3]:
            ans[3] = xya[i][1]

print(0 if (ans[2]-ans[0])*(ans[3]-ans[1]) < 0 else (ans[2]-ans[0])*(ans[3]-ans[1]))

Submission status: Wrong Answer

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

ans=[0,0,w,h]
for i in range(n):
    if xya[i][2] == 1:
        if xya[i][0] > ans[0]:
            ans[0] = xya[i][0]
    elif xya[i][2] == 2:
        if xya[i][0] < ans[2]:
            ans[2] = xya[i][0]
    elif xya[i][2] == 3:
        if xya[i][1] > ans[1]:
            ans[1] = xya[i][1]
    elif xya[i][2] == 4:
        if xya[i][1] < ans[3]:
            ans[3] = xya[i][1]

print(0 if (ans[2]-ans[0])*(ans[3]-ans[1]) <
      0 else (ans[2]-ans[0])*(ans[3]-ans[1]))

Submission status: Wrong Answer

Solution code:
Wg, Hg, n = map(int, input().split())
Ws, Hs = 0, 0

for i in range(n):
  x, y, a = map(int, input().split())
  if a == 1:
    Ws = x
  elif a == 2:
    Wg = x
  elif a == 3:
    Hs = y
  elif a == 4:
    Hg = y
    
  if Ws > Wg or Hs > Hg:
    break
    
ans = (Wg - Ws) * (Hg - Hs)
if ans <= 0:
  print("0")
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
w,h,n=map(int,input().split())
l = [[int(i) for i in input().split()] for i in range(n)]
right=w
left=0
up=h
down=0
# l [i] [j] は、i個目の箱のインデックスjの要素。
for i in range(n):
    if l[i][2]==1:
        left=max(left,l[i][0])
    elif l[i][2]==2:
        right=min(right,l[i][0])
    elif l[i][2]==3:
        down=max(down,l[i][1])
    elif l[i][2]==4:
        up=min(up,l[i][1])
square_size=(right-left)*(up-down)
print(square_size)

Submission status: Wrong Answer

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

mask = {}
for i in range(1, 5):
  if i%2 == 1:
    mask[i] = 0
  elif i == 2:
    mask[i] = W
  elif i == 4:
    mask[i] = H

for i in range(N):
  x, y, a = map(int, input().split())
  if a <= 2:
    mask[a] = x
  else:
    mask[a] = y


if mask[1] >= mask[2] or mask[3] >= mask[4]:
  ans = 0
else:
  ans =  (mask[1] - mask[2]) * (mask[3] - mask[4])
print(ans)

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
mask = {i:-1 for i in range(1,5)}

for i in range(N):
  x, y, a = map(int, input().split())
  if a <= 2:
    mask[a] = x
  else:
    mask[a] = y

for i in range(1, 5):
  if mask[i] == -1:
    if i == 1:
      mask[i] = 0
    elif i == 2:
      mask[i] = W
    elif i == 3:
      mask[i] = 0
    elif i == 4:
      mask[i] = H
      
if mask[1] > mask[2] or mask[3] > mask[4]:
  ans = 0
else:
  ans =  (mask[1] - mask[2]) * (mask[3] - mask[4])
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)]

boundary=[0,0,W,H]

for i in range(N):
  a=xya[i][2]
  if a==1:
    if boundary[0]<xya[i][0]:
      boundary[0]=xya[i][0]
  elif a==2:
    if boundary[2]>xya[i][0]:
      boundary[2]=xya[i][0]
  elif a==3:
    if boundary[1]<xya[i][1]:
      boundary[1]=xya[i][1]
  else:
    if boundary[3]>xya[i][1]:
      boundary[3]=xya[i][1]

print(max(0,(boundary[2]-boundary[0])*(boundary[3]-boundary[1])))

Submission status: Wrong Answer

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

boundary=[0,0,W,H]

for i in range(N):
  a=xya[i][2]
  if a==1:
    boundary[0]=xya[i][0]
  elif a==2:
    boundary[2]=xya[i][0]
  elif a==3:
    boundary[1]=xya[i][1]
  else:
    boundary[3]=xya[i][1]

print(max(0,(boundary[2]-boundary[0])*(boundary[3]-boundary[1])))

Submission status: Wrong Answer

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

for i in range(n):
    x = xya[i][0]
    y = xya[i][1]
    a = xya[i][2]
    if a == 1 and xwyh[0] < x:
        xwyh[0] += x
    elif a == 2 and xwyh[1] > x:
        xwyh[1] = x
    elif a == 3 and xwyh[2] < y:
        xwyh[2] += y
    elif a == 4 and xwyh[3] > y:
        xwyh[3] = y

if xwyh[0] < xwyh[1] and xwyh[2] < xwyh[3]:
    ans = (xwyh[1] - xwyh[0]) * (xwyh[3] - xwyh[2])
else:
    ans = 0

print(ans)

Submission status: Wrong Answer

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

for i in range(n):
    x = xya[i][0]
    y = xya[i][1]
    a = xya[i][2]
    if a == 1 and xwyh[0] < x:
        xwyh[0] += x
    elif a == 2 and xwyh[1] > x:
        xwyh[1] = x
    elif a == 3 and xwyh[2] < y:
        xwyh[2] += y
    elif a == 4 and xwyh[3] > y:
        xwyh[3] = y

ans = max((xwyh[1] - xwyh[0]) * (xwyh[3] - xwyh[2]), 0)
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    W,H,N = inputMap()
    x_hidari = 0
    x_migi = W
    y_shita = 0
    y_ue = H
    
    for i in range(N):
        x,y,a = inputMap()
        
        if a == 1:
            if x_hidari < x:
                x_hidari = x
        elif a == 2:
            if x_migi > x:
                x_migi = x
        elif a == 3:
            if y_shita < y:
                y_shita = y
        else:
            if y_ue > y:
                y_ue = y
                
    #print("{} {} {} {}".format(x_hidari,x_migi,y_ue,y_shita))
    ans = (x_migi-x_hidari) * (y_ue-y_shita)
    print(max(0,ans))
    
    
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    W,H,N = inputMap()
    x_hidari = 0
    x_migi = W
    y_shita = 0
    y_ue = H
    
    for i in range(N):
        x,y,a = inputMap()
        
        if a == 1:
            if x_hidari < x:
                x_hidari = x
        elif a == 2:
            if x_migi > x:
                x_migi = x
        elif a == 3:
            if y_shita < y:
                y_shita = y
        else:
            if y_ue > y:
                y_ue = y
                
    #print("{} {} {} {}".format(x_hidari,x_migi,y_ue,y_shita))
    ans = ((W - x_hidari) - (W - x_migi)) * ((H - y_shita) - (H - y_ue))
    print(max(0,ans))
    
    
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
def solve():
  w,h,n = (int(i) for i in input().split())
  lx = 0
  ly = 0
  rx = w
  ry = h
  for i in range(n):
    x,y,a = (int(i) for i in input().split())
    if a == 1:
      lx = max(lx,x)
    elif a == 2:
      rx = min(rx,x)
    elif a == 3:
      ly = max(ly,y)
    else:
      ry = min(ry,y)
  print(max(0,(rx-lx)*(ry-ly)))
solve()

Submission status: Wrong Answer

Solution code:
w, h, n = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(n)]
 
x1 = 0
x2 = w
y1 = 0
y2 = h
for i in range(n):
	if a[i][2] == 1:
		x1 = max(x1, a[i][0])
	elif a[i][2] == 2:
		x2 = min(x2, a[i][0])
	elif a[i][2] == 3:
		y1 = max(y1,a[i][1])
	elif a[i][2] == 4:
		y2 = min(y2, a[i][1])

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

Submission status: Wrong Answer

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

xmin,xmax = 0,W
ymin,ymax = 0,H
for n in range(N):
  x,y,a = map(int,input().split())
  if a==1:
    xmin = max(xmin,x)
  elif a==2:
    xmax = min(xmax,x)
  elif a==3:
    ymin = max(ymin,y)
  elif a==4:
    ymax = min(ymax,y)

print(max(0,(xmax-xmin)*(ymax-ymin)))

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
lx = 0
rx = W
dy = 0
uy = H
for _ in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        lx = x
    elif a == 2:
        rx = x
    elif a == 3:
        dy = y
    elif a == 4:
        uy = y
if 0 > rx - lx or 0 > uy - dy:
    print(0)
else:
    print((rx - lx) * (uy - dy))

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
lx = 0
rx = W
dy = 0
uy = H
for _ in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        lx = x
    elif a == 2:
        rx = x
    elif a == 3:
        dy = y
    elif a == 4:
        uy = y
if 0 >= rx - lx or 0 >= uy - dy:
    print(0)
else:
    print((rx - lx) * (uy - dy))

Submission status: Wrong Answer

Solution code:
import sys
x,y,nums = map(int,input().split())
points = [0] *nums
x1,y1 = 0,0
x2,y2 = x,y

for i in range (nums):
    points[i] = list(map(int,input().split()))

for i in range (nums):

    if points[i][2] == 1:
        if x1 < points[i][0]:
            x1 = points[i][0]

    elif points[i][2] == 2:
        if x2 > x - points[i][0]:
            x2 = points[i][0]

    elif points[i][2] == 3:
        if y1 < points[i][1]:
            y1 = points[i][1]

    elif points[i][2] == 4:
        if y2 > y - points[i][1]:
            y2 = points[i][1]

if  (x1 + (x - x2)) >= x or (y1 + (y - y2)) >= y:
    print(0)
    sys.exit()

result = (x - (x1 + ( x - x2))) * (y -(y1 + (y - y2)))
print(result)

Submission status: Wrong Answer

Solution code:
import sys
x,y,nums = map(int,input().split())
points = [0] *nums
x1,y1 = 0,0
x2,y2 = x,y

for i in range (nums):
    points[i] = list(map(int,input().split()))

for i in range (nums):

    if points[i][2] == 1:
        if x1 < points[i][0]:
            x1 = points[i][0]

    elif points[i][2] == 2:
        if x2 > x - points[i][0]:
            x2 = points[i][0]

    elif points[i][2] == 3:
        if y1 < points[i][1]:
            y1 = points[i][1]

    elif points[i][2] == 4:
        if y2 > y - points[i][1]:
            y2 = points[i][1]

if  (x1 + (x - x2)) >= x or -(y1 + (y - y2)) >= y:
    print(0)
    sys.exit()

result = (x - (x1 + ( x - x2))) * (y -(y1 + (y - y2)))
print(result)

Submission status: Wrong Answer

Solution code:
import sys
x,y,nums = map(int,input().split())
points = [0] *nums
x1,x2 ,y1,y2 = 0,1000000000,0,1000000000

for i in range (nums):
    points[i] = list(map(int,input().split()))

for i in range (nums):

    if points[i][2] == 1:
        if x1 < points[i][0]:
            x1 = points[i][0]

    elif points[i][2] == 2:
        if x2 > points[i][0]:
            x2 = points[i][0]

    elif points[i][2] == 3:
        if y1 < points[i][1]:
            y1 = points[i][1]

    elif points[i][2] == 4:
        if y2 > points[i][1]:
            y2 = points[i][1]

if x - x+1+ (x-x2) >= x or y - y+1 +(y - y2 ) >= y:
    print(0)
    sys.exit()

if x2 == 1000000000:
    x2 = x

if y2 == 1000000000:
    y2 = y

result =(x - (x1 + ( x - x2))) * (y - (y1 + ( y - y2)))
print(result)

Submission status: Wrong Answer

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

left_x = 0
right_x = w
bottom_y = 0
top_y = h

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

for x, y, a in xya:
    if a == 1:
        left_x = x
    elif a == 2:
        right_x = x
    elif a == 3:
        bottom_y = y
    else:
        top_y = y

    if left_x >= right_x or bottom_y >= top_y:
        print(0)
        exit()

ans = (right_x - left_x) * (top_y - bottom_y)
print(ans)

Submission status: Wrong Answer

Solution code:
w, h, n = map(int, input().split())
d1 = [0, 0]
d2 = [w, 0]
d3 = [w, h]
d4 = [0, h]

for _ in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        d1[0] = x
        d4[0] = x
    elif a == 2:
        d2[0] = x
        d3[0] = x
    elif a == 3:
        d1[1] = y
        d2[1] = y
    else:
        d3[1] = y
        d4[1] = y

ans = (d2[0] - d1[0]) * (d3[1] - d2[1])
print(max(0, ans))

Submission status: Wrong Answer

Solution code:
import numpy as np
h,w,n=map(int,input().split())
mass = np.ones([h,w])
#print(mass)
for i in range(n):
  x,y,a = map(int,input().split())
  if a==1:
    mass[:,:x]=0
  if a==2:
    mass[:,x:]=0
  if a==3:
    mass[(h-y)-1:,:]=0
  if a==4:
    mass[:(h-y)-1,:]=0
#  print(mass)
check = np.sum(mass,axis=1)
check = np.sum(check,axis=0)
print(check)

Submission status: Wrong Answer

Solution code:
import numpy as np
h,w,n=map(int,input().split())
mass = np.ones([h,w])
print(mass)
for i in range(n):
  x,y,a = map(int,input().split())
  if a==1:
    mass[:,:x]=0
  if a==2:
    mass[:,x:]=0
  if a==3:
    mass[(h-y)-1:,:]=0
  if a==4:
    mass[:(h-y)-1,:]=0
  print(mass)
check = np.sum(mass,axis=1)
check = np.sum(check,axis=0)
print(check)

Submission status: Wrong Answer

Solution code:
import numpy as np
h,w,n=map(int,input().split())
mass = np.ones([h,w])
#print(mass)
for i in range(n):
  x,y,a = map(int,input().split())
  if a==1:
    mass[:,:x]=0
  if a==2:
    mass[:,x-1:]=0
  if a==3:
    mass[(h-y):,:]=0
  if a==4:
    mass[:(h-y)-1,:]=0
  #print(mass)
check = np.sum(mass,axis=1)
check = np.sum(check,axis=0)
print(check)

Submission status: Wrong Answer

Solution code:
import numpy as np
h,w,n=map(int,input().split())
mass = np.ones([h,w])
print(mass)
for i in range(n):
  x,y,a = map(int,input().split())
  if a==1:
    mass[:,:x]=0
  if a==2:
    mass[:,x-1:]=0
  if a==3:
    mass[(h-y):,:]=0
  if a==4:
    mass[:(h-y)-1,:]=0
  print(mass)
check = np.sum(mass,axis=1)
check = np.sum(check,axis=0)
print(check)

Submission status: Wrong Answer

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

x1 = 0
x2 = w
y1 = 0
y2 = h
for i in range(n):
    if a[i][2] == 1:
        x1 = max(x1, a[i][0])
    elif a[i][2] == 2:
        x2 = min(x2, a[i][0])
    elif a[i][2] == 3:
        y1 = max(y1,a[i][1])
    else:
        y2 = min(y2, a[i][1])
print(max(0,(x2-x1)*(y2-y1)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# 最終エリアの上端:t(a=4),下端:b(a=3),右端:r(a=2),左端:l(a=1)
D = {'t': H, 'b': 0, 'r': W, 'l': 0}

for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:  # 左端
        D['l'] = max(D['l'], x)
    elif a == 2:  # 右端
        D['r'] = min(D['r'], x)
    elif a == 3:  # 下端
        D['b'] = max(D['b'], y)
    elif a == 4:  # 上端
        D['t'] = min(D['t'], y)

print(str(max((D['t']-D['b'])*(D['r']-D['l']), 0)))

Submission status: Wrong Answer

Solution code:
w,h,n = map(int,input().split())
x=[]
for i in range(n):
    x.append(list(map(int,input().split())))
#x軸の最小を求める(a=1のときの最大のxと同義）
Xmin = 0
for xi in range(n):
    if x[xi][2] == 1:
        Xmin =max(Xmin,x[xi][0])
#x軸の最大を求める(a=2のときの最小のxと同義）
Xmax = w
for xj in range(n):
    if x[xj][2]==2:
        Xmax =min(Xmax,x[xj][0])
#y軸の最小を求める(a=3のときの最大のyと同義）
Ymin = 0
for yi in range(n):
    if x[yi][2] == 3:
        Ymin =max(Ymin,x[yi][1])
#y軸の最大を求める(a=4のときの最小のyと同義）
Ymax = h
for yj in range(n):
    if x[yj][2]==4:
        Ymax =min(Ymax,x[yj][1])
print((Xmax-Xmin)*(Ymax-Ymin))

Submission status: Wrong Answer

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

x_max_1 = 0
x_max_2 = 0
y_max_3 = 0
y_max_4 = 0

for i in range(N):
    if a[i] == 1:
        b = x[i]
        if b > x_max_1:
            x_max_1 = b
    elif a[i] == 2:
        b = x[i]
        if b > x_max_2:
            x_max_2 = b
    elif a[i] == 3:
        b = y[i]
        if b > y_max_3:
            y_max_3 = b
    else :
        b = y[i]
        if b > y_max_4:
            y_max_4 = b

if x_max_2 == 0:
    x_max_2 = W

if y_max_4 == 0:
    y_max_4 = H

if x_max_2 <= x_max_1  or y_max_4 <= y_max_3:
    print(0)
else :
    ans = ((x_max_2 - x_max_1) * (y_max_4 - y_max_3))
    print(ans)

Submission status: Wrong Answer

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

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 and min_x < x:
        min_x = x
    if a == 2 and x < max_x:
        max_x = x
    if a == 3 and min_y < y:
        min_y = y
    if a == 4 and y < max_y:
        max_y = y
        
ans = (max_x-min_x)*(max_y-min_y)
if ans < 0:
    ans = 0
print(ans)

Submission status: Wrong Answer

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

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 and min_x < x:
        min_x = x
    if a == 2 and x < max_x:
        max_x = x
    if a == 3 and min_y < y:
        min_y = y
    if a == 4 and y < max_y:
        max_y = y

print((max_x-min_x)*(max_y-min_y))

Submission status: Wrong Answer

Solution code:
width, high, num = map(int, input().split())
arr = [list(map(int, input().split())) for i in range(num)]

def rec(xl, yl, xh, yh, arr):
    if len(arr) == 0:
        if xl>xh or yl>yh:
            return 0
        else:
            return (xh-xl)*(yh-yl)
    if arr[0][2] == 1:
        xl = arr[0][0]
        arr = arr[1:len(arr)]
        return rec(xl, yl, xh, yh, arr)
    elif arr[0][2] == 2:
        xh = arr[0][0]
        arr = arr[1:len(arr)]
        return rec(xl, yl, xh, yh, arr)
    elif arr[0][2] == 3:
        yl = arr[0][1]
        arr = arr[1:len(arr)]
        return rec(xl, yl, xh, yh, arr)
    elif arr[0][2] == 4:
        yh = arr[0][1]
        arr = arr[1:len(arr)]
        return rec(xl, yl, xh, yh, arr)

print(rec(0, 0, width, high, arr))

Submission status: Wrong Answer

Solution code:
width, high, num = map(int, input().split())
arr = [list(map(int, input().split())) for i in range(num)]

def rec(xl, yl, xh, yh, arr):
    if len(arr) == 0:
        if xl>xh or yl>yh:
            return 0
        else:
            return xh*yh
    if arr[0][2] == 1:
        xl = arr[0][0]
        arr = arr[1:len(arr)]
        return rec(xl, yl, xh, yh, arr)
    elif arr[0][2] == 2:
        xh = arr[0][0]
        arr = arr[1:len(arr)]
        return rec(xl, yl, xh, yh, arr)
    elif arr[0][2] == 3:
        yl = arr[0][1]
        arr = arr[1:len(arr)]
        return rec(xl, yl, xh, yh, arr)
    elif arr[0][2] == 4:
        yh = arr[0][1]
        arr = arr[1:len(arr)]
        return rec(xl, yl, xh, yh, arr)

print(rec(0, 0, width, high, arr))

Submission status: Wrong Answer

Solution code:
width, high, num = map(int, input().split())
arr = [list(map(int, input().split())) for i in range(num)]

sq = width * high
def rec(w, h, arr):
	if len(arr) == 0:
		return w*h
	if (arr[0][0] > w and (arr[0][2] == 1 or arr[0][2] == 2)) or (arr[0][1] > h and (arr[0][2] == 3 and arr[0][2] == 4)):
		arr = arr[1:len(arr)]
		return rec(w, h, arr)
	if arr[0][2] == 1:
		w -= arr[0][0]
		tmp = arr[0][0]
		for i in range(len(arr)):
			arr[i][0] = max(0, arr[i][0]-tmp)
		arr = arr[1:len(arr)]
		return rec(w, h, arr)
	elif arr[0][2] == 2:
		w = arr[0][0]
		arr = arr[1:len(arr)]
		return rec(w, h, arr)
	elif arr[0][2] == 3:
		h -= arr[0][1]
		tmp = arr[0][1]
		for i in range(len(arr)):
			arr[i][1] = max(0, arr[i][1]-tmp)
		arr = arr[1:len(arr)]
		return rec(w, h, arr)
	elif arr[0][2] == 4:
		h = arr[0][1]
		arr = arr[1:len(arr)]
		return rec(w, h, arr)

print(rec(width, high, arr))

Submission status: Wrong Answer

Solution code:
width, high, num = map(int, input().split())
arr = [list(map(int, input().split())) for i in range(num)]

sq = width * high
def rec(w, h, arr):
	if len(arr) == 0:
		return w*h
	if (arr[0][0] > w and (arr[0][2] == 1 or arr[0][2] == 2)) or (arr[0][1] > h and (arr[0][2] == 3 and arr[0][2] == 4)):
		arr = arr[1:len(arr)]
		return rec(w, h, arr)
	if arr[0][2] == 1:
		w -= arr[0][0]
		tmp = arr[0][0]
		for i in range(len(arr)):
			arr[i][0] = max(0, arr[i][0]-tmp)
		arr = arr[1:len(arr)]
		return rec(w, h, arr)
	elif arr[0][2] == 2:
		w = arr[0][0]
		print("w",w)
		arr = arr[1:len(arr)]
		return rec(w, h, arr)
	elif arr[0][2] == 3:
		h -= arr[0][1]
		tmp = arr[0][1]
		for i in range(len(arr)):
			arr[i][1] = max(0, arr[i][1]-tmp)
		arr = arr[1:len(arr)]
		return rec(w, h, arr)
	elif arr[0][2] == 4:
		h = arr[0][1]
		arr = arr[1:len(arr)]
		return rec(w, h, arr)

print(rec(width, high, arr))

Submission status: Wrong Answer

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

for i in range(N):
    if points[i][2] == 1:
        width[0] = points[i][0]
    elif points[i][2] == 2:
        width[1] = points[i][0]
    elif points[i][2] == 3:
        hight[0] = points[i][1]
    elif points[i][2] == 4:
        hight[1] = points[i][1]
    if width[0] >= width[1] or hight[0] >= hight[1]:
        print(0)
        exit() 

area = (width[1] - width[0]) * (hight[1] - hight[0])
print(area)

Submission status: Wrong Answer

Solution code:
W, H, N = map(int, input().split())
more_y = H
less_y = 0
more_x = W
less_x = 0
for _ in range(N):
  _x, _y, _type = map(int, input().split())
  if _type == 1:
    less_x = max(less_x, _x)
  elif _type == 2:
    more_x = min(more_x, _x)
  elif _type == 3:
    less_y = max(less_y, _y)
  else:
    more_y = min(more_y, _y)
print(max(0, (more_x-less_x)*(more_y-less_y)))