Submission #1124523

#TimeUsernameProblemLanguageResultExecution timeMemory
1124523FubuGoldPlahte (COCI17_plahte)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 100000; struct Query { int x,type,l,r,id; Query() {}; Query(int _x,int _t,int _l,int _r,int _id) : x(_x),type(_t),l(_l),r(_r),id(_id) {} bool operator < (Query &qr) const { if (x == qr.x) return type < qr.type; return x < qr.x; } }; vector<Query> qr; set<pair<int,int>> st; int col_inp[MAXN+1]; int pa[MAXN+1]; bool re_add[MAXN+1]; vector<int> adj[MAXN+1]; set<int> col[MAXN+1]; int ans[MAXN+1]; int n,m; void dfs(int u) { int mx_v = -1; int mx_sz = 0; for (int i=0;i<adj[u].size();i++) { int v = adj[u][i]; dfs(v); if (col[v].size() > mx_sz) { mx_v = v; mx_sz = col[v].size(); } } if (mx_v != -1) { col[u].swap(col[mx_v]); for (int i=0;i<adj[u].size();i++) { int v = adj[u][i]; for (set<int>::iterator it = col[v].begin();it != col[v].end();it++) { col[u].insert(*it); } col[v].clear(); } } ans[u] = col[u].size(); } signed main() { // freopen("LOANGMUC.inp","r",stdin); // freopen("LOANGMUC.out","w",stdout); cin.tie(0) -> sync_with_stdio(0); cin >> n >> m; for (int i=1;i<=n;i++) { int x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2; qr.push_back(Query(x1,0,y1,y2,i)); qr.push_back(Query(x2,2,y1,y2,i)); } for (int i=1;i<=m;i++) { int x,y; cin >> x >> y >> col_inp[i]; qr.push_back(Query(x,1,y,y,i)); } sort(qr.begin(),qr.end()); st.insert(make_pair((int)1e9+1,0)); for (int i=0;i<qr.size();i++) { int id = qr[i].id; if (qr[i].type == 0) { int l = qr[i].l, r = qr[i].r; set<pair<int,int>>::iterator it = st.lower_bound(make_pair(r,-1)); adj[it->second].push_back(id); pa[id] = it->second; if (it->first == r) { re_add[id] = 1; st.erase(it); } st.insert(make_pair(r,id)); st.insert(make_pair(l-1,pa[id])); } else if (qr[i].type == 2) { int r = qr[i].r; set<pair<int,int>>::iterator it = st.lower_bound(make_pair(r,-1)); set<pair<int,int>>::iterator tmp = it; it++; st.erase(tmp); if (re_add[id]) { it = st.insert(make_pair(r,pa[id])); } while (true) { tmp = it; if (tmp == st.begin()) break; tmp--; if (tmp->second != pa[id]) break; st.erase(tmp); } } else { int p = qr[i].l; set<pair<int,int>>::iterator it = st.lower_bound(make_pair(p,-1)); // for (auto x : st) cerr << "why " << x.first << ' ' << x.second << '\n'; col[it->second].insert(col_inp[id]); } } dfs(0); for (int i=1;i<=n;i++) cout << ans[i] << '\n'; return 0; }

Compilation message (stderr)

plahte.cpp: In function 'int main()':
plahte.cpp:89:51: error: no match for 'operator=' (operand types are 'std::set<std::pair<int, int> >::iterator' {aka 'std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator'} and 'std::pair<std::_Rb_tree_const_iterator<std::pair<int, int> >, bool>')
   89 |                 it = st.insert(make_pair(r,pa[id]));
      |                                                   ^
In file included from /usr/include/c++/11/map:60,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:81,
                 from plahte.cpp:1:
/usr/include/c++/11/bits/stl_tree.h:328:12: note: candidate: 'constexpr std::_Rb_tree_const_iterator<std::pair<int, int> >& std::_Rb_tree_const_iterator<std::pair<int, int> >::operator=(const std::_Rb_tree_const_iterator<std::pair<int, int> >&)'
  328 |     struct _Rb_tree_const_iterator
      |            ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/bits/stl_tree.h:328:12: note:   no known conversion for argument 1 from 'std::pair<std::_Rb_tree_const_iterator<std::pair<int, int> >, bool>' to 'const std::_Rb_tree_const_iterator<std::pair<int, int> >&'
/usr/include/c++/11/bits/stl_tree.h:328:12: note: candidate: 'constexpr std::_Rb_tree_const_iterator<std::pair<int, int> >& std::_Rb_tree_const_iterator<std::pair<int, int> >::operator=(std::_Rb_tree_const_iterator<std::pair<int, int> >&&)'
/usr/include/c++/11/bits/stl_tree.h:328:12: note:   no known conversion for argument 1 from 'std::pair<std::_Rb_tree_const_iterator<std::pair<int, int> >, bool>' to 'std::_Rb_tree_const_iterator<std::pair<int, int> >&&'