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:
import collections
w, h, x, y = map(int, input().split())
area = []
# xの直線
area.append(min(h*x, h*(w-x)))

# yの直線
area.append(min(w*y, w*(h-y)))

# 角たち
a = w * h
tmp = h**2 * x / y
area.append(min(tmp, a - tmp))
tmp = w**2 * y / x
area.append(min(tmp, a - tmp))
tmp = w**2 * y / (w - x)
area.append(min(tmp, a - tmp))
tmp = h**2 * x / (h - y)
area.append(min(tmp, a - tmp))

ans_c = collections.Counter(area)

ans = sorted(ans_c.items(), reverse=True)[0]
size = ans[0]
a = 0
if ans[1] > 1:
    a = 1

print("{} {}".format(size, a))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

divide_x = (x * H, (W-x) * H)
divide_y = (W * y, W * (H-y))
max_value = max(min(divide_x), min(divide_y))
if min(divide_x) == min(divide_y):
    is_mullt_ans = 1
else:
     is_mullt_ans = 0

print(max_value, is_mult_ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# coding: utf-8

import sys
def input(): return sys.stdin.readline().strip()

# N = int(input())
# L = [int(x) for x in input().split()]
W, H, x, y = map(int, input().split())
# S = input()



ko = [-1] * 3
ko[0] = min(x * H, (W - x) * H)
ko[1] = min(y * W, (H - y) * W)
if y / x == H / W:
    ko[2] = (W * H) / 2

maxm = max(ko)
print(maxm, 1 if ko.count(maxm) > 1 else 0)

Submission status: Runtime Error

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

ans = 0
flag = 0
if (W / x == 2) and (H / y == 2):
  ans = W * H / 2
  flag = 1
else:
#  ans1 = 0
  if (W - x) > x:
    ans = x * H
  else:
    ans = (W - x) * H
 

print(float(ans), flag)

Submission status: Runtime Error

Solution code:

W, H, x, y = map(int, input().split())
if x=W:
    if H-y < y:
        y = H-y
    print(y*W, "0")    
elif y=H:
    if W-x < x:
        x = W-x
    print(x*H, "0")
    
else:
    if W-x < x:
        x = W-x
    if H-y < y:
        y = H-y

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

Submission status: Runtime Error

Solution code:
import collections
w, h, x, y = map(int, input().split())
area = []
# xの直線
area.append(min(h*x, h*(w-x)))

# yの直線
area.append(min(w*y, w*(h-y)))

# 角たち
a = w * h
tmp = h**2 * x / y
area.append(min(tmp, a - tmp))
tmp = w**2 * y / x
area.append(min(tmp, a - tmp))

ans_c = collections.Counter(area)

ans = sorted(ans_c.items(), reverse=True)[0]
size = ans[0]
a = 0
if ans[1] > 1:
    a = 1

print("{} {}".format(size, a))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
W,H,x,y=map(int,input().split())
X=min(W-x,x)
S1=X*H
Y=min(H-y,y)
S2=Y*W
if S1==S2:
  print(S1,1)
elif H/W==y/x:
  if S1>S2:
    print(S1,1)
  else:
    print(S2,1)
elif S1>S2:
  print(S1,0)
else:
  print(S2,0)

Submission status: Runtime Error

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

W, H, x,y =[int(x) for x in input().split()]

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

Submission status: Runtime Error

Solution code:


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


if y/x == h/w:
    num = 1
else:
    num = 0

print(h*w/2, num)

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
n=input().rstrip().split(" ")
for i in range(4):
    n[i]=int(n[i])
S=n[0]*n[1]
senter=[n[0]/2,n[1]/2]#1
dis=[n[2],n[3]]#2
a=senter[1]-dis[1]
b=dis[0]-senter[0]
if(senter[1]=dis[1] and senter[0]=dis[0]):
    print(str(S/2) 1)
else:
    print(4 0)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

s=float(w*h/2)

if w%2==0 and h%2==0:
    if w//2==x and h//2==y:
        ans=1
else:
    ans=0

print(str(float(s))+" "+str(ans))

Submission status: Runtime Error

Solution code:
inputa = list(map(int, input().split()))

S = inputa[0] * inputa[1] / 2

# W:H = x:y
# Hx = yW
# y = (H/W)x

if W / 2 == x:
  if H / 2 == y:
    print (S, " 1")
    exit(0)
print (S, " 0")

Submission status: Runtime Error

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

ans = 0
flag = 0
if (W / x == 2) and (H / y == 2):
  ans1 = 0
  if (W - x) > x:
    ans1 = x * H
  else:
    ans1 = (W - x) * H
  
  ans2 = 0
  if (H - y) > y:
    ans2 = W * y
  else:
    ans2 = W * (H - y)
  
  if ans1 < ans2:
    ans = ans1
  else:
    ans = ans2
    
  flag = 1
else:
  ans = W * H / 2

print(ans, flag)

Submission status: Runtime Error

Solution code:
# coding: utf-8

import sys
def input(): return sys.stdin.readline().strip()

# N = int(input())
# L = [int(x) for x in input().split()]
W, H, x, y = map(int, input().split())
# S = input()

ko = [-1] * 3
ko[0] = min(x * H, (W - x) * H)
ko[1] = min(y * W, (H - y) * W)
if y / x == (H - y) / (W - x):
    ko[2] = (W * H) / 2

maxm = max(ko)
print(maxm, 1 if ko.count(maxm) > 1 else 0)

Submission status: Runtime Error

Solution code:
W,H,x,y ==map(int ,raw_input().split())
i = 0
if x*2 == W and y +2 ==H:
    i = 1
print float(W*H)/2,i

Submission status: Runtime Error

Solution code:
w,h,x,y = map(int,input().split())
first = min(x*h,(w-x)*h)
second =min(y*w,(h-y)*w)
if first == second:
        print(f"{first:6f} 1")
else:
        print(f"{max(first,second):6f} 0")

Submission status: Runtime Error

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

c_x = w/2
c_y = h/2

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

Submission status: Runtime Error

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

ans = 0
flag = 0
if (W / x == 2) and (H / y == 2):
  ans1 = 0
  if (W - x) > x:
    ans1 = x * H
  else:
    ans1 = (W - x) * H
  
  ans2 = 0
  if (H - y) > y:
    ans2 = W * y
  else:
    ans2 = W * (H - y)
  
  if ans1 < ans2:
    ans = ans1
  else:
    ans = ans2
    
  flag = 1
else:
  ans = W * H / 2

print(round(float(ans), 6), flag)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys


def solve(W, H, x, y):
    if x==0:
        ans = W*min(y, H-y)
        print(ans+" 0")
        return
    if y == 0:
        ans = H*min(x, W-x)
        print(ans+" 0")
        return

    s1 = W*min(y, H-y)
    s2 = H*min(x, W-x)
    if y*W > H*x:
        s_ = H**2*x/(2*y)
        s3 = min(H*W - s_, s_)
    else:
        s_ = W**2*y/(2*x)
        s3 = min(H*W - s_, s_)
    ss = [s1, s2, s3]
    ans = str(max(ss))
    if len(list(set(ss))) == len(ss):
        flag = "0"
    else:
        flag = "1"
    print(ans + " " + flag)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    W = int(next(tokens))  # type: int
    H = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    y = int(next(tokens))  # type: int
    solve(W, H, x, y)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!

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


if(W%x==0 and H%y==0):
    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())
first = min(x*h,(w-x)*h)
second =min(y*w,(h-y)*w)
if first == second:
        print(f"{float(first)} 0")
else:
        print(f"{float(max(first,second))} 0")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
W, H, x, y = map(int, 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((W*H)/2, 0)
elif (x/y == W/H) or (y/x == H/W):
    print((W*H)/2, 0)
elif abs(W/2-x) > abs(H/2-y):
    A = W*y
    B = W*(H-y)
    print(min(A,B), 0)
elif abs(H/2-y) > abs(W/2-x):
    A = H*x
    B = H*(W-x)
    print(min(A,B), 0)
else:
    print((W*H)/2, 1)

Submission status: Runtime Error

Solution code:
W,H,x,y ==map(int ,raw_input().split())
i = 0
if x*2 = W and y +2 =H:
    i = 1
print float(W*H)/2,i

Submission status: Runtime Error

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

print(H*W/2)

if x = W/2 and y = H/2:
    print(1)
else:
    print(0)

Submission status: Runtime Error

Solution code:
import sys

W, H, x, y = list(map(int, sys.stdin.readline()))
b = 0

if x == W/2 and y == H/2:
    b = 1

print(str(W*H/2) + " " + str(b))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
W, H, x, y = map(float, input().split())
jufuku = 0
if W % x == 0 and H % y == 0:
    kiri = W * H / 2
    jufuku = 1
else:
    # 縦
    tate = min((W - x) * H, x * H)
    # 横
    yoko = min(W * (H - y), W * y)
    if tate == yoko:
        jufuku = 1
    else:
        kiri = max(tate, yoko)
print(kiri, jufuku)

Submission status: Runtime Error

Solution code:
h,w,x,y = (int(num) for num in input().split())
if h==w:
    if(x==y and x!=h/2):
        print(h*w/2,0)
    else:
        print(h*w/2,1)
else:
    if(x==h/2 or y==w/2):
        print(h*w/2,0)
    else:
        prtin(h*w/2,1)

Submission status: Runtime Error

Solution code:
W, H, x, y = [int(item) for item in input().split()]
S = W * H
m = max(min(x/W, 1-x/W), min(y/H, 1-y/H))
ans_s = S * m
ans_m = 0
if (W/x == 2 and H/y==2):
  ans_m = 1
print (ans_s, ans_m)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys

input = sys.stdin.readline

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

if w == h:
    print(f"{w * h / 2} 1")
else:
    print(f"{w * h / 2} 0")

Submission status: Runtime Error

Solution code:
W, H, x, y = map(int, raw_input().split())
int mul = 0
if x*2 == W and y*2 == H:
 mul = 1
A = W * H / 2.0
print '%f %d' % (A, mul)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
2 2 1 1

Submission status: Runtime Error

Solution code:
N = input()
N = int(N)
s = [[ int(i) for i in input().split()] for i in range(N)]
W = [int(i) for i in input().split()] 


W,H,x,y = (int(i) for i in input().split())
hoge = 0
if W//2 == x and H // 2 == y:
    hoge = 1

print(str(W*H//2) +" " + str(hoge))