답안 #680588

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
680588 2023-01-11T10:27:44 Z sysia 원 고르기 (APIO18_circle_selection) C++17
49 / 100
3000 ms 181944 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 oo = 1e18, oo2 = 1e9+7, K = 30;
const int mod = 998244353;

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);
    }
    sort(a.begin(), a.end());
    vector<int>ans(n, -1), ord(n);
    for (int i = 0; i<n; i++) ord[a[i].i] = i;
    debug(ord);
    for (int rep = K; rep >= 1; rep--){
        map<pair<int, int>, vector<int>>divide;
        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 1 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 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 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 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 1 ms 328 KB Output is correct
19 Correct 3 ms 852 KB Output is correct
20 Correct 4 ms 844 KB Output is correct
21 Correct 3 ms 844 KB Output is correct
22 Correct 56 ms 5136 KB Output is correct
23 Correct 55 ms 5420 KB Output is correct
24 Correct 43 ms 4372 KB Output is correct
25 Correct 45 ms 4948 KB Output is correct
26 Correct 48 ms 5324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 203 ms 21224 KB Output is correct
2 Correct 255 ms 27928 KB Output is correct
3 Correct 196 ms 27180 KB Output is correct
4 Correct 184 ms 26900 KB Output is correct
5 Correct 563 ms 27304 KB Output is correct
6 Correct 2045 ms 74024 KB Output is correct
7 Correct 708 ms 28880 KB Output is correct
8 Correct 943 ms 38652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1850 ms 92552 KB Output is correct
3 Execution timed out 3057 ms 115052 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3056 ms 47868 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 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 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 1 ms 328 KB Output is correct
19 Correct 3 ms 852 KB Output is correct
20 Correct 4 ms 844 KB Output is correct
21 Correct 3 ms 844 KB Output is correct
22 Correct 56 ms 5136 KB Output is correct
23 Correct 55 ms 5420 KB Output is correct
24 Correct 43 ms 4372 KB Output is correct
25 Correct 45 ms 4948 KB Output is correct
26 Correct 48 ms 5324 KB Output is correct
27 Correct 6 ms 1364 KB Output is correct
28 Correct 6 ms 1292 KB Output is correct
29 Correct 6 ms 1252 KB Output is correct
30 Correct 100 ms 11200 KB Output is correct
31 Correct 100 ms 11024 KB Output is correct
32 Correct 103 ms 8576 KB Output is correct
33 Correct 52 ms 10468 KB Output is correct
34 Correct 57 ms 10424 KB Output is correct
35 Correct 77 ms 10284 KB Output is correct
36 Correct 1821 ms 100472 KB Output is correct
37 Correct 1972 ms 88972 KB Output is correct
38 Correct 1944 ms 101920 KB Output is correct
39 Correct 524 ms 14916 KB Output is correct
40 Correct 512 ms 14940 KB Output is correct
41 Correct 495 ms 14960 KB Output is correct
42 Correct 389 ms 14080 KB Output is correct
43 Correct 1372 ms 181304 KB Output is correct
44 Correct 1366 ms 181744 KB Output is correct
45 Correct 1398 ms 181388 KB Output is correct
46 Correct 1392 ms 181532 KB Output is correct
47 Correct 1585 ms 181944 KB Output is correct
48 Correct 1511 ms 181812 KB Output is correct
49 Correct 1660 ms 181832 KB Output is correct
50 Correct 1408 ms 181508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 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 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 1 ms 328 KB Output is correct
19 Correct 3 ms 852 KB Output is correct
20 Correct 4 ms 844 KB Output is correct
21 Correct 3 ms 844 KB Output is correct
22 Correct 56 ms 5136 KB Output is correct
23 Correct 55 ms 5420 KB Output is correct
24 Correct 43 ms 4372 KB Output is correct
25 Correct 45 ms 4948 KB Output is correct
26 Correct 48 ms 5324 KB Output is correct
27 Correct 203 ms 21224 KB Output is correct
28 Correct 255 ms 27928 KB Output is correct
29 Correct 196 ms 27180 KB Output is correct
30 Correct 184 ms 26900 KB Output is correct
31 Correct 563 ms 27304 KB Output is correct
32 Correct 2045 ms 74024 KB Output is correct
33 Correct 708 ms 28880 KB Output is correct
34 Correct 943 ms 38652 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 1850 ms 92552 KB Output is correct
37 Execution timed out 3057 ms 115052 KB Time limit exceeded
38 Halted 0 ms 0 KB -