简单模拟,把用不用传送门的情况都考虑就行了
AcWing 1737 传送
#include<bits/stdc++.h>
using namespace std;
const int N = 110;
int s[N];
int a, b, x, y;
int res1, res2, ans;
int main()
{
cin>>a>>b>>x>>y;
res1 = abs(a - x) + abs(y - b);
res2 = abs(a - y) + abs(x - b);
ans = min(abs(b - a), min(res1, res2));
cout<<ans<<endl;
return 0;
}