Codeforces Round #687 (Div. 2, based on Technocup 2021 Elimination Round 2) A. Prison Break
2024-10-15 13:07:06
- 题意:有一张\(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;
}
最新文章
- RedHat5--yun源无法使用问题解决
- Linux VPS新硬盘分区与挂载教程
- bignum 大数模板
- new 动态分配数组空间
- css3动画使用技巧之—JQ配合css3实现轮播之animation-delay应用
- POJ 2635 The Embarrassed Cryptographer 大数模
- js常用操作代码
- python爬虫抓取豆瓣电影
- javascript DOM操作 节点的遍历
- hdu 1130 How Many Trees?(Catalan数)
- css3 calc()的用法
- 02-VC中的变量类型
- bootstrap研究感想1
- kdtree HDU5992
- .net core 发布linux报错“The configured user limit (128) on the number of inotify instances has been reached”
- 江苏省选2019Round1游记
- node踩坑之This is probably not a problem with npm. There is likely additional logging output above.错误
- Objective-C优缺点
- java虚拟机学习-触摸java常量池(13-1)
- bootstrap datepicker含有hasDatepicker无法弹出