QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#507854#8335. Fast Hash Transformucup-team2307#Compile Error//C++203.1kb2024-08-06 21:44:392024-08-06 21:44:39

Judging History

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

  • [2024-08-06 21:44:39]
  • 评测
  • [2024-08-06 21:44:39]
  • 提交

answer

#pragma GCC optimize("O3")
#pragma GCC target("avx2")

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ull=unsigned long long;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using pii = pair<int, int>;
using vi = vector<int>;
#define fi first
#define se second
#define pb push_back

const int L=64;

using row=array<bool,L+1>;
using matr=array<row,L+1>;

consteval matr UNIT()
{
    matr res={};
    for(int i=0;i<=L;i++)
        res[i][i]=true;
    return res;
}

matr mul(const matr& l,const matr& r)
{
    matr res={};
    for(int i=0;i<=L;i++)
        for(int j=0;j<=L;j++)
            for(int k=0;k<=L;k++)
                res[i][k]^=l[i][j]&&r[j][k];
    return res;
}

void print(matr m)
{
    for(int i=0;i<=L;i++,cout<<"\n")
        for(int j=0;j<=L;j++)
            cout<<m[i][j];
    cout<<"\n";
}

matr read()
{
    matr res={};
    res[L][L]=true;
//    cout<<"read start"<<endl;
    int m;
    cin>>m;
    while(m--)
    {
        int s,o;
        ull a;
        cin>>s>>o>>a;
        for(int i=0;i<L;i++)
        {
            int j=(i+s)%L;
            if(o==0)
            {
                if((a>>j)&1)
                    res[L][j]^=1;
                else
                    res[i][j]^=1;
            }
            else
            {
                if((a>>j)&1)
                    res[i][j]^=1;
            }
        }
    }
    ull b;
    cin>>b;
    for(int i=0;i<L;i++)
        if((b>>i)&1)
            res[L][i]^=1;
//    cout<<"read end"<<endl;
//    print(res);
    return res;
}

struct Tree {
    typedef matr T;
    static constexpr T unit = UNIT();
    T f(const T& a, const T& b) { return mul(a,b); } // (any associative fn)
    vector<T> s; int n;
    Tree(int n = 0, T def = unit) : s(2*n, def), n(n) {}
    void update(int pos, const T& val) {
        for (s[pos += n] = val; pos /= 2;)
            s[pos] = f(s[pos * 2], s[pos * 2 + 1]);
    }
    T query(int b, int e) { // query [b, e)
        T ra = unit, rb = unit;
        for (b += n, e += n; b < e; b /= 2, e /= 2) {
            if (b % 2) ra = f(ra, s[b++]);
            if (e % 2) rb = f(s[--e], rb);
        }
        return f(ra, rb);
    }
};

signed main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

    int n,q,c;
    cin>>n>>q>>c;
    Tree tree(n);
    for(int i=0;i<n;i++)
        tree.update(i,read());
    while(q--)
    {
        int op;
        cin>>op;
        if(op==0)
        {
            int l,r;
            ull x;
            cin>>l>>r>>x;
            matr m=tree.query(l-1,r);
//            print(m);
            ull res=0;
            for(int i=0;i<L;i++)
                for(int j=0;j<L;j++)
                    if(m[i][j]&&((x>>i)&1))
                        res^=1ULL<<j;
            for(int j=0;j<L;j++)
                if(m[L][j])
                    res^=1ULL<<j;
            cout<<res<<"\n";
        }
        else
        {
            int l;
            cin>>l;
            tree.update(l-1,read());
        }
    }
}

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:4:
/usr/include/c++/13/bits/allocator.h: In destructor ‘constexpr std::_Vector_base<std::array<std::array<bool, 65>, 65>, std::allocator<std::array<std::array<bool, 65>, 65> > >::_Vector_impl::~_Vector_impl()’:
/usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘constexpr std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::array<std::array<bool, 65>, 65>]’: 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
      |              ^~~~~~~~~~~~