-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorat.cpp
58 lines (50 loc) · 1.19 KB
/
orat.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
const long long INF = 2e9;
struct st {
string x, y;
long long a, b, c, d;
int r1, r2;
bool operator<(const st& o) {
long long dx1 = a - c, dx2 = o.a - o.c;
long long dy1 = b - d, dy2 = o.b - o.d;
return (dx1 * dx1 + dy1 * dy1 > dx2 * dx2 + dy2 * dy2);
};
long long F() {
long long dx = a - c;
long long dy = b - d;
return dx * dx + dy * dy;
}
};
long long G(long long x) {
long long l = 1, r = INF, ret = INF;
while (l <= r) {
long long mid = (l + r) >> 1;
if (mid * mid <= x) {
ret = mid;
l = mid + 1;
} else {
r = mid - 1;
}
}
return ret;
}
int n;
st p[N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> p[i].x >> p[i].a >> p[i].b >> p[i].r1;
cin >> p[i].y >> p[i].c >> p[i].d >> p[i].r2;
}
sort(p + 1, p + 1 + n);
for (int i = 1; i <= n; i++) {
long long res = p[i].F();
cout << p[i].x << " " << p[i].y << " " << G(res) << '\n';
}
return 0;
}