[cf] Codeforces Round #687 (Div 2)
作者:互联网
Codeforces Round #687 (Div 2)
A.Prison Break
水题,直接找4个角,距离出口最远的距离,就是答案
#include <bits/stdc++.h>
using namespace std;
void file()
{
#ifdef ONLINE_JUDGE
#else
freopen( "d:/workProgram/test.txt","r",stdin );
#endif
}
int main()
{
//file();
int t ;
cin >> t;
while(t --){
int n,m,r,c;
cin >> n >> m >>r >> c;
int maxn = 0;
int a,b;
///case1
a = r - 1; b = c - 1;
maxn = max( maxn, a + b);
///case2
a = abs(r - 1); b = abs( c - m );
maxn = max( maxn, a + b);
///case3
a = abs(r - n); b = abs( c - 1 );
maxn = max( maxn, a + b);
///case4
a = abs(r - n); b = abs( c - m );
maxn = max( maxn, a + b);
cout << maxn <<endl;
}
return 0;
}
B.Repainting Street
标签:int,max,cf,Codeforces,abs,maxn,file,687,Div 来源: https://www.cnblogs.com/hoppz/p/14076237.html