Submission #1200261

#TimeUsernameProblemLanguageResultExecution timeMemory
120026112345678The Potion of Great Power (CEOI20_potion)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int nx=1e5+5, k=50; int n, m; vector<int> h; vector<set<pair<int, int>>> sv[nx]; vector<pair<int, int>> event[nx]; void init(int N, int D, int H[]) { n=N; for (int i=0; i<n; i++) h.push_back(H[i]); for (int i=0; i<n; i++) event[i].push_back({0, 0}), sv[i].push_back(set<int> {}); } void recalculate(int idx) { auto tmp=sv[idx].back(); for (int j=event[idx].size()-k; j<event[idx].size(); j++) { if (tmp.find({h[event[idx][j].second], event[idx][j].second})!=tmp.end()) tmp.erase({h[event[idx][j].second], event[idx][j].second}); else tmp.insert({h[event[idx][j].second], event[idx][j].second}); } sv[idx].push_back(tmp); } vector<int> getstate(int idx, int date) { int t=lower_bound(event[idx].begin(), event[idx].end(), make_pair(date, INT_MAX))-event[idx].begin()-1; int lst=(t)/k*k; auto tmp=sv[idx][(t)/k]; for (int j=lst+1; j<=t; j++) { if (tmp.find({h[event[idx][j].second], event[idx][j].second})!=tmp.end()) tmp.erase({h[event[idx][j].second], event[idx][j].second}); else tmp.insert({h[event[idx][j].second], event[idx][j].second}); } vector<int> ch; for (auto x:tmp) ch.push_back(x.first); //cout<<"query "<<idx<<' '<<x<<'\n'; return ch; } void curseChanges(int U, int A[], int B[]) { m=U; for (int i=0; i<m; i++) { event[A[i]].push_back({i+1, B[i]}); if (event[A[i]].size()%k==1) recalculate(A[i]); event[B[i]].push_back({i+1, A[i]}); if (event[B[i]].size()%k==1) recalculate(B[i]); } } int question(int x, int y, int d) { int res=1e9, idxy=0; auto hx=getstate(x, d), hy=getstate(y, d); for (int i=0; i<hx.size(); i++) { while (idxy+1<hy.size()&&hy[idxy+1]<=hx[i]) idxy++; if (idxy<hy.size()) res=min(res, abs(hx[i]-hy[idxy])); if (idxy+1<hy.size()) res=min(res, abs(hx[i]-hy[idxy+1])); } return res; }

Compilation message (stderr)

potion.cpp: In function 'void init(int, int, int*)':
potion.cpp:15:72: error: no matching function for call to 'std::vector<std::set<std::pair<int, int> > >::push_back(std::set<int>)'
   15 |     for (int i=0; i<n; i++) event[i].push_back({0, 0}), sv[i].push_back(set<int> {});
      |                                                         ~~~~~~~~~~~~~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from potion.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::set<std::pair<int, int> >; _Alloc = std::allocator<std::set<std::pair<int, int> > >; std::vector<_Tp, _Alloc>::value_type = std::set<std::pair<int, int> >]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from 'std::set<int>' to 'const value_type&' {aka 'const std::set<std::pair<int, int> >&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::set<std::pair<int, int> >; _Alloc = std::allocator<std::set<std::pair<int, int> > >; std::vector<_Tp, _Alloc>::value_type = std::set<std::pair<int, int> >]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from 'std::set<int>' to 'std::vector<std::set<std::pair<int, int> > >::value_type&&' {aka 'std::set<std::pair<int, int> >&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~