답안 #111233

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
111233 2019-05-14T11:06:41 Z SamAnd 원 고르기 (APIO18_circle_selection) C++17
7 / 100
1765 ms 43132 KB
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
const int N = 300005;
struct ban
{
    int i;
    int x, y, r;
};
bool operator<(const ban& a, const ban& b)
{
    if (a.r < b.r)
        return true;
    if (a.r > b.r)
        return false;
    return a.i > b.i;
}

int n;
ban a[N];

int ans[N];

priority_queue<ban> q;
int get()
{
    while (1)
    {
        if (q.empty())
            return -1;
        ban t = q.top();
        q.pop();
        if (!ans[t.i])
            return t.i;
    }
}

bool stg(long long x1, long long y1, long long r1, long long x2, long long y2, long long r2)
{
    return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) <= (r1 + r2) * (r1 + r2);
}

void solv0()
{
    for (int i = 1; i <= n; ++i)
        q.push(a[i]);
    while (1)
    {
        int i = get();
        if (i == -1)
            return;
        for (int j = 1; j <= n; ++j)
        {
            if (!ans[j])
            {
                if (stg(a[i].x, a[i].y, a[i].r, a[j].x, a[j].y, a[j].r))
                {
                    ans[j] = i;
                }
            }
        }
    }
}

void solv1()
{
    for (int i = 1; i <= n; ++i)
        q.push(a[i]);
    set<pair<int, int> > s;
    for (int i = 1; i <= n; ++i)
    {
        s.insert(m_p(a[i].x - a[i].r, i));
        s.insert(m_p(a[i].x + a[i].r, i));
    }
    while (1)
    {
        int i = get();
        if (i == -1)
            return;
        int l = a[i].x - a[i].r;
        int r = a[i].x + a[i].r;
        queue<int> q;
        for (set<pair<int, int> >::iterator it = s.lower_bound(m_p(l, 0)); it != s.end(); ++it)
        {
            if ((*it).first > r)
                break;
            ans[(*it).second] = i;
            q.push((*it).second);
        }
        while (!q.empty())
        {
            s.erase(m_p(a[q.front()].x - a[q.front()].r, q.front()));
            s.erase(m_p(a[q.front()].x - a[q.front()].r, q.front()));
            q.pop();
        }
    }
}

int main()
{
    //freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        a[i].i = i;
        cin >> a[i].x >> a[i].y >> a[i].r;
    }
    if (n <= 5000)
        solv0();
    else
        solv1();
    for (int i = 1; i <= n; ++i)
        cout << ans[i] << ' ';
    cout << endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 15 ms 640 KB Output is correct
20 Correct 11 ms 640 KB Output is correct
21 Correct 11 ms 640 KB Output is correct
22 Correct 111 ms 692 KB Output is correct
23 Correct 104 ms 728 KB Output is correct
24 Correct 103 ms 760 KB Output is correct
25 Correct 107 ms 640 KB Output is correct
26 Correct 108 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1765 ms 43132 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Incorrect 459 ms 13872 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1460 ms 40772 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 15 ms 640 KB Output is correct
20 Correct 11 ms 640 KB Output is correct
21 Correct 11 ms 640 KB Output is correct
22 Correct 111 ms 692 KB Output is correct
23 Correct 104 ms 728 KB Output is correct
24 Correct 103 ms 760 KB Output is correct
25 Correct 107 ms 640 KB Output is correct
26 Correct 108 ms 640 KB Output is correct
27 Incorrect 37 ms 1812 KB Output isn't correct
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 15 ms 640 KB Output is correct
20 Correct 11 ms 640 KB Output is correct
21 Correct 11 ms 640 KB Output is correct
22 Correct 111 ms 692 KB Output is correct
23 Correct 104 ms 728 KB Output is correct
24 Correct 103 ms 760 KB Output is correct
25 Correct 107 ms 640 KB Output is correct
26 Correct 108 ms 640 KB Output is correct
27 Incorrect 1765 ms 43132 KB Output isn't correct
28 Halted 0 ms 0 KB -