Submission #407857

# Submission time Handle Problem Language Result Execution time Memory
407857 2021-05-19T04:52:39 Z tengiz05 Circle selection (APIO18_circle_selection) C++17
12 / 100
896 ms 36468 KB
#include <bits/stdc++.h>
using i64 = long long;
inline i64 sq(int x) { return i64(x) * x; }
int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n;
    std::cin >> n;
    std::vector<int> x(n), y(n), r(n);
    for (int i = 0; i < n; i++) {
        std::cin >> x[i] >> y[i] >> r[i];
    }
    std::vector<int> ans(n, -1);
    std::vector<int> ind(n);
    iota(ind.begin(), ind.end(), 0);
    sort(ind.begin(), ind.end(), [&](int i, int j) {
        if (r[i] == r[j]) return i < j;
        return r[i] > r[j];
    });
    std::set<std::pair<int, int>> sr;
    for (int i = 0; i < n; i++) {
        sr.emplace(x[i] - r[i], i);
        sr.emplace(x[i] + r[i], i);
    }
    for (auto i : ind) {
        if (~ans[i]) continue;
        while (sr.size()) {
            auto it = sr.lower_bound({x[i] - r[i], -1});
            if (it == sr.end()) break;
            int j = it->second;
            if (it->first <= x[i] + r[i]) {
                if (ans[j] == -1)
                    ans[j] = i;
                sr.erase(it);
            } else break;
        }
    }
    for (auto x : ans) assert(~x), std::cout << x + 1 << ' ';
    std::cout << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 896 ms 36464 KB Output is correct
2 Correct 864 ms 36468 KB Output is correct
3 Correct 790 ms 36216 KB Output is correct
4 Correct 869 ms 36412 KB Output is correct
5 Correct 736 ms 36260 KB Output is correct
6 Correct 769 ms 36340 KB Output is correct
7 Correct 777 ms 36264 KB Output is correct
8 Correct 803 ms 36324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 860 ms 36020 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -