A. Prison Break(思维)Technocup 2021 - Elimination Round 2
原题链接:http://codeforces.com/contest/1415/problem/A

 测试样例
input
3
10 10 1 1
3 5 2 4
10 2 5 1
output
18
4
6
题意: 给定一个 n ∗ m n*m n∗m的大小的牢房,现在每个牢房中有一个罪犯,给定一个逃脱口 ( x , y ) (x,y) (x,y),问所有罪犯逃脱出去的最短时间。
解题思路: 简单的思维题,实际上就是在判断哪个点离逃脱口最远,显然这个点必然是牢房的四个顶点其中之一。比较这四个顶点哪个离逃脱口最远即可。
AC代码
/*
*blog:https://blog.csdn.net/hzf0701
*邮箱:unique_powerhouse@qq.com
*注:文章若有任何问题请私信我或评论区留言,谢谢支持。
*/
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,n,a) for(int i=n;i>=a;i--)
using namespace std;
typedef long long ll;
const int maxn=1e5;//数组所开最大值
const int mod=1e9+7;//模
const int inf=0x3f3f3f3f;//无穷大
int t,n,m,r,c;
void solve(){
    int maxx=max(max(n-r+m-c,n-r+c-1),max(r-1+c-1,r-1+m-c));
    cout<<maxx<<endl;
}
int main(){
    while(cin>>t){
        while(t--){
            cin>>n>>m>>r>>c;
            solve();
        }
    }
    return 0;
}

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号