#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fi first
#define se second
#define ll long long
#define ld long double
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mpp make_pair
#define ve vector
using namespace std;
using namespace __gnu_pbds;
template<class T> using oset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll inf = 1e18; const int iinf = 1e9;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T> inline bool chmin(T& a, T b) { return (a > b ? a = b, 1 : 0); }
template <typename T> inline bool chmax(T& a, T b) { return (a < b ? a = b, 1 : 0); }
#define int long long
#define sqr(x) ((x)*1ll*(x))
struct cir { int x, y, r, id; };
inline int ds(const cir &a, const cir &b) { return sqr(a.x-b.x)+sqr(a.y-b.y); }
inline bool isec(const cir &a, const cir &b) { return ds(a, b) <= sqr(a.r + b.r); }
inline bool operator < (const cir &a, const cir &b) {
if (a.r != b.r) return a.r > b.r;
else if (a.id != b.id) return a.id < b.id;
else if (a.x != b.x) return a.x < b.x;
else return a.y < b.y;
}
inline void solve() {
int n;
cin >> n;
set<cir> st;
for (int i = 0; i < n; ++i) {
int x, y, r;
cin >> x >> y >> r;
st.insert({x, y, r, i});
}
ve<int> ans(n);
while (sz(st)) {
cir f = *st.begin();
st.erase(st.begin());
ans[f.id] = f.id;
ve<cir> bad;
for (auto &c : st) {
if (isec(f, c)) {
ans[c.id] = f.id;
bad.pb(c);
}
}
for (auto x : bad) st.erase(x);
}
for (auto i : ans) cout << i + 1 << " ";
}
signed main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int q = 1; // cin >> q;
while (q--) solve();
cerr << fixed << setprecision(3) << "Time execution: " << (double)clock() / CLOCKS_PER_SEC << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
324 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
464 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
2 ms |
468 KB |
Output is correct |
19 |
Correct |
4 ms |
1236 KB |
Output is correct |
20 |
Correct |
4 ms |
1220 KB |
Output is correct |
21 |
Correct |
4 ms |
1108 KB |
Output is correct |
22 |
Correct |
159 ms |
864 KB |
Output is correct |
23 |
Correct |
152 ms |
868 KB |
Output is correct |
24 |
Correct |
153 ms |
872 KB |
Output is correct |
25 |
Correct |
163 ms |
976 KB |
Output is correct |
26 |
Correct |
151 ms |
864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
399 ms |
49412 KB |
Output is correct |
2 |
Correct |
490 ms |
45632 KB |
Output is correct |
3 |
Correct |
433 ms |
41236 KB |
Output is correct |
4 |
Correct |
429 ms |
49356 KB |
Output is correct |
5 |
Execution timed out |
3051 ms |
30848 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
3058 ms |
11588 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3019 ms |
34048 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
324 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
464 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
2 ms |
468 KB |
Output is correct |
19 |
Correct |
4 ms |
1236 KB |
Output is correct |
20 |
Correct |
4 ms |
1220 KB |
Output is correct |
21 |
Correct |
4 ms |
1108 KB |
Output is correct |
22 |
Correct |
159 ms |
864 KB |
Output is correct |
23 |
Correct |
152 ms |
868 KB |
Output is correct |
24 |
Correct |
153 ms |
872 KB |
Output is correct |
25 |
Correct |
163 ms |
976 KB |
Output is correct |
26 |
Correct |
151 ms |
864 KB |
Output is correct |
27 |
Correct |
8 ms |
2128 KB |
Output is correct |
28 |
Correct |
8 ms |
2120 KB |
Output is correct |
29 |
Correct |
9 ms |
2048 KB |
Output is correct |
30 |
Correct |
840 ms |
1436 KB |
Output is correct |
31 |
Correct |
841 ms |
1424 KB |
Output is correct |
32 |
Correct |
819 ms |
1436 KB |
Output is correct |
33 |
Correct |
92 ms |
16196 KB |
Output is correct |
34 |
Correct |
98 ms |
16176 KB |
Output is correct |
35 |
Correct |
101 ms |
16096 KB |
Output is correct |
36 |
Execution timed out |
3070 ms |
11436 KB |
Time limit exceeded |
37 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
324 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
464 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
2 ms |
468 KB |
Output is correct |
19 |
Correct |
4 ms |
1236 KB |
Output is correct |
20 |
Correct |
4 ms |
1220 KB |
Output is correct |
21 |
Correct |
4 ms |
1108 KB |
Output is correct |
22 |
Correct |
159 ms |
864 KB |
Output is correct |
23 |
Correct |
152 ms |
868 KB |
Output is correct |
24 |
Correct |
153 ms |
872 KB |
Output is correct |
25 |
Correct |
163 ms |
976 KB |
Output is correct |
26 |
Correct |
151 ms |
864 KB |
Output is correct |
27 |
Correct |
399 ms |
49412 KB |
Output is correct |
28 |
Correct |
490 ms |
45632 KB |
Output is correct |
29 |
Correct |
433 ms |
41236 KB |
Output is correct |
30 |
Correct |
429 ms |
49356 KB |
Output is correct |
31 |
Execution timed out |
3051 ms |
30848 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |