显示原始代码
#include <bits/stdc++.h>
#define LL long long
using namespace std;
#define il inline
#define rd read()
#define int long long
const int L = 1e5 + 10, lim = 1e6, inf = 1e9, mod = 1e9 + 7;
int n;
double X1, Y1, X2, Y2, dis[L];
il double cul(double x, double y) {
double ans = sqrt(x * x + y * y);
return ans;
}
il int read() {
int res = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
res = res * 10 + c - 48;
c = getchar();
}
return res * f;
}
signed main(void) {
n = rd;
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> X1 >> Y1 >> X2 >> Y2;
double x, y;
for (int i = 1; i <= n; ++i) {
cin >> x >> y;
if (X1 <= x && x <= X2)
dis[i] = min(abs(y - Y1), abs(y - Y2));
else if (Y1 <= y && y <= Y2)
dis[i] = min(abs(x - X1), abs(x - X2));
else {
int xx = min(abs(x - X1), abs(x - X2)), yy = min(abs(y - Y1), abs(y - Y2));
dis[i] = cul(xx, yy);
}
}
double minn = inf;
int k = 0;
for (int i = 1; i <= n; ++i) {
printf("%.9lf ", dis[i]);
if (dis[i] < minn)
minn = dis[i], k = i;
}
printf("\n%lld\n", k);
return 0;
}