Submission #50126

# Submission time Handle Problem Language Result Execution time Memory
50126 2018-06-07T16:43:25 Z mirbek01 Circle selection (APIO18_circle_selection) C++17
0 / 100
158 ms 3816 KB
# include <bits/stdc++.h>

# define f first
# define s second

using namespace std;

const int N = 1e5 + 2;

struct st{
      int x, y, r, id;
} a[N];

int n, fl = 1, ans[N];

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

int main(){
      cin >> n;

      for(int i = 1; i <= n; i ++){
            cin >> a[i].x >> a[i].y >> a[i].r;
            a[i].id = i;
            if(a[i].y) fl = 0;
      }

      if(fl){
            sort(a + 1, a + n + 1, cmp);
            set < pair <int, int> > st;
            for(int i = 1; i <= n; i ++){
                  st.insert({a[i].x, a[i].id});
            }
            for(int i = 1; i <= n; i ++){
                  if(ans[a[i].id]) continue;
                  vector < pair <int, int> > v;
                  for(auto j = st.lower_bound({a[i].x - a[i].r, 0}); j != st.end() && j->first <= a[i].x + a[i].r; j ++){
                        ans[j->s] = a[i].id;
                        v.push_back({j->f, j->s});
                  }
                  while(v.size()){
                        st.erase(v.back());
                        v.pop_back();
                  }
            }
            for(int i = 1; i <= n; i ++){
                  cout << ans[i] << " ";
            }
      }
}
/**
11
9 9 2
13 2 1
11 8 2
3 3 2
3 12 1
12 14 1
9 8 5
2 8 2
5 2 1
14 4 2
14 14 1
**/
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 142 ms 3816 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3816 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 158 ms 3816 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -