显示原始代码
#include <bits/stdc++.h>
#define USE_STD
#define USE_LL
#define USE_TOOL
#ifdef USE_STD
using namespace std;
#endif
#ifdef USE_LL
#define int long long
#endif
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define _rep(i, l, r) for (int i = (l); i >= (r); i--)
#define all(x) (x).begin(), x.end()
#define endl '\n'
#define inf32 0x3f3f3f3f
#define max32 INT_MAX
using i64 = long long;
using u64 = unsigned long long;
using i128 = __int128;
using pii = std::pair<int, int>;
template <typename T>
void print(const T &t) {
std::cout << t << endl;
}
template <typename T, typename... Args>
void print(const T &t, const Args... args) {
std::cout << t << ' ';
print(args...);
}
template <typename T>
void debug(const T &t) {
#ifdef USE_DEBUG
std::cout << t << "\n\n";
#endif
}
template <typename T, typename... Args>
void debug(const T &t, const Args... args) {
#ifdef USE_DEBUG
std::cout << t << ' ';
debug(args...);
#endif
}
#ifdef USE_TOOL
i64 ceilDiv(i64 n, i64 m) {
if (n >= 0) {
return (n + m - 1) / m;
} else {
return n / m;
}
}
i64 floorDiv(i64 n, i64 m) {
if (n >= 0) {
return n / m;
} else {
return (n - m + 1) / m;
}
}
template <class T>
void chmax(T &a, T b) {
if (a < b) {
a = b;
}
}
template <class T>
void chmin(T &a, T b) {
if (a > b) {
a = b;
}
}
i128 gcd(i128 a, i128 b) { return b ? gcd(b, a % b) : a; }
#endif
int read();
void write(int);
const int N = 5e5 + 5;
const int MOD = 1e9 + 7;
void solve() {
int n = read();
int l = read(), d = read(), r = read(), u = read();
vector<pii> p;
p.push_back({ l, d });
p.push_back({ l, u });
p.push_back({ r, u });
p.push_back({ r, d });
int idx = -1;
double v = inf32;
rep(i, 0, n) {
double x = read(), y = read();
double dd = inf32;
if (u >= y && d <= y) {
chmin(dd, (double)min(abs(x - l), abs(x - r)));
} else if (l <= x && r >= x) {
chmin(dd, (double)min(abs(u - y), abs(d - y)));
} else {
rep(i, 0, 4) {
double x1 = p[i].first, y1 = p[i].second;
chmin(dd, sqrt((double)pow(x1 - x, 2) + pow(y1 - y, 2)));
}
}
printf("%.9f ", dd);
if (dd < v) {
idx = i;
v = dd;
}
}
cout << endl;
print(idx + 1);
}
signed main() {
int T = 1;
debug("hello world");
#ifdef IN_FILE
freopen(IN_FILE, "r", stdin);
#endif
#ifdef OUT_FILE
freopen(OUT_FILE, "w", stdout);
#endif
#ifdef REAP_READ
std::cin >> T;
#endif
#ifdef USE_IOS
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);
#endif
while (T--) {
solve();
}
return 0;
}
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}
inline void write(int x) {
if (x < 0) {
putchar('-');
x = -x;
}
if (x > 9)
write(x / 10);
putchar(x % 10 + '0');
}