Submission #1107088

# Submission time Handle Problem Language Result Execution time Memory
1107088 2024-10-31T15:59:50 Z mispertion Circle selection (APIO18_circle_selection) C++17
72 / 100
3000 ms 99136 KB
#include<bits/stdc++.h>

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define int ll
using ld = long double;
using pii = pair<int, int>;
#define F first
#define S second

const ld PI = 3.1415926535;
const int N = 5e5 + 2;
const int M = 2e6 + 1;
int mod = 998244353;
const int infi = INT_MAX;
const ll infl = LLONG_MAX;

int mult(int a, int b) {
    return a * 1LL * b % mod;
}

int sum(int a, int b) {
    if (a + b < 0)
        return a + b + mod;
    if (a + b >= mod)
        return a + b - mod;
    return a + b;
}


ll binpow(ll a, ll n) {
    if (n == 0)
        return 1;
    if (n % 2 == 1) {
        return binpow(a, n - 1) * a % mod;
    } else {
        ll b = binpow(a, n / 2);
        return b * b % mod;
    }
}

int n, ans[N];
int csz = 1e9+1;
set<pair<pii, pii>> cs;
map<pii, vector<pair<pii, pii>>> mp;

pii get(int x, int y){
    return {floor((ld)x / (ld)csz), floor((ld)y / (ld)csz)};
}

bool inter(pair<pii, pii> a, pair<pii, pii> b){
    return (((a.S.F - b.S.F) * (a.S.F - b.S.F) + (a.S.S - b.S.S) * (a.S.S - b.S.S)) <= (a.F.F + b.F.F) * (a.F.F + b.F.F));
}

void solve() {
    cin >> n;
    for(int i = 1; i <= n; i++){
        int x, y, r;
        cin >> x >> y >> r;
        cs.insert({{r, n - i + 1}, {x, y}});
        mp[get(x, y)].push_back({{r, n - i + 1}, {x, y}});
    }
    while(cs.size() > 0){
        auto e = *cs.rbegin();
        cs.erase(e);
        if(e.F.F <= csz / 2){
            csz = e.F.F;
            map<pii, vector<pair<pii, pii>>> np;
            for(auto bl : mp){
                for(auto crc : bl.S){
                    np[get(crc.S.F, crc.S.S)].push_back(crc);
                }
            }
            mp.swap(np);
        }        
        ans[n - e.F.S + 1] = n - e.F.S + 1;
        pii bl = get(e.S.F, e.S.S);
        for(int x = bl.F - 2; x <= bl.F + 2; x++){
            for(int y = bl.S - 2; y <= bl.S + 2; y++){
                if(mp.find({x, y}) == mp.end())
                    continue;
                for(auto crc : mp[{x, y}]){
                    if(inter(crc, e)){
                        if(ans[n - crc.F.S + 1] == 0){
                            ans[n - crc.F.S + 1] = n - e.F.S + 1;
                            cs.erase(crc);
                        }
                    }
                }
            }
        }
    }
    for(int i = 1; i <= n; i++)
        cout << ans[i] << ' ';
    cout << '\n';
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 504 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 504 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 2 ms 592 KB Output is correct
17 Correct 2 ms 592 KB Output is correct
18 Correct 2 ms 672 KB Output is correct
19 Correct 5 ms 1104 KB Output is correct
20 Correct 5 ms 1228 KB Output is correct
21 Correct 6 ms 1200 KB Output is correct
22 Correct 19 ms 1932 KB Output is correct
23 Correct 20 ms 1980 KB Output is correct
24 Correct 19 ms 1932 KB Output is correct
25 Correct 21 ms 2092 KB Output is correct
26 Correct 18 ms 2096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 447 ms 62008 KB Output is correct
2 Correct 445 ms 67268 KB Output is correct
3 Correct 419 ms 59232 KB Output is correct
4 Correct 381 ms 62944 KB Output is correct
5 Correct 711 ms 63648 KB Output is correct
6 Correct 1484 ms 86012 KB Output is correct
7 Correct 1006 ms 81336 KB Output is correct
8 Correct 1126 ms 82540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 890 ms 35428 KB Output is correct
3 Execution timed out 3066 ms 99136 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1121 ms 86756 KB Output is correct
2 Correct 829 ms 84272 KB Output is correct
3 Correct 643 ms 70568 KB Output is correct
4 Correct 960 ms 84448 KB Output is correct
5 Correct 932 ms 86604 KB Output is correct
6 Correct 443 ms 63656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 504 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 504 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 2 ms 592 KB Output is correct
17 Correct 2 ms 592 KB Output is correct
18 Correct 2 ms 672 KB Output is correct
19 Correct 5 ms 1104 KB Output is correct
20 Correct 5 ms 1228 KB Output is correct
21 Correct 6 ms 1200 KB Output is correct
22 Correct 19 ms 1932 KB Output is correct
23 Correct 20 ms 1980 KB Output is correct
24 Correct 19 ms 1932 KB Output is correct
25 Correct 21 ms 2092 KB Output is correct
26 Correct 18 ms 2096 KB Output is correct
27 Correct 21 ms 3440 KB Output is correct
28 Correct 9 ms 2760 KB Output is correct
29 Correct 9 ms 2760 KB Output is correct
30 Correct 45 ms 3728 KB Output is correct
31 Correct 40 ms 3664 KB Output is correct
32 Correct 42 ms 3696 KB Output is correct
33 Correct 95 ms 18292 KB Output is correct
34 Correct 100 ms 16816 KB Output is correct
35 Correct 330 ms 31608 KB Output is correct
36 Correct 811 ms 35184 KB Output is correct
37 Correct 676 ms 35448 KB Output is correct
38 Correct 812 ms 35460 KB Output is correct
39 Correct 282 ms 27136 KB Output is correct
40 Correct 292 ms 27488 KB Output is correct
41 Correct 301 ms 27544 KB Output is correct
42 Correct 218 ms 29620 KB Output is correct
43 Correct 245 ms 28680 KB Output is correct
44 Correct 230 ms 28884 KB Output is correct
45 Correct 235 ms 28676 KB Output is correct
46 Correct 236 ms 28676 KB Output is correct
47 Correct 241 ms 28840 KB Output is correct
48 Correct 231 ms 28872 KB Output is correct
49 Correct 238 ms 28676 KB Output is correct
50 Correct 246 ms 28748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 504 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 504 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 2 ms 592 KB Output is correct
17 Correct 2 ms 592 KB Output is correct
18 Correct 2 ms 672 KB Output is correct
19 Correct 5 ms 1104 KB Output is correct
20 Correct 5 ms 1228 KB Output is correct
21 Correct 6 ms 1200 KB Output is correct
22 Correct 19 ms 1932 KB Output is correct
23 Correct 20 ms 1980 KB Output is correct
24 Correct 19 ms 1932 KB Output is correct
25 Correct 21 ms 2092 KB Output is correct
26 Correct 18 ms 2096 KB Output is correct
27 Correct 447 ms 62008 KB Output is correct
28 Correct 445 ms 67268 KB Output is correct
29 Correct 419 ms 59232 KB Output is correct
30 Correct 381 ms 62944 KB Output is correct
31 Correct 711 ms 63648 KB Output is correct
32 Correct 1484 ms 86012 KB Output is correct
33 Correct 1006 ms 81336 KB Output is correct
34 Correct 1126 ms 82540 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 890 ms 35428 KB Output is correct
37 Execution timed out 3066 ms 99136 KB Time limit exceeded
38 Halted 0 ms 0 KB -