QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#65159 | #5117. Find Maximum | dad11 | Compile Error | / | / | C++14 | 1.5kb | 2022-11-27 20:53:42 | 2022-11-27 20:53:45 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2022-11-27 20:53:45]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2022-11-27 20:53:42]
- 提交
answer
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long LL;
const int N=40;
int f(int x)
{
if(x==2) return 3;
if(x==1) return 2;
if(x==3) return 3;
if(x==4) return 4;
}
int main()
{
int t;
cin>>t;
while(t--)
{
LL l,r;
cin>>l>>r;
if(r<=4)
{
cout<<f(r)<<endl;
continue;
}
vector<int> a,b;
while(l)
{
a.push_back(l%3);
l/=3;
}
while(r)
{
b.push_back(r%3);
r/=3;
}
reverse(a.begin(),a.end());
reverse(b.begin(),b.end());
if(a.size()==b.size())
{
LL ans1=0;
for(int i=0;i<b.size();i++) ans1+=b[i];
ans1+=b.size();
int pos=0;
for(int i=0;i<b.size();i++)
{
if(b[i]>a[i])
{
pos=i;
break;
}
}
for(int i=pos+1;i<b.size();i++) b[i]=2;
b[pos]-=1;
LL ans=0;
for(int i=0;i<b.size();i++) ans+=b[i];
ans+=b.size();
cout<<max(ans,ans1)<<endl;
}
else
{
LL ans=0;
LL cnt=0;
for(int i=0;i<b.size();i++) cnt+=b[i];
if(cnt==2*b.size()) ans=3*b.size();
else
{
LL maxn=0;
for(int i=0;i<b.size();i++) maxn+=b[i];
maxn+=b.size();
if(b[0]==2||(cnt-b[0]==2*(b.size()-1)))
{
ans=2*(b.size()-1)+1+b.size();
}
else ans=3*(b.size()-1);
}
if(b[0]==1&&b[1]==2&&b.size()>=2)
{
ans=max(ans,2*(b.size()-1)+b.size());
}
ans=max(ans,maxn);
cout<<ans<<endl;
}
}
return 0;
}
Details
answer.code: In function ‘int main()’: answer.code:84:40: error: no matching function for call to ‘max(LL&, std::vector<int>::size_type)’ 84 | ans=max(ans,2*(b.size()-1)+b.size()); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/algorithm:61, from answer.code:2: /usr/include/c++/11/bits/stl_algobase.h:254:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’ 254 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/11/bits/stl_algobase.h:254:5: note: template argument deduction/substitution failed: answer.code:84:40: note: deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’}) 84 | ans=max(ans,2*(b.size()-1)+b.size()); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/algorithm:61, from answer.code:2: /usr/include/c++/11/bits/stl_algobase.h:300:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’ 300 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/11/bits/stl_algobase.h:300:5: note: template argument deduction/substitution failed: answer.code:84:40: note: deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’}) 84 | ans=max(ans,2*(b.size()-1)+b.size()); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/algorithm:62, from answer.code:2: /usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)’ 3461 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/11/bits/stl_algo.h:3461:5: note: template argument deduction/substitution failed: answer.code:84:40: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’ 84 | ans=max(ans,2*(b.size()-1)+b.size()); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/algorithm:62, from answer.code:2: /usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)’ 3467 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/11/bits/stl_algo.h:3467:5: note: template argument deduction/substitution failed: answer.code:84:40: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’ 84 | ans=max(ans,2*(b.size()-1)+b.size()); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ answer.code:86:37: error: ‘maxn’ was not declared in this scope; did you mean ‘main’? 86 | ans=max(ans,maxn); | ^~~~ | main answer.code: In function ‘int f(int)’: answer.code:15:1: warning: control reaches end of non-void function [-Wreturn-type] 15 | } | ^