Submission #1313213

#TimeUsernameProblemLanguageResultExecution timeMemory
1313213jahongirCircle selection (APIO18_circle_selection)C++20
Compilation error
0 ms0 KiB
#pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; #define pb push_back #define all(a) a.begin(),a.end() typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef unsigned long long ull; typedef vector<int> vi; bool check(const array<int,3> &a, const array<int,3> &b){ ll dx = a[0]-b[0], dy = a[1]-b[1], r = a[2]+b[2]; return dx*dx + dy*dy <= r*r; } void solve(){ int n; cin >> n; vector<array<int,3>> vec(n); unordered_map<ll,set<int>> mp; int cnt = 0; for(auto &[x,y,r] : vec){ cin >> x >> y >> r; mp[(x/r) + ((y/r)<<30)].insert(cnt++); } vector<int> ind(n); iota(all(ind),0); sort(all(ind),[&](const int &i, const int &j){ if(vec[i][2]==vec[j][2]) return i < j; return vec[i][2] > vec[j][2]; }); vector<int> res(n,-1); int r = vec[ind[0]][2]; int lim = 10; for(int i = 0; i < n; i++) if(res[ind[i]]==-1){ int x = vec[ind[i]][0], y = vec[ind[i]][1]; for(int dx = -lim; dx <= lim; dx++) for(int dy = -lim; dy <= lim; dy++){ vector<int> rem; for(auto j : mp[(x/r+dx)+((y/r+dy)<<30)]){ if(check(vec[ind[i]],vec[j])){ rem.emplace_back(j); res[j] = ind[i]; } } for(auto j : rem) mp[{x/r+dx,y/r+dy}].erase(j); } } for(auto x : res) cout << x+1 << ' '; } signed main(){ cin.tie(0)->sync_with_stdio(0); int t = 1; // cin >> t; while(t--){solve();} }

Compilation message (stderr)

circle_selection.cpp: In function 'void solve()':
circle_selection.cpp:60:23: error: no match for 'operator[]' (operand types are 'std::unordered_map<long long int, std::set<int> >' and '<brace-enclosed initializer list>')
   60 |                     mp[{x/r+dx,y/r+dy}].erase(j);
      |                       ^
In file included from /usr/include/c++/13/unordered_map:41,
                 from /usr/include/c++/13/functional:63,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53,
                 from circle_selection.cpp:4:
/usr/include/c++/13/bits/unordered_map.h:986:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type&) [with _Key = long long int; _Tp = std::set<int>; _Hash = std::hash<long long int>; _Pred = std::equal_to<long long int>; _Alloc = std::allocator<std::pair<const long long int, std::set<int> > >; mapped_type = std::set<int>; key_type = long long int]'
  986 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/13/bits/unordered_map.h:986:34: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::unordered_map<long long int, std::set<int> >::key_type&' {aka 'const long long int&'}
  986 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/unordered_map.h:990:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&&) [with _Key = long long int; _Tp = std::set<int>; _Hash = std::hash<long long int>; _Pred = std::equal_to<long long int>; _Alloc = std::allocator<std::pair<const long long int, std::set<int> > >; mapped_type = std::set<int>; key_type = long long int]'
  990 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/13/bits/unordered_map.h:990:29: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::unordered_map<long long int, std::set<int> >::key_type&&' {aka 'long long int&&'}
  990 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~