# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
99832 | 2019-03-07T17:01:04 Z | TadijaSebez | Circle selection (APIO18_circle_selection) | C++11 | 3000 ms | 52628 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long #define mp make_pair #define pb push_back struct circle{ ll x,y,r;int id;circle(){}circle(ll a, ll b, ll c):x(a),y(b),r(c){}}; ll sq(ll x){ return x*x;} bool sec(circle a, circle b){ return sq(a.x-b.x)+sq(a.y-b.y)<=sq(a.r+b.r);} bool operator < (circle a, circle b){ return a.r<b.r;} const int N=300050; const int mul=2e9+7; const int inf=1e9+7; circle a[N],b[N]; int ans[N]; unordered_map<ll,int> id; set<pair<int,int>> all[N]; int main() { int n,i; scanf("%i",&n); for(i=1;i<=n;i++) scanf("%lld %lld %lld",&a[i].x,&a[i].y,&a[i].r),a[i].id=i,b[i]=a[i]; sort(a+1,a+1+n,[](circle a, circle b){ return a.r>b.r || a.r==b.r && a.id<b.id;}); for(int j=30;j>=0;j--) { int po=1<<j; id.clear(); int cnt=0; for(i=1;i<=n;i++) if(!ans[a[i].id]) { pair<int,int> pa=mp(floor((double)a[i].x/po),floor((double)a[i].y/po)); ll p=pa.first; if(!id[p]) id[p]=++cnt,all[cnt].clear(); all[id[p]].insert(mp(pa.second,a[i].id)); } //for(i=1;i<=cnt;i++) sort(all[i].begin(),all[i].end()); for(i=1;i<=n;i++) if(!ans[a[i].id] && a[i].r>=(1<<j-1)) { int x=floor((double)a[i].x/po); int y=floor((double)a[i].y/po); for(int l=-2;l<=2;l++) { ll p=x+l; if(!id.count(p)) continue; int idx=id[p]; auto lb=all[idx].upper_bound(mp(y-3,inf)); auto rb=all[idx].upper_bound(mp(y+2,inf)); vector<pair<int,int>> er; for(auto r=lb;r!=rb;r++) { int c=r->second; if(sec(b[c],a[i])) ans[c]=a[i].id,er.pb(*r);; } for(auto h:er) all[idx].erase(h); } } } for(i=1;i<=n;i++) printf("%i%c",ans[i],i==n?'\n':' '); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 14464 KB | Output is correct |
2 | Correct | 15 ms | 14464 KB | Output is correct |
3 | Correct | 17 ms | 14464 KB | Output is correct |
4 | Correct | 14 ms | 14464 KB | Output is correct |
5 | Correct | 15 ms | 14464 KB | Output is correct |
6 | Correct | 15 ms | 14464 KB | Output is correct |
7 | Correct | 15 ms | 14464 KB | Output is correct |
8 | Correct | 14 ms | 14464 KB | Output is correct |
9 | Correct | 15 ms | 14464 KB | Output is correct |
10 | Correct | 15 ms | 14464 KB | Output is correct |
11 | Correct | 14 ms | 14464 KB | Output is correct |
12 | Correct | 16 ms | 14464 KB | Output is correct |
13 | Correct | 16 ms | 14464 KB | Output is correct |
14 | Correct | 16 ms | 14464 KB | Output is correct |
15 | Correct | 16 ms | 14464 KB | Output is correct |
16 | Correct | 17 ms | 14592 KB | Output is correct |
17 | Correct | 16 ms | 14592 KB | Output is correct |
18 | Correct | 19 ms | 14592 KB | Output is correct |
19 | Correct | 23 ms | 15104 KB | Output is correct |
20 | Correct | 23 ms | 15104 KB | Output is correct |
21 | Correct | 28 ms | 15104 KB | Output is correct |
22 | Correct | 38 ms | 15096 KB | Output is correct |
23 | Correct | 44 ms | 14976 KB | Output is correct |
24 | Correct | 39 ms | 15224 KB | Output is correct |
25 | Correct | 45 ms | 15224 KB | Output is correct |
26 | Correct | 41 ms | 15232 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1174 ms | 52628 KB | Output is correct |
2 | Correct | 1529 ms | 50676 KB | Output is correct |
3 | Correct | 1556 ms | 52032 KB | Output is correct |
4 | Correct | 836 ms | 51768 KB | Output is correct |
5 | Execution timed out | 3021 ms | 47500 KB | Time limit exceeded |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 14464 KB | Output is correct |
2 | Correct | 1095 ms | 27032 KB | Output is correct |
3 | Execution timed out | 3101 ms | 47388 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3017 ms | 47472 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 14464 KB | Output is correct |
2 | Correct | 15 ms | 14464 KB | Output is correct |
3 | Correct | 17 ms | 14464 KB | Output is correct |
4 | Correct | 14 ms | 14464 KB | Output is correct |
5 | Correct | 15 ms | 14464 KB | Output is correct |
6 | Correct | 15 ms | 14464 KB | Output is correct |
7 | Correct | 15 ms | 14464 KB | Output is correct |
8 | Correct | 14 ms | 14464 KB | Output is correct |
9 | Correct | 15 ms | 14464 KB | Output is correct |
10 | Correct | 15 ms | 14464 KB | Output is correct |
11 | Correct | 14 ms | 14464 KB | Output is correct |
12 | Correct | 16 ms | 14464 KB | Output is correct |
13 | Correct | 16 ms | 14464 KB | Output is correct |
14 | Correct | 16 ms | 14464 KB | Output is correct |
15 | Correct | 16 ms | 14464 KB | Output is correct |
16 | Correct | 17 ms | 14592 KB | Output is correct |
17 | Correct | 16 ms | 14592 KB | Output is correct |
18 | Correct | 19 ms | 14592 KB | Output is correct |
19 | Correct | 23 ms | 15104 KB | Output is correct |
20 | Correct | 23 ms | 15104 KB | Output is correct |
21 | Correct | 28 ms | 15104 KB | Output is correct |
22 | Correct | 38 ms | 15096 KB | Output is correct |
23 | Correct | 44 ms | 14976 KB | Output is correct |
24 | Correct | 39 ms | 15224 KB | Output is correct |
25 | Correct | 45 ms | 15224 KB | Output is correct |
26 | Correct | 41 ms | 15232 KB | Output is correct |
27 | Correct | 29 ms | 15788 KB | Output is correct |
28 | Correct | 33 ms | 15744 KB | Output is correct |
29 | Correct | 31 ms | 15812 KB | Output is correct |
30 | Correct | 70 ms | 15736 KB | Output is correct |
31 | Correct | 68 ms | 15864 KB | Output is correct |
32 | Correct | 98 ms | 15864 KB | Output is correct |
33 | Correct | 173 ms | 26844 KB | Output is correct |
34 | Correct | 176 ms | 26740 KB | Output is correct |
35 | Correct | 278 ms | 26828 KB | Output is correct |
36 | Correct | 1431 ms | 27940 KB | Output is correct |
37 | Correct | 1252 ms | 28076 KB | Output is correct |
38 | Correct | 1274 ms | 27588 KB | Output is correct |
39 | Correct | 2642 ms | 31128 KB | Output is correct |
40 | Correct | 2703 ms | 31224 KB | Output is correct |
41 | Correct | 2705 ms | 31196 KB | Output is correct |
42 | Correct | 885 ms | 26488 KB | Output is correct |
43 | Correct | 1203 ms | 30580 KB | Output is correct |
44 | Correct | 1398 ms | 30700 KB | Output is correct |
45 | Correct | 1386 ms | 30600 KB | Output is correct |
46 | Correct | 1181 ms | 30596 KB | Output is correct |
47 | Correct | 1196 ms | 30600 KB | Output is correct |
48 | Correct | 1320 ms | 30736 KB | Output is correct |
49 | Correct | 1462 ms | 30444 KB | Output is correct |
50 | Correct | 1418 ms | 30620 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 14464 KB | Output is correct |
2 | Correct | 15 ms | 14464 KB | Output is correct |
3 | Correct | 17 ms | 14464 KB | Output is correct |
4 | Correct | 14 ms | 14464 KB | Output is correct |
5 | Correct | 15 ms | 14464 KB | Output is correct |
6 | Correct | 15 ms | 14464 KB | Output is correct |
7 | Correct | 15 ms | 14464 KB | Output is correct |
8 | Correct | 14 ms | 14464 KB | Output is correct |
9 | Correct | 15 ms | 14464 KB | Output is correct |
10 | Correct | 15 ms | 14464 KB | Output is correct |
11 | Correct | 14 ms | 14464 KB | Output is correct |
12 | Correct | 16 ms | 14464 KB | Output is correct |
13 | Correct | 16 ms | 14464 KB | Output is correct |
14 | Correct | 16 ms | 14464 KB | Output is correct |
15 | Correct | 16 ms | 14464 KB | Output is correct |
16 | Correct | 17 ms | 14592 KB | Output is correct |
17 | Correct | 16 ms | 14592 KB | Output is correct |
18 | Correct | 19 ms | 14592 KB | Output is correct |
19 | Correct | 23 ms | 15104 KB | Output is correct |
20 | Correct | 23 ms | 15104 KB | Output is correct |
21 | Correct | 28 ms | 15104 KB | Output is correct |
22 | Correct | 38 ms | 15096 KB | Output is correct |
23 | Correct | 44 ms | 14976 KB | Output is correct |
24 | Correct | 39 ms | 15224 KB | Output is correct |
25 | Correct | 45 ms | 15224 KB | Output is correct |
26 | Correct | 41 ms | 15232 KB | Output is correct |
27 | Correct | 1174 ms | 52628 KB | Output is correct |
28 | Correct | 1529 ms | 50676 KB | Output is correct |
29 | Correct | 1556 ms | 52032 KB | Output is correct |
30 | Correct | 836 ms | 51768 KB | Output is correct |
31 | Execution timed out | 3021 ms | 47500 KB | Time limit exceeded |
32 | Halted | 0 ms | 0 KB | - |