Submission #52631

# Submission time Handle Problem Language Result Execution time Memory
52631 2018-06-26T10:01:43 Z Kubalionzzale Circle selection (APIO18_circle_selection) C++14
7 / 100
300 ms 2144 KB
#include <iostream>
#include <set>
#include <math.h>
#include <algorithm>
#include <functional>

long double abss(long double x)
{
    if (x < 0)
        return -x;
    else
        return x;
}

long double sqr(long double x)
{
    return x * x;
}

struct compare {
    bool operator() (const std::pair<int, int>& lhs, const std::pair<int, int>& rhs) const {
        if (lhs.first != rhs.first)
            return lhs.first > rhs.first;
        else
            return lhs.second < rhs.second;
    }
};

void firstSubtask(int n)
{
    std::set< std::pair<int, int>, compare > set;
    int visited[300010] = { 0 };
    int x[300010], y[300010], r[300010];
    for (int i = 1; i <= n; ++i)
    {
        std::cin >> x[i] >> y[i] >> r[i];
        set.insert(std::make_pair(r[i], i));
    }

    while (set.empty() == false)
    {
        std::pair<int, int> p = *set.begin();
        set.erase(set.begin());
        int xs = x[p.second], ys = y[p.second], rs = r[p.second];
        visited[p.second] = p.second;

        for (auto it = set.begin(); it != set.end();)
        {
            std::pair<int, int> sec = *it;
            int xq = x[sec.second], yq = y[sec.second], rq = r[sec.second];
            long double dist = sqrt(sqr(xq * 1.0 - xs * 1.0) + sqr(yq * 1.0 - ys * 1.0));

  //          std::cout << p.second << " " << sec.second << " " << dist << " " << rq * 1.0 + rs * 1.0 << "\n";

            if (dist <= rq * 1.0 + rs * 1.0)
            {
                visited[sec.second] = p.second;
                it = set.erase(it);
            }
            else
            {
                ++it;
            }
        }
    }

    for (int i = 1; i <= n; ++i)
    {
        std::cout << visited[i] << " ";
    }
}

int main()
{
    int n;
    std::cin >> n;

    if (n <= 5000)
    {
        firstSubtask(n);
        return 0;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1532 KB Output is correct
2 Correct 3 ms 1532 KB Output is correct
3 Correct 4 ms 1712 KB Output is correct
4 Correct 3 ms 1772 KB Output is correct
5 Correct 3 ms 1772 KB Output is correct
6 Correct 4 ms 1772 KB Output is correct
7 Correct 4 ms 1772 KB Output is correct
8 Correct 4 ms 1772 KB Output is correct
9 Correct 5 ms 1772 KB Output is correct
10 Correct 4 ms 1772 KB Output is correct
11 Correct 4 ms 1772 KB Output is correct
12 Correct 4 ms 1772 KB Output is correct
13 Correct 3 ms 1772 KB Output is correct
14 Correct 3 ms 1772 KB Output is correct
15 Correct 3 ms 1772 KB Output is correct
16 Correct 5 ms 1772 KB Output is correct
17 Correct 7 ms 1792 KB Output is correct
18 Correct 6 ms 1828 KB Output is correct
19 Correct 12 ms 2044 KB Output is correct
20 Correct 13 ms 2044 KB Output is correct
21 Correct 13 ms 2140 KB Output is correct
22 Correct 268 ms 2140 KB Output is correct
23 Correct 270 ms 2144 KB Output is correct
24 Correct 300 ms 2144 KB Output is correct
25 Correct 272 ms 2144 KB Output is correct
26 Correct 272 ms 2144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2144 KB Output is correct
2 Incorrect 2 ms 2144 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1532 KB Output is correct
2 Correct 3 ms 1532 KB Output is correct
3 Correct 4 ms 1712 KB Output is correct
4 Correct 3 ms 1772 KB Output is correct
5 Correct 3 ms 1772 KB Output is correct
6 Correct 4 ms 1772 KB Output is correct
7 Correct 4 ms 1772 KB Output is correct
8 Correct 4 ms 1772 KB Output is correct
9 Correct 5 ms 1772 KB Output is correct
10 Correct 4 ms 1772 KB Output is correct
11 Correct 4 ms 1772 KB Output is correct
12 Correct 4 ms 1772 KB Output is correct
13 Correct 3 ms 1772 KB Output is correct
14 Correct 3 ms 1772 KB Output is correct
15 Correct 3 ms 1772 KB Output is correct
16 Correct 5 ms 1772 KB Output is correct
17 Correct 7 ms 1792 KB Output is correct
18 Correct 6 ms 1828 KB Output is correct
19 Correct 12 ms 2044 KB Output is correct
20 Correct 13 ms 2044 KB Output is correct
21 Correct 13 ms 2140 KB Output is correct
22 Correct 268 ms 2140 KB Output is correct
23 Correct 270 ms 2144 KB Output is correct
24 Correct 300 ms 2144 KB Output is correct
25 Correct 272 ms 2144 KB Output is correct
26 Correct 272 ms 2144 KB Output is correct
27 Incorrect 2 ms 2144 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1532 KB Output is correct
2 Correct 3 ms 1532 KB Output is correct
3 Correct 4 ms 1712 KB Output is correct
4 Correct 3 ms 1772 KB Output is correct
5 Correct 3 ms 1772 KB Output is correct
6 Correct 4 ms 1772 KB Output is correct
7 Correct 4 ms 1772 KB Output is correct
8 Correct 4 ms 1772 KB Output is correct
9 Correct 5 ms 1772 KB Output is correct
10 Correct 4 ms 1772 KB Output is correct
11 Correct 4 ms 1772 KB Output is correct
12 Correct 4 ms 1772 KB Output is correct
13 Correct 3 ms 1772 KB Output is correct
14 Correct 3 ms 1772 KB Output is correct
15 Correct 3 ms 1772 KB Output is correct
16 Correct 5 ms 1772 KB Output is correct
17 Correct 7 ms 1792 KB Output is correct
18 Correct 6 ms 1828 KB Output is correct
19 Correct 12 ms 2044 KB Output is correct
20 Correct 13 ms 2044 KB Output is correct
21 Correct 13 ms 2140 KB Output is correct
22 Correct 268 ms 2140 KB Output is correct
23 Correct 270 ms 2144 KB Output is correct
24 Correct 300 ms 2144 KB Output is correct
25 Correct 272 ms 2144 KB Output is correct
26 Correct 272 ms 2144 KB Output is correct
27 Incorrect 2 ms 2144 KB Output isn't correct
28 Halted 0 ms 0 KB -