#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 300000;
int xc[1+MAX_N], yc[1+MAX_N], rc[1+MAX_N];
int poz[1+MAX_N], rez[1+MAX_N];
long long ld[1+MAX_N], rd[1+MAX_N];
set<pair<long long, int>> sl, sr;
bool cmp(int a, int b) {
return rc[a] > rc[b] || (rc[a] == rc[b] && a < b);
}
double dist(int xa, int ya, int xb, int yb) {
return sqrt((long long)(xa - xb) * (xa - xb) +
(long long)(ya - yb) * (ya - yb));
}
int main() {
#ifdef HOME
FILE *fin = fopen("input.in", "r");
FILE *fout = fopen("output.out", "w");
#else
FILE *fin = stdin;
FILE *fout = stdout;
#endif
int n, ox, oy, mnx, mny;
mnx = mny = 1000000000;
fscanf(fin, "%d", &n);
for(int i = 1; i <= n; ++i) {
fscanf(fin, "%d%d%d", &xc[i], &yc[i], &rc[i]);
mnx = min(mnx, xc[i]);
mny = min(mny, yc[i]);
}
ox = oy = -2000000000;
for(int i = 1; i <= n; ++i) {
xc[i] -= mnx;
yc[i] -= mny;
long long d = llabs(ox - xc[i]) + llabs(oy - yc[i]);
ld[i] = d - 2 * rc[i];
rd[i] = d + 2 * rc[i];
sl.insert(make_pair(ld[i], i));
sl.insert(make_pair(rd[i], i));
poz[i - 1] = i;
}
sort(poz, poz + n, cmp);
for(int i = 0; i < n; ++i) {
int x = poz[i];
if(rez[x] == 0) {
set<pair<long long, int> >::iterator it;
it = sl.lower_bound(make_pair(ld[x], -1));
while(it != sl.end() && it->first <= rd[x]) {
int todel = it->second;
if((long long)(rc[x] + rc[todel]) * (rc[x] + rc[todel]) >=
(long long)(xc[x] - xc[todel]) * (xc[x] - xc[todel]) +
(long long)(yc[x] - yc[todel]) * (yc[x] - yc[todel])) {
rez[todel] = x;
sl.erase(make_pair(ld[todel] + rd[todel] - it->first, todel));
it = sl.erase(it);
} else
it++;
}
}
}
for(int i = 1; i <= n; ++i)
fprintf(fout, "%d ", rez[i]);
#ifdef HOME
fclose(fin);
fclose(fout);
#endif
return 0;
}
Compilation message
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:34:8: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
fscanf(fin, "%d", &n);
~~~~~~^~~~~~~~~~~~~~~
circle_selection.cpp:37:9: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
fscanf(fin, "%d%d%d", &xc[i], &yc[i], &rc[i]);
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
568 KB |
Output is correct |
4 |
Correct |
2 ms |
568 KB |
Output is correct |
5 |
Correct |
2 ms |
568 KB |
Output is correct |
6 |
Correct |
2 ms |
568 KB |
Output is correct |
7 |
Correct |
2 ms |
568 KB |
Output is correct |
8 |
Correct |
2 ms |
576 KB |
Output is correct |
9 |
Correct |
2 ms |
576 KB |
Output is correct |
10 |
Correct |
2 ms |
576 KB |
Output is correct |
11 |
Correct |
2 ms |
704 KB |
Output is correct |
12 |
Correct |
2 ms |
712 KB |
Output is correct |
13 |
Correct |
2 ms |
712 KB |
Output is correct |
14 |
Correct |
2 ms |
712 KB |
Output is correct |
15 |
Correct |
2 ms |
712 KB |
Output is correct |
16 |
Correct |
3 ms |
764 KB |
Output is correct |
17 |
Correct |
3 ms |
764 KB |
Output is correct |
18 |
Correct |
3 ms |
764 KB |
Output is correct |
19 |
Correct |
8 ms |
1404 KB |
Output is correct |
20 |
Correct |
8 ms |
1404 KB |
Output is correct |
21 |
Correct |
8 ms |
1420 KB |
Output is correct |
22 |
Correct |
9 ms |
1436 KB |
Output is correct |
23 |
Correct |
9 ms |
1452 KB |
Output is correct |
24 |
Correct |
9 ms |
1468 KB |
Output is correct |
25 |
Correct |
8 ms |
1468 KB |
Output is correct |
26 |
Correct |
8 ms |
1468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1328 ms |
50892 KB |
Output is correct |
2 |
Correct |
1393 ms |
50940 KB |
Output is correct |
3 |
Correct |
1343 ms |
50940 KB |
Output is correct |
4 |
Correct |
1399 ms |
50940 KB |
Output is correct |
5 |
Correct |
1108 ms |
50940 KB |
Output is correct |
6 |
Correct |
1121 ms |
50940 KB |
Output is correct |
7 |
Correct |
1158 ms |
50940 KB |
Output is correct |
8 |
Correct |
1096 ms |
50940 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
50940 KB |
Output is correct |
2 |
Correct |
654 ms |
50940 KB |
Output is correct |
3 |
Correct |
2692 ms |
50940 KB |
Output is correct |
4 |
Correct |
2668 ms |
50940 KB |
Output is correct |
5 |
Execution timed out |
3046 ms |
50940 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1195 ms |
50940 KB |
Output is correct |
2 |
Correct |
952 ms |
50940 KB |
Output is correct |
3 |
Execution timed out |
3050 ms |
50940 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
568 KB |
Output is correct |
4 |
Correct |
2 ms |
568 KB |
Output is correct |
5 |
Correct |
2 ms |
568 KB |
Output is correct |
6 |
Correct |
2 ms |
568 KB |
Output is correct |
7 |
Correct |
2 ms |
568 KB |
Output is correct |
8 |
Correct |
2 ms |
576 KB |
Output is correct |
9 |
Correct |
2 ms |
576 KB |
Output is correct |
10 |
Correct |
2 ms |
576 KB |
Output is correct |
11 |
Correct |
2 ms |
704 KB |
Output is correct |
12 |
Correct |
2 ms |
712 KB |
Output is correct |
13 |
Correct |
2 ms |
712 KB |
Output is correct |
14 |
Correct |
2 ms |
712 KB |
Output is correct |
15 |
Correct |
2 ms |
712 KB |
Output is correct |
16 |
Correct |
3 ms |
764 KB |
Output is correct |
17 |
Correct |
3 ms |
764 KB |
Output is correct |
18 |
Correct |
3 ms |
764 KB |
Output is correct |
19 |
Correct |
8 ms |
1404 KB |
Output is correct |
20 |
Correct |
8 ms |
1404 KB |
Output is correct |
21 |
Correct |
8 ms |
1420 KB |
Output is correct |
22 |
Correct |
9 ms |
1436 KB |
Output is correct |
23 |
Correct |
9 ms |
1452 KB |
Output is correct |
24 |
Correct |
9 ms |
1468 KB |
Output is correct |
25 |
Correct |
8 ms |
1468 KB |
Output is correct |
26 |
Correct |
8 ms |
1468 KB |
Output is correct |
27 |
Correct |
15 ms |
50940 KB |
Output is correct |
28 |
Correct |
16 ms |
50940 KB |
Output is correct |
29 |
Correct |
16 ms |
50940 KB |
Output is correct |
30 |
Correct |
16 ms |
50940 KB |
Output is correct |
31 |
Correct |
20 ms |
50940 KB |
Output is correct |
32 |
Correct |
18 ms |
50940 KB |
Output is correct |
33 |
Correct |
296 ms |
50940 KB |
Output is correct |
34 |
Correct |
267 ms |
50940 KB |
Output is correct |
35 |
Correct |
300 ms |
50940 KB |
Output is correct |
36 |
Correct |
327 ms |
50940 KB |
Output is correct |
37 |
Correct |
326 ms |
50940 KB |
Output is correct |
38 |
Correct |
499 ms |
50940 KB |
Output is correct |
39 |
Correct |
1932 ms |
50940 KB |
Output is correct |
40 |
Correct |
2228 ms |
50940 KB |
Output is correct |
41 |
Correct |
2195 ms |
50940 KB |
Output is correct |
42 |
Correct |
1541 ms |
50940 KB |
Output is correct |
43 |
Correct |
258 ms |
50940 KB |
Output is correct |
44 |
Correct |
226 ms |
50940 KB |
Output is correct |
45 |
Correct |
276 ms |
50940 KB |
Output is correct |
46 |
Correct |
274 ms |
50940 KB |
Output is correct |
47 |
Correct |
280 ms |
50940 KB |
Output is correct |
48 |
Correct |
245 ms |
50940 KB |
Output is correct |
49 |
Correct |
284 ms |
50940 KB |
Output is correct |
50 |
Correct |
273 ms |
50940 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
568 KB |
Output is correct |
4 |
Correct |
2 ms |
568 KB |
Output is correct |
5 |
Correct |
2 ms |
568 KB |
Output is correct |
6 |
Correct |
2 ms |
568 KB |
Output is correct |
7 |
Correct |
2 ms |
568 KB |
Output is correct |
8 |
Correct |
2 ms |
576 KB |
Output is correct |
9 |
Correct |
2 ms |
576 KB |
Output is correct |
10 |
Correct |
2 ms |
576 KB |
Output is correct |
11 |
Correct |
2 ms |
704 KB |
Output is correct |
12 |
Correct |
2 ms |
712 KB |
Output is correct |
13 |
Correct |
2 ms |
712 KB |
Output is correct |
14 |
Correct |
2 ms |
712 KB |
Output is correct |
15 |
Correct |
2 ms |
712 KB |
Output is correct |
16 |
Correct |
3 ms |
764 KB |
Output is correct |
17 |
Correct |
3 ms |
764 KB |
Output is correct |
18 |
Correct |
3 ms |
764 KB |
Output is correct |
19 |
Correct |
8 ms |
1404 KB |
Output is correct |
20 |
Correct |
8 ms |
1404 KB |
Output is correct |
21 |
Correct |
8 ms |
1420 KB |
Output is correct |
22 |
Correct |
9 ms |
1436 KB |
Output is correct |
23 |
Correct |
9 ms |
1452 KB |
Output is correct |
24 |
Correct |
9 ms |
1468 KB |
Output is correct |
25 |
Correct |
8 ms |
1468 KB |
Output is correct |
26 |
Correct |
8 ms |
1468 KB |
Output is correct |
27 |
Correct |
1328 ms |
50892 KB |
Output is correct |
28 |
Correct |
1393 ms |
50940 KB |
Output is correct |
29 |
Correct |
1343 ms |
50940 KB |
Output is correct |
30 |
Correct |
1399 ms |
50940 KB |
Output is correct |
31 |
Correct |
1108 ms |
50940 KB |
Output is correct |
32 |
Correct |
1121 ms |
50940 KB |
Output is correct |
33 |
Correct |
1158 ms |
50940 KB |
Output is correct |
34 |
Correct |
1096 ms |
50940 KB |
Output is correct |
35 |
Correct |
2 ms |
50940 KB |
Output is correct |
36 |
Correct |
654 ms |
50940 KB |
Output is correct |
37 |
Correct |
2692 ms |
50940 KB |
Output is correct |
38 |
Correct |
2668 ms |
50940 KB |
Output is correct |
39 |
Execution timed out |
3046 ms |
50940 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |