QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#303027#2733. Rainfall CaptureCamillusCompile Error//C++201.5kb2024-01-11 16:59:172024-01-11 16:59:17

Judging History

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

  • [2024-01-11 16:59:17]
  • 评测
  • [2024-01-11 16:59:17]
  • 提交

answer

#include "bits/stdc++.h"

using ll = long long;
using namespace std;

random_device rd;
mt19937_64 rnd(rd());

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    auto cost = [&]() -> int {
        vector<int> left(n, -1);
        vector<int> right(n, -1);

        vector<int> Q;

        for (int i = 0; i < n; i++) {
            while (!Q.empty() && a[Q.back()] <= a[i]) {
                Q.pop_back();
            }

            if (!Q.empty()) {
                left[i] = Q.back();
            }

            Q.push_back(i);
        }

        Q.clear();

        for (int i = n - 1; i >= 0; i--) {
            while (!Q.empty() && a[Q.back()] < a[i]) {
                Q.pop_back();
            }

            if (!Q.empty()) {
                right[i] = Q.back();
            }

            Q.push_back(i);
        }

        int sum = 0;

        for (int i = 0; i < n; i++) {
            if (left[i] != -1 && right[i] != -1 && a[right[i]] != a[i]) {
                sum += (right[i] - left[i] - 1) * (min(a[right[i]], a[left[i]]) - a[i]);
            }
        }

        return sum;
    };

    set<int> Q;

    sort(a.begin(), a.end());

    while (1.l * clock() / CLOCKS_PER_SEC < 0.99l) {
        shuffle(a.begin(), a.end(), rand);
        Q.insert(cost());
    }

    for (int x : Q) {
        cout << x << " ";
    }
    cout << "\n";
    return 0;
}

詳細信息

In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algo.h: In instantiation of ‘void std::shuffle(_RAIter, _RAIter, _UGenerator&&) [with _RAIter = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _UGenerator = int (&)() noexcept]’:
answer.code:69:16:   required from here
/usr/include/c++/11/bits/stl_algo.h:3750:9: error: ‘std::remove_reference<int (&)() noexcept>::type’ {aka ‘int() noexcept’} is not a class, struct, or union type
 3750 |         __uc_type;
      |         ^~~~~~~~~
/usr/include/c++/11/bits/stl_algo.h:3778:44: error: ‘std::remove_reference<int (&)() noexcept>::type’ {aka ‘int() noexcept’} is not a class, struct, or union type
 3778 |           const pair<__uc_type, __uc_type> __pospos =
      |                                            ^~~~~~~~
/usr/include/c++/11/bits/stl_algo.h:3778:44: error: ‘std::remove_reference<int (&)() noexcept>::type’ {aka ‘int() noexcept’} is not a class, struct, or union type