QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#770870#9568. Left Shifting 3RUOHUICompile Error//C++20997b2024-11-22 01:00:202024-11-22 01:00:21

Judging History

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

  • [2024-11-22 01:00:21]
  • 评测
  • [2024-11-22 01:00:20]
  • 提交

answer

#include "bits/stdc++.h"
#define int long long
#define ull unsigned long long
#define PII pair<int, int>
#define TIII tuple<int, int, int>
#define LL __int128
#define eps 1e-6
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
constexpr int N = 2e6 + 10, M = 2e6 + 10, mod = 1e9 + 7, inf = 1e18;
int n, m;

void solve()
{
    int k;
    cin >> n >> k;
    string s;
    cin >> s;
    int ans = 0;
    s += s.substr(0, min(k, 7));
    for (int i = 0; i < s.size(); i++)
    {
        if (s.substr(i, 7) == "nanjing")
            ans++;
    }
    cout << ans << endl;
}

signed main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(2);

#ifndef ONLINE_JUDGE
    freopen("in.txt", "rt", stdin);
    freopen("out.txt", "wt", stdout);
#endif

    int Cases = 1;
    cin >> Cases;
    while (Cases--)
    {
        solve();
    }
    return 0;
}

详细

answer.code: In function ‘void solve()’:
answer.code:20:25: error: no matching function for call to ‘min(long long int&, int)’
   20 |     s += s.substr(0, min(k, 7));
      |                      ~~~^~~~~~
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:20:25: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
   20 |     s += s.substr(0, min(k, 7));
      |                      ~~~^~~~~~
/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:20:25: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
   20 |     s += s.substr(0, min(k, 7));
      |                      ~~~^~~~~~
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:20:25: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   20 |     s += s.substr(0, min(k, 7));
      |                      ~~~^~~~~~
/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:20:25: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   20 |     s += s.substr(0, min(k, 7));
      |                      ~~~^~~~~~