답안 #579108

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
579108 2022-06-18T11:36:46 Z noedit 원 고르기 (APIO18_circle_selection) C++17
72 / 100
3000 ms 248416 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 301010
#define INF 1000000010
pair<pair<int, int>, pair<int, int>> in[MAX];
int X[MAX];
int Y[MAX];
int R[MAX];
int ind[MAX];
int ri[MAX];
int ans[MAX];
inline ll sq(ll x)
{
    return x * x;
}
inline bool chk(int i, int j)
{
    return sq(X[i] - X[j]) + sq(Y[i] - Y[j]) <= sq(R[i] + R[j]);
}
bool isrange(int x, int y)
{
    if (x < 0 || y < 0)
    {
        return false;
    }
    return true;
}
inline ll trans(int x, int y)
{
    return ((ll)x * (ll)INF) + y;
}
bool cmp(pair<pair<int, int>, pair<int, int>>& p1, pair<pair<int, int>, pair<int, int>>& p2)
{
    if (p1.first.first == p2.first.first)
    {
        return p1.first.second < p2.first.second;
    }
    else
    {
        return p1.first.first > p2.first.first;
    }
}
unordered_map<ll, vector<int>> mp;
signed main()
{
    ios::sync_with_stdio(false), cin.tie(0);
    int n;
    cin >> n;
    int i;
    for (i = 1; i <= n; i++)
    {
        cin >> in[i].second.first >> in[i].second.second >> in[i].first.first, in[i].first.second = i;
    }
    sort(in + 1, in + n + 1, cmp);
    for (i = 1; i <= n; i++)
    {
        tie(X[i], Y[i], R[i], ind[i]) = make_tuple(in[i].second.first + INF, in[i].second.second + INF, in[i].first.first, in[i].first.second);
    }
    int k;
    int s, e;
    e = 0;
    for (k = 30; k >= 0; k--)
    {
        int r = 1 << k;
        s = e + 1;
        if (R[s] < r / 2)
        {
            continue;
        }
        mp.clear();
        e = 0;
        for (i = s; i <= n; i++)
        {
            if (ans[i])
            {
                continue;
            }
            int x, y;
            x = X[i] >> k;
            y = Y[i] >> k;
            if (R[i] < r / 2 && !e) e = i - 1;
            int xx, yy;
            for (xx = x - 1; xx <= x + 1; xx++)
            {
                for (yy = y - 1; yy <= y + 1; yy++)
                {
                    mp[((ll)xx << 31LL) + yy].push_back(i);
                }
            }
        }
        if (e == 0) e = n;
        for (i = s; i <= e; i++)
        {
            if (ans[i])
            {
                continue;
            }
            ans[i] = i;
            int x, y;
            x = X[i] >>k;
            y = Y[i] >>k;
            int xx, yy;
            for (xx = x - 1; xx <= x + 1; xx++)
            {
                for (yy = y - 1; yy <= y + 1; yy++)
                {
                    ll t = ((ll)xx << 31LL) + yy;
                    for (auto c : mp[t]) if (!ans[c] && chk(c, i)) ans[c] = i;
                }
            }
        }
    }
    for (i = 1; i <= n; i++)
    {
        ri[ind[i]] = i;
    }
    for (i = 1; i <= n; i++)
    {
        cout << ind[ans[ri[i]]] << ' ';
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 468 KB Output is correct
17 Correct 2 ms 468 KB Output is correct
18 Correct 2 ms 468 KB Output is correct
19 Correct 4 ms 724 KB Output is correct
20 Correct 4 ms 724 KB Output is correct
21 Correct 4 ms 852 KB Output is correct
22 Correct 17 ms 4764 KB Output is correct
23 Correct 20 ms 4784 KB Output is correct
24 Correct 20 ms 4784 KB Output is correct
25 Correct 19 ms 4784 KB Output is correct
26 Correct 20 ms 4824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 216 ms 22124 KB Output is correct
2 Correct 202 ms 22176 KB Output is correct
3 Correct 216 ms 22224 KB Output is correct
4 Correct 205 ms 21948 KB Output is correct
5 Correct 322 ms 33724 KB Output is correct
6 Correct 1539 ms 65052 KB Output is correct
7 Correct 435 ms 32172 KB Output is correct
8 Correct 672 ms 39980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 973 ms 84448 KB Output is correct
3 Correct 2822 ms 247140 KB Output is correct
4 Correct 2980 ms 247096 KB Output is correct
5 Execution timed out 3081 ms 162992 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1548 ms 248296 KB Output is correct
2 Correct 1547 ms 248416 KB Output is correct
3 Correct 620 ms 37212 KB Output is correct
4 Correct 1565 ms 248416 KB Output is correct
5 Correct 1519 ms 248344 KB Output is correct
6 Correct 314 ms 31996 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 468 KB Output is correct
17 Correct 2 ms 468 KB Output is correct
18 Correct 2 ms 468 KB Output is correct
19 Correct 4 ms 724 KB Output is correct
20 Correct 4 ms 724 KB Output is correct
21 Correct 4 ms 852 KB Output is correct
22 Correct 17 ms 4764 KB Output is correct
23 Correct 20 ms 4784 KB Output is correct
24 Correct 20 ms 4784 KB Output is correct
25 Correct 19 ms 4784 KB Output is correct
26 Correct 20 ms 4824 KB Output is correct
27 Correct 7 ms 1236 KB Output is correct
28 Correct 8 ms 1200 KB Output is correct
29 Correct 7 ms 1120 KB Output is correct
30 Correct 43 ms 9308 KB Output is correct
31 Correct 83 ms 9364 KB Output is correct
32 Correct 42 ms 9348 KB Output is correct
33 Correct 71 ms 7436 KB Output is correct
34 Correct 74 ms 7548 KB Output is correct
35 Correct 85 ms 7848 KB Output is correct
36 Correct 1024 ms 86608 KB Output is correct
37 Correct 970 ms 86680 KB Output is correct
38 Correct 1107 ms 86304 KB Output is correct
39 Correct 686 ms 17712 KB Output is correct
40 Correct 683 ms 17844 KB Output is correct
41 Correct 708 ms 17856 KB Output is correct
42 Correct 187 ms 15328 KB Output is correct
43 Correct 494 ms 81748 KB Output is correct
44 Correct 693 ms 81784 KB Output is correct
45 Correct 460 ms 81708 KB Output is correct
46 Correct 460 ms 81768 KB Output is correct
47 Correct 506 ms 81848 KB Output is correct
48 Correct 454 ms 81816 KB Output is correct
49 Correct 459 ms 81772 KB Output is correct
50 Correct 491 ms 81800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 468 KB Output is correct
17 Correct 2 ms 468 KB Output is correct
18 Correct 2 ms 468 KB Output is correct
19 Correct 4 ms 724 KB Output is correct
20 Correct 4 ms 724 KB Output is correct
21 Correct 4 ms 852 KB Output is correct
22 Correct 17 ms 4764 KB Output is correct
23 Correct 20 ms 4784 KB Output is correct
24 Correct 20 ms 4784 KB Output is correct
25 Correct 19 ms 4784 KB Output is correct
26 Correct 20 ms 4824 KB Output is correct
27 Correct 216 ms 22124 KB Output is correct
28 Correct 202 ms 22176 KB Output is correct
29 Correct 216 ms 22224 KB Output is correct
30 Correct 205 ms 21948 KB Output is correct
31 Correct 322 ms 33724 KB Output is correct
32 Correct 1539 ms 65052 KB Output is correct
33 Correct 435 ms 32172 KB Output is correct
34 Correct 672 ms 39980 KB Output is correct
35 Correct 0 ms 340 KB Output is correct
36 Correct 973 ms 84448 KB Output is correct
37 Correct 2822 ms 247140 KB Output is correct
38 Correct 2980 ms 247096 KB Output is correct
39 Execution timed out 3081 ms 162992 KB Time limit exceeded
40 Halted 0 ms 0 KB -