Problem p03001 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep_r(i, n, m) for (int i = m; i < n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x)                                                                \
  for (auto itr : x) {                                                         \
    debug(itr);                                                                \
  }

template <class T> inline void chmax(T &ans, T t) {
  if (t > ans)
    ans = t;
}
template <class T> inline void chmin(T &ans, T t) {
  if (t < ans)
    ans = t;
}

int main() {
  double w, h, x, y;
  cin >> w >> h >> x >> y;

  cout << fixed;
  cout << setprecision(12);

  if ((x == w and y == h) or (x == 0 and y == h) or (x == w and y == 0) or
      (x == 0 and y == 0)) {
    cout << (h * w) / 2 << " " << 0 << endl;
    return 0;
  }

  double tx = w / 2, ty = h / 2;

  if (x == tx and y == ty) {
    cout << (h * w) / 2 << " " << 1 << endl;
    return 0;
  }

  if (x < tx and y > ty) {
    double cx = x + tx;
    if (cx / tx == y / ty) {
      cout << (h * w) / 2 << " " << 0 << endl;
      return 0;
    }
  } else if (x > tx and y < ty) {
    double cy = y + ty;
    if (x / tx == cy / ty) {
      cout << (h * w) / 2 << " " << 0 << endl;
      return 0;
    }
  }

  if (x / tx == y / ty) {
    cout << (h * w) / 2 << " " << 0 << endl;
    return 0;
  }

  if ((x == 0 or x == w or y == 0 or y == h)) {
    cout << (h * w) / 2 << " " << 0 << endl;
    return 0;
  }

  {
    double s1 = x * h, s2 = (w - x) * h;
    double h1 = y * w, h2 = (h - y) * w;
    // cout << s1 << " " << s2 << " " << h1 << " " << h2 << endl;
    assert(false);
    cout << max(min(s1, s2), min(h1, h2)) << " ";
    if (min(s1, s2) == min(h1, h2)) {
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
  }
}


Fixed submission:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep_r(i, n, m) for (int i = m; i < n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x)                                                                \
  for (auto itr : x) {                                                         \
    debug(itr);                                                                \
  }

template <class T> inline void chmax(T &ans, T t) {
  if (t > ans)
    ans = t;
}
template <class T> inline void chmin(T &ans, T t) {
  if (t < ans)
    ans = t;
}

int main() {
  double w, h, x, y;
  cin >> w >> h >> x >> y;

  cout << fixed;
  cout << setprecision(12);

  if ((x == w and y == h) or (x == 0 and y == h) or (x == w and y == 0) or
      (x == 0 and y == 0)) {
    cout << (h * w) / 2 << " " << 0 << endl;
    return 0;
  }

  double tx = w / 2, ty = h / 2;

  if (x == tx and y == ty) {
    cout << (h * w) / 2 << " " << 1 << endl;
    return 0;
  }

  if (x < tx and y > ty) {
    double cx = x + tx;
    if (cx / tx == y / ty) {
      cout << (h * w) / 2 << " " << 0 << endl;
      return 0;
    }
  } else if (x > tx and y < ty) {
    double cy = y + ty;
    if (x / tx == cy / ty) {
      cout << (h * w) / 2 << " " << 0 << endl;
      return 0;
    }
  }

  if (x / tx == y / ty) {
    cout << (h * w) / 2 << " " << 0 << endl;
    return 0;
  }

  if ((x == 0 or x == w or y == 0 or y == h)) {
    cout << (h * w) / 2 << " " << 0 << endl;
    return 0;
  }

  { cout << (h * w) / 2 << " " << 0 << endl; }
}