USACO/Bronze
백준 15751 Teleportation (USACO February 2018 Bronze 1번)
ssam..
2020. 3. 7. 00:01
문제 링크: https://www.acmicpc.net/problem/15751
15751번: Teleportation
The first and only line of input contains four space-separated integers: $a$ and $b$, describing the start and end locations, followed by $x$ and $y$, describing the teleporter. All positions are integers in the range $0 \ldots 100$, and they are not neces
www.acmicpc.net
세가지 방법중 최소값이 답임.
1. 시작점에서 도착점으로 순간이동 없이 바로 가는것.
2. 시작점에서 x로, x에서 y는 순간이동, y에서 도착점으로 가는것.
3. 시작점에서 y로, y에서 x는 순간이동, x에서 도착점으로 가는것.
1
2
3
4
5
6
7
8
9
10
11
12
13
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int a, b, x, y;
cin >> a >> b >> x >> y;
cout << min(abs(a - b), min(abs(a - x) + abs(b - y), abs(a - y) + abs(b - x))) << '\n';
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|