답안 #217757

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
217757 2020-03-30T16:26:55 Z Vimmer 원 고르기 (APIO18_circle_selection) C++14
7 / 100
3000 ms 24440 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] << " ";
}

Compilation message

circle_selection.cpp: In function 'int main()':
circle_selection.cpp:117:13: warning: unused variable 'v' [-Wunused-variable]
         int v = t[1];
             ^
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 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 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 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 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 10 ms 640 KB Output is correct
22 Correct 330 ms 640 KB Output is correct
23 Correct 326 ms 760 KB Output is correct
24 Correct 322 ms 640 KB Output is correct
25 Correct 324 ms 644 KB Output is correct
26 Correct 305 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 151 ms 24440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Execution timed out 3085 ms 5368 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3082 ms 15608 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 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 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 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 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 10 ms 640 KB Output is correct
22 Correct 330 ms 640 KB Output is correct
23 Correct 326 ms 760 KB Output is correct
24 Correct 322 ms 640 KB Output is correct
25 Correct 324 ms 644 KB Output is correct
26 Correct 305 ms 640 KB Output is correct
27 Correct 10 ms 896 KB Output is correct
28 Correct 10 ms 896 KB Output is correct
29 Correct 9 ms 896 KB Output is correct
30 Correct 1325 ms 1016 KB Output is correct
31 Correct 1340 ms 992 KB Output is correct
32 Correct 1314 ms 904 KB Output is correct
33 Correct 63 ms 6012 KB Output is correct
34 Correct 58 ms 6008 KB Output is correct
35 Correct 77 ms 6000 KB Output is correct
36 Execution timed out 3046 ms 5368 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 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 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 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 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 10 ms 640 KB Output is correct
22 Correct 330 ms 640 KB Output is correct
23 Correct 326 ms 760 KB Output is correct
24 Correct 322 ms 640 KB Output is correct
25 Correct 324 ms 644 KB Output is correct
26 Correct 305 ms 640 KB Output is correct
27 Incorrect 151 ms 24440 KB Output isn't correct
28 Halted 0 ms 0 KB -