QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#426091#7615. Sequence Foldingreal_sigma_team#Compile Error//C++201.6kb2024-05-30 20:57:202024-05-30 20:57:21

Judging History

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

  • [2024-05-30 20:57:21]
  • 评测
  • [2024-05-30 20:57:20]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

using ll = long long;


#define int long long

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);

    ll n;
    int m;
    cin >> n >> m;
    map<ll, int> cost, val;
    vector<ll> pts;
    for (int i = 0; i < m; ++i) {
        ll x;
        cin >> x;
        cost[x] = 1;
        val[x] = 1;
        pts.push_back(x);
    }
    ll pw = 1;
    ll ans = 0;
    while (n != 1) {
        for (auto& x : pts) {
            x = min(x, n + 1 - x);
        }
        sort(pts.begin(), pts.end());
        pts.resize(unique(pts.begin(), pts.end()) - pts.begin());
//        cout << n << ' ' << ans << endl;
//        for (auto x : pts) cout << x << ' ';
//        cout << endl;
        for (auto x : pts) {
            ll y = n + 1 - x;
            if (!val.count(x) || !cost.count(x)) {
                val[x] = 0;
                cost[x] = pw;
            }
            if (!val.count(y) || !cost.count(y)) {
                val[y] = 0;
                cost[y] = pw;
            }
            cost[x] = min(cost[x], 1);
            cost[y] = min(cost[y], 1);
            cerr << n << ' ' << x << ' ' << y << ' ' << val[x] << ' ' << cost[x] << ' ' << val[y] << ' ' << cost[y] << endl;
            if (val[x] == val[y]) {
                cost[x] += cost[y];
            } else {
                if (cost[y] < cost[x]) swap(cost[x], cost[y]), swap(val[x], val[y]);
                ans += cost[x];
                val[x] = val[y];
                cost[x] = cost[y] - cost[x];
            }
        }
        n /= 2;
        pw *= 2;
    }
    cout << ans;
}

Details

answer.code: In function ‘int main()’:
answer.code:45:26: error: no matching function for call to ‘min(std::map<long long int, long long int>::mapped_type&, int)’
   45 |             cost[x] = min(cost[x], 1);
      |                       ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)’
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
answer.code:45:26: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
   45 |             cost[x] = min(cost[x], 1);
      |                       ~~~^~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note:   template argument deduction/substitution failed:
answer.code:45:26: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
   45 |             cost[x] = min(cost[x], 1);
      |                       ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)’
 5775 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5775:5: note:   template argument deduction/substitution failed:
answer.code:45:26: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   45 |             cost[x] = min(cost[x], 1);
      |                       ~~~^~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)’
 5785 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note:   template argument deduction/substitution failed:
answer.code:45:26: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   45 |             cost[x] = min(cost[x], 1);
      |                       ~~~^~~~~~~~~~~~
answer.code:46:26: error: no matching function for call to ‘min(std::map<long long int, long long int>::mapped_type&, int)’
   46 |             cost[y] = min(cost[y], 1);
      |                       ~~~^~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)’
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
answer.code:46:26: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
   46 |             cost[y] = min(cost[y], 1);
      |                       ~~~^~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note:   template argument deduction/substitution failed:
answer.code:46:26: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
   46 |             cost[y] = min(cost[y], 1);
      |                       ~~~^~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)’
 5775 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5775:5: note:   template argument deduction/substitution failed:
answer.code:46:26: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   46 |             cost[y] = min(cost[y], 1);
      |                       ~~~^~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)’
 5785 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note:   template argument deduction/substitution failed:
answer.code:46:26: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   46 |             cost[y] = min(cost[y], 1);
      |                       ~~~^~~~~~~~~~~~