mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
6d0ead9b6a
5300-5399
34 lines
834 B
C++
34 lines
834 B
C++
#include <cstdio>
|
|
#include <algorithm>
|
|
#include <cstring>
|
|
using namespace std;
|
|
typedef long long ll;
|
|
int main(void) {
|
|
ll n, m, x, y;
|
|
while (scanf ("%I64d%I64d%I64d%I64d", &n, &m, &x, &y) == 4) {
|
|
if (n > m) {
|
|
swap (n, m); swap (x, y);
|
|
}
|
|
if (x > n - x + 1) {
|
|
x = n - x + 1;
|
|
}
|
|
if (y > m - y + 1) {
|
|
y = m - y + 1;
|
|
}
|
|
ll hm = (m + 1) / 2, hn = (n + 1) / 2;
|
|
ll ans = min (hm, hn);
|
|
if (m == n) {
|
|
if (m % 2 == 1) {
|
|
if (x == hn && y == hm) ans--;
|
|
}
|
|
}
|
|
else {
|
|
ll t = min (y, n - x);
|
|
ans = max (ans, t);
|
|
ans = min (ans, hm);
|
|
}
|
|
printf ("%I64d\n", ans);
|
|
}
|
|
return 0;
|
|
}
|