Submission #52629

#TimeUsernameProblemLanguageResultExecution timeMemory
52629KubalionzzaleCircle selection (APIO18_circle_selection)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <set> #include <math.h> #include <algorithm> #include <functional> long double abss(long double x) { if (x < 0) return -x; else return x; } long double sqr(long double x) { return x * x; } struct compare { bool operator() (const std::pair<int, int>& lhs, const std::pair<int, int>& rhs) const { if (lhs.first != rhs.first) return lhs.first > rhs.first; else return lhs.second < rhs.second; } }; void firstSubtask(int n) { std::set< std::pair<int, int>, compare > set; int visited[300010] = { 0 }; int x[300010], y[300010], r[300010]; for (int i = 1; i <= n; ++i) { std::cin >> x[i] >> y[i] >> r[i]; set.insert(std::make_pair(r[i], i)); } while (set.empty() == false) { std::pair<int, int> p = *set.begin(); set.erase(set.begin()); int xs = x[p.second], ys = y[p.second], rs = r[p.second]; visited[p.second] = p.second; for (auto it = set.begin(); it != set.end();) { std::pair<int, int> sec = *it; int xq = x[sec.second], yq = y[sec.second], rq = r[sec.second]; long double dist = sqrt(sqr(xq * 1.0 - xs * 1.0) + sqr(yq * 1.0 - ys * 1.0)); // std::cout << p.second << " " << sec.second << " " << dist << " " << rq * 1.0 + rs * 1.0 << "\n"; if (dist <= rq * 1.0 + rs * 1.0) { visited[sec.second] = p.second; it = set.erase(it); } else { ++it; } } } for (int i = 1; i <= n; ++i) { std::cout << visited[i] << " "; } } int main() { int n; std::cin >> n; if (n <= 5000) { firstSubtask(n, x, y, r); return 0; } }

Compilation message (stderr)

circle_selection.cpp: In function 'int main()':
circle_selection.cpp:80:25: error: 'x' was not declared in this scope
         firstSubtask(n, x, y, r);
                         ^
circle_selection.cpp:80:28: error: 'y' was not declared in this scope
         firstSubtask(n, x, y, r);
                            ^
circle_selection.cpp:80:31: error: 'r' was not declared in this scope
         firstSubtask(n, x, y, r);
                               ^