QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#408706#6699. Wandering RobotCharlie983Compile Error//C++141.1kb2024-05-10 21:42:042024-05-10 21:42:05

Judging History

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

  • [2024-05-10 21:42:05]
  • 评测
  • [2024-05-10 21:42:04]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ll long long
#define endl '\n'
#define pb push_back
const int N = 1e6 + 10,M=210;
const ll inf=0x3f3f3f3f,mod=1e9+7;
int dx[]={0,0,-1,1},dy[]={-1,1,0,0};
void solve()
{
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    int x=0,y=0;
    int maxx=0;
    for(int i=0;i<s.size();i++)
    {
        int op;
        if(s[i]=='L')op=0;
        else if(s[i]=='R')op=1;
        else if(s[i]=='U')op=2;
        else if(s[i]=='D')op=3;
        x+=dx[op];
        y+=dy[op];
        maxx=max(maxx,abs(x)+abs(y));
    }
    int fx=(k-1)*x,fy=(k-1)*y;
    maxx=max(maxx=abs(fx)+abs(fy));
    for(int i=0;i<s.size();i++)
    {
        int op;
        if(s[i]=='L')op=0;
        else if(s[i]=='R')op=1;
        else if(s[i]=='U')op=2;
        else if(s[i]=='D')op=3;
        fx+=dx[op];
        fy+=dy[op];
        maxx=max(maxx,abs(fx)+abs(fy));
    }
    cout<<maxx<<endl;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int T=1;
    cin>>T;
    while(T--)
    {
    solve();
    }
return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:30:13: error: no matching function for call to ‘max(long long int&)’
   30 |     maxx=max(maxx=abs(fx)+abs(fy));
      |          ~~~^~~~~~~~~~~~~~~~~~~~~~
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:30:13: note:   candidate expects 2 arguments, 1 provided
   30 |     maxx=max(maxx=abs(fx)+abs(fy));
      |          ~~~^~~~~~~~~~~~~~~~~~~~~~
/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:30:13: note:   candidate expects 3 arguments, 1 provided
   30 |     maxx=max(maxx=abs(fx)+abs(fy));
      |          ~~~^~~~~~~~~~~~~~~~~~~~~~
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:30:13: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   30 |     maxx=max(maxx=abs(fx)+abs(fy));
      |          ~~~^~~~~~~~~~~~~~~~~~~~~~
/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:30:13: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   30 |     maxx=max(maxx=abs(fx)+abs(fy));
      |          ~~~^~~~~~~~~~~~~~~~~~~~~~