Submission #402119

# Submission time Handle Problem Language Result Execution time Memory
402119 2021-05-11T10:51:40 Z teehandsome Circle selection (APIO18_circle_selection) C++11
7 / 100
3000 ms 1048580 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define endl '\n'
#define INF 1e9+7
#define all(x) x.begin(),x.end()
using namespace std;
using namespace __gnu_pbds;
using ll=long long;
using pii=pair<int,int>;
using ppi=pair<int,pii>;
using oset=tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;

template<typename T>
void _print(vector<T> x) {cerr<<"{"; for(auto e:x) cerr<<e<<","; cerr<<"}";}
void _print(pii x) {cerr<<"{"<<x.first<<","<<x.second<<"}";}
template<typename T>
void _print(T x) {cerr<<x;}

void dbg() {cerr<<endl;}
template<typename Head,typename... Tail>
void dbg(Head H,Tail... T) {
    _print(H);
    if(sizeof...(T)) cerr<<",";
    else cerr<<"\"]";
    dbg(T...);
}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:[\"",dbg(__VA_ARGS__)

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

struct dt {
    ll x,y,r;
    int idx;
    bool intersect(const dt &aa) {
        return (x-aa.x)*(x-aa.x)+(y-aa.y)*(y-aa.y)<=(r+aa.r)*(r+aa.r);
    }
    bool operator<(const dt &aa) {
        return r<aa.r;
    }
};

bool operator>(const dt &aa,const dt &bb) {
        if(aa.r==bb.r) return aa.x<bb.x;
        return aa.r>bb.r;
}

bool same[5010][5010];

int main () {
    ios::sync_with_stdio(false); cin.tie(0);
    int n; cin>>n;
    vector<dt> a(n);
    for(int i=0;i<n;i++) cin>>a[i].x>>a[i].y>>a[i].r,a[i].idx=i;
    sort(all(a),greater<dt>());
    vector<int> ans(n,-1);

    vector<int> inlist[n];
    for(int i=0;i<n;i++) {
        for(int j=i+1;j<n;j++) {
            if(a[i].intersect(a[j])) {
                inlist[i].push_back(j);
            }
        }
    }

    for(int i=0;i<n;i++) {
        int u=a[i].idx;
        if(ans[u]!=-1) continue;
        ans[u]=u;
        for(auto e:inlist[i]) {
            int v=a[e].idx;
            if(ans[v]!=-1) continue;
            ans[v]=u;
        }
    }
//    debug(ans);

    for(int i=0;i<n;i++) cout<<ans[i]+1<<" "; cout<<endl;
}

Compilation message

circle_selection.cpp: In function 'int main()':
circle_selection.cpp:79:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   79 |     for(int i=0;i<n;i++) cout<<ans[i]+1<<" "; cout<<endl;
      |     ^~~
circle_selection.cpp:79:47: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   79 |     for(int i=0;i<n;i++) cout<<ans[i]+1<<" "; cout<<endl;
      |                                               ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 316 KB Output is correct
16 Correct 6 ms 2404 KB Output is correct
17 Correct 6 ms 2180 KB Output is correct
18 Correct 5 ms 2764 KB Output is correct
19 Correct 91 ms 60596 KB Output is correct
20 Correct 92 ms 62252 KB Output is correct
21 Correct 119 ms 38340 KB Output is correct
22 Correct 45 ms 716 KB Output is correct
23 Correct 45 ms 748 KB Output is correct
24 Correct 46 ms 744 KB Output is correct
25 Correct 45 ms 744 KB Output is correct
26 Correct 48 ms 744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 2511 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Execution timed out 3067 ms 8432 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3047 ms 17912 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 316 KB Output is correct
16 Correct 6 ms 2404 KB Output is correct
17 Correct 6 ms 2180 KB Output is correct
18 Correct 5 ms 2764 KB Output is correct
19 Correct 91 ms 60596 KB Output is correct
20 Correct 92 ms 62252 KB Output is correct
21 Correct 119 ms 38340 KB Output is correct
22 Correct 45 ms 716 KB Output is correct
23 Correct 45 ms 748 KB Output is correct
24 Correct 46 ms 744 KB Output is correct
25 Correct 45 ms 744 KB Output is correct
26 Correct 48 ms 744 KB Output is correct
27 Correct 461 ms 167608 KB Output is correct
28 Correct 352 ms 209092 KB Output is correct
29 Correct 358 ms 199344 KB Output is correct
30 Correct 178 ms 1172 KB Output is correct
31 Correct 178 ms 1168 KB Output is correct
32 Correct 170 ms 1168 KB Output is correct
33 Runtime error 1915 ms 1048580 KB Execution killed with signal 9
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 316 KB Output is correct
16 Correct 6 ms 2404 KB Output is correct
17 Correct 6 ms 2180 KB Output is correct
18 Correct 5 ms 2764 KB Output is correct
19 Correct 91 ms 60596 KB Output is correct
20 Correct 92 ms 62252 KB Output is correct
21 Correct 119 ms 38340 KB Output is correct
22 Correct 45 ms 716 KB Output is correct
23 Correct 45 ms 748 KB Output is correct
24 Correct 46 ms 744 KB Output is correct
25 Correct 45 ms 744 KB Output is correct
26 Correct 48 ms 744 KB Output is correct
27 Runtime error 2511 ms 1048576 KB Execution killed with signal 9
28 Halted 0 ms 0 KB -