Submission #405406

#TimeUsernameProblemLanguageResultExecution timeMemory
405406saleh원 고르기 (APIO18_circle_selection)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 5000 + 3; /* 11 9 9 2 13 2 1 11 8 2 3 3 2 3 12 1 12 14 1 9 8 5 2 8 2 5 2 1 14 4 2 14 14 1 */ int n, x[MAXN], y[MAXN], r[MAXN], par[MAXN]; struct cmp { bool operator ()(int a, int b) { return r[a] > r[b]? true: (r[a] == r[b]? a < b: false); } }; set<int, cmp> s; auto dis(int a, int b) { return sqrt(abs(x[a] - x[b]) * abs(x[a] - x[b]) + abs(y[a] - y[b]) * abs(y[a] - y[b])); } bool sect(int a, int b) { return dis(a, b) <= r[a] + r[b]; } int main() { cin >> n; if (n >= MAXN) return 0; for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> r[i]; for (int i = 0; i < n; i++) s.insert(i); while (!s.empty()) { int x = *s.begin(); for (auto i = s.begin(); i != s.end(); ) if (sect(*i, x)) { par[*i] = x; i = s.erase(i); } else i++; } for (int i = 0; i < n; i++) cout << par[i] + 1 << ' '; return 0; }

Compilation message (stderr)

In file included from /usr/include/c++/10/map:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from circle_selection.cpp:1:
/usr/include/c++/10/bits/stl_tree.h: In instantiation of 'static const _Key& std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_S_key(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type) [with _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = cmp; _Alloc = std::allocator<int>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type = const std::_Rb_tree_node<int>*]':
/usr/include/c++/10/bits/stl_tree.h:2101:47:   required from 'std::pair<std::_Rb_tree_node_base*, std::_Rb_tree_node_base*> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_unique_pos(const key_type&) [with _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = cmp; _Alloc = std::allocator<int>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::key_type = int]'
/usr/include/c++/10/bits/stl_tree.h:2154:4:   required from 'std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(_Arg&&) [with _Arg = const int&; _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = cmp; _Alloc = std::allocator<int>]'
/usr/include/c++/10/bits/stl_set.h:512:25:   required from 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = int; _Compare = cmp; _Alloc = std::allocator<int>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<int, int, std::_Identity<int>, cmp, std::allocator<int> >::const_iterator; std::set<_Key, _Compare, _Alloc>::value_type = int]'
circle_selection.cpp:49:40:   required from here
/usr/include/c++/10/bits/stl_tree.h:780:8: error: static assertion failed: comparison object must be invocable as const
  780 |        is_invocable_v<const _Compare&, const _Key&, const _Key&>,
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~