QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#942482#5053. Random ShufflePhysics212303Compile Error//C++171.7kb2025-03-19 09:29:412025-03-19 09:29:42

Judging History

This is the latest submission verdict.

  • [2025-03-19 09:29:42]
  • Judged
  • [2025-03-19 09:29:41]
  • Submitted

answer

#pragma GCC target("avx,avx2,tune=native")
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const int B=64;
inline int lowbit(int x){return x&-x;}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int n; cin>>n;
  vector<int> a(n+1),m(n+1),p(n+1);
  for(int i=1;i<=n;i++)
    cin>>a[i],m[a[i]]=i;
  auto b=a;
  for(int i=n;i;i--)
    p[i]=m[i],swap(m[i],m[a[i]]),swap(a[i],a[p[i]--]);
  vector s(n+1,vector<ull>(B));
  for(int i=0;i<B;i++)
    s[0][i]=1ull<<i;
  vector<bitset<B+1> > e;
  for(int i=1;i<=n&&e.size()<B;i++){
    auto t=s[i]=s[i-1];
    for(int j=13;j<B;j++)
      s[i][j]^=t[j-13];
    t=s[i];
    for(int j=7;j<B;j++)
      s[i][j-7]^=t[j];
    t=s[i];
    for(int j=17;j<B;j++)
      s[i][j]^=t[j-17];
    for(int j=0;1<<j+1<=lowbit(i)&&e.size()<B;j++){
      e.emplace_back(bitset<B+1>(s[i][j]));
      if(p[i]>>j&1)e.back().set(B);
    }
  }
  vector<int> f;
  for(int i=0;i<B;i++){
    if(!e[i][i])
      for(int j=i+1;j<B;j++)
        if(e[j][i]){swap(e[i],e[j]); break;}
    if(e[i][i]){
      for(int j=i+1;j<B;j++)
        if(e[j][i])e[j]^=e[i];
    }
    else f.emplace_back(i);
  }
  auto pd=[&](ull S){
    vector<int> c(n+1);
    iota(c.begin(),c.end(),0);
    for(int i=1;i<=n;i++){
      S^=S<<13,S^=S>>7,S^=S<<17;
      swap(c[i],c[S%i+1]);
    }
    return b==c;
  };
  for(int i=0;i<1<<f.size();i++){
    ull S=0;
    for(int j=0;j<f.size();j++)
      if(i>>j&1)S|=1ull<<f[j];
    for(int j=B-1;~j;j--)
      if(e[j][j]){
        int x=e[j][B];
        for(int k=j+1;k<B;k++)
          if(e[j][k])x^=S>>k&1;
        if(x)S|=1ull<<j;
      }
    if(pd(S))cout<<(S)<<endl,exit(0);
  }
  return 0;
}

Details

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