98972024-03-17 14:46:35gortomiHadjáratcpp17Forditási hiba
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
using namespace std;
#define fi first
#define se second
vector<set<pair<int, int> > > dp;
bool can(int ind, int r, int a)
{
    auto it = dp[ind].lower_bound(make_pair(r, 0));
    if(it == dp[ind].begin()) return 0;
    it--;
    return it -> second < a;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    dp.resize(n + 1);
    dp[0].insert({0, 0});
    const int INF = 1e6 + 1;
    for(int i = 1; i <= n; i++) dp[i].insert({INF, INF});
    int maxi = 0;
    unordered_map<pair<int, int>, int> ind;
    vector<int> p(n + 1);
    for(int i = 1; i <= n; i++)
    {
        int r, a;
        cin >> r >> a;
        if(!ind.count(make_pair(r, a))) ind[{r, a}] = i;
        int l = 0, ri = n;
        while(l + 1 != ri)
        {
            int m = (l + ri) / 2;
            if(can(m, r, a)) l = m;
            else ri = m;
        }

        auto it2 = dp[l].lower_bound(make_pair(r, 0));
        it2--;//cout << "ok" << endl;
        p[i] = ind[*it2];
        auto pind = dp[l + 1].lower_bound(make_pair(r, 0));
        if(pind != dp[l + 1].end() && pind -> fi == r && pind -> se <= a)
        {
            continue;
        }

        while(1)
        {
            auto it = dp[l + 1].upper_bound(make_pair(r, a));
            if(it != dp[l + 1].end() && it -> second >= a)
            {
                dp[l + 1].erase(it);
            }
            else break;
        }
        dp[l + 1].insert(make_pair(r, a));
        maxi = max(maxi, l + 1);
    }
    cout << maxi << "\n";
    vector<int> ans;
    for(int i = ind[*dp[maxi].begin()]; i != 0; i = p[i]) ans.push_back(i);
    reverse(ans.begin(), ans.end());
    for(auto x : ans) cout << x << " ";
}
Forditási hiba
exit status 1
main.cpp: In function 'int main()':
main.cpp:25:40: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]'
   25 |     unordered_map<pair<int, int>, int> ind;
      |                                        ^~~
In file included from /usr/include/c++/11/unordered_map:47,
                 from /usr/include/c++/11/functional:61,
                 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 main.cpp:1:
/usr/include/c++/11/bits/unordered_map.h:141:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >;...