Submission #102388

#TimeUsernameProblemLanguageResultExecution timeMemory
102388tjdgus4384Circle selection (APIO18_circle_selection)C++14
7 / 100
3091 ms21384 KiB
#include<cstdio> #include<algorithm> #include<iostream> #include<vector> using namespace std; vector<pair<pair<long long int, long long int>, pair<long long int, long long int> > > v; vector<long long int> answer; bool visited[500003]; bool can(long long int a, long long int b){ long long int ax = v[a].second.first; long long int ay = v[a].second.second; long long int bx = v[b].second.first; long long int by = v[b].second.second; long long int x = (ax - bx) * (ax - bx) + (ay - by) * (ay - by); long long int y = (v[a].first.first + v[b].first.first) * (v[a].first.first + v[b].first.first); return (v[a].first.first + v[b].first.first) * (v[a].first.first + v[b].first.first) >= x; } int main(){ long long int n; scanf("%lld", &n); v.resize(n + 1); answer.resize(n + 1); for(long long int i = 1;i <= n;i++){ scanf("%lld %lld %lld", &v[i].second.first, &v[i].second.second, &v[i].first.first); v[i].first.second = i; v[i].first.first = -v[i].first.first; } sort(v.begin() + 1, v.end()); for(long long int i = 1;i <= n;i++){ if(visited[i]) continue; for(long long int j = 1;j <= n;j++){ if(visited[j]) continue; if(can(i, j)){ answer[v[j].first.second] = v[i].first.second; visited[j] = true; } } } for(long long int i = 1;i <= n;i++){ printf("%lld ", answer[i]); } return 0; }

Compilation message (stderr)

circle_selection.cpp: In function 'bool can(long long int, long long int)':
circle_selection.cpp:16:19: warning: unused variable 'y' [-Wunused-variable]
     long long int y = (v[a].first.first + v[b].first.first) * (v[a].first.first + v[b].first.first);
                   ^
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld", &n);
     ~~~~~^~~~~~~~~~~~
circle_selection.cpp:26:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld %lld %lld", &v[i].second.first, &v[i].second.second, &v[i].first.first);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...