QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#243926#6400. Game: Celesteucup-team1198Compile Error//C++204.3kb2023-11-08 19:19:442023-11-08 19:19:45

Judging History

你现在查看的是最新测评结果

  • [2023-11-08 19:19:45]
  • 评测
  • [2023-11-08 19:19:44]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define pii pair<int, int>
#define ld long double
#define all(a) (a).begin(), (a).end()

const int K = 20;
const int MAXN = 1 << K;
unordered_map<pair<int, int>, int> nodes_by_children[K + 1];
vector<pair<int, int>> nodes[K + 1];

bool cmp(int rk, int tree1, int tree2) {
    if (tree1 == tree2)
        return false;
    if (rk == 0)
        return tree1 < tree2;
    if (nodes[rk][tree1].second != nodes[rk][tree2].second) {
        return cmp(rk - 1, nodes[rk][tree1].second, nodes[rk][tree2].second);
    }
    return cmp(rk - 1, nodes[rk][tree1].first, nodes[rk][tree2].first);
}

int add_one(int tree, int rk, int left, int right, int i) {
    if (left + 1 == right) {
        return tree + 1;
    }
    int l1 = nodes[rk][tree].first;
    int r1 = nodes[rk][tree].second;
    int mid = (left + right) / 2;
    if (i < mid)
        l1 = add_one(l1, rk - 1, left, mid, i);
    else
        r1 = add_one(r1, rk - 1, mid, right, i);
    if (nodes_by_children[rk].count(make_pair(l1, r1)))
        return nodes_by_children[rk][make_pair(l1, r1)];
    nodes[rk].emplace_back(l1, r1);
    nodes_by_children[rk][make_pair(l1, r1)] = nodes[rk].size() - 1;
    return nodes[rk].size() - 1;
}

void restore_ans(int tree, int rk, int left, int right, vector<int>& ans) {
    if (left + 1 == right) {
        for (int j = 0; j < tree; ++j)
            ans.emplace_back(left);
        return;
    }
    int mid = (left + right) / 2;
    restore_ans(nodes[rk][tree].second, rk - 1, mid, right, ans);
    restore_ans(nodes[rk][tree].first, rk - 1, left, mid, ans);
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin >> t;
    for (int i = 1; i <= K; ++i) {
        nodes[i].emplace_back(0, 0);
        nodes_by_children[i][make_pair(0, 0)] = 0;
    }
    while (t--) {
        int n, L, R;
        cin >> n >> L >> R;
        vector<int> x(n);
        for (int i = 0; i < n; ++i)
            cin >> x[i];
        vector<int> a(n);
        for (int i = 0; i < n; ++i)
            cin >> a[i];
        int cur_rk = 0;
        while ((1 << cur_rk) <= n)
            ++cur_rk;
        vector<int> dp(n, -1);
        dp[0] = add_one(0, cur_rk, 0, 1 << cur_rk, a[0]);

        vector<int> stack1;
        vector<int> mx1;
        vector<int> stack2;
        vector<int> mx2;
        
        auto queue_push = [&](int x) {
            stack2.emplace_back(x);
            if (mx2.empty() || cmp(cur_rk, mx2.back(), x))
                mx2.emplace_back(x);
            else
                mx2.emplace_back(mx2.back());
        };
        auto queue_pop = [&]() {
            if (stack1.empty()) {
                while (!stack2.empty()) {
                    int x = stack2.back();

                    stack1.emplace_back(x);
                    if (mx1.empty() || cmp(cur_rk, mx1.back(), x))
                        mx1.emplace_back(x);
                    else
                        mx1.emplace_back(mx1.back());

                    stack2.pop_back();
                    mx2.pop_back();
                }
            }
            stack1.pop_back();
            mx1.pop_back();
        };

        int l1 = 0, r1 = 0;
        for (int i = 1; i < n; ++i) {
            while (r1 < i && x[r1] <= x[i] - L) {
                if (dp[r1] != -1)
                    queue_push(dp[r1]);
                ++r1;
            }
            while (l1 < i && x[l1] < x[i] - R) {
                if (dp[l1] != -1)
                    queue_pop();
                ++l1;
            }
            if (stack1.empty() && stack2.empty()) {
                dp[i] = -1;
            } else {
                int opt = -1;
                if (stack2.empty())
                    opt = mx1.back();
                else if (stack1.empty())
                    opt = mx2.back();
                else if (cmp(cur_rk, mx1.back(), mx2.back()))
                    opt = mx2.back();
                else
                    opt = mx1.back();
                dp[i] = add_one(opt, cur_rk, 0, 1 << cur_rk, a[i]);
            }
        }
        if (dp[n - 1] == -1)
            cout << -1 << '\n';
        else {
            vector<int> ans;
            restore_ans(dp[n - 1], cur_rk, 0, 1 << cur_rk, ans);
            cout << ans.size() << '\n';
            for (int x : ans)
                cout << x << ' ';
            cout << '\n';
        }
    }
    return 0;
}

詳細信息

answer.code:11:59: 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> >]’
   11 | unordered_map<pair<int, int>, int> nodes_by_children[K + 1];
      |                                                           ^
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 answer.code: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> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]’ is implicitly deleted because the default definition would be ill-formed:
  141 |       unordered_map() = default;
      |       ^~~~~~~~~~~~~
/usr/include/c++/11/bits/unordered_map.h:141:7: error: use of deleted function ‘std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]’
In file included from /usr/include/c++/11/unordered_map:46,
                 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 answer.code:1:
/usr/include/c++/11/bits/hashtable.h:528:7: note: ‘std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]’ is implicitly deleted because the default definition would be ill-formed:
  528 |       _Hashtable() = default;
      |       ^~~~~~~~~~
/usr/include/c++/11/bits/hashtable.h:528:7: error: use of deleted function ‘std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]’
In file included from /usr/include/c++/11/bits/hashtable.h:35,
                 from /usr/include/c++/11/unordered_map:46,
                 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 answer.code:1:
/usr/include/c++/11/bits/hashtable_policy.h:1604:7: note: ‘std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]’ is implicitly deleted because the default definition would be ill-formed:
 1604 |       _Hashtable_base() = default;
      |       ^~~~~~~~~~~~~~~
/usr/include/c++/11/bits/hashtable_policy.h:1604:7: error: use of deleted function ‘std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _R...