• 题意:有一张\(n\)x\(m\)的图,图中每个点都关押着罪犯,在坐标\((r,c)\)处有一个出口,每名罪犯每秒可以可以像上下最有移动一个单位或者不动,问所有罪犯能够逃离监狱的最少时间.
  • 题解:直接算四个顶点到出口的值求个最大即可.
  • 代码:
#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;
}

最新文章

  1. RedHat5--yun源无法使用问题解决
  2. Linux VPS新硬盘分区与挂载教程
  3. bignum 大数模板
  4. new 动态分配数组空间
  5. css3动画使用技巧之—JQ配合css3实现轮播之animation-delay应用
  6. POJ 2635 The Embarrassed Cryptographer 大数模
  7. js常用操作代码
  8. python爬虫抓取豆瓣电影
  9. javascript DOM操作 节点的遍历
  10. hdu 1130 How Many Trees?(Catalan数)
  11. css3 calc()的用法
  12. 02-VC中的变量类型
  13. bootstrap研究感想1
  14. kdtree HDU5992
  15. .net core 发布linux报错“The configured user limit (128) on the number of inotify instances has been reached”
  16. 江苏省选2019Round1游记
  17. node踩坑之This is probably not a problem with npm. There is likely additional logging output above.错误
  18. Objective-C优缺点
  19. java虚拟机学习-触摸java常量池(13-1)
  20. bootstrap datepicker含有hasDatepicker无法弹出

热门文章

  1. ReentrantLock-源码解析
  2. python函数2-函数参数
  3. Python基础语法2-数据类型
  4. 【Linux】history用法
  5. 1.2V转3V芯片,电路图很少就三个元件
  6. 使用Canal作为mysql的数据同步工具
  7. 如果using语句中出现异常,资源会被释放掉吗?
  8. 一文说通Dotnet的委托
  9. (01)-Python3之--字符串操作
  10. NAT模式、路由模式、桥接模式的区别