Problem:


Score : 300 points

Problem Statement

There is a rectangle in a coordinate plane. The coordinates of the four vertices are (0,0), (W,0), (W,H), and (0,H).
You are given a point (x,y) which is within the rectangle or on its border. We will draw a straight line passing through (x,y) to cut the rectangle into two parts. Find the maximum possible area of the part whose area is not larger than that of the other. Additionally, determine if there are multiple ways to cut the rectangle and achieve that maximum.

Constraints

1 \leq W,H \leq 10^9

0\leq x\leq W

0\leq y\leq H

All values in input are integers.

Input

Input is given from Standard Input in the following format:

W H x y

Output

Print the maximum possible area of the part whose area is not larger than that of the other, followed by 1 if there are multiple ways to cut the rectangle and achieve that maximum, and 0 otherwise.

The area printed will be judged correct when its absolute or relative error is at most 10^{-9}.

Sample Input 1

2 3 1 2

Sample Output 1

3.000000 0

The line x=1 gives the optimal cut, and no other line does.

Sample Input 2

2 2 1 1

Sample Output 2

2.000000 1



Sample input:
2 3 1 2


Sample output:
3.000000 0

Submission status: Runtime Error

Solution code:
W, H, x, y = map(int, input().split())
flag = 1 if x == W/2 and y == H/2 else 0
print(f"{W*H/2} {flag}")

Submission status: Runtime Error

Solution code:
w,h,x,y=map(int,input().split())
ans=w*h/2
if w/2=x and h/2=y:
    print(ans,1)
else:
    print(ans,0)

Submission status: Runtime Error

Solution code:
w,h,x,y=map(int,input().split())
ans=w*h/2
if w=2*x and h=2*y:
    print(ans,1)
else:
    print(ans,0)

Submission status: Runtime Error

Solution code:
w,h,x,y=map(int,input().split())
ans=[w*h/2]
if y/x==h/w or y/x==w/h:
    ans.append(1)
else:ans.append(0)
print(*ans)

Submission status: Runtime Error

Solution code:
W,H,x,y=map(int, input().split())
D = 0.5*H*W
if (W/x) == 2 and (H/y)==2:
  R = 1
else:
  R = 0
print(D, R)

Submission status: Runtime Error

Solution code:
W,H,x,y=map(int, input().split())
D = 0.5*H*W
if W//x==2 and H//y==2:
  R = 1
else:
  R = 0
print(D, R)

Submission status: Runtime Error

Solution code:
W,H,x,y=map(int, input().split())
  D = 0.5*H*W
  if W//x==2 and H//y==2:
    R = 1:
  else:
    R = 0
print(D, R)

Submission status: Runtime Error

Solution code:
W,H,x,y=map(int, input().split())
if W-x < x:x = W-x
if H-y < y:y = H-y
D1 = x*H
D2 = y*W
if x !=0 and y!=0:
  D = max(D1,D2)
  if x==y:
    R = 1
  else
    R = 0
else:
  D = 0.5*H*W
  R = 0
print(D, R)

Submission status: Runtime Error

Solution code:
w,h,x,y=map(int,input().split())
m=w*h/2
if w%x==0 and h%y==0:
    print(m,1)
else:
    print(m,0)

Submission status: Runtime Error

Solution code:
w, h, x, y = map(int, input().split())
out = 0
if (x != 0 and x != w and y!= 0 and y != h)
  out = 1
print(w*h/2, out)

Submission status: Runtime Error

Solution code:
W, H, x, y = map(int, input().split())
a = x*H
b = y*W
if x != 0 and x != W and y != 0 and y != H:
  if a < b:
    print(str(a) + " " + str(0))
  elif b < a:
    print(str(b) + " " + str(0))
  else:
    print(str(a) + " " + str(1))
else:
  print(str((H*W)/2) + " " + 0)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**9)
def input():
    return sys.stdin.readline().rstrip()

def main():
    W,H,x,y=map(int,input().split())
    S=W*H/2
    b=1 if x==W//2 and y==H//2 else 0
    print(f'%s %s' % (S, b))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**9)
def input():
    return sys.stdin.readline().rstrip()

def main():
    W,H,x,y=map(int,input().split())
    S=W*H/2
    b=1 if x==W//2 and y==H//2 else 0
    print(f'{S} {b}'.format(S=S, b=b))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**9)
def input():
    return sys.stdin.readline().rstrip()

def main():
    W,H,x,y=map(int,input().split())
    S=W*H/2
    b=1 if x==W//2 and y==H//2 else 0
    print(f'{S} {b}')

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
W,H,x,y = input().split()
W,H,x,y = int(W),int(H),int(x),int(y)

cw = W/2
cH = H/2

if(cw==x):
    print(W*H/2)
    if(cH==y):
        print(1)
    else:
        print(0)

else:
    y0 = y-((y-cJ)/(x-cW))*x
    y1 = y-((y-cJ)/(x-cW))*(x-W)
    print((y0+y1)*W/2)
    print(0)

Submission status: Runtime Error

Solution code:
W,H,x,y = input().split()
W,H,x,y = int(W),int(H),int(x),int(y)

cw = W//2
cH = H//2

if(cw==x):
    print(W*H//2)
    if(cH==y):
        print(1)
    else:
        print(0)
else:
    y0 = y-((y-cJ)/(x-cW))*x
    y1 = y-((y-cJ)/(x-cW))*(x-W)
    print((y0+y1)*W//2)
    print(0)

Submission status: Runtime Error

Solution code:
H = list(map(int,input().split()))
h = H[0]
w = H[1]
x = H[2]
y = H[3]

if (h-2*x)*(w-2*y)!=0 or ((h-2*x==0) and (w-2*y==0)) and (x != h x != 0 or y != 0 y != w):
  a = 1
else:
  a = 0

print(h*w/2,a)

Submission status: Runtime Error

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

men = w*h/2

if w/h == x/y:
    flg = 1
else:
    flg = 0
print("{0:.6f}".format(men) + " " + str(flg))

Submission status: Runtime Error

Solution code:
#解答
w, h, x, y = list(map(int, input().split()))
ans = 0
 
if ((x, y) == (w / 2, h / 2)):
    print("{s} {mul}".format(s=(w * h / 2), mul=1))
else:
    print("{s} {mul}".format(s=(w * h / 2), mul=0))
w, h, x, y = list(map(int, input().split()))
ans = 0

if ((x, y) == (w / 2, h / 2)):
    print("{s} {mul}".format(s=(w * h / 2), mul=1))
else:
    print("{s} {mul}".format(s=(w * h / 2), mul=0))

Submission status: Runtime Error

Solution code:
w,h,x,y=map(int,input().split())
n=0
if w%x==0 and h%y==0:
  n=1
print(float(w*h/2), end=" ")
print(n)

Submission status: Runtime Error

Solution code:
def p_c():
    W, H, x, y = map(int, input().split())
    is0 = W / 2 == x ^ H / 2 == y
    print(W * H / 2, 0 if is0 else 1)
    
p_c()

Submission status: Runtime Error

Solution code:
W,H,x,y=map(int,input().split())
if x==W/2 and y==H/2:
  print(float(W*H/2),1)
elif x==W/2 and (not y==H/2):
  print(float(W*H/2),0)
elif (not x==W/2) and y==H/2:
  print(float(W*H/2),0)
else:
  if H/W==y/x or W/H==-(y/x):
    print(float(W*H/2),0)
  else:
    print(float(W*H/2),0)

Submission status: Runtime Error

Solution code:
W,H,x,y=map(int,input().split())
if x==W/2 and y==H/2:
  print(float(W*H/2),1)
elif x==W/2 and (not y==H/2):
  print(float(W*H/2),0)
elif (not x==W/2) and y==H/2:
  print(float(W*H/2),0)
else:
  if H/W==y/x or W/H==-(y/x):
    print(float(W*H/2),0)
  else:
    print(float(W*H/2),0)

Submission status: Runtime Error

Solution code:
# -*- coding:utf8 -*-

w,h,x,y = map(int, input().split())
rec = w * h
o = '0'
all = sorted([rec * (y / h), rec * (h - y)/ h, rec * (x / w), rec * (w - x)/ w], reverse = True)
for i, n in enumerate(all):
    if n <= rec / 2:
        tr = n
        if tr == rec / 2:
            if all[i + 2] == tr:
                o = '1'
                break
        else:
            if all[i + 1] == tr:
                o = '1'
                break
ans = str(tr) + ' ' + o
print(ans)

Submission status: Runtime Error

Solution code:
W,H,x,y = map(int, input().split())
if(x == 0 or x == W or y == 0 or Y == H):
	print(0, 0)
	exit(0)

if (W*y < H*x):
	if(W == y * 2):
		print(W*y, 1)
	else:
		print(W*y, 0)
elif (W*y > H*x):
	if(H == x * 2):
		print(H*x, 1)
	else:
		print(H*x, 0)
else:
	print(W*y, 1)

Submission status: Runtime Error

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

size = 0
flag = 0

if W < x && H < y:
  if W > H:
    if y > H - y:
      size = (H-y)*W
    else:
      size = y*W
  else:
    if x > W - x:
      size = (W-x)*H
    else:
      size = x*H
  
    if W==H:
      flag=1
elif W == x:
  if y > H - y:
    size = (H-y)*W
  else:
    size = y*W
    
elif H == y:
  if x > W - x:
    size = (W-x)*H
  else:
    size = x*H
  

  
print(str(size) + " " + str(flag))

Submission status: Runtime Error

Solution code:
from math import isclose


w, h, x, y = map(float, input().split())

if isclose(x, w / 2) and isclose(y, h / 2):
    print((w * h) / 2, 1)
else:
    print((w * h) / 2, 0)

Submission status: Runtime Error

Solution code:
import math
W, H, x, y = map(int, input().split())
half_s = W*H/2
tmp = (x-y)**2**0.5
print(half_s,math.floor(tmp-1))

Submission status: Runtime Error

Solution code:
W , H ,x , y = map(int,input().split())
horizon = min(W * y , W * (H - y))
vertical = min(H * x , H * (W - x))
flag = False
# 直線上に存在すれば三角形の面積
if x == W or y == H or x == 0 or y == 0:
    print("{:.6f}".format((W * H) / 2) , end = ' ')
    print("0")
# 直線上にない時
else:
    print('{:.6f}'.format(max(horizon , vertical)) , end = ' ')
    #if horizon == vertical:
    if x == W//2 and y == H //2
        print("1")
    else:
        print('0')

Submission status: Runtime Error

Solution code:
W, H, x, y = map(int, input().split())
if W % 2 == 0 and H % 2 == 0 and x, y = W/2, H/2 :
    print(str(W*H/2)+ ' ' + str(1))
else:
    print(str(w*H/2)+ ' ' + str(0))

Submission status: Runtime Error

Solution code:
W, H, x, y = map(int, input().split())
if W % 2 == 0 and H % 2 == 0 and x, y = W/2, H/2 :
    print(W * H /2, 1)
else:
    print(W * H /2, 0)

Submission status: Runtime Error

Solution code:
w, h, x, y = map(int, input().split())
s = 0
if w / x ==  h / y == 2:
  s = 1
print('{:.6f}'.format(w * h / 2), s)

Submission status: Runtime Error

Solution code:
W, H, x, y = map(int,input().split())
if x == W/2 and y = H/2:
    judge = 1
else:
    judge = 0
ans = (H*W)/2
print(str(ans)+' '+str(judge))

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

W,H,x,y=map(int,input().split())
l=[0,0]
if H/W==y/x or -H/W==(H-h)/x or (x==0 and y==H) or (x==0 and y==0) or (x==W and y==0) or (x==W and y==H):
    l.append(H*W/2)
v=min(x*H,(W-x)*H)
l.append(v)
h=min(y*W,(H-y)*W)
l.append(h)
l.sort()
if l[-1]==l[-2]:
    print(l[-1],1)
else:
    print(l[-1],0)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

W,H,x,y=map(int,input().split())
l=[0]
if H/W==y/x:
    l.append(H*W/2)
v=min(x*H,(W-x)*H)
l.append(v)
h=min(y*W,(H-y)*W)
l.append(h)
l.sort()
if l[-1]==l[-2]:
    print(l[-1],1)
else:
    print(l[-1],0)

Submission status: Runtime Error

Solution code:
W,H,x,y = list(map(int, input().split()))
area=[]
diaA = (W * H) - (y * x / W) / 2
diaB = (W * H) - (x * y / H) / 2
diaC = (y * x / W) / 2
diaD = (x * y / H) / 2
area.extend([x * H, (W - x) * H, W * y, W * (H - y), diaA, diaB, diaC, diaD])
area.sort()
print(area[4])
elif area.count(area[4]) >= 2:
    print(1)
else:
    print(0)

Submission status: Runtime Error

Solution code:
W,H,x,y = map(int, input().split())
print(W*H/2)
if W==2*x  and H=2*y:
  print(1)
else:
  print(0)

Submission status: Runtime Error

Solution code:

#N = int(input())
A = input().split()
#B = input().split()
for i in range(N+1):
    A[i] = int(A[i])
#for i in range(N):
#    B[i] = int(B[i])

ue = A[0]*(A[1]-A[2])
shita = A[0]*A[2]
migi = A[1]*(A[0]-A[3])
hidari = A[1]*A[3]
chinpo = True

if ue > shita:
    if migi > hidari:
        if migi == ue:
            print(str(ue) + " " + "1")
        else:
            print(str(ue) + " " + "0")
    else:
        if migi == hidari:
            print(str(migi) + " " + "1")
            chinpo = False 
        if hidari == ue & chinpo:
            print(str(ue) + " " + "1")
        else:
            print(str(ue) + " " + "0")
else:
    if ue == shita:
        print(str(ue) + " " + "1")
        chinpo = False
    if migi > hidari & chinpo:
        if migi == ue:
            print(str(ue) + " " + "1")
        else:
            print(str(ue) + " " + "0")
    else:
        if migi == hidari:
            print(str(migi) + " " + "1")
            chinpo = False
        if hidari == ue & chinpo:
            print(str(ue) + " " + "1")
        else:
            print(str(ue) + " " + "0")

Submission status: Runtime Error

Solution code:
w,h,x,y=map(int,input().split())
z=0
if x==h//2 or x==w//2 or y==h//2 or y==w//2:
    z=1
print(w*h/2+' '+z)

Submission status: Runtime Error

Solution code:
W, H, x, y = map(int, input().split())
print(' '.join(str(W * H / 2.0), '1' if (W//2 == x) and (H//2 == y) else '0'))

Submission status: Runtime Error

Solution code:
W,H,x,y = map(int,input().split())
print(W*H/2)
if W//2 == x && H//2 == y:
    print(1)
else:
    print(0)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
c = list(map(int, input().split()))
s = [0]
ans = 0
for i in range(n):
    s.append(s[-1]+c[i])
r = 0
for l in range(n):
    while r<n and s[r]-s[l]<k:
        r+=1
    ans+=n-r+int(s[r]-s[l]>=k)
print(ans)

Submission status: Runtime Error

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

elif w/2==x and h/2==y:
    ans=1

else:
    ans=0


print(w*h/2,ans)

Submission status: Runtime Error

Solution code:
w, h, x, y = map(int, input().split())
print((x * y) / 2, 1 if [x, y]=[w / 2, h / 2] else 0)

Submission status: Runtime Error

Solution code:
import sys
import math
w, h, x, y = map(int, sys.stdin.readline().split())

d = [None for i in range(4)]
d[0] = abs(x*1+y*(-1)+w*h)/math.sqrt(1**2 + (-1)**2)
d[1] = abs(x*(-h/w)+y*(-1)+h)/math.sqrt((-h/w)**2 + (-1)**2)
d[2] = abs(x-w*0.5)
d[3] = abs(y-h*0.5)

if int(w-2*x)==0 and int(h-2*y)==0:
  print(w*h/2.0, 1)
  exit()
elif int(w-2*x)==0 or int(h-2*y)==0:
  print(w*h/2.0, 0)
  exit()

if int(d1) == 0 or int(d2) == 0:
  if int(w-2*x)==0 and int(h-2*y)==0:
    print(w*h/2.0, 1)
  else:
    print(w*h/2.0, 0)
elif d.index().min(d) == 0:
  if x > 0.5*w:
    if y < h/w*x:
      print((x*w*w)/y*0.5, 0)
    else:
      print((x*h*h)/y*0.5, 0)
  else:
    b = h - (h-y)/(w-x)*w
    if y < h/w*x:
      print(h*(w-b*(w-x)/(h-y))*0.5, 0)
    else:
      print(w*(h-b)*0.5, 0)
elif d.index().min(d) == 1:
  if int(d[0]-d[1]) == 0:
    casenum = 1
  else:
    casenum = 0
    
  if x > 0.5*w:
    if  y > -h/w*x+h:
      print(w*(-(y-h)*w/x)*0.5, casenum)
    else:
      print(h*x*h/(h-y)*0.5, casenum)
  else:
    b = (h + y*w/(x-w)) * (x-w)/y
    if  y > -h/w*x+h:
      print(h*(w-(b-h)*x/(y-h))*0.5, casenum)
    else:
      print(w*(h-b)*0.5, casenum)
elif d.index().min(d) == 2:
  if y > 0.5*h:
    b = w*y/(w-2*x)
    x1=(x-0.5*w)/y*(b-h)
    if x > 0.5*w:
      print(h*(0.5*w+w-x1)*0.5, 0)
    else:
      print(h*(0.5*w+0.5*w-x1)*0.5, 0)
  else:
    b = h - 0.5*w*y/(x-0.5*w)
    x1=b*y/(0.5*w-x)
    if x > 0.5*w:
      print(0.5*h(0.5*w+w-x1), 0)
    else:
      print(0.5*h(0.5*w+0.5*w-x1), 0)    
elif d.index().min(d) == 3:
  if int(d[2]-d[3]) == 0:
    casenum = 1
  else:
    casenum = 0
  if x > 0.5*w:
    if y > 0.5*h:
      print(0.5*w*(0.5*h+h-(y-0.5*h)/x*w+0.5*h), casenum)
    else:
      print(0.5*w*(0.5*h+0.5*h-(y-0.5*h)/x*w+0.5*h), casenum)
  else:
    if y > 0.5*h:
      print(0.5*w*(0.5*h+h-(0.5*h-w*(y-0.5*h)/(x-w))), casenum)
    else:
      print(0.5*w*(0.5*h+0.5*h-(0.5*h-w*(y-0.5*h)/(x-w))), casenum)

Submission status: Runtime Error

Solution code:
import sys
import math
w, h, x, y = map(int, sys.stdin.readline().split())

d = [None for i in range(4)]
d[0] = abs(x*1+y*(-1)+w*h)/math.sqrt(1**2 + (-1)**2)
d[1] = abs(x*(-h/w)+y*(-1)+h)/math.sqrt((-h/w)**2 + (-1)**2)
d[2] = abs(x-w*0.5)
d[3] = abs(y-h*0.5)

if int(w-2*x)==0 and int(h-2*y)==0:
  print(w*h/2.0, 1)
  exit()
elif int(w-2*x)==0 or int(h-2*y)==0:
  print(w*h/2.0, 0)
  exit()

if int(d1) == 0 or int(d2) == 0:
  print(1,1)
  exit()
  if int(w-2*x)==0 and int(h-2*y)==0:
    print(w*h/2.0, 1)
  else:
    print(w*h/2.0, 0)
elif d.index().min(d) == 0:
  if x > 0.5*w:
    if y < h/w*x:
      print((x*w*w)/y*0.5, 0)
    else:
      print((x*h*h)/y*0.5, 0)
  else:
    b = h - (h-y)/(w-x)*w
    if y < h/w*x:
      print(h*(w-b*(w-x)/(h-y))*0.5, 0)
    else:
      print(w*(h-b)*0.5, 0)
elif d.index().min(d) == 1:
  if int(d[0]-d[1]) == 0:
    casenum = 1
  else:
    casenum = 0
    
  if x > 0.5*w:
    if  y > -h/w*x+h:
      print(w*(-(y-h)*w/x)*0.5, casenum)
    else:
      print(h*x*h/(h-y)*0.5, casenum)
  else:
    b = (h + y*w/(x-w)) * (x-w)/y
    if  y > -h/w*x+h:
      print(h*(w-(b-h)*x/(y-h))*0.5, casenum)
    else:
      print(w*(h-b)*0.5, casenum)
elif d.index().min(d) == 2:
  if y > 0.5*h:
    b = w*y/(w-2*x)
    x1=(x-0.5*w)/y*(b-h)
    if x > 0.5*w:
      print(h*(0.5*w+w-x1)*0.5, 0)
    else:
      print(h*(0.5*w+0.5*w-x1)*0.5, 0)
  else:
    b = h - 0.5*w*y/(x-0.5*w)
    x1=b*y/(0.5*w-x)
    if x > 0.5*w:
      print(0.5*h(0.5*w+w-x1), 0)
    else:
      print(0.5*h(0.5*w+0.5*w-x1), 0)    
elif d.index().min(d) == 3:
  if int(d[2]-d[3]) == 0:
    casenum = 1
  else:
    casenum = 0
  if x > 0.5*w:
    if y > 0.5*h:
      print(0.5*w*(0.5*h+h-(y-0.5*h)/x*w+0.5*h), casenum)
    else:
      print(0.5*w*(0.5*h+0.5*h-(y-0.5*h)/x*w+0.5*h), casenum)
  else:
    if y > 0.5*h:
      print(0.5*w*(0.5*h+h-(0.5*h-w*(y-0.5*h)/(x-w))), casenum)
    else:
      print(0.5*w*(0.5*h+0.5*h-(0.5*h-w*(y-0.5*h)/(x-w))), casenum)

Submission status: Runtime Error

Solution code:
import sys
import math
w, h, x, y = map(int, sys.stdin.readline().split())

d = [None for i in range(4)]
d[0] = abs(x*1+y*(-1)+w*h)/math.sqrt(1**2 + (-1)**2)
d[1] = abs(x*(-h/w)+y*(-1)+h)/math.sqrt((-h/w)**2 + (-1)**2)
d[2] = abs(x-w*0.5)
d[3] = abs(y-h*0.5)

if int(w-2*x)==0 and int(h-2*y)==0:
  print(w*h/2.0, 1)
  exit()
elif int(w-2*x)==0 or int(h-2*y)==0:
  print(w*h/2.0, 0)
  exit()

if int(d1) == 0 or int(d2) == 0:
  if int(w-2*x)==0 and int(h-2*y)==0:
    print(w*h/2.0, 1)
  else:
    print(w*h/2.0, 0)
elif d.index().min(d) == 0:
  if x > 0.5*w:
    if y < h/w*x:
      print((x*w*w)/y*0.5, 0)
    else:
      print((x*h*h)/y*0.5, 0)
  else:
    b = h - (h-y)/(w-x)*w
    if y < h/w*x:
      print(h*(w-b*(w-x)/(h-y))*0.5, 0)
    else:
      print(w*(h-b)*0.5, 0)
elif d.index().min(d) == 1:
  print(1,1)
  exit()
  if int(d[0]-d[1]) == 0:
    casenum = 1
  else:
    casenum = 0
    
  if x > 0.5*w:
    if  y > -h/w*x+h:
      print(w*(-(y-h)*w/x)*0.5, casenum)
    else:
      print(h*x*h/(h-y)*0.5, casenum)
  else:
    b = (h + y*w/(x-w)) * (x-w)/y
    if  y > -h/w*x+h:
      print(h*(w-(b-h)*x/(y-h))*0.5, casenum)
    else:
      print(w*(h-b)*0.5, casenum)
elif d.index().min(d) == 2:
  if y > 0.5*h:
    b = w*y/(w-2*x)
    x1=(x-0.5*w)/y*(b-h)
    if x > 0.5*w:
      print(h*(0.5*w+w-x1)*0.5, 0)
    else:
      print(h*(0.5*w+0.5*w-x1)*0.5, 0)
  else:
    b = h - 0.5*w*y/(x-0.5*w)
    x1=b*y/(0.5*w-x)
    if x > 0.5*w:
      print(0.5*h(0.5*w+w-x1), 0)
    else:
      print(0.5*h(0.5*w+0.5*w-x1), 0)    
elif d.index().min(d) == 3:
  if int(d[2]-d[3]) == 0:
    casenum = 1
  else:
    casenum = 0
  if x > 0.5*w:
    if y > 0.5*h:
      print(0.5*w*(0.5*h+h-(y-0.5*h)/x*w+0.5*h), casenum)
    else:
      print(0.5*w*(0.5*h+0.5*h-(y-0.5*h)/x*w+0.5*h), casenum)
  else:
    if y > 0.5*h:
      print(0.5*w*(0.5*h+h-(0.5*h-w*(y-0.5*h)/(x-w))), casenum)
    else:
      print(0.5*w*(0.5*h+0.5*h-(0.5*h-w*(y-0.5*h)/(x-w))), casenum)

Submission status: Runtime Error

Solution code:
import sys
import math
w, h, x, y = map(int, sys.stdin.readline().split())

d = [None for i in range(4)]
d[0] = abs(x*1+y*(-1)+w*h)/math.sqrt(1**2 + (-1)**2)
d[1] = abs(x*(-h/w)+y*(-1)+h)/math.sqrt((-h/w)**2 + (-1)**2)
d[2] = abs(x-w*0.5)
d[3] = abs(y-h*0.5)

if int(w-2*x)==0 and int(h-2*y)==0:
  print(w*h/2.0, 1)
  exit()
elif int(w-2*x)==0 or int(h-2*y)==0:
  print(w*h/2.0, 0)
  exit()

if int(d1) == 0 or int(d2) == 0:
  if int(w-2*x)==0 and int(h-2*y)==0:
    print(w*h/2.0, 1)
  else:
    print(w*h/2.0, 0)
elif d.index().min(d) == 0:
  if x > 0.5*w:
    if y < h/w*x:
      print((x*w*w)/y*0.5, 0)
    else:
      print((x*h*h)/y*0.5, 0)
  else:
    b = h - (h-y)/(w-x)*w
    if y < h/w*x:
      print(h*(w-b*(w-x)/(h-y))*0.5, 0)
    else:
      print(w*(h-b)*0.5, 0)
elif d.index().min(d) == 1:
  if int(d[0]-d[1]) == 0:
    casenum = 1
  else:
    casenum = 0
    
  if x > 0.5*w:
    if  y > -h/w*x+h:
      print(w*(-(y-h)*w/x)*0.5, casenum)
    else:
      print(h*x*h/(h-y)*0.5, casenum)
  else:
    b = (h + y*w/(x-w)) * (x-w)/y
    if  y > -h/w*x+h:
      print(h*(w-(b-h)*x/(y-h))*0.5, casenum)
    else:
      print(w*(h-b)*0.5, casenum)
elif d.index().min(d) == 2:
  print(1,1)
  exit()
  if y > 0.5*h:
    b = w*y/(w-2*x)
    x1=(x-0.5*w)/y*(b-h)
    if x > 0.5*w:
      print(h*(0.5*w+w-x1)*0.5, 0)
    else:
      print(h*(0.5*w+0.5*w-x1)*0.5, 0)
  else:
    b = h - 0.5*w*y/(x-0.5*w)
    x1=b*y/(0.5*w-x)
    if x > 0.5*w:
      print(0.5*h(0.5*w+w-x1), 0)
    else:
      print(0.5*h(0.5*w+0.5*w-x1), 0)    
elif d.index().min(d) == 3:
  if int(d[2]-d[3]) == 0:
    casenum = 1
  else:
    casenum = 0
  if x > 0.5*w:
    if y > 0.5*h:
      print(0.5*w*(0.5*h+h-(y-0.5*h)/x*w+0.5*h), casenum)
    else:
      print(0.5*w*(0.5*h+0.5*h-(y-0.5*h)/x*w+0.5*h), casenum)
  else:
    if y > 0.5*h:
      print(0.5*w*(0.5*h+h-(0.5*h-w*(y-0.5*h)/(x-w))), casenum)
    else:
      print(0.5*w*(0.5*h+0.5*h-(0.5*h-w*(y-0.5*h)/(x-w))), casenum)

Submission status: Runtime Error

Solution code:
import sys
import math
w, h, x, y = map(int, sys.stdin.readline().split())

d = [None for i in range(4)]
d[0] = abs(x*1+y*(-1)+w*h)/math.sqrt(1**2 + (-1)**2)
d[1] = abs(x*(-h/w)+y*(-1)+h)/math.sqrt((-h/w)**2 + (-1)**2)
d[2] = abs(x-w*0.5)
d[3] = abs(y-h*0.5)

if int(w-2*x)==0 and int(h-2*y)==0:
  print(w*h/2.0, 1)
  exit()
elif int(w-2*x)==0 or int(h-2*y)==0:
  print(w*h/2.0, 0)
  exit()

if int(d1) == 0 or int(d2) == 0:
  if int(w-2*x)==0 and int(h-2*y)==0:
    print(w*h/2.0, 1)
  else:
    print(w*h/2.0, 0)
elif d.index().min(d) == 0:
  if x > 0.5*w:
    if y < h/w*x:
      print((x*w*w)/y*0.5, 0)
    else:
      print((x*h*h)/y*0.5, 0)
  else:
    b = h - (h-y)/(w-x)*w
    if y < h/w*x:
      print(h*(w-b*(w-x)/(h-y))*0.5, 0)
    else:
      print(w*(h-b)*0.5, 0)
elif d.index().min(d) == 1:
  if int(d[0]-d[1]) == 0:
    casenum = 1
  else:
    casenum = 0
    
  if x > 0.5*w:
    if  y > -h/w*x+h:
      print(w*(-(y-h)*w/x)*0.5, casenum)
    else:
      print(h*x*h/(h-y)*0.5, casenum)
  else:
    b = (h + y*w/(x-w)) * (x-w)/y
    if  y > -h/w*x+h:
      print(h*(w-(b-h)*x/(y-h))*0.5, casenum)
    else:
      print(w*(h-b)*0.5, casenum)
elif d.index().min(d) == 2:
  if y > 0.5*h:
    b = w*y/(w-2*x)
    x1=(x-0.5*w)/y*(b-h)
    if x > 0.5*w:
      print(h*(0.5*w+w-x1)*0.5, 0)
    else:
      print(h*(0.5*w+0.5*w-x1)*0.5, 0)
  else:
    b = h - 0.5*w*y/(x-0.5*w)
    x1=b*y/(0.5*w-x)
    if x > 0.5*w:
      print(0.5*h(0.5*w+w-x1), 0)
    else:
      print(0.5*h(0.5*w+0.5*w-x1), 0)    
elif d.index().min(d) == 3:
  print(1,1)
  exit()
  if int(d[2]-d[3]) == 0:
    casenum = 1
  else:
    casenum = 0
  if x > 0.5*w:
    if y > 0.5*h:
      print(0.5*w*(0.5*h+h-(y-0.5*h)/x*w+0.5*h), casenum)
    else:
      print(0.5*w*(0.5*h+0.5*h-(y-0.5*h)/x*w+0.5*h), casenum)
  else:
    if y > 0.5*h:
      print(0.5*w*(0.5*h+h-(0.5*h-w*(y-0.5*h)/(x-w))), casenum)
    else:
      print(0.5*w*(0.5*h+0.5*h-(0.5*h-w*(y-0.5*h)/(x-w))), casenum)

Submission status: Runtime Error

Solution code:
import sys
import math
w, h, x, y = map(int, sys.stdin.readline().split())

d = [None for i in range(4)]
d[0] = abs(x*1+y*(-1)+w*h)/math.sqrt(1**2 + (-1)**2)
d[1] = abs(x*(-h/w)+y*(-1)+h)/math.sqrt((-h/w)**2 + (-1)**2)
d[2] = abs(x-w*0.5)
d[3] = abs(y-h*0.5)

print(1,1)
eixt()
if int(w-2*x)==0 and int(h-2*y)==0:
  print(w*h/2.0, 1)
  exit()
elif int(w-2*x)==0 or int(h-2*y)==0:
  print(w*h/2.0, 0)
  exit()

if int(d1) == 0 or int(d2) == 0:
  if int(w-2*x)==0 and int(h-2*y)==0:
    print(w*h/2.0, 1)
  else:
    print(w*h/2.0, 0)
elif d.index().min(d) == 0:
  if x > 0.5*w:
    if y < h/w*x:
      print((x*w*w)/y*0.5, 0)
    else:
      print((x*h*h)/y*0.5, 0)
  else:
    b = h - (h-y)/(w-x)*w
    if y < h/w*x:
      print(h*(w-b*(w-x)/(h-y))*0.5, 0)
    else:
      print(w*(h-b)*0.5, 0)
elif d.index().min(d) == 1:
  if int(d[0]-d[1]) == 0:
    casenum = 1
  else:
    casenum = 0
    
  if x > 0.5*w:
    if  y > -h/w*x+h:
      print(w*(-(y-h)*w/x)*0.5, casenum)
    else:
      print(h*x*h/(h-y)*0.5, casenum)
  else:
    b = (h + y*w/(x-w)) * (x-w)/y
    if  y > -h/w*x+h:
      print(h*(w-(b-h)*x/(y-h))*0.5, casenum)
    else:
      print(w*(h-b)*0.5, casenum)
elif d.index().min(d) == 2:
  if y > 0.5*h:
    b = w*y/(w-2*x)
    x1=(x-0.5*w)/y*(b-h)
    if x > 0.5*w:
      print(h*(0.5*w+w-x1)*0.5, 0)
    else:
      print(h*(0.5*w+0.5*w-x1)*0.5, 0)
  else:
    b = h - 0.5*w*y/(x-0.5*w)
    x1=b*y/(0.5*w-x)
    if x > 0.5*w:
      print(0.5*h(0.5*w+w-x1), 0)
    else:
      print(0.5*h(0.5*w+0.5*w-x1), 0)    
elif d.index().min(d) == 3:
  if int(d[2]-d[3]) == 0:
    casenum = 1
  else:
    casenum = 0
  if x > 0.5*w:
    if y > 0.5*h:
      print(0.5*w*(0.5*h+h-(y-0.5*h)/x*w+0.5*h), casenum)
    else:
      print(0.5*w*(0.5*h+0.5*h-(y-0.5*h)/x*w+0.5*h), casenum)
  else:
    if y > 0.5*h:
      print(0.5*w*(0.5*h+h-(0.5*h-w*(y-0.5*h)/(x-w))), casenum)
    else:
      print(0.5*w*(0.5*h+0.5*h-(0.5*h-w*(y-0.5*h)/(x-w))), casenum)

Submission status: Runtime Error

Solution code:
import sys
import math
w, h, x, y = map(int, sys.stdin.readline().split())

d = [None for i in range(4)]
d[0] = abs(x*1+y*(-1)+w*h)/math.sqrt(1**2 + (-1)**2)
d[1] = abs(x*(-h/w)+y*(-1)+h)/math.sqrt((-h/w)**2 + (-1)**2)
d[2] = abs(x-w*0.5)
d[3] = abs(y-h*0.5)

if int(w-2*x)==0 and int(h-2*y)==0:
  print(w*h/2.0, 1)
  exit()
elif int(w-2*x)==0 or int(h-2*y)==0:
  print(w*h/2.0, 0)
  exit()

if int(d1) == 0 or int(d2) == 0:
  print(1,1)
  eixt()
  if int(w-2*x)==0 and int(h-2*y)==0:
    print(w*h/2.0, 1)
  else:
    print(w*h/2.0, 0)
elif d.index().min(d) == 0:
  if x > 0.5*w:
    if y < h/w*x:
      print((x*w*w)/y*0.5, 0)
    else:
      print((x*h*h)/y*0.5, 0)
  else:
    b = h - (h-y)/(w-x)*w
    if y < h/w*x:
      print(h*(w-b*(w-x)/(h-y))*0.5, 0)
    else:
      print(w*(h-b)*0.5, 0)
elif d.index().min(d) == 1:
  if int(d[0]-d[1]) == 0:
    casenum = 1
  else:
    casenum = 0
    
  if x > 0.5*w:
    if  y > -h/w*x+h:
      print(w*(-(y-h)*w/x)*0.5, casenum)
    else:
      print(h*x*h/(h-y)*0.5, casenum)
  else:
    b = (h + y*w/(x-w)) * (x-w)/y
    if  y > -h/w*x+h:
      print(h*(w-(b-h)*x/(y-h))*0.5, casenum)
    else:
      print(w*(h-b)*0.5, casenum)
elif d.index().min(d) == 2:
  if y > 0.5*h:
    b = w*y/(w-2*x)
    x1=(x-0.5*w)/y*(b-h)
    if x > 0.5*w:
      print(h*(0.5*w+w-x1)*0.5, 0)
    else:
      print(h*(0.5*w+0.5*w-x1)*0.5, 0)
  else:
    b = h - 0.5*w*y/(x-0.5*w)
    x1=b*y/(0.5*w-x)
    if x > 0.5*w:
      print(0.5*h(0.5*w+w-x1), 0)
    else:
      print(0.5*h(0.5*w+0.5*w-x1), 0)    
elif d.index().min(d) == 3:
  if int(d[2]-d[3]) == 0:
    casenum = 1
  else:
    casenum = 0
  if x > 0.5*w:
    if y > 0.5*h:
      print(0.5*w*(0.5*h+h-(y-0.5*h)/x*w+0.5*h), casenum)
    else:
      print(0.5*w*(0.5*h+0.5*h-(y-0.5*h)/x*w+0.5*h), casenum)
  else:
    if y > 0.5*h:
      print(0.5*w*(0.5*h+h-(0.5*h-w*(y-0.5*h)/(x-w))), casenum)
    else:
      print(0.5*w*(0.5*h+0.5*h-(0.5*h-w*(y-0.5*h)/(x-w))), casenum)

Submission status: Runtime Error

Solution code:
import sys
import math
w, h, x, y = map(int, sys.stdin.readline().split())

d = [None for i in range(4)]
d[0] = abs(x*1+y*(-1)+w*h)/math.sqrt(1**2 + (-1)**2)
d[1] = abs(x*(-h/w)+y*(-1)+h)/math.sqrt((-h/w)**2 + (-1)**2)
d[2] = abs(x-w*0.5)
d[3] = abs(y-h*0.5)

if int(w-2*x)==0 and int(h-2*y)==0:
  print(w*h/2.0, 1)
  exit()
elif int(w-2*x)==0 or int(h-2*y)==0:
  print(w*h/2.0, 0)
  exit()

if int(d1) == 0 or int(d2) == 0:
  if int(w-2*x)==0 and int(h-2*y)==0:
    print(w*h/2.0, 1)
  else:
    print(w*h/2.0, 0)
elif d.index().min(d) == 0:
  print(1,1)
  eixt()
  if x > 0.5*w:
    if y < h/w*x:
      print((x*w*w)/y*0.5, 0)
    else:
      print((x*h*h)/y*0.5, 0)
  else:
    b = h - (h-y)/(w-x)*w
    if y < h/w*x:
      print(h*(w-b*(w-x)/(h-y))*0.5, 0)
    else:
      print(w*(h-b)*0.5, 0)
elif d.index().min(d) == 1:
  if int(d[0]-d[1]) == 0:
    casenum = 1
  else:
    casenum = 0
    
  if x > 0.5*w:
    if  y > -h/w*x+h:
      print(w*(-(y-h)*w/x)*0.5, casenum)
    else:
      print(h*x*h/(h-y)*0.5, casenum)
  else:
    b = (h + y*w/(x-w)) * (x-w)/y
    if  y > -h/w*x+h:
      print(h*(w-(b-h)*x/(y-h))*0.5, casenum)
    else:
      print(w*(h-b)*0.5, casenum)
elif d.index().min(d) == 2:
  if y > 0.5*h:
    b = w*y/(w-2*x)
    x1=(x-0.5*w)/y*(b-h)
    if x > 0.5*w:
      print(h*(0.5*w+w-x1)*0.5, 0)
    else:
      print(h*(0.5*w+0.5*w-x1)*0.5, 0)
  else:
    b = h - 0.5*w*y/(x-0.5*w)
    x1=b*y/(0.5*w-x)
    if x > 0.5*w:
      print(0.5*h(0.5*w+w-x1), 0)
    else:
      print(0.5*h(0.5*w+0.5*w-x1), 0)    
elif d.index().min(d) == 3:
  if int(d[2]-d[3]) == 0:
    casenum = 1
  else:
    casenum = 0
  if x > 0.5*w:
    if y > 0.5*h:
      print(0.5*w*(0.5*h+h-(y-0.5*h)/x*w+0.5*h), casenum)
    else:
      print(0.5*w*(0.5*h+0.5*h-(y-0.5*h)/x*w+0.5*h), casenum)
  else:
    if y > 0.5*h:
      print(0.5*w*(0.5*h+h-(0.5*h-w*(y-0.5*h)/(x-w))), casenum)
    else:
      print(0.5*w*(0.5*h+0.5*h-(0.5*h-w*(y-0.5*h)/(x-w))), casenum)

Submission status: Runtime Error

Solution code:
import sys
import math
w, h, x, y = map(int, sys.stdin.readline().split())

d = [None for i in range(4)]
d[0] = abs(x*1+y*(-1)+w*h)/math.sqrt(1**2 + (-1)**2)
d[1] = abs(x*(-h/w)+y*(-1)+h)/math.sqrt((-h/w)**2 + (-1)**2)
d[2] = abs(x-w*0.5)
d[3] = abs(y-h*0.5)

if int(w-2*x)==0 and int(h-2*y)==0:
  print(w*h/2.0, 1)
  exit()
elif int(w-2*x)==0 or int(h-2*y)==0:
  print(w*h/2.0, 0)
  exit()

if int(d1) == 0 or int(d2) == 0:
  if int(w-2*x)==0 and int(h-2*y)==0:
    print(w*h/2.0, 1)
  else:
    print(w*h/2.0, 0)
elif d.index().min(d) == 0:
  if x > 0.5*w:
    if y < h/w*x:
      print((x*w*w)/y*0.5, 0)
    else:
      print((x*h*h)/y*0.5, 0)
  else:
    b = h - (h-y)/(w-x)*w
    if y < h/w*x:
      print(h*(w-b*(w-x)/(h-y))*0.5, 0)
    else:
      print(w*(h-b)*0.5, 0)
elif d.index().min(d) == 1:
  print(1,1)
  eixt()
  if int(d[0]-d[1]) == 0:
    casenum = 1
  else:
    casenum = 0
    
  if x > 0.5*w:
    if  y > -h/w*x+h:
      print(w*(-(y-h)*w/x)*0.5, casenum)
    else:
      print(h*x*h/(h-y)*0.5, casenum)
  else:
    b = (h + y*w/(x-w)) * (x-w)/y
    if  y > -h/w*x+h:
      print(h*(w-(b-h)*x/(y-h))*0.5, casenum)
    else:
      print(w*(h-b)*0.5, casenum)
elif d.index().min(d) == 2:
  if y > 0.5*h:
    b = w*y/(w-2*x)
    x1=(x-0.5*w)/y*(b-h)
    if x > 0.5*w:
      print(h*(0.5*w+w-x1)*0.5, 0)
    else:
      print(h*(0.5*w+0.5*w-x1)*0.5, 0)
  else:
    b = h - 0.5*w*y/(x-0.5*w)
    x1=b*y/(0.5*w-x)
    if x > 0.5*w:
      print(0.5*h(0.5*w+w-x1), 0)
    else:
      print(0.5*h(0.5*w+0.5*w-x1), 0)    
elif d.index().min(d) == 3:
  if int(d[2]-d[3]) == 0:
    casenum = 1
  else:
    casenum = 0
  if x > 0.5*w:
    if y > 0.5*h:
      print(0.5*w*(0.5*h+h-(y-0.5*h)/x*w+0.5*h), casenum)
    else:
      print(0.5*w*(0.5*h+0.5*h-(y-0.5*h)/x*w+0.5*h), casenum)
  else:
    if y > 0.5*h:
      print(0.5*w*(0.5*h+h-(0.5*h-w*(y-0.5*h)/(x-w))), casenum)
    else:
      print(0.5*w*(0.5*h+0.5*h-(0.5*h-w*(y-0.5*h)/(x-w))), casenum)