QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#321499 | #4207. Uplifting Excursion | Zaunese | Compile Error | / | / | C++14 | 1.8kb | 2024-02-04 20:37:34 | 2024-02-04 20:37:35 |
Judging History
answer
#include <cstdio>
#include <vector>
#include <iostream>
using namespace std;
const int M = 605,NV=300;
#define int long long
const int inf = 1e18;
#define pb push_back
int read()
{
int x=0,f=1;char c;
while((c=getchar())<'0' || c>'9') {if(c=='-') f=-1;}
while(c>='0' && c<='9') {x=(x<<3)+(x<<1)+(c^48);c=getchar();}
return x*f;
}
int n,m,a[M],dp[2][2*NV*NV+5];vector<int> v[M];
signed main()
{
n=read();m=read();
for(int i=0;i<=(n<<1);i++)
{
a[i]=read();
if(i==n) continue;
for(int j=0;j<=40;j++) if((1ll<<j)<=a[i])
v[j].pb(i-n),a[i]-=(1ll<<j);
for(int j=40;j>=0;j--) if((1ll<<j)<=a[i])
v[j].pb(i-n),a[i]-=(1ll<<j);
}
int e=0,t=1,L=NV*NV,R=NV*NV;dp[0][NV*NV]=inf;
//都增加inf,这样0就相当于-inf
for(int i=0;i<=40;i++)
{
for(int d:v[i])
{
e^=1;t^=1;
int tl=min(L,max(0ll,L+d));
int tr=max(R,min(2*NV*NV,R+d));
for(int j=L;j<=R;j++) dp[e][j]=dp[t][j];
for(int j=tl;j<L;j++) dp[e][j]=0;
for(int j=R+1;j<=tr;j++) dp[e][j]=0;
for(int j=L,k;j<=R;j++) if((k=j+d)>=0 && k<=2*NV*NV)
dp[e][k]=max(dp[e][k],dp[t][j]+(1ll<<i));
L=tl;R=tr;
}
e^=1;t^=1;
for(int j=L;j<=R;j++) dp[e][j]=0;
int tl=NV*NV,tr=NV*NV;
for(int j=L,k;j<=R;j++) if((j&1)==(m>>i&1))
{
k=NV*NV+(j-NV*NV>>1);
dp[e][k]=max(dp[e][k],dp[t][j]);
tl=min(tl,k);tr=max(tr,k);
}
L=tl;R=tr;
}
if((m>>41)+NV*NV<L || (m>>41)+NV*NV>R || dp[e][(m>>41)+NV*NV]<inf)
{puts("impossible");return 0;}
printf("%lld\n",dp[e][(m>>41)+NV*NV]-inf+a[n]);
}
Details
answer.code: In function ‘int main()’: answer.code:37:29: error: no matching function for call to ‘min(int, long long int)’ 37 | int tr=max(R,min(2*NV*NV,R+d)); | ~~~^~~~~~~~~~~~~ In file included from /usr/include/c++/13/vector:62, from answer.code:2: /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:37:29: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’) 37 | int tr=max(R,min(2*NV*NV,R+d)); | ~~~^~~~~~~~~~~~~ /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:37:29: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’) 37 | int tr=max(R,min(2*NV*NV,R+d)); | ~~~^~~~~~~~~~~~~