Submission #119068

# Submission time Handle Problem Language Result Execution time Memory
119068 2019-06-20T09:03:53 Z Charis02 Circle selection (APIO18_circle_selection) C++14
7 / 100
724 ms 35980 KB
#include<iostream>
#include<set>
#include<cmath>
#include<algorithm>
#define ll long long
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 1000004
#define INF 1e9+7

using namespace std;

struct circle{
    ll x;
    ll y;
    ll r;
    ll id;
};

bool by_r(const circle &a,const circle &b)
{
    if(a.r == b.r)
    {
        return a.id < b.id;
    }

    return a.r > b.r;
}

ll n;
circle ar[N];
pair < ll,ll > v[N];
bool used[N];
set < ll > rs,ys;
ll ans[N];

double dist(ll x1,ll y1,ll x2,ll y2)
{
    return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

bool intersect(const circle &a,const circle &b)
{
    double c1c2 = dist(a.x,a.y,b.x,b.y);

    return (c1c2 <= a.r + b.r);
}

void first_subtask()
{
    rep(i,1,n+1)
    {
        if(used[i])
            continue;
        else
        {
            ans[ar[i].id] = ar[i].id;
            used[i] = true;

            rep(j,i+1,n+1)
            {
                if(used[j])
                    continue;

                if(intersect(ar[i],ar[j]))
                {
                    ans[ar[j].id] = ar[i].id;
                    used[j] = true;
                }
            }
        }
    }

    return;
}

void second_subtask()
{
    rep(i,1,n+1)
    {
        v[i].first = ar[i].x - ar[i].r;
        v[i].second = ar[i].x + ar[i].r;
    }

    sort(v+1,v+n+1);
}

void third_subtask()
{

}

void fourth_subtask()
{

}

void solve()
{
    cin >> n;

    rep(i,1,n+1)
    {
        cin >> ar[i].x >> ar[i].y >> ar[i].r;

        ar[i].id = i;

        rs.insert(ar[i].r);
        ys.insert(ar[i].y);
    }

    sort(ar+1,ar+n+1,by_r);

    if(n <= 5000)
    {
        first_subtask();
    }
    if(ys.size() == 1)
    {
        second_subtask();
    }
    else if(rs.size() == 1)
    {
        fourth_subtask();
    }
    else
    {
        third_subtask();
    }

    rep(i,1,n+1)
    {
        cout << ans[i] << " ";
    }

    return;
}

int main()
{
    solve();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 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 2 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 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 512 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 4 ms 512 KB Output is correct
17 Correct 4 ms 512 KB Output is correct
18 Correct 4 ms 512 KB Output is correct
19 Correct 12 ms 1152 KB Output is correct
20 Correct 12 ms 1152 KB Output is correct
21 Correct 12 ms 1152 KB Output is correct
22 Correct 103 ms 1152 KB Output is correct
23 Correct 104 ms 1144 KB Output is correct
24 Correct 105 ms 1204 KB Output is correct
25 Correct 102 ms 1144 KB Output is correct
26 Correct 102 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 724 ms 35980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 301 ms 15352 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 713 ms 32448 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 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 2 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 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 512 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 4 ms 512 KB Output is correct
17 Correct 4 ms 512 KB Output is correct
18 Correct 4 ms 512 KB Output is correct
19 Correct 12 ms 1152 KB Output is correct
20 Correct 12 ms 1152 KB Output is correct
21 Correct 12 ms 1152 KB Output is correct
22 Correct 103 ms 1152 KB Output is correct
23 Correct 104 ms 1144 KB Output is correct
24 Correct 105 ms 1204 KB Output is correct
25 Correct 102 ms 1144 KB Output is correct
26 Correct 102 ms 1152 KB Output is correct
27 Incorrect 22 ms 1920 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 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 2 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 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 512 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 4 ms 512 KB Output is correct
17 Correct 4 ms 512 KB Output is correct
18 Correct 4 ms 512 KB Output is correct
19 Correct 12 ms 1152 KB Output is correct
20 Correct 12 ms 1152 KB Output is correct
21 Correct 12 ms 1152 KB Output is correct
22 Correct 103 ms 1152 KB Output is correct
23 Correct 104 ms 1144 KB Output is correct
24 Correct 105 ms 1204 KB Output is correct
25 Correct 102 ms 1144 KB Output is correct
26 Correct 102 ms 1152 KB Output is correct
27 Incorrect 724 ms 35980 KB Output isn't correct
28 Halted 0 ms 0 KB -