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())
count = 0
area_a = 0
area_b = 0
output = 0

if (x == 0 and y == 0) or (x == w and y == 0) or (x == w and y == h) or (x == 0 and y == h):
    output = w*h/2

elif x == 0 or x == w:
    output = (y+(h-y)) * w/2
elif y == 0 or y == h:
    output = (x+(w-x)) * h/2

else:
    center_x, center_y = w/2, h/2
    print("y={}x+{}".format(center_x - x, center_y - y))
    i = center_x - x
    j = center_y - y
    w0_h = i*0 + j
    w1_h = i*x + j
    if (w0_h <= h and w0_h >= 0) and (w1_h <= h and w1_h >= 0):
        output = (w0_h+(h-w1_h)) * w/2
    h0_w = -(j/i)
    h1_w = (h-j)/i
    if (h0_w <= w and h0_w >= 0) and (h1_w <= w and h1_w >= 0):
        output = (h0_w+(w-h1_w)) * h/2

print(str(output) + " " + str(count))

Submission status: Runtime Error

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

#print("{0} {1} {2} {3}".format(str(w), str(h), str(x), str(y)))

if x > w/2:
    x = w - x
if y > h/2:
    y = h - y

# 横
men1 = w * y
men2 = w * (h-y)

# 縦
men3 = x * h
men4 = (w-x) * h

#print("{0} {1} {2} {3}".format(str(w), str(h), str(x), str(y)))
#print("{0} {1} {2} {3}".format(str(men1), str(men2), str(men3), str(men4)))

out2 = 0

if min(men1, men2) == 0:
    out1 = min(men3, men4)
elif min(men3, men4) == 0:
    out1 = min(men1, men2)
else:
    out1 = max(min(men1, men2), min(men3, men4))

if min(men1, men2) == min(men3, men4):
    out2 = 1
if men1 == men2 or men3 == men4):
    out2 = 1

if x == 0 and y ==0:
    out1 = x*y /2
    out2 = 0

print("{0} {1}".format(out1, out2))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
W, H, x, y = map(int, input().split())

if x == W/2:
    print(H*W/2, 0)
else:
    b = (H-W)/2
    a = (y-b)/x
    print((a*W+2*b)*W/2, 1)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(W, H, x, y):
    if W/2 == x and H/2 == y:
        return (W*H)/2, 1

    if y == H/W * x:
        return (W*H)/2, 0

    ans = max(min((W-x) * H, x*H), min(W * (H-y), W*y))
    if x == 0:
        ans = max(min((W * y) / 2, W * (H-y) / 2))
    if y == 0:
        ans = max(min((x * H) / 2, (W-x) * H / 2))
    return ans, 0


def main():
    W, H, x, y = read_int_n()
    print('%f %d' % slv(W, H, x, y))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

if w%x == 0 and h%y == 0:
	print(w*h/2.0, "1")
else:
	print(w*h/2.0, "0")

Submission status: Runtime Error

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

Submission status: Runtime Error

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

s1 = float(min(x*H, W*H-x*H))
s2 = float(min(y*W, W*H-y*W))
s3 = float(min((y/x*W * W * 0.5), H/((-1*(H-y)/x) + H) * H * 0.5))

b = 0
if s1 != s2 and s2 != s3 and s1 != s3:
	b = 0
else:
	b = 1
    
print(max(s1, s2, s3), b)

Submission status: Runtime Error

Solution code:
def check(ans, ans_, n):
    if ans == n:
        ans_ = 1
    elif ans < n:
        ans = n
    return ans, ans_

W, H, x, y = list(map(int, input().split()))
total = W * H

ans = min(H*x, total-H*x)
ans_ = 0
ans, ans_ = check(ans, ans_, min(W*y, total-W*y))

for w, h, y_ in [(0, 0, H), (W, 0, H)]:
    a = (y-h) / (x-w)
    x_ = abs(y_ / a)
    if x_ < H/2:
        n = W * y_ / 2
    else:
        n = H * x_ / 2
    ans, ans_ = check(ans, ans_, min(n, total-n))

for w, h, x_ in [(0, H, W), (W, H, W)]:
    a = (y-h) / (x-w)
    y_ = x_ * a
    if y_ >= 0:
        n = (H - y_) * x_ / 2
    else:
        n = y_ * x_ / 2
    ans, ans_ = check(ans, ans_, min(n, total-n))

print(ans, ans_)

Submission status: Runtime Error

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

mx = min(x, w-x)*h
my = min(y, h-y)*w
if (x == 0 or y == 0) or (x == w or y == h):
    print(max(mx, my), 0)
else:
    if mx == my:
        print(mx, 1)
    else:
        print(max(mx, my), 0)

Submission status: Runtime Error

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

if (W==x or x == 0) and (H==y or y == 0):
    ans = H*W/2
    ans2 = 0

else:
    v1 = min(x,W-x)*H
    v2 = min(y,H-y)*W
    
    ans = max (v1,v2)
    if v1 == v2:
        ans2 = 1
    else:
        ans2 = 0
if H ==X:
    ans2 =1

print(ans,ans2)

Submission status: Runtime Error

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

s = (w*h/2)

if (w/2 == x and h/2 != y)
or (w/2 != x and h/2 == y) \
or (w == x and 0 == y) \
or (0 == x and h == y) \
or (w == x and h == y) \
or (0 == x and 0 == y)):
  print(s,0)
else:
  print(s,1)

Submission status: Runtime Error

Solution code:
W, H, x, y = map(int,input().split())
buf_x = W-x
buf_y = H-y
if buf_x >= x:
  ver_area = H*x
else:
  ver_area = H*buf_x
if buf_y >= y:
  hori_area = W*y
else:
  hori_area = W*buf_y

if x*2 == W and y*2 ==H:
  print(float(W*H/2),1)
elif x*2 == W:
  print(float(W*H/2),0)
elif y*2 == H:
  print(float(W*H/2),0)
else:
  if W*y == H*x:
    print(float(W*H/2),0)
  elif x*H == W*(H-Y):
    print(float(W*H/2),0)
  else:
    if ver_area <= hori_area:
      print(float(hori_area),0)
    else:
      print(float(ver_area),0)

Submission status: Runtime Error

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

menseki = W * H
minmenseki = menseki / 2

flg = False

if (W % x == 0) and (H % y == 0):
    flg = True

if flg:
    print(str(minmenseki) + " " + "1")
else:
    print(str(minmenseki) + " " + "0")

Submission status: Runtime Error

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

d_center_W = abs(W/2 - x)
d_center_H = abs(H/2 - y)
d_45_plus =  abs((H/W)*x-1*y)/np.sqrt((H/W)**2+(-1)**2)
d_45_minus = abs((H/W)*x+y-H)/np.sqrt((H/W)**2+1**2)

min_d = min(d_center_W,d_center_H,d_45_plus,d_45_minus)
smflg = False

if [d_center_W,d_center_H,d_45_plus,d_45_minus].count(min_d) > 1:
        smflg = True

ans = 0

if min_d == d_center_W:
        if x <= W/2:
                ans = x*H/1
        else:
                ans = (W-x)*H/1
elif min_d == d_center_H:
        if y <= H/2:
                ans = y*W/1
        else:
                ans = (H-y)*W/1
elif min_d == d_45_plus:
        if x == 0 and y == 0:
                ans = x/y/x
                ans = H*W/2
        elif x == 0:
                ans = (H-(y-(H/W)*x))*(W-(W/H)*y+x)/2
        elif y/x >= H/W:
                ans = (H-(y-(H/W)*x))*(W-(W/H)*y+x)/2
        else:
                ans = (H-(x-(W/H)*y))*(H+y-(W/H)*x)/2
elif min_d == d_45_plus:
        if x <= W/2:
                x += (W/2-x)*2
        else:
                x -= (x-W/2)*2
        if x == 0:
                ans = (H-(y-(H/W)*x))*(W-(W/H)*y+x)/2
        elif y/x >= H/W:
                ans = (H-(y-(H/W)*x))*(W-(W/H)*y+x)/2
        else:
                ans = (H-(x-(W/H)*y))*(H+y-(W/H)*x)/2
if smflg:
        smstr = '1'
else:
        smstr = '0'

if H == 1 and W == 1:
        ans = 1/2

print(str(ans) + ' ' + smstr)

Submission status: Runtime Error

Solution code:
W,H,x,y = map(int,input().split())
if x == W/2 and y != H/2:
  print(x*H,0)
elif x!= W/2 and y == W/2:
  print(y*W,0)
elif x == W/2 and y == H/2:
  print(x*H,1)
elif (x == 0 and y == 0) or (x == W and y == 0) or (x == 0 and y == H) or (x == W and y == H):
  print(W*H/2,0)
elif x < W/2 and y < H/2 and Wy-xH>=0:
  print(W**2*(H-y)/(W-x)*2,0)
elif x < W/2 and y < H/2 and Wy-xH<0:
  print(H**2*(W-x)/(H-y)*2,0)
elif x < W/2 and y > H/2 and W(H-y)-xH>=0:
  print(W**2*y/(W-x)*2,0)
elif x < W/2 and y > H/2 and W(H-y)-xH<0:
  print(H**2*(W-x)/y*2,0)
elif x > W/2 and y < H/2 and Wy-(W-x)H>=0:
  print(W**2*(H-y)/x*2,0)
elif x > W/2 and y < H/2 and Wy-(W-x)H<0:
  print(H**2*x/(H-y)*2,0)
elif x > W/2 and y > H/2 and xH-Wy>=0:
  print(W**2*y/x*2,0)
elif x > W/2 and y > H/2 and xH-Wy<0:
  print(H**2*x/y*2,0)

Submission status: Runtime Error

Solution code:
import numpy as np

A = input()

W, H, x, y = map(int,A.split( ))

S1 = x * H
S2 = (W-x) * H
if (S1>S2):
  S3 = S2
else:
  S3 = S1

S4 = (H-y) * W
S5 = y * W

if (S4>S5):
  S6 = S5
else:
  S6 = S4

if(S3>S6):
  Ans = S3
  pat = 0
else if(S3=s6):
  Ans = S3
  pat = 1
else:
  Ans = S6
  pat = 0

print("{} {}".format(Ans,pat))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def inpl(): return list(map(int, input().split()))
W, H, x, y = inpl()
if x > W/2:
    x = W-x
if y > H/2:
    y = H-y

a = W*y
b = H*x
if x == 0 or y == 0:
    print(H*W/2, 0)
elif W/H == x/y:
    print(H*W/2, int(W/2==x))
elif a > b:
    print(a, int(2*x == W))
else:
    print(b, int(2*y == H))
    raise

Submission status: Runtime Error

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

d_center_W = abs(W/2 - x)
d_center_H = abs(H/2 - y)
d_45_plus =  abs((H/W)*x-1*y)/np.sqrt((H/W)**2+(-1)**2)
d_45_minus = abs((H/W)*x+y-H)/np.sqrt((H/W)**2+1**2)

min_d = min(d_center_W,d_center_H,d_45_plus,d_45_minus)
smflg = False

if [d_center_W,d_center_H,d_45_plus,d_45_minus].count(min_d) > 1:
        smflg = True

ans = 0

if min_d == d_center_W:
        if x <= W/2:
                ans = x*H/1
        else:
                ans = (W-x)*H/1
elif min_d == d_center_H:
        if y <= H/2:
                ans = y*W/1
        else:
                ans = (H-y)*W/1
elif min_d == d_45_plus:
        if x == 0:
                ans = x/y
                ans = (H-(y-(H/W)*x))*(W-(W/H)*y+x)/2
        elif y/x >= H/W:
                ans = (H-(y-(H/W)*x))*(W-(W/H)*y+x)/2
        else:
                ans = (H-(x-(W/H)*y))*(H+y-(W/H)*x)/2
elif min_d == d_45_plus:
        if x <= W/2:
                x += (W/2-x)*2
        else:
                x -= (x-W/2)*2
        if x == 0:
                ans = (H-(y-(H/W)*x))*(W-(W/H)*y+x)/2
        elif y/x >= H/W:
                ans = (H-(y-(H/W)*x))*(W-(W/H)*y+x)/2
        else:
                ans = (H-(x-(W/H)*y))*(H+y-(W/H)*x)/2
if smflg:
        smstr = '1'
else:
        smstr = '0'

if H == 1 and W == 1:
        ans = 1/2

print(str(ans) + ' ' + smstr)

Submission status: Runtime Error

Solution code:
def inpl(): return list(map(int, input().split()))
W, H, x, y = inpl()
if x > W/2:
    x = W-x
if y > H/2:
    y = H-y

a = W*y
b = H*x
if x == 0 or y == 0:
    print(H*W/2, 0)
    raise
elif W/H == x/y:
    print(H*W/2, int(W/2==x))
elif a > b:
    print(a, int(2*x == W))
else:
    print(b, int(2*y == H))

Submission status: Runtime Error

Solution code:
import numpy as np

A = input()

W, H, x, y = map(int,A.split( ))

S1 = x * H
S2 = (W-x) * H
if (S1>S2):
  S3 = S2
else:
  S3 = S1

S4 = (H-y) * W
S5 = y * W

if (S4>S5):
  S6 = S5
else:
  S6 = S4

if(S3>S6):
  Ans = S3
  pat = 0
else if(S3=s6):
  Ans = S3
  pat = 1
else:
  Ans = S6
  pat = 0

print('{} {}'.format(Ans,pat))

Submission status: Runtime Error

Solution code:
from sys import stdin
W,H,x,y = [int(x) for x in stdin.readline().rstrip().split()]
if W == H and x == y == (W/2):
    print((W*H) / 2,1)

elif W == H and x == y and x != (W/2):
    print(min(x,W-x) * float(H),1)
    
elif (W/2) == x and (H/2) == y:
    print((W*H)/2,1)

elif x == W and y == 0:
    print((W*H)/2,0)
    
elif x == 0 and y == H:
    print((W*H)/2,0)

elif x == W and y == H:
    print((W*H)/2,0)
    
elif x == 0 and y == 0:
    print((W*H)/2,0)

elif (W/x) == (H/y):
    print((W*H)/2,0)
    
else:
    squ1 = min(x,W-x) * float(H)
    squ2 = min(y,H-y) * float(W)
    print(max(squ1,squ2),0)

Submission status: Runtime Error

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

s1 = float(min(x*H, W*H-x*H))
s2 = float(min(y*W, W*H-y*W))
s3 = float(min((y/x*W * W * 0.5), H/((-1*(H-y)/x) + H) * H * 0.5))

print(max(s1, s2, s3), 0 if s1 != s2 != s3 else 1)

Submission status: Runtime Error

Solution code:
import numpy as np

A = input()

W, H, x, y = map(int,A.split())

S1 = x * H
S2 = (W-x) * H
if (S1>S2):
  S3 = S2
else:
  S3 = S1

S4 = (H-y) * W
S5 = y * W

if (S4>S5):
  S6 = S5
else:
  S6 = S4

if(S3>S6):
  Ans = S3
  pat = 0
else if(S3=s6):
  Ans = S3
  pat = 1
else:
  Ans = S6
  pat = 0

print('{} {}'.format(Ans,pat))

Submission status: Runtime Error

Solution code:
from sys import stdin
W,H,x,y = [int(x) for x in stdin.readline().rstrip().split()]
if W == H and x == y == (W/2):
    print((W*H) / 2,1)

elif W == H and x == y and x != (W/2):
    print(min(x,W-x) * float(H),1)
    
elif (W/2) == x and (H/2) == y:
    print((W*H)/2,1)

elif x == W and y == 0:
    print((W*H)/2,0)
    
elif x == 0 and y == H:
    print((W*H)/2,0)

elif x == W and y == H:
    print((W*H)/2,0)
    
elif x == 0 and y == 0:
    print((W*H)/2,0)

elif W%x == 0 and H%y == 0:
    print((W*H)/2,0)
    
else:
    squ1 = min(x,W-x) * float(H)
    squ2 = min(y,H-y) * float(W)
    print(max(squ1,squ2),0)

Submission status: Runtime Error

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

a=list(map(int,input().split()))
sowa=[a[0]]
for i in range(1,n):
    temp=sowa[-1]+a[i]
    sowa.append(temp)
ans=0
for i in range(n):
    if sowa[i]>=k:
        ans+=1
        for j in reversed(range(i)):
            bubun=sowa[i]-sowa[j]
            if bubun>=k:
                ans+=j+1
                break
print(ans)

Submission status: Runtime Error

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

if (x,y) in [(w,0), (0,h), (0,0), (w,h)] or x/w+y/h==1 or y/x==h/w:
    print(w*h/2, 0)
    sys.exit()

s1 = min(x*h, (w-x)*h)
s2 = min(y*w, (h-y)*w)

if s1==s2:
    print(s1, 1)
else:
    print(max(s1,s2), 0)

Submission status: Runtime Error

Solution code:
import numpy as np

A = input()

W, H, x, y = map(int,A.split())

S1 = x * H
S2 = (W-x) * H
if (S1>S2):
  S3 = S2
else:
  S3 = S1

S4 = (H-y) * W
S5 = y * W

if (S4>S5):
  S6 = S5
else:
  S6 = S4

if(S3>S6):
  Ans = S3
  pat = 0
else if(S3=s6):
  Ans = S3
  pat = 1
else:
  Ans = S6
  pat = 0

print('{0:06d} {}'.format(Ans,pat))

Submission status: Runtime Error

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


if(x == W and y == H):
    ans = (H * W) / 2
    print('{0} {1}'.format(ans, '0'))

elif(x == W):
    ans = W * min(y, H-y)
    print('{0} {1}'.format(ans, '0'))

elif(y == H):
    ans = min(x, W-x) * H
    print('{0} {1}'.format(ans, '0'))

elif(x == W//2 and y == H//2):
    ans = (W * H) / 2
    print('{0} {1}'.format(ans, '1'))

elif(x == W//2):
    ans = x * H
    print('{0} {1}'.format(ans, '0'))

elif(y == H//2):
    ans = W * y
    print('{0} {1}'.format(ans, '0'))

else:

    if(x < W//2 and y < H//2):
        b = H - (((H-y) / (W-x)) * W)
        if(b > 0):
            ans = (W * (H - b)) / 2
            print('{0} {1}'.format(ans, '0'))
        
        else:
            ans = ((-1 * b * ((W-x) / (H -y))) * H) / 2
            print('{0} {1}'.format(ans, '0'))
    
    elif(x > W//2 and y < H//2):
        b = -1 * (((-1 * y) / (W-x)) * W)
        if(b < H):
            ans = (b * W) / 2
            print('{0} {1}'.format(ans, '0'))
        else:
            ans = (((H-b) / ((-1 * y) / (W-x))) * H) / 2
            print('{0} {1}'.format(ans, '0'))
    
    elif(x < W//2 and y > H//2):
        b = H
        if(x <= y):
            print('{0} {1}'.format(ans, '0'))
        else:
            print('{0} {1}'.format(ans, '0'))
    else:
        b = H - ((y / x) * W)
        if(x <= y):
            print('{0} {1}'.format(ans, '0'))
        else:
            print('{0} {1}'.format(ans, '0'))

Submission status: Runtime Error

Solution code:
W, H, x, y = map(int, input().split())
if W == H and x == y and W/2 == x:
    print("{0} {1}".format(W * H / 2, 1))
else:
    x_min = min(x, W - x)
    y_min = min(y, H - y)
    x_area = x_min * H
    y_area = W * y_min

    if y/x == (H/2)/(W/2):
        print("{0} {1}".format(W * H / 2, 1))
    elif x_area != y_area:
        print("{0} {1}".format(max(x_area, y_area), 0))
    else:
        if x_area == y_area == 0:
            print("{0} {1}".format(W * H / 2, 0))
        else:
            print("{0} {1}".format(x_area, 1))

Submission status: Runtime Error

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

cnt = 0

s1 = float((abs(w - x) * abs(h)) / x)
s2 = float((abs(w - 0) * abs(h - y)) / y)

cnt = [s1,s2]
ans = cnt.count(max(cnt))
if ans > 1:
    print(max(cnt), '1')
else:
    print(max(cnt), '0')

Submission status: Runtime Error

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


if(x == W and y == H):
    ans = (H * W) / 2
    print('{0} {1}'.format(ans, '0'))

elif(x == W):
    ans = W * min(y, H-y)
    print('{0} {1}'.format(ans, '0'))

elif(y == H):
    ans = min(x, W-x) * H
    print('{0} {1}'.format(ans, '0'))

elif(x == W//2 and y == H//2):
    ans = (W * H) / 2
    print('{0} {1}'.format(ans, '1'))

elif(x == W//2):
    ans = x * H
    print('{0} {1}'.format(ans, '0'))

elif(y == H//2):
    ans = W * y
    print('{0} {1}'.format(ans, '0'))

else:

    if(x < W//2 and y < H//2):
        b = H - (((H-y) / (W-x)) * W)
        if(b > 0):
            ans = (W * (H - b)) / 2
            print('{0} {1}'.format(ans, '0'))
        
        else:
            ans = ((-1 * b * ((W-x) / (H -y))) * H) / 2
            print('{0} {1}'.format(ans, '0'))
    
    elif(x > W//2 and y < H//2):
        b = -1 * (((-1 * y) / (W-x)) * W)
        if(b < H):
            ans = (b * w) / 2
            print('{0} {1}'.format(ans, '0'))
        else:
            ans = (((H-b) / ((-1 * y) / (W-x))) * H) / 2
            print('{0} {1}'.format(ans, '0'))
    
    elif(x < W//2 and y > H//2):
        b = H
        if(x <= y):
            print('{0} {1}'.format(ans, '0'))
        else:
            print('{0} {1}'.format(ans, '0'))
    else:
        b = H - ((y / x) * W)
        if(x <= y):
            print('{0} {1}'.format(ans, '0'))
        else:
            print('{0} {1}'.format(ans, '0'))

Submission status: Runtime Error

Solution code:
W, H, x, y = map(int, input().split())
S = max(min(x*H, (W-x)*H), min(W*y, W*(H-y)))
cond = 1 if W/H==x/y else 0
    
print(S, cond)

Submission status: Runtime Error

Solution code:
w,h,x,y = map(int, input().split())
p = 0
if (x==0)|(x==w)|(y==0)|(y==h):
  mens = 0
  p = 0
if (x==(w/2))|(y==(h/2)):
  mens = w*h/2
  if (x==(w/2))&(y==(h/2)):
    p = 1
  else:
    p = 0
elif ((x/y)==(w/h))|(y == -(h/w)*x+h):
  p = 1
  mens = min(x,w-x)*h
else:
  if ((y<h/w*x)&(y<-(h/w)*x+h))|((y>h/w*x)&(y>-(h/w)*x+h)):
    p = 0
    mens = min(y,h-y)*w
  else:
    p = 0
    mens = min(x,w-x)*h
print(mens, p)

Submission status: Runtime Error

Solution code:
W, H, x, y = map(int, input().split())
if W == H and x == y and W/2 == x:
    print("{0} {1}".format(W * H / 2, 1))
else:
    x_min = min(x, W - x)
    y_min = min(y, H - y)
    x_area = x_min * H
    y_area = W * y_min
    if y/x == (W/2)/(H/2):
        print("{0} {1}".format(W * H / 2, 1))
    elif x_area != y_area:
        print("{0} {1}".format(max(x_area, y_area), 0))
    else:
        if x_area == y_area == 0:
            print("{0} {1}".format(W * H / 2, 0))
        else:
            print("{0} {1}".format(x_area, 1))

Submission status: Runtime Error

Solution code:
def solve():
    w, h, x, y = map(float, input().split())
    if (x == 0 and y == 0) or (x == w and y == h) or (x == 0 and y == h) or (x == w and y == 0):
        print(max(h, w) / 2, 1)
    ans = []
    if y != 0:
        ans.append(sorted((w * y, w * (h - y)))[0])
    if x != 0:
        ans.append(sorted((h * x, h * (w - x)))[0])
    print(max(ans), int(ans.count(max(ans)) != 1))
solve()

Submission status: Runtime Error

Solution code:
def solve():
    w, h, x, y = map(float, input().split())
    if (x == 0 and y == 0) or (x == w and y == h) or (x == 0 and y == h) or (x == w and y == 0):
        print(max(h, w) / 2, 0)
    ans = []
    if y != 0:
        ans.append(sorted((w * y, w * (h - y)))[0])
    if x != 0:
        ans.append(sorted((h * x, h * (w - x)))[0])
    print(max(ans), int(ans.count(max(ans)) != 1))
solve()

Submission status: Runtime Error

Solution code:
import sys

input = sys.stdin.readline


def main():
    W, H, x, y = [int(i) for i in input().split()]
    min_x = 0
    min_y = 0
    areas = []
    if 0 < x < W:
        area_a = x * (H - min_y)
        area_b = (W - x) * (H - min_y)
        areas.append(min([area_a, area_b]))

    if 0 < y < H:
        area_a = (W - min_x) * y
        area_b = (W - min_x) * (H - y)
        areas.append(min([area_a, area_b]))
    multi_flag = 0
    if areas > 1 and len(set(areas)) == 1:
        multi_flag = 1
    min_area = 0
    if areas:
        min_area = max(areas)
    print(min_area, multi_flag)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

count = 0
s = 0
if 2 * x == W and 2 * y == H:
    s = W * H / 2
    count = 4
else:

    if (x == 0 and y == 0) or (x == 0 and y == H) or (x == W and y == 0) or (x == W and y == H):
        s = W * H / 2
        count = 1
    elif (x == 0 and 2 * y == H) or (x == W and 2 * y == H) or (2 * x == W and y == 0) or (2 * x == W and y == H)
        s = W * H / 2
        count = 1
    else:
        if 2 * x == W:
            s = W * H / 2
            count = 1

        elif 2 * y == H:
            s = W * H / 2
            count = 1
        else:
            a = (H - 2 * y) / (2 * x - W)
            if a > 0:
                if ((H + a * x - y) / a) <= W and ((a * x - y) / a) >= 0:
                    s = (H**2 / 2 + H * (a * x - y)) / a
                    count += 2
            elif a < 0:
                s = a * (W**2) / 2 + (y - a * x) * W
                a *= -1
                if (a * W + y - a * x) <= H and (y - a * x) >= 0:
                    count += 2
if count == 1:
    print("{0:.6f}".format(s),0)
else:
    print("{0:.6f}".format(s),1)

Submission status: Runtime Error

Solution code:
def solve():
    w, h, x, y = map(float, input().split())
    if (x == 0 and y == 0) or (x == w and y == h) or (x == 0 and y == h) or (x == w and y == 0):
        print(min(h, w) / 2, 0)
    ans = []
    if y != 0:
        ans.append(sorted((w * y, w * (h - y)))[0])
    if x != 0:
        ans.append(sorted((h * x, h * (w - x)))[0])
    print(max(ans), int(ans.count(max(ans)) != 1))
solve()

Submission status: Runtime Error

Solution code:
import numpy as np

A = input()

W, H, x, y = map(int,A.split())

S1 = x * H
S2 = (W-x) * H
if (S1>S2):
  S3 = S2
else:
  S3 = S1

S4 = (H-y) * W
S5 = y * W

if (S4>S5):
  S6 = S5
else:
  S6 = S4

if(S3>S6):
  Ans = 'S3'
  pat = '0'
else if(S3=s6):
  Ans = 'S3'
  pat = '1'
else:
  Ans = 'S6'
  pat = '0'

print(Ans+pat)

Submission status: Runtime Error

Solution code:
def solve():
    w, h, x, y = map(float, input().split())
    if (x == 0 and y == 0) or (x == w and y == h) or (x == 0 and y == h) or (x == w and y == 0):
        print(min(h, w) / 2, 1)
    ans = []
    if y != 0:
        ans.append(sorted((w * y, w * (h - y)))[0])
    if x != 0:
        ans.append(sorted((h * x, h * (w - x)))[0])
    print(max(ans), int(ans.count(max(ans)) != 1))
solve()

Submission status: Runtime Error

Solution code:
import sys
w,h,x,y=map(int,input().split())
#l=[int(i) for i in input().split()]
a=[y*w,(h-y)*w]
a.sort()
b=[x*h,(w-x)*h]
b.sort()
d=[a[0],b[0]]
d.sort()
#print(a,b,d)
#0,0 x,y 
if abs((h/w)-(y/x)) < sys.float_info.epsilon:
    print((w*h)/2,0)
elif x!=w and abs((h/w)-y/(x-w))< sys.float_info.epsilon:
    print((w*h)/2,0)
elif (x==0 and y==0) or (x==w and y==h) or (x==0 and y==h) or (x==w and y==0):
    print((w*h)/2,0)
elif d[0]==d[1]:
    print(d[1],1)
else:
    print(d[1],0)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
#a = int(input())
# スペース区切りの整数の入力
#b, c = map(int, input().split())
# 文字列の入力
#s = input()
# 出力
#print("{} {}".format(a+b+c, s))

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

count = 0
s = 0
if 2 * x == W and 2 * y == H:
    s = W * H / 2
    count = 4
else:

    if (x == 0 and y == 0) or (x == 0 and y == H) or (x == W and y == 0) or (x == W and y == H):
        s = W * H / 2
        count = 1
    elif (x == 0 and 2 * y == H) or (x == W and 2 * y == H) or (2 * x == W and y == 0) or (2 * x == W and y == H)
        s = W * H / 2
        count = 1
    else:        
        if 2 * x == W:
            s = W * H / 2
            count = 1

        elif 2 * y == H:
            s = W * H / 2
            count = 1
        else:
            a = (H - 2 * y) / (2 * x - W)
            if a > 0:
                if ((H + a * x - y) / a) <= W and ((a * x - y) / a) >= 0:
                    s = (H**2 / 2 + H * (a * x - y)) / a
                    count += 2
            elif a < 0:
                s = a * (W**2) / 2 + (y - a * x) * W
                a *= -1
                if (a * W + y - a * x) <= H and (y - a * x) >= 0:
                    count += 2
if count == 1:
    print("{0:.6f}".format(s),0)
else:
    print("{0:.6f}".format(s),1)

Submission status: Runtime Error

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

if x == W or y == H or x == 0 or y == 0:
    ans = H*W/2
    ans_2 = 0
if x*H == y*W or (W-x)*H == y*W or :
    ans = H*W/2
    if float(x) == W/2 and float(y) == H/2:
        ans_2 = 1
    else:
        ans_2 = 0
else:
    yoko_a = W * y
    yoko_b = W * (H-y)
    yoko = min(yoko_a, yoko_b)

    tate_a = H * x
    tate_b = H * (W-x)
    tate = min(tate_a, tate_b)
    
    ans = max(tate, yoko)
    ans = float(ans)

    if tate == yoko:
        ans_2 = 1
    else:
        ans_2 = 0

print(ans, ans_2)

Submission status: Runtime Error

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

d_center_W = abs(W/2 - x)
d_center_H = abs(H/2 - y)
d_45_plus =  abs((H/W)*x-1*y)/np.sqrt((H/W)**2+(-1)**2)
d_45_minus = abs((H/W)*x+y-H)/np.sqrt((H/W)**2+1**2)

min_d = min(d_center_W,d_center_H,d_45_plus,d_45_minus)
smflg = False

if [d_center_W,d_center_H,d_45_plus,d_45_minus].count(min_d) > 1:
        smflg = True

ans = 0

if min_d == d_center_W:
        if x <= W/2:
                ans = x*H/1
        else:
                ans = (W-x)*H/1
elif min_d == d_center_H:
        if y <= H/2:
                ans = y*W/1
        else:
                ans = (H-y)*W/1
elif min_d == d_45_plus:
        # if x == 0:
        #         ans = (H-(y-(H/W)*x))*(W-(W/H)*y+x)/2
        if y/x >= H/W:
                ans = (H-(y-(H/W)*x))*(W-(W/H)*y+x)/2
        else:
                ans = (H-(x-(W/H)*y))*(H+y-(W/H)*x)/2
elif min_d == d_45_plus:
        if x <= W/2:
                x += (W/2-x)*2
        else:
                x -= (x-W/2)*2
        if x == 0:
                ans = (H-(y-(H/W)*x))*(W-(W/H)*y+x)/2
        elif y/x >= H/W:
                ans = (H-(y-(H/W)*x))*(W-(W/H)*y+x)/2
        else:
                ans = (H-(x-(W/H)*y))*(H+y-(W/H)*x)/2
if smflg:
        smstr = '1'
else:
        smstr = '0'

if H == 1 and W == 1:
        ans = 1/2

print(str(ans) + ' ' + smstr)

Submission status: Runtime Error

Solution code:
import numpy as np
W,H,x,y = map(int,input().split())
min_s = H*(W-2*x)
ts = H*x
flag = 0 
for d in range(0,360,0.5):
    if(d == 90 or d == 270):
        continue
    rad = np.deg2rad(d)
    a = np.tan(rad)
    h = a*W - 2*a*x + 2*y
    men = (a*x-y+h/2)*W
    s = round(abs(W*H - 2 * men),9)
    if min_s > s:
        min_s = s
        ts = men
    elif min_s == s:
        flag = 1
    
print(ts,flag)

Submission status: Runtime Error

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

if x==w/2 and y==h/2:
    print(w*h/2)
    print(1)

elif x==w/2 or y==h/2:
    print(w*h/2)
    print(0)

elif x==w or y==h:
    print(w*h)
    print(0)

else:
    tmpa=x*h
    tmpc=(w-x)*h
    tmpb=w*y
    tmpd=w*(h-y)

    print(max(min(tmpa,tmpc),min(tmpb,tmpd))
    print(0)

Submission status: Runtime Error

Solution code:
W,H,x,y = map(float,input().split())
width = max(x, W-x)
height = max(y, H-y)
menseki_1 = width*H
menseki_2 = height*W
menseki = min(menseki_2,menseki_1)
if menseki_1==menseki_2:
    print("{:.9f}".format(menseki), '1')
elif menseki_1<menseki_2 and height==H/2:
    print("{:.9f}".format(menseki), '1')
elif menseki_2<menseki_1 and width==W/2:
    print("{:.9f}".format(menseki), '1')
elif menseki = ((H*W)/2):
  	print("{:.9f}".format(menseki), '1')
else:
    print("{:.9f}".format(menseki), '0')

Submission status: Runtime Error

Solution code:
import sys

input = sys.stdin.readline


def main():
    W, H, x, y = [int(i) for i in input().split()]
    min_x = 0
    min_y = 0
    areas = []
    if 0 < x < W:
        area_a = x * (H - min_y)
        area_b = (W - x) * (H - min_y)
        areas.append(min([area_a, area_b]))

    if 0 < y < H:
        area_a = (W - min_x) * y
        area_b = (W - min_x) * (H - y)
        areas.append(min([area_a, area_b]))
    multi_flag = 0
    if areas > 1 and len(set(areas)) == 1:
        multi_flag = 1

    print(max(areas), multi_flag)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import sys
w,h,x,y=map(int,input().split())
#l=[int(i) for i in input().split()]
a=[y*w,(h-y)*w]
a.sort()
b=[x*h,(w-x)*h]
b.sort()
d=[a[0],b[0]]
d.sort()
#print(a,b,d)
#0,0 x,y 
if abs((h/w)-(y/x) < sys.float_info.epsilon:
    print((w*h)/2,0)
elif x!=w and abs((h/w)-y/(x-w))< sys.float_info.epsilon:
    print((w*h)/2,0)
elif (x==0 and y==0) or (x==w and y==h) or (x==0 and y==h) or (x==w and y==0):
    print((w*h)/2,0)
elif d[0]==d[1]:
    print(d[1],1)
else:
    print(d[1],0)