专栏文章
P1639 [USACO18FEB] Teleportation B 题解
P1639题解参与者 1已保存评论 0
文章操作
快速查看文章及其快照的属性,并进行相关操作。
- 当前评论
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @minclgr3
- 此快照首次捕获于
- 2025/12/02 00:12 3 个月前
- 此快照最后确认于
- 2025/12/02 00:12 3 个月前
P1639 [USACO18FEB] Teleportation B 题解
代码中的两个swap是为了保证
CPP#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
int a,b,x,y; cin >> a >> b >> x >> y;
if(x > y) swap(x,y);
if(a > b) swap(a,b);
cout << min(b - a,abs(x - a) + abs(y - b));//取用传送门和不用传送门的最短距离
return 0;
}
相关推荐
评论
共 0 条评论,欢迎与作者交流。
正在加载评论...