QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#321498 | #4207. Uplifting Excursion | Zaunese | Compile Error | / | / | C++14 | 4.1kb | 2024-02-04 20:37:21 | 2024-02-04 20:37:23 |
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]);
}
//#define dxx
#ifdef dxx
#define dbg(...) fprintf(stderr,__VA_ARGS__)
#define dex(a) dbg(#a"=%lld onL%d infun %s\n",(ll)a,__LINE__,__FUNCTION__)
#include<cstdlib>
#define pause sys##tem("pause")
#define _GLIBCXX_DEBUG
#endif
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define fi first
#define se second
const int NV=300;
using ll=long long;
using std::max;
using std::min;
template<class T> void cmax(T&a,T b){a=max(a,b);}
template<class T> void cmin(T&a,T b){a=min(a,b);}
namespace xm{
std::vector<int> vc[45];
ll a[NV*2+5],f[2][NV*NV*2+5];
void _(){
ll Len;
int N;
scanf("%d%lld",&N,&Len);
for(int i=0;i<=N*2;++i){
scanf("%lld",a+i);
if(i==N) continue;
for(int j=0;j<=40;++j) if(1ll<<j<=a[i]){
a[i]-=1ll<<j;
vc[j].push_back(i-N);
}
for(int j=40;~j;--j) if(1ll<<j<=a[i]){
a[i]-=1ll<<j;
vc[j].push_back(i-N);
}
}
int cur=0,lst=1,L=NV*NV,R=NV*NV;
f[0][NV*NV]=1e18;
for(int i=0,tl,tr;i<=40;++i){
for(int d:vc[i]){
cur^=1;
lst^=1;
tl=min(L,max(0,L+d));
tr=max(R,min(NV*NV*2,R+d));
for(int j=tl;j<L;++j) f[cur][j]=0;
for(int j=L;j<=R;++j) f[cur][j]=f[lst][j];
for(int j=R+1;j<=tr;++j) f[cur][j]=0;
for(int j=L,k;j<=R;++j){
k=j+d;
if(0<=k&&k<=NV*NV*2)
cmax(f[cur][k],f[lst][j]+(1ll<<i));
}
L=tl;
R=tr;
}
cur^=1;
lst^=1;
tl=NV*NV;
tr=NV*NV;
for(int j=L;j<=R;++j) f[cur][j]=0;
for(int j=L,k;j<=R;++j) if((j&1)==(Len>>i&1)){
k=NV*NV+(j-NV*NV>>1);
cmax(f[cur][k],f[lst][j]);
cmin(tl,k);
cmax(tr,k);
}
L=tl;
R=tr;
}
if((Len>>41)+NV*NV<L||(Len>>41)+NV*NV>R||f[cur][(Len>>41)+NV*NV]<ll(1e18))
puts("impossible");
else printf("%lld\n",ll(f[cur][(Len>>41)+NV*NV]-ll(1e18)+a[N]));
}
}
int main(){
xm::_();
return 0;
}
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)); | ~~~^~~~~~~~~~~~~ /usr/include/strings.h: At global scope: answer.code:6:18: error: ‘long long long’ is too long for GCC 6 | #define int long long | ^~~~ answer.code:6:13: error: ‘long long long’ is too long for GCC 6 | #define int long long | ^~~~ answer.code:6:18: error: ‘long long long’ is too long for GCC 6 | #define int long long | ^~~~ /usr/include/c++/13/bits/uniform_int_dist.h: In member function ‘std::uniform_int_distribution<_IntType>::result_type std::uniform_int_distribution<_IntType>::operator()(_UniformRandomBitGenerator&, const param_type&)’: answer.code:6:18: error: ‘long long long’ is too long for GCC 6 | #define int long long | ^~~~ answer.code:6:18: error: ‘long long long’ is too long for GCC 6 | #define int long long | ^~~~ /usr/include/c++/13/bits/stl_algo.h: In function ‘void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare)’: answer.code:6:13: error: expected primary-expression before ‘long’ 6 | #define int long long | ^~~~ In file included from /usr/include/c++/13/algorithm:61, from answer.code:71: /usr/include/c++/13/bits/stl_algo.h:1857:29: error: expected ‘)’ before ‘long’ 1857 | if (__last - __first > int(_S_threshold)) | ~ ^ | ) answer.code:6:13: error: expected primary-expression before ‘long’ 6 | #define int long long | ^~~~ /usr/include/c++/13/bits/stl_algo.h:1859:51: error: expected ‘)’ before ‘long’ 1859 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~ ^ | ) answer.code:6:13: error: expected primary-expression before ‘long’ 6 | #define int long long | ^~~~ /usr/include/c++/13/bits/stl_algo.h:1860:52: error: expected ‘)’ before ‘long’ 1860 | std::__unguarded_insertion_sort(__first + int(_S_threshold), __last, | ~ ^ | ) /usr/include/c++/13/bits/stl_algo.h: In function ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare)’: answer.code:6:13: error: expected primary-expression before ‘long’ 6 | #define int long long | ^~~~ /usr/include/c++/13/bits/stl_algo.h:1922:32: error: expected ‘)’ before ‘long’ 1922 | while (__last - __first > int(_S_threshold)) | ~ ^ | ) answer.code:6:13: error: expected primary-expression before ‘long’ 6 | #define int long long | ^~~~ answer.code: At global scope: answer.code:76:11: error: conflicting declaration ‘const long long int NV’ 76 | const int NV=300; | ^~ answer.code:5:19: note: previous declaration as ‘const int NV’ 5 | const int M = 605,NV=300; | ^~ answer.code: In function ‘void xm::_()’: answer.code:90:17: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long long int*’ [-Wformat=] 90 | scanf("%d%lld",&N,&Len); | ~^ ~~ | | | | int* long long int* | %lld answer.code:110:29: error: no matching function for call to ‘max(int, long long int)’ 110 | tl=min(L,max...