#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
#define rep(a,b,c) for(int a=b;a<=c;++a)
#define per(a,b,c) for(int a=b;a>=c;--a)
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
int t;
int n,m,r,c;
int main() {
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
cin>>t;
while(t--){
cin>>n>>m>>r>>c;
ll cnt1=r-1+c-1;
ll cnt2=n-r+c-1;
ll cnt3=r-1+m-c;
ll cnt4=n-r+m-c;
ll ans=max(cnt1,cnt2);
ans=max(ans,cnt3);
cout<<max(ans,cnt4)<<‘\n‘;
}
return 0;
}
Codeforces Round #687 (Div. 2, based on Technocup 2021 Elimination Round 2) A. Prison Break
原文:https://www.cnblogs.com/lr599909928/p/14058168.html