1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| #include<cctype> #include<cmath> #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<string> #include<queue> #include<stack> #include<set> #include<map>
using namespace std;
typedef long long LL; typedef unsigned long long ULL; const int maxn=210; const int inf=0x7fffffff; const double eps=1e-3;
int N,M;
int main() { int x,y; while(~scanf("%d%d%d%d",&N,&M,&x,&y)) { if (M<N) { swap(N,M); swap(x,y); } int t0=(N+1)>>1; int up=x-1; int down=N-x; int left=y-1; int right=M-y; if ((N&1)&&N==M&&x==y&&x==(N+1)/2) printf("%d\n",t0-1);
else { x=min(x,N-x+1); y=min(y,M-y+1); t0=max(t0,min(N-x,y)); t0=min(t0,(M+1)/2); printf("%d\n",t0); }
} return 0; }
|