AtCoder Beginner Contest 130 - Rectangle Cutting

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-----
2 3 1 2

-----Sample Output-----
3.000000 0

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

Source: atcoder | Difficulty: EASY


Solutions:
(a, b, x, y) = map(int, input().split())
print(a * b / 2, int(x + x == a and y + y == b))


(W, H, x, y) = map(int, input().split())
print(W * H / 2, (W == x * 2) & (H == y * 2) + 0)


(W, H, x, y) = map(int, input().split())
print(W * H / 2, int(W == 2 * x and H == 2 * y))


(w, h, x, y) = map(int, input().split())
print(w * h / 2, int((x == w / 2) & (y == h / 2)))


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


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


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


(w, h, x, y) = map(int, input().split())
print(w * h / 2, sum([2 * x == w and 2 * y == h]))


(w, h, x, y) = map(int, input().split())
print(w * (h / 2), 1 * (w / 2 == x and h / 2 == y))


(W, H, x, y) = map(int, input().split())
S = W * H / 2
T = 1 * ((2 * x, 2 * y) == (W, H))
print(S, T)


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


(W, H, x, y) = map(int, input().split())
print(W * H / 2, int(W * H == x * y * 4))


(a, b, c, d) = map(int, input().split())
print(a * b / 2.0, int((a == c * 2) & (b == d * 2)))


(w, h, x, y) = list(map(int, input().split()))
print(w * h / 2, int(w == x * 2 and h == y * 2))


(w, h, x, y) = map(int, input().split())
s = w * h * 0.5
t = 1 if w == 2 * x and h == 2 * y else 0
print(s, t)


(W, H, X, Y) = map(int, input().split())
c = 0
if X == W / 2 and Y == H / 2:
	c = 1
print(W * H / 2.0, c)


(a, b, c, d) = map(int, input().split())
print(a * b / 2, 1 if a / 2 == c and b / 2 == d else 0)


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


(w, h, x, y) = [int(i) for i in input().split()]
print(w * h / 2, 1 if w / 2 == x and h / 2 == y else 0)


import sys
sys.setrecursionlimit(10 ** 8)
ini = lambda : int(sys.stdin.readline())
inl = lambda : [int(x) for x in sys.stdin.readline().split()]
ins = lambda : sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print('\x1b[33m', *a, '\x1b[0m', **dict(file=sys.stderr, **kw))

def solve():
	(w, h, x, y) = inl()
	a = w * h / 2.0
	multi = 1 if 2 * x == w and 2 * y == h else 0
	return (float(a), multi)
print(*solve())


import math
import collections
ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(map(int, input().split()))
(w, h, x, y) = mi()
ans = w * h / 2
check = 0
if x == w / 2 and y == h / 2:
	check = 1
print('{} {}'.format(ans, check))


(W, H, X, Y) = map(int, input().split())
a = W * H / 2
b = 1 if X * 2 == W and Y * 2 == H else 0
print(a, b)


(W, H, X, Y) = map(int, input().split())
print(W * H / 2, 0 if W / 2 != X or H / 2 != Y else 1)


(w, h, x, y) = list(map(float, input().split()))
half_w = w / 2
half_h = h / 2
max_area = w * h / 2
if x == half_w and y == half_h:
	print('{:.9f} 1'.format(max_area))
else:
	print('{:.9f} 0'.format(max_area))


(W, H, x, y) = map(int, input().split())
print(W * H * 0.5, int(x == W * 0.5 and y == H * 0.5))


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


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


(w, h, x, y) = map(int, input().split())
mx = w * h / 2
no = 0
if x == w / 2 and y == h / 2:
	no = 1
print(mx, no)


(w, h, x, y) = map(int, input().split())
m = w * h / 2
print(m, int(w == 2 * x and h == 2 * y))


(W, H, x, y) = map(int, open(0).read().split())
print(W * H / 2, int(x == W / 2 and y == H / 2))


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


(w, h, x, y) = map(int, input().split())
print('%f %d' % (w * h / 2, int((x * 2 == w) & (y * 2 == h))))


(W, H, x, y) = map(int, input().split())
print(W * H / 2, ((W / 2 == x) & (H / 2 == y)) * 1)


(n, m, x, y) = map(int, input().split())
print(n * m / 2, int(x == n / 2 and y == m / 2))


def solve():
	(w, h, x, y) = map(int, input().split())
	print(w * h / 2, end=' ')
	print(1 if 2 * x == w and 2 * y == h else 0)

def __starting_point():
	solve()
__starting_point()


(w, h, x, y) = map(int, input().split())
print('{:.10f}'.format(w * h / 2), int(x * 2 == w and y * 2 == h))


(w, h, x, y) = map(int, input().split())
che = 0
center = (w / 2, h / 2)
if (x, y) == center:
	che = 1
print(w * h / 2, che)


(W, H, X, Y) = map(int, input().split(' '))
print(W * H / 2, int(W / 2 == X and H / 2 == Y))


(W, H, x, y) = map(float, input().split())
print(W * H / 2, (0, 1)[x == W / 2 and y == H / 2])


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


(w, h, *xy) = map(int, input().split())
print(w * h / 2, ([w / 2, h / 2] == xy) + 0)


(w, h, x, y) = map(int, input().split(' '))
chu = [w / 2, h / 2]
che = 0
sq = 0
if [x, y] == chu:
	che = 1
sq = h * w / 2
print(sq, che)


(w, h, x, y) = [int(x) for x in input().split()]
print(w * h / 2, int(2 * x == w and 2 * y == h))


(W, H, x, y) = map(int, input().split(' '))
print(W * H / 2, int(all([W / 2 == x, H / 2 == y])))


import sys
(w, h, x, y) = map(float, input().split())
S = w * h / 2
if x * 2 == w:
	if y * 2 == h:
		print(f'{S:.08f}' + ' 1')
		return
print(f'{S:.08f}' + ' 0')


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


(w, h, x, y) = map(int, input().split())
s = h * w / 2
ans = int((w / 2, h / 2) == (x, y))
print(s, ans)


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


import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
input = sys.stdin.readline

def RD():
	return input().rstrip()

def F():
	return float(input().rstrip())

def I():
	return int(input().rstrip())

def MI():
	return map(int, input().split())

def MF():
	return map(float, input().split())

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

def TI():
	return tuple(map(int, input().split()))

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

def Init(H, W, num):
	return [[num for i in range(W)] for j in range(H)]

def main():
	(W, H, x, y) = MI()
	ans = H * W / 2
	ans2 = 0
	if W / 2 == x and H / 2 == y:
		ans2 = 1
	print(ans, ans2)

def __starting_point():
	main()
__starting_point()


(W, H, x, y) = map(int, input().split())
S = W * H / 2
d = int(x * 2 == W and y * 2 == H)
print(S, d)


INT = lambda : int(input())
INTM = lambda : map(int, input().split())
STRM = lambda : map(str, input().split())
STR = lambda : str(input())
LIST = lambda : list(map(int, input().split()))
LISTS = lambda : list(map(str, input().split()))

def do():
	(w, h, x, y) = INTM()
	cx = w / 2
	cy = h / 2
	flg = 0
	if cx == x and cy == y:
		flg = 1
	print(w * h / 2, flg)

def __starting_point():
	do()
__starting_point()


(W, H, x, y) = map(int, input().split())
S = W * H
distx = abs(W / 2 - x)
disty = abs(H / 2 - y)
if distx == disty == 0:
	ans = (S / 2, 1)
else:
	ans = (S / 2, 0)
print(*ans)


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


(w, h, x0, y0) = [int(i) for i in input().split()]
print(w * h / 2, 1 if x0 == w / 2 and y0 == h / 2 else 0)


(a, b, c, d) = map(int, input().split())
print(a * b / 2, int(c * 2 == a and d * 2 == b))


(W, H, x, y) = [int(i) for i in input().split()]
print(W * H / 2, int(x * 2 == W and y * 2 == H))


from decimal import Decimal
(W, H, x, y) = map(int, input().split())
if W / 2 == x and H / 2 == y:
	print(Decimal(W * H / 2), 1)
else:
	print(Decimal(W * H / 2), 0)


(a, b, x, y) = map(int, input().split())
print(a * b / 2, 1 if a / 2 == x and b / 2 == y else 0)


(T, Y, x, y) = map(int, input().split())
a = '0'
if T / 2 == x and Y / 2 == y:
	a = '1'
print(T * Y / 2, a)


(W, H, a, b) = map(int, input().split())
print(W * H / 2, int(a == W - a and b == H - b))


(W, H, x, y) = list(map(float, input().split()))
ans = W * H
ans = float(float(ans) / 2.0)
ans2 = 0
if x == float(float(W) / 2) and y == float(float(H) / 2):
	ans2 = 1
print(str(ans) + ' ' + str(ans2))


(w, h, x, y) = map(int, input().split())
print(w * h / 2, '01'[w / 2 == x and h / 2 == y])


(W, H, X, Y) = map(int, input().split())
ans_1 = W * H / 2
'{:.5f}'.format(0.01)
ans_2 = 0
if W / 2 == X and H / 2 == Y:
	ans_2 = 1
print('{:.7f}'.format(ans_1), ans_2)


(w, h, x, y) = map(int, input().split())
s = 0.5 * w * h
i = 0
if 2 * x == w and 2 * y == h:
	i += 1
print(s, i)


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


(W, H, x, y) = list(map(int, input().split()))
f = x == W / 2 and y == H / 2
print(W * H / 2, int(f))


(w, h, x, y) = map(int, input().split())
print(w * h / 2.0, int(w / 2.0 == x and h / 2.0 == y))


def main():
	import sys
	pin = sys.stdin.readline
	pout = sys.stdout.write
	perr = sys.stderr.write
	(W, H, x, y) = map(int, pin().split())
	ans = W * H / 2
	pout(f'{ans} ')
	if W - x == x and H - y == y:
		print(1)
	else:
		print(0)
	return
main()


(W, H, X, Y) = map(int, input().split())
a = W * H // 2
if W * H % 2 == 1:
	a = str(a) + '.5'
b = int(W == X * 2 and H == Y * 2)
print(a, b)