Submission #217753

# Submission time Handle Problem Language Result Execution time Memory
217753 2020-03-30T16:17:41 Z Vimmer Circle selection (APIO18_circle_selection) C++14
7 / 100
3000 ms 24564 KB
#include <bits/stdc++.h>

#define F first
#define S second
#define sz(x) int(x.size())
#define pb push_back
#define N 300005
#define M ll(998244353)

using namespace std;

typedef long double ld;
typedef long long ll;
typedef short int si;


int psh[N * 4], t[N], ans[N], anser[N];

vector <pair <pair <int, int>, int>  > gr;

void build(int v, int tl, int tr)
{
    if (tl > tr) return;

    if (tl == tr) t[v] = tl; else

    {
        int md = (tl + tr) >> 1;

        build(v + v, tl, md);

        build(v + v + 1, md + 1, tr);

        if (gr[t[v + v]].F.S > gr[t[v + v + 1]].F.S) t[v] = t[v + v]; else t[v] = t[v + v + 1];
    }
}

void Push(int v, int tl, int tr)
{
    if (psh[v] == 0) return;

    t[v] = -1;

    if (tl == tr) ans[tl] = psh[v];
    else
    {
        if (psh[v + v] == 0) psh[v + v] = psh[v];

        if (psh[v + v + 1] == 0) psh[v + v + 1] = psh[v];
    }

    psh[v] = 0;
}
void upd(int v, int tl, int tr, int l, int r, int val)
{
    if (tr < l || tr < l || tl > tr || psh[v] != 0) return;

    Push(v, tl, tr);

    if (l <= tl && tr <= r) {psh[v] = val; Push(v, tl, tr); return;}

    int md = (tl + tr) >> 1;

    upd(v + v, tl, md, l, r, val);

    upd(v + v + 1, md + 1, tr, l, r, val);

    if (t[v + v] == -1) t[v] = t[v + v + 1]; else

    if (t[v + v + 1] == -1) t[v] = t[v + v]; else
    {
        if (gr[t[v + v]].F.S > gr[t[v + v + 1]].F.S) t[v] = t[v + v];
          else t[v] = t[v + v + 1];
    }
}

void gt(int v, int tl, int tr, int pos)
{
    Push(v, tl, tr);

    if (tl == tr) return;

    int md = (tl + tr) >> 1;

    if (pos <= md) gt(v + v, tl, md, pos); else gt(v + v + 1, md + 1, tr, pos);
}
int main()
{
    ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n;

    cin >> n;

    for (int i = 0; i < n; i++) ans[i] = -1;

    ld x[n], y[n], r[n];

    bool f = 1;

    for (int i = 0; i < n; i++) {cin >> x[i] >> y[i] >> r[i]; if (y[i] != 0) f = 0;}

    if (f)
    {
        gr.resize(n);

        for (int i = 0; i < n; i++) {gr[i].F.F = x[i]; gr[i].F.S = r[i]; gr[i].S = i;}

        sort(gr.begin(), gr.end());

        vector <int> vr; vr.resize(n);

        for (int i = 0; i < n; i++) vr[i] = gr[i].F.F;

        build(1, 0, n - 1);

        int v = t[1];

        while (v != -1)
        {
            int l = lower_bound(vr.begin(), vr.end(), gr[v].F.F - gr[v].F.S) - vr.begin();

            int r = upper_bound(vr.begin(), vr.end(), gr[v].F.F + gr[v].F.S) - vr.begin() - 1;

            upd(1, 0, n - 1, l, r, gr[v].S + 1);

            v = t[1];
        }

        for (int i = 0; i < n; i++) gt(1, 0, n - 1, i);

        for (int i = 0; i < n; i++) anser[gr[i].S] = ans[i];

        for (int i = 0; i < n; i++) cout << anser[i] << " ";

        exit(0);
    }

    int s = n;

    while (s > 0)
    {
        int nm = -1;

        for (int i = 0; i < n; i++)
        {
            if (ans[i] != -1) continue;

            if (nm == -1 || r[nm] < r[i]) nm = i;
        }

        for (int i = 0; i < n; i++)
        {
            if (ans[i] != -1) continue;

            ld rst = sqrt(pow(abs(x[nm] - x[i]), 2) + pow(abs(y[nm] - y[i]), 2));

            if (r[nm] + r[i] >= rst) {ans[i] = nm + 1; s--;}
        }
    }

    for (int i = 0; i < n; i++) cout << ans[i] << " ";
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Correct 6 ms 384 KB Output is correct
19 Correct 10 ms 640 KB Output is correct
20 Correct 10 ms 640 KB Output is correct
21 Correct 10 ms 640 KB Output is correct
22 Correct 315 ms 760 KB Output is correct
23 Correct 310 ms 640 KB Output is correct
24 Correct 312 ms 640 KB Output is correct
25 Correct 309 ms 640 KB Output is correct
26 Correct 312 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3075 ms 24564 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Execution timed out 3079 ms 5496 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3049 ms 15608 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Correct 6 ms 384 KB Output is correct
19 Correct 10 ms 640 KB Output is correct
20 Correct 10 ms 640 KB Output is correct
21 Correct 10 ms 640 KB Output is correct
22 Correct 315 ms 760 KB Output is correct
23 Correct 310 ms 640 KB Output is correct
24 Correct 312 ms 640 KB Output is correct
25 Correct 309 ms 640 KB Output is correct
26 Correct 312 ms 640 KB Output is correct
27 Correct 16 ms 896 KB Output is correct
28 Correct 18 ms 896 KB Output is correct
29 Correct 16 ms 896 KB Output is correct
30 Correct 1295 ms 912 KB Output is correct
31 Correct 1358 ms 904 KB Output is correct
32 Correct 1313 ms 1016 KB Output is correct
33 Correct 128 ms 6136 KB Output is correct
34 Correct 128 ms 6008 KB Output is correct
35 Correct 129 ms 6012 KB Output is correct
36 Execution timed out 3063 ms 5368 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Correct 6 ms 384 KB Output is correct
19 Correct 10 ms 640 KB Output is correct
20 Correct 10 ms 640 KB Output is correct
21 Correct 10 ms 640 KB Output is correct
22 Correct 315 ms 760 KB Output is correct
23 Correct 310 ms 640 KB Output is correct
24 Correct 312 ms 640 KB Output is correct
25 Correct 309 ms 640 KB Output is correct
26 Correct 312 ms 640 KB Output is correct
27 Execution timed out 3075 ms 24564 KB Time limit exceeded
28 Halted 0 ms 0 KB -