Submission #487848

#TimeUsernameProblemLanguageResultExecution timeMemory
487848leakedCircle selection (APIO18_circle_selection)C++14
0 / 100
3087 ms22272 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...