QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#735210#9568. Left Shifting 3paoxiaomo#Compile Error//C++20912b2024-11-11 18:22:342024-11-11 18:22:36

Judging History

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

  • [2024-11-11 18:22:36]
  • 评测
  • [2024-11-11 18:22:34]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define endl '\n'
void Solve()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s = s + s;
    string p = "nanjing";
    int m = p.size();
    vector<int> v;
    for (int i = 0; i + m - 1 < 2 * n; i++)
    {
        if (s.substr(i, m) == p)
            v.push_back(i);
    }
    int res = 0;
    for (int i = 0; i <= k && i < n; i++)
    {
        int j = i + n - 1;
        auto L = lower_bound(v.begin(), v.end(), i) - v.begin();
        auto R = upper_bound(v.begin(), v.end(), j - m + 1) - v.begin() - 1;
        if (L > R || L >= v.size() || R < 0)
            continue;
        res = max(res, R - L + 1);
    }
    cout << res << endl;
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T;
    cin >> T;
    while (T--)
        Solve();
}

Details

answer.code: In function ‘void Solve()’:
answer.code:29:18: error: no matching function for call to ‘max(long long int&, long int)’
   29 |         res = max(res, R - L + 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:257:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
answer.code:29:18: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘long int’)
   29 |         res = max(res, R - L + 1);
      |               ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
answer.code:29:18: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘long int’)
   29 |         res = max(res, R - L + 1);
      |               ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)’
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
answer.code:29:18: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   29 |         res = max(res, R - L + 1);
      |               ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)’
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
answer.code:29:18: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   29 |         res = max(res, R - L + 1);
      |               ~~~^~~~~~~~~~~~~~~~