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

Solution in C# (Mono 4.6.2.0) (judge verdict: Accepted)

using System;
using System.Linq;
using System.Collections.Generic;

namespace Contest
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC130.C();
        }
        class ABC130
        {
            public static void A()
            {
                Console.WriteLine(Read.Int() < Read.Int() ? 0 : 10);
            }
            public static void B()
            {
                var N = Read.Int();
                var X = Read.Int();
                var L = Read.LongN();
                var D = Util.ASum(L);
                Console.WriteLine(D.Count(x => x <= X));
            }
            public static void C()
            {
                var W = Read.Long();
                var H = Read.Long();
                var x = Read.Long();
                var y = Read.Long();
                bool isCenter = W == x * 2 && H == y * 2;
                Console.WriteLine("{0} {1}", 1.0 * H * W / 2, isCenter ? 1 : 0);
            }
            public static void D()
            {
                var N = Read.Int();
                var K = Read.Long();
                var A = Read.LongN();
                long count = 0;
                int right = 0;
                long total = 0;
                for(int left = 0; left < N; ++left)
                {
                    while (right < N && total + A[right] < K)
                    {
                        total += A[right];
                        right++;
                    }
                    count += right - left;
                    if (left == right)
                    {
                        right++;
                    }
                    else
                    {
                        total -= A[left];
                    }
                }
                Console.WriteLine((long)N * (N + 1) / 2 - count);
            }
            public static void E()
            {
                var N = Read.Int();
                var M = Read.Int();
                var S = Read.IntN();
                var T = Read.IntN();
                var dp1 = new long[N + 1, M + 1];
                var dp2 = new long[N + 1, M + 1];
                for (int i = 0; i < N; ++i)
                {
                    for (int j = 0; j < M; ++j)
                    {
                        dp1[i + 1, j + 1] = S[i] == T[j] ? dp2[i, j] + 1 : 0;
                        dp2[i + 1, j + 1] = (dp2[i + 1, j] + dp2[i, j + 1] - dp2[i, j] + dp1[i + 1, j + 1]) % Util.P;
                    }
                }
                Console.WriteLine(dp2[N, M] + 1);
            }
            public static void F()
            {
                var N = Read.Int();
                //List<double> X = new List<double>();
                //List<double> Y = new List<double>();
                //List<string> D = new List<string>();
                //for(int i = 0; i < N; ++i)
                //{
                //    var s = Read.StrN();
                //    X.Add(Convert.ToDouble(s[0]));
                //    Y.Add(Convert.ToDouble(s[1]));
                //    D.Add(s[2]);
                //}
                double maxX_UD = Double.MinValue, minX_UD = Double.MaxValue, maxX_L = Double.MinValue, minX_L = Double.MaxValue, maxX_R = Double.MinValue, minX_R = Double.MaxValue;
                double maxY_LR = Double.MinValue, minY_LR = Double.MaxValue, maxY_D = Double.MinValue, minY_D = Double.MaxValue, maxY_U = Double.MinValue, minY_U = Double.MaxValue;
                for (int i = 0; i < N; ++i)
                {
                    var s = Read.StrN();
                    var x  =Convert.ToDouble(s[0]);
                    var y = Convert.ToDouble(s[1]);
                    switch (s[2])
                    {
                        case "U":
                            maxX_UD = Math.Max(maxX_UD, x);
                            minX_UD = Math.Min(minX_UD, x);
                            maxY_U = Math.Max(maxY_U, y);
                            minY_U = Math.Max(minY_U, y);
                            break;
                        case "D":
                            maxX_UD = Math.Max(maxX_UD, x);
                            minX_UD = Math.Min(minX_UD, x);
                            maxY_D = Math.Max(maxY_D, y);
                            minY_D = Math.Max(minY_D, y);
                            break;
                        case "L":
                            maxX_L = Math.Max(maxX_L, x);
                            minX_L = Math.Min(minX_L, x);
                            maxY_LR = Math.Max(maxY_LR, y);
                            minY_LR = Math.Min(minY_LR, y);
                            break;
                        case "R":
                            maxX_R = Math.Max(maxX_R, x);
                            minX_R = Math.Min(minX_R, x);
                            maxY_LR = Math.Max(maxY_LR, y);
                            minY_LR = Math.Min(minY_LR, y);
                            break;
                    }
                }
                List<double> candidate = new List<double>();
                candidate.Add(0);
                candidate.Add(maxX_L - maxX_UD);
                candidate.Add(maxX_L - minX_UD);
                candidate.Add(minX_L - maxX_UD);
                candidate.Add(minX_L - minX_UD);
                candidate.Add(maxX_UD - maxX_R);
                candidate.Add(minX_UD - maxX_R);
                candidate.Add(maxX_UD - minX_R);
                candidate.Add(minX_UD - minX_R);
                candidate.Add((maxX_L - maxX_R) / 2);
                candidate.Add((minX_L - minX_R) / 2);
                candidate.Add(maxY_D - maxY_LR);
                candidate.Add(maxY_D - minY_LR);
                candidate.Add(minY_D - maxY_LR);
                candidate.Add(minY_D - minY_LR);
                candidate.Add(maxY_LR - maxY_U);
                candidate.Add(minY_LR - maxY_U);
                candidate.Add(maxY_LR - minY_U);
                candidate.Add(minY_LR - minY_U);
                candidate.Add((maxY_D - maxY_U) / 2);
                candidate.Add((minY_D - minY_U) / 2);
                candidate = candidate.Distinct().Where(x => x >= 0 && x < 1e9).ToList();
                double min = Double.MaxValue;
                foreach(var t in candidate)
                {
                    double maxX = Math.Max(maxX_UD, Math.Max(maxX_L - t, maxX_R + t));
                    double minX = Math.Min(minX_UD, Math.Min(minX_L - t, minX_R + t));
                    double maxY = Math.Max(maxY_LR, Math.Max(maxY_D - t, maxY_U + t));
                    double minY = Math.Min(minY_LR, Math.Min(minY_D - t, minY_U + t));
                    double v = (maxX - minX) * (maxY - minY);
                    min = Math.Min(min, v);
                }
                Console.WriteLine(min);
            }
        }

        class Util
        {
            public static readonly long P = 1000000007;
            public static long[] ASum(long[] array)
            {
                var res = new long[array.Length + 1];
                for (int i = 0; i < array.Length; ++i)
                {
                    res[i + 1] = res[i] + array[i];
                }
                return res;
            }

        }

        static class Read
        {
            static Queue<string> queue = new Queue<string>();
            static void Enqueue() { var ss = Console.ReadLine().Split(' '); foreach (var s in ss) { queue.Enqueue(s); } }
            public static int Int() { if (queue.Count == 0) { Enqueue(); } return Convert.ToInt32(queue.Dequeue()); }
            public static long Long() { if (queue.Count == 0) { Enqueue(); } return Convert.ToInt64(queue.Dequeue()); }
            public static string Str() { if (queue.Count == 0) { Enqueue(); } return queue.Dequeue(); }
            public static int[] IntN() { return Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray(); }
            public static long[] LongN() { return Console.ReadLine().Split(' ').Select(s => Convert.ToInt64(s)).ToArray(); }
            public static string[] StrN() { return Console.ReadLine().Split(' '); }
            public static Tuple<int, int>[] TupleInt(int n) { List<Tuple<int, int>> list = new List<Tuple<int, int>>(); for (int i = 0; i < n; ++i) { var ab = Read.IntN(); list.Add(new Tuple<int, int>(ab[0], ab[1])); } return list.ToArray(); }
            public static Tuple<long, long>[] TupleLong(int n) { List<Tuple<long, long>> list = new List<Tuple<long, long>>(); for (int i = 0; i < n; ++i) { var ab = Read.LongN(); list.Add(new Tuple<long, long>(ab[0], ab[1])); } return list.ToArray(); }
            public static Tuple<string, string>[] TupleStr(int n) { List<Tuple<string, string>> list = new List<Tuple<string, string>>(); for (int i = 0; i < n; ++i) { var ab = Read.StrN(); list.Add(new Tuple<string, string>(ab[0], ab[1])); } return list.ToArray(); }
            public static Tuple<double, double>[] TupleDouble(int n) { List<Tuple<double, double>> list = new List<Tuple<double, double>>(); for (int i = 0; i < n; ++i) { var ab = Read.LongN(); list.Add(new Tuple<double, double>(ab[0], ab[1])); } return list.ToArray(); }
            public static long[,] LongMatrix(int r, int c)
            {
                var mat = new long[r, c];
                for (int i = 0; i < r; ++i)
                {
                    var x = Read.LongN();
                    for (int j = 0; j < c; ++j)
                    {
                        mat[i, j] = x[j];
                    }
                }
                return mat;
            }
            public static Dictionary<int, HashSet<int>> AdjacencyList(int N, int M)
            {
                Dictionary<int, HashSet<int>> dict = new Dictionary<int, HashSet<int>>();
                for (int i = 0; i <= N; ++i)
                {
                    dict.Add(i, new HashSet<int>());
                }
                for (int i = 0; i < M; ++i)
                {
                    var ab = Read.IntN();
                    dict[ab[0]].Add(ab[1]);
                    dict[ab[1]].Add(ab[0]);
                }
                return dict;
            }
            public static Dictionary<int, Dictionary<int, long>> AdjacencyListWithWeight(int N, int M)
            {
                Dictionary<int, Dictionary<int, long>> dict = new Dictionary<int, Dictionary<int, long>>();
                for (int i = 0; i <= N; ++i)
                {
                    dict.Add(i, new Dictionary<int, long>());
                }
                for (int i = 0; i < M; ++i)
                {
                    var ab = Read.IntN();
                    dict[ab[0]].Add(ab[1], ab[2]);
                    dict[ab[1]].Add(ab[0], ab[2]);
                }
                return dict;
            }
        }
    }
}