Submission #217754

# Submission time Handle Problem Language Result Execution time Memory
217754 2020-03-30T16:23:02 Z Vimmer Circle selection (APIO18_circle_selection) C++14
7 / 100
3000 ms 49272 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 * 4], 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) {if (ans[tl] == -1) 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++) {int X, Y, R; cin >> X >> Y >> R; if (Y != 0) f = 0; x[i] = X; y[i] = Y; r[i] = R;}

    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 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 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 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 7 ms 640 KB Output is correct
20 Correct 7 ms 640 KB Output is correct
21 Correct 7 ms 640 KB Output is correct
22 Correct 313 ms 640 KB Output is correct
23 Correct 332 ms 760 KB Output is correct
24 Correct 319 ms 640 KB Output is correct
25 Correct 314 ms 640 KB Output is correct
26 Correct 310 ms 676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 183 ms 49272 KB Execution killed with signal 11 (could be triggered by violating memory limits)
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 3081 ms 5368 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3086 ms 15608 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 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 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 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 7 ms 640 KB Output is correct
20 Correct 7 ms 640 KB Output is correct
21 Correct 7 ms 640 KB Output is correct
22 Correct 313 ms 640 KB Output is correct
23 Correct 332 ms 760 KB Output is correct
24 Correct 319 ms 640 KB Output is correct
25 Correct 314 ms 640 KB Output is correct
26 Correct 310 ms 676 KB Output is correct
27 Correct 10 ms 896 KB Output is correct
28 Correct 19 ms 896 KB Output is correct
29 Correct 9 ms 896 KB Output is correct
30 Correct 1329 ms 1016 KB Output is correct
31 Correct 1328 ms 912 KB Output is correct
32 Correct 1349 ms 1016 KB Output is correct
33 Correct 59 ms 6012 KB Output is correct
34 Correct 57 ms 6008 KB Output is correct
35 Correct 68 ms 6008 KB Output is correct
36 Execution timed out 3074 ms 5372 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 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 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 7 ms 640 KB Output is correct
20 Correct 7 ms 640 KB Output is correct
21 Correct 7 ms 640 KB Output is correct
22 Correct 313 ms 640 KB Output is correct
23 Correct 332 ms 760 KB Output is correct
24 Correct 319 ms 640 KB Output is correct
25 Correct 314 ms 640 KB Output is correct
26 Correct 310 ms 676 KB Output is correct
27 Runtime error 183 ms 49272 KB Execution killed with signal 11 (could be triggered by violating memory limits)
28 Halted 0 ms 0 KB -