QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#396328#8322. 魔法手杖Physics212303Compile Error//C++171.6kb2024-04-22 17:32:252024-04-22 17:32:25

Judging History

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

  • [2024-04-22 17:32:25]
  • 评测
  • [2024-04-22 17:32:25]
  • 提交

answer

#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2")
#include<bits/stdc++.h>
using namespace std;
typedef __int128 ll;
inline ll read(){
  ll x=0; char c=getchar();
  while(!isdigit(c))c=getchar();
  while(isdigit(c))x=(x<<1)+(x<<3)+(c^48),c=getchar();
  return x;
}
inline void write(ll x){
  if(x>9)write(x/10);
  putchar(x%10+48);
}
struct S{
  int l=-1,r=-1; ll a,b;
  S(){}
  S(ll A,ll B){l=r=-1,a=A,b=B;}
  inline int& operator [](const int &x){return x?r:l;}
};
int main(){
  read(); int t=read();
  while(t--){
    const int n=read(),m=read(),k=read();
    const ll w=(ll)1<<k;
    vector<ll> a(n);
    vector<int> b(n);
    for(auto &i:a)i=read();
    for(auto &i:b)i=read();
    vector<S> T; T.emplace_back(w,0);
    for(int i=0;i<n;i++){
      int u=0; T[0].a=min(T[0].a,a[i]),T[0].b+=b[i];
      for(int j=k-1;~j;j--){
        int s=a[i]>>j&1;
        if(T[u][s]<0)T[u][s]=T.size(),T.emplace_back(w,0);
        T[u=T[u][s]].a=min(T[u].a,a[i]),T[u].b+=b[i];
      }
    }
    function<ll(int,int,int,ll,ll,ll)> f=[&](int u,int d,int m,ll x,ll y,ll z){
      if(d<0)return z;
      const ll w=(ll)1<<d;
      if(u<0)return (x|w|w-1)+y;
      const int l=T[u].l,r=T[u].r; ll c=-1;
      if((r<0||T[r].b<=m)&&(x|w|w-1)+min(y,r<0?y:T[r].a)>=(z|w))
        c=max(c,f(l,d-1,m-(r<0?0:T[r].b),x|w,min(y,r<0?y:T[r].a),z|w));
      if((l<0||T[l].b<=m)&&(x|w-1)+min(y,l<0?y:T[l].a)>=(z|w))
        c=max(c,f(r,d-1,m-(l<0?0:T[l].b),x,min(y,l<0?y:T[l].a),z|w));
      return ~c?c:max(f(l,d-1,m,x,y,z),f(r,d-1,m,x|w,y,z));
    };
    write(T[0].b<=m?w+T[0].a-1:f(0,k-1,m,0,w,0)),putchar(10);
  }
  return 0;
}

Details

In file included from /usr/include/c++/13/string:43,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from answer.code:2:
/usr/include/c++/13/bits/allocator.h: In destructor ‘std::_Vector_base<S, std::allocator<S> >::_Vector_impl::~_Vector_impl()’:
/usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = S]’: target specific option mismatch
  184 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/13/vector:66,
                 from /usr/include/c++/13/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53:
/usr/include/c++/13/bits/stl_vector.h:133:14: note: called from here
  133 |       struct _Vector_impl
      |              ^~~~~~~~~~~~