Submission #701388

# Submission time Handle Problem Language Result Execution time Memory
701388 2023-02-21T06:54:02 Z Abrar_Al_Samit Circle selection (APIO18_circle_selection) C++17
7 / 100
3000 ms 35340 KB
#include<bits/stdc++.h>
using namespace std;

long long sqrd(int x) {
  return x * 1LL * x;
}
struct circle {
  int x, y, r, j;

  bool operator< (const circle& b) const {
    if(r!=b.r) return r > b.r;
    return j < b.j;
  }

  bool intersect(const circle& b) const {
    return sqrd(x-b.x) + sqrd(y-b.y) <= sqrd(r+b.r);
  }
};
void PlayGround() {
  int n;
  cin>>n;

  set<circle>s;
  for(int i=0; i<n; ++i) {
    int x, y, r;
    cin>>x>>y>>r;

    circle z = {x, y, r, i+1};
    s.insert(z);
  }

  int ans[n+1];
  while(!s.empty()) {
    auto cur = *s.begin();
    s.erase(cur);

    ans[cur.j] = cur.j;

    vector<circle>cache;
    for(auto z : s) {
      if(cur.intersect(z)) {
        cache.push_back(z);
        ans[z.j] = cur.j;
      }
    }
    for(auto z : cache) {
      s.erase(z);
    }
  }
  for(int i=1; i<=n; ++i) {
    cout<<ans[i]<<' ';
  }


  // cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  PlayGround();
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 316 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 324 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 5 ms 976 KB Output is correct
20 Correct 4 ms 980 KB Output is correct
21 Correct 4 ms 852 KB Output is correct
22 Correct 137 ms 724 KB Output is correct
23 Correct 138 ms 760 KB Output is correct
24 Correct 161 ms 772 KB Output is correct
25 Correct 135 ms 848 KB Output is correct
26 Correct 147 ms 764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 348 ms 35340 KB Output is correct
2 Correct 420 ms 33364 KB Output is correct
3 Correct 368 ms 31092 KB Output is correct
4 Correct 356 ms 35280 KB Output is correct
5 Execution timed out 3057 ms 24992 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Execution timed out 3056 ms 9636 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3059 ms 28044 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 316 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 324 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 5 ms 976 KB Output is correct
20 Correct 4 ms 980 KB Output is correct
21 Correct 4 ms 852 KB Output is correct
22 Correct 137 ms 724 KB Output is correct
23 Correct 138 ms 760 KB Output is correct
24 Correct 161 ms 772 KB Output is correct
25 Correct 135 ms 848 KB Output is correct
26 Correct 147 ms 764 KB Output is correct
27 Correct 7 ms 1620 KB Output is correct
28 Correct 9 ms 1604 KB Output is correct
29 Correct 7 ms 1600 KB Output is correct
30 Correct 716 ms 1236 KB Output is correct
31 Correct 720 ms 1228 KB Output is correct
32 Correct 730 ms 1236 KB Output is correct
33 Correct 92 ms 12224 KB Output is correct
34 Correct 76 ms 12188 KB Output is correct
35 Correct 85 ms 12024 KB Output is correct
36 Execution timed out 3065 ms 9480 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 316 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 324 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 5 ms 976 KB Output is correct
20 Correct 4 ms 980 KB Output is correct
21 Correct 4 ms 852 KB Output is correct
22 Correct 137 ms 724 KB Output is correct
23 Correct 138 ms 760 KB Output is correct
24 Correct 161 ms 772 KB Output is correct
25 Correct 135 ms 848 KB Output is correct
26 Correct 147 ms 764 KB Output is correct
27 Correct 348 ms 35340 KB Output is correct
28 Correct 420 ms 33364 KB Output is correct
29 Correct 368 ms 31092 KB Output is correct
30 Correct 356 ms 35280 KB Output is correct
31 Execution timed out 3057 ms 24992 KB Time limit exceeded
32 Halted 0 ms 0 KB -