Submission #487856

# Submission time Handle Problem Language Result Execution time Memory
487856 2021-11-16T19:45:22 Z leaked Circle selection (APIO18_circle_selection) C++14
0 / 100
3000 ms 22280 KB
#include <bits/stdc++.h>

#define f first
#define s second
#define sz(x) (int)(x).size()
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pw(x) (1LL<<(x))
#define m_p make_pair
#define fast_iati ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

template <class T> bool umin(T &a,const T &b){return (a>b?a=b,1:0);}
template <class T> bool umax(T &a,const T &b){return (a<b?a=b,1:0);}
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;

const int inf=-2e9;
signed main(){
    fast_iati;
    int n;
    cin>>n;
    vec<int>x(n),y(n),r(n);
    int ok=1;
    for(int i=0;i<n;i++)
        cin>>x[i]>>y[i]>>r[i],ok&=(y[i]==0);
    vec<int>perm(n,0);
        iota(all(perm),0);
    sort(all(perm),[&](int i,int j){return m_p(r[i],-i)>m_p(r[j],-j);});
//    for(int i=0;i<n;i++){
//        cout<<r[perm[i]]<<' '<<perm[i]<<endl;
//    }
    vec<int>p(n,-1);
    if(!ok){

        for(auto &i : perm){
            if(p[i]!=-1) continue;
            for(int j=0;j<n;j++){
                if(p[j]!=-1) continue;
                if(y[i]==y[j]){
                    if(abs(x[i]-x[j])<=r[i]){
                        p[j]=i;
                    }
                }
                else{
                    ld k=(ld)(y[i]-y[j])/(y[i]+y[j]);

                }
//                if(){
//                    p[j]=i;
//                }
            }
        }

    }
    else{
//        assert(false);
        set<pii>st;
        for(int i=0;i<n;i++) st.insert({x[i],i});
        for(auto &i : perm){
            if(p[i]!=-1) continue;
            int l=x[i]-r[i],rt=x[i]+r[i];
            while(1){
                auto it=st.lower_bound(m_p(l,-inf));
                if(it==st.end() || it->f>rt) break;
                assert(p[it->s]==-1);
                p[it->s]=i;
                st.erase(it);
            }
//            assert(p[i]==i);
        }
    }
    for(auto &z : p)
        cout<<z+1<<' ';
    return 0;
}
/*
4 2 4
3 1 1 10
9 2 2 4
7 2 5 7
4 1 8 10
5 3
5 6
5 9
1 10
3
1 0 2
2 0 2
4 0 1
2 0
2 1
1 2

2 1 3
1 1 1 4
1 1 2 6
1 3
1 5
1 7

1 1 1
100000000 1 1 1
1 1
*/

Compilation message

circle_selection.cpp: In function 'int main()':
circle_selection.cpp:50:24: warning: unused variable 'k' [-Wunused-variable]
   50 |                     ld k=(ld)(y[i]-y[j])/(y[i]+y[j]);
      |                        ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 313 ms 22280 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3059 ms 6136 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -