Submission #487848

# Submission time Handle Problem Language Result Execution time Memory
487848 2021-11-16T19:38:57 Z leaked Circle selection (APIO18_circle_selection) C++14
0 / 100
3000 ms 22272 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);});
    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{
        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);
            }
        }
    }
    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


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:47:24: warning: unused variable 'k' [-Wunused-variable]
   47 |                     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 265 ms 22272 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 3087 ms 6132 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 -