Submission #59938

# Submission time Handle Problem Language Result Execution time Memory
59938 2018-07-23T10:57:08 Z Flugan42 Circle selection (APIO18_circle_selection) C++14
7 / 100
936 ms 65900 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
#define rep(i,a,b) for(int i = a; i < b; i++)
#define per(i,a,b) for(int i = a; i >= b; i--)
#define inf 1000000000000000000
#define sz(x) (ll)(x).size()
#define all(x) x.begin(),x.end()

struct circle {
  ll x,y,r,id;
} ;
vector< circle > inp;
vi vis;
vii endp,endpy;
circle _;
ll n;

bool mysort(circle a, circle b){
  if (a.r == b.r) return a.id < b.id;
  return a.r > b.r;
}

ld dist(ll i, ll j){
  ll dx = inp[i].x-inp[j].x, dy = inp[i].y-inp[j].y;
  return sqrt(ld(dx*dx)+ld(dy*dy));
}

int main(){
  cin >> n; inp.assign(n,_);
  rep(i,0,n){
    cin >> inp[i].x >> inp[i].y >> inp[i].r;
    inp[i].id = i;
  }
  sort(all(inp),mysort);
  rep(i,0,n){
    endp.push_back(make_pair(inp[i].x-inp[i].r,i));
    endp.push_back(make_pair(inp[i].x+inp[i].r,i));
    endpy.push_back(make_pair(inp[i].y-inp[i].r,i));
    endpy.push_back(make_pair(inp[i].y+inp[i].r,i));
  }
  sort(all(endp));

  if (n <= 10000){
    vis.assign(n,-1);
    rep(i,0,n){
      if (vis[i] != -1) continue;
      rep(j,0,n){
        if (vis[j] != -1) continue;
        if (dist(i,j) <= inp[i].r+inp[j].r) vis[j] = inp[i].id;
      }
    }
  } else {
    vis.assign(n,-1);
    rep(i,0,n){
      if (vis[i] != -1) continue;
      ll lo = lower_bound(all(endp),make_pair(inp[i].x-inp[i].r,0LL))-endp.begin();
      while (endp[lo].first <= inp[i].x+inp[i].r){
        if (vis[endp[lo].second] == -1) vis[endp[lo].second] = inp[i].id;
        lo++;
      }
    }
  }
  vi res; res.assign(n,0);
  rep(i,0,n){
    res[inp[i].id] = vis[i];
  }
  rep(i,0,n) cout << res[i]+1 << " ";
  cout << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 560 KB Output is correct
5 Correct 2 ms 560 KB Output is correct
6 Correct 3 ms 560 KB Output is correct
7 Correct 3 ms 560 KB Output is correct
8 Correct 3 ms 560 KB Output is correct
9 Correct 2 ms 560 KB Output is correct
10 Correct 2 ms 560 KB Output is correct
11 Correct 3 ms 596 KB Output is correct
12 Correct 2 ms 596 KB Output is correct
13 Correct 3 ms 596 KB Output is correct
14 Correct 4 ms 596 KB Output is correct
15 Correct 3 ms 620 KB Output is correct
16 Correct 5 ms 620 KB Output is correct
17 Correct 7 ms 636 KB Output is correct
18 Correct 4 ms 748 KB Output is correct
19 Correct 13 ms 1272 KB Output is correct
20 Correct 14 ms 1272 KB Output is correct
21 Correct 20 ms 1288 KB Output is correct
22 Correct 205 ms 1360 KB Output is correct
23 Correct 217 ms 1448 KB Output is correct
24 Correct 147 ms 1448 KB Output is correct
25 Correct 166 ms 1448 KB Output is correct
26 Correct 144 ms 1448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 636 ms 35572 KB Output is correct
2 Correct 725 ms 35788 KB Output is correct
3 Correct 798 ms 35788 KB Output is correct
4 Correct 674 ms 35796 KB Output is correct
5 Runtime error 607 ms 61900 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 61900 KB Output is correct
2 Incorrect 227 ms 61900 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 936 ms 65900 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 560 KB Output is correct
5 Correct 2 ms 560 KB Output is correct
6 Correct 3 ms 560 KB Output is correct
7 Correct 3 ms 560 KB Output is correct
8 Correct 3 ms 560 KB Output is correct
9 Correct 2 ms 560 KB Output is correct
10 Correct 2 ms 560 KB Output is correct
11 Correct 3 ms 596 KB Output is correct
12 Correct 2 ms 596 KB Output is correct
13 Correct 3 ms 596 KB Output is correct
14 Correct 4 ms 596 KB Output is correct
15 Correct 3 ms 620 KB Output is correct
16 Correct 5 ms 620 KB Output is correct
17 Correct 7 ms 636 KB Output is correct
18 Correct 4 ms 748 KB Output is correct
19 Correct 13 ms 1272 KB Output is correct
20 Correct 14 ms 1272 KB Output is correct
21 Correct 20 ms 1288 KB Output is correct
22 Correct 205 ms 1360 KB Output is correct
23 Correct 217 ms 1448 KB Output is correct
24 Correct 147 ms 1448 KB Output is correct
25 Correct 166 ms 1448 KB Output is correct
26 Correct 144 ms 1448 KB Output is correct
27 Correct 26 ms 65900 KB Output is correct
28 Correct 29 ms 65900 KB Output is correct
29 Correct 26 ms 65900 KB Output is correct
30 Correct 725 ms 65900 KB Output is correct
31 Correct 667 ms 65900 KB Output is correct
32 Correct 660 ms 65900 KB Output is correct
33 Correct 302 ms 65900 KB Output is correct
34 Correct 238 ms 65900 KB Output is correct
35 Incorrect 269 ms 65900 KB Output isn't correct
36 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 560 KB Output is correct
5 Correct 2 ms 560 KB Output is correct
6 Correct 3 ms 560 KB Output is correct
7 Correct 3 ms 560 KB Output is correct
8 Correct 3 ms 560 KB Output is correct
9 Correct 2 ms 560 KB Output is correct
10 Correct 2 ms 560 KB Output is correct
11 Correct 3 ms 596 KB Output is correct
12 Correct 2 ms 596 KB Output is correct
13 Correct 3 ms 596 KB Output is correct
14 Correct 4 ms 596 KB Output is correct
15 Correct 3 ms 620 KB Output is correct
16 Correct 5 ms 620 KB Output is correct
17 Correct 7 ms 636 KB Output is correct
18 Correct 4 ms 748 KB Output is correct
19 Correct 13 ms 1272 KB Output is correct
20 Correct 14 ms 1272 KB Output is correct
21 Correct 20 ms 1288 KB Output is correct
22 Correct 205 ms 1360 KB Output is correct
23 Correct 217 ms 1448 KB Output is correct
24 Correct 147 ms 1448 KB Output is correct
25 Correct 166 ms 1448 KB Output is correct
26 Correct 144 ms 1448 KB Output is correct
27 Correct 636 ms 35572 KB Output is correct
28 Correct 725 ms 35788 KB Output is correct
29 Correct 798 ms 35788 KB Output is correct
30 Correct 674 ms 35796 KB Output is correct
31 Runtime error 607 ms 61900 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Halted 0 ms 0 KB -