Submission #106929

#TimeUsernameProblemLanguageResultExecution timeMemory
106929tictaccatCircle selection (APIO18_circle_selection)C++14
0 / 100
3006 ms25312 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int MAX = 3e5; int n; vector<pair<int,pair<int,int>>> circles(MAX); vector<int> old,cur; vector<int> elim(MAX); int dist(pair<int,int> p1, pair<int,int> p2) { return (p2.first-p1.first)*(p2.first-p1.first) + (p2.second-p1.second)*(p2.second-p1.second); } bool intsct(pair<int,pair<int,int>> c1, pair<int,pair<int,int>> c2) { return dist(c1.second,c2.second) <= (c1.first+c2.first)*(c1.first+c2.first); } main() { // cin.tie(0); // ios::sync_with_stdio(false); cin >> n; for (int i = 0; i < n; i++) { int x,y,r; cin >> x >> y >> r; circles[i] = make_pair(r,make_pair(x,y)); cur.push_back(i); } while (cur.size() > 0) { old = cur; cur.clear(); sort(old.begin(),old.end(),[](int i, int j) {return circles[i].first > circles[j].first || (circles[i].first == circles[j].first && i < j);}); cout << old[0]+1 << ": "; for (int i = 0; i < old.size(); i++) { if (!intsct(circles[old[i]],circles[old[0]])) { cur.push_back(old[i]); } else { elim[old[i]] = old[0]; cout << old[i]+1 << " "; } } cout << "\n"; } for (int i = 0; i < n; i++) { cout << elim[i]+1 << " "; } return 0; }

Compilation message (stderr)

circle_selection.cpp:22:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:39:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < old.size(); i++) {
                         ~~^~~~~~~~~~~~
#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...