답안 #680595

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
680595 2023-01-11T10:32:51 Z sysia 원 고르기 (APIO18_circle_selection) C++17
49 / 100
3000 ms 179268 KB
//Sylwia Sapkowska
#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
using namespace std;

void __print(int x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define int long long
typedef pair<int, int> T;
const int K = 30;

struct circle{
    int x, y, r, i; 
    circle(){}
    circle(int _x, int _y, int _r, int _i){x = _x, y = _y, r = _r, i = _i;}
    bool operator <(const circle&he)const {return r == he.r ? i < he.i : r > he.r; }
    bool intersect(circle he){return (x - he.x) * (x - he.x) + (y - he.y) * (y - he.y) <= (r + he.r) * (r + he.r); }
};

void solve(){
    int n; cin >> n;
    vector<circle>a;
    for (int i = 0; i<n; i++){
        int x, y, r; cin >> x >> y >> r;
        a.emplace_back(x, y, r, i);
    }
    stable_sort(a.begin(), a.end());
    vector<int>ans(n, -1), ord(n);
    for (int i = 0; i<n; i++) ord[a[i].i] = i;
    map<pair<int, int>, vector<int>>divide;
    for (int rep = K; rep >= 1; rep--){
        divide.clear();
        bool any = 0;
        for (int i = 0; i<n; i++){
            if (ans[i] == -1){
                divide[{a[ord[i]].x >> rep, a[ord[i]].y >> rep}].emplace_back(i);
                any = 1;
            }
        }
        if (!any) break;
        auto what = [&](int i){
            T curr = {a[ord[i]].x >> rep, a[ord[i]].y >> rep};
            // debug(curr);
            for (int x = -2; x <= 2; x++){
                for (int y = -2; y <= 2; y++){
                    T s = {curr.first + x, curr.second + y};
                    for (auto idx: divide[s]){
                        if (ans[idx] == -1 && a[ord[i]].intersect(a[ord[idx]])){
                            ans[idx] = i;
                        }
                    }
                }
            }
        };
        for (int i = 0; i<n; i++){
            if (ans[a[i].i] == -1 && a[i].r >= (1<<(rep-1))){
                what(a[i].i);
            }
        }
    }
    for (int i = 0; i<n; i++){
        cout << ans[i]+1 << " ";
    }
    cout << "\n";
}

int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 260 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 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 384 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 3 ms 732 KB Output is correct
20 Correct 3 ms 728 KB Output is correct
21 Correct 3 ms 728 KB Output is correct
22 Correct 50 ms 5040 KB Output is correct
23 Correct 50 ms 5260 KB Output is correct
24 Correct 50 ms 4232 KB Output is correct
25 Correct 59 ms 4848 KB Output is correct
26 Correct 54 ms 5120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 245 ms 21272 KB Output is correct
2 Correct 205 ms 21296 KB Output is correct
3 Correct 264 ms 20620 KB Output is correct
4 Correct 178 ms 20108 KB Output is correct
5 Correct 628 ms 22660 KB Output is correct
6 Correct 2079 ms 69372 KB Output is correct
7 Correct 683 ms 24076 KB Output is correct
8 Correct 993 ms 33932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1772 ms 89696 KB Output is correct
3 Execution timed out 3095 ms 94856 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3092 ms 68948 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 260 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 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 384 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 3 ms 732 KB Output is correct
20 Correct 3 ms 728 KB Output is correct
21 Correct 3 ms 728 KB Output is correct
22 Correct 50 ms 5040 KB Output is correct
23 Correct 50 ms 5260 KB Output is correct
24 Correct 50 ms 4232 KB Output is correct
25 Correct 59 ms 4848 KB Output is correct
26 Correct 54 ms 5120 KB Output is correct
27 Correct 7 ms 1048 KB Output is correct
28 Correct 7 ms 1024 KB Output is correct
29 Correct 8 ms 1048 KB Output is correct
30 Correct 97 ms 10860 KB Output is correct
31 Correct 101 ms 10740 KB Output is correct
32 Correct 108 ms 8292 KB Output is correct
33 Correct 52 ms 7364 KB Output is correct
34 Correct 55 ms 7412 KB Output is correct
35 Correct 69 ms 7424 KB Output is correct
36 Correct 2029 ms 97900 KB Output is correct
37 Correct 2140 ms 86332 KB Output is correct
38 Correct 2162 ms 99172 KB Output is correct
39 Correct 462 ms 13856 KB Output is correct
40 Correct 620 ms 13828 KB Output is correct
41 Correct 561 ms 13876 KB Output is correct
42 Correct 372 ms 12484 KB Output is correct
43 Correct 1567 ms 178800 KB Output is correct
44 Correct 1433 ms 179100 KB Output is correct
45 Correct 1322 ms 178864 KB Output is correct
46 Correct 1408 ms 178900 KB Output is correct
47 Correct 1311 ms 179172 KB Output is correct
48 Correct 1442 ms 179176 KB Output is correct
49 Correct 1512 ms 179268 KB Output is correct
50 Correct 1426 ms 178976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 260 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 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 384 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 3 ms 732 KB Output is correct
20 Correct 3 ms 728 KB Output is correct
21 Correct 3 ms 728 KB Output is correct
22 Correct 50 ms 5040 KB Output is correct
23 Correct 50 ms 5260 KB Output is correct
24 Correct 50 ms 4232 KB Output is correct
25 Correct 59 ms 4848 KB Output is correct
26 Correct 54 ms 5120 KB Output is correct
27 Correct 245 ms 21272 KB Output is correct
28 Correct 205 ms 21296 KB Output is correct
29 Correct 264 ms 20620 KB Output is correct
30 Correct 178 ms 20108 KB Output is correct
31 Correct 628 ms 22660 KB Output is correct
32 Correct 2079 ms 69372 KB Output is correct
33 Correct 683 ms 24076 KB Output is correct
34 Correct 993 ms 33932 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1772 ms 89696 KB Output is correct
37 Execution timed out 3095 ms 94856 KB Time limit exceeded
38 Halted 0 ms 0 KB -