QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#377925#5053. Random ShuffleInfinityNS#WA 39ms4452kbC++172.8kb2024-04-05 20:22:412024-04-05 20:23:00

Judging History

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

  • [2024-04-05 20:23:00]
  • 评测
  • 测评结果:WA
  • 用时:39ms
  • 内存:4452kb
  • [2024-04-05 20:22:41]
  • 提交

answer

#include<bits/stdc++.h>

#define f first
#define s second
#define ll uint64_t
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
using namespace std;

vector<ll> pw;
vector<ll> shft(vector<ll> tr,int dir){
    vector<ll> ans=tr;
    for(int i=0;i<64;i++){
        int j=i+dir;
        if(j>=0&&j<64){
            ans[i]^=tr[j];
        }
    }
    return ans;
}
vector<int> st={-13,7,-17};
vector<ll> step(vector<ll> t){
    for(auto p:st)t=shft(t,p);
    return t;
}
ll nxt(ll x){
    x^=x<<13;
    x^=x>>7;
    x^=x<<17;
    return x;
}
vector<pair<ll,int>> base(64,{-1,-1});
void ins(pair<ll,int> x){
    for(int i=63;i>=0;i--){
        if(x.f&pw[i]){
            if(base[i].f==-1){
                base[i]=x;
                //bitset<64> a=x.f;
                //cout << a << " " << x.s << endl;
                return;
            }
            x.f^=base[i].f;
            x.s^=base[i].s;
        }
    }
}
vector<ll> xs;
void gen(int i,ll dosada){
    if(i==64){
        xs.pb(dosada);
        return;
    }
    if(base[i].f==-1){
        gen(i+1,dosada^pw[i]);
        gen(i+1,dosada);
        return;
    }
    ll ima=dosada&base[i].f;
    int tt=(__builtin_popcountll(ima))%2;
    if(tt==base[i].s){
        gen(i+1,dosada);
    }
    else{
        gen(i+1,dosada^pw[i]);
    }
}
int main(){
    pw.pb(1);
    for(int i=0;i<63;i++){
        pw.pb(pw.back()+pw.back());
    }
    int n;
    scanf("%i",&n);
    vector<int> pos(n),a(n);
    for(int i=0;i<n;i++){
        scanf("%i",&a[i]);
        a[i]--;
        pos[a[i]]=i;
    }
    vector<int> e;
    for(int i=n-1;i>=0;i--){
        int d=pos[i];
        int tr=a[i];
        e.pb(d);
        a[d]=tr;
        pos[tr]=d;
    }
    reverse(all(e));
    vector<pair<ll,int>> eq;
    vector<ll> t;
    for(int i=0;i<64;i++)t.pb(pw[i]);
    for(int i=0;i<min(n,100);i++){
        //bitset<64> x=t[0];
        //cout << x << endl;
        t=step(t);
        int j=i+1;
        int c=e[i];
        int ind=0;
        while(j%2==0){
            eq.pb({t[ind],c%2});
            bitset<64> a=t[ind];
            //cout << a << endl;
            //cout << i << " " << t[ind] << " " << ind << endl;
            j/=2;
            ind++;
            c/=2;
        }
    }
    sort(all(eq));
    reverse(all(eq));
    for(auto p:eq)ins(p);
    gen(0,0);
    for(auto p:xs){
        bool ok=1;
        ll x=p;
        for(int i=0;i<n;i++){
            int c=e[i];
            int j=i+1;
            x=nxt(x);
            if((x%j)==c){

            }
            else{
                ok=0;
                break;
            }
        }
        if(ok){
            cout << x << endl;
            return 0;
        }
    }
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 39ms
memory: 4452kb

input:

50
36 22 24 21 27 50 28 14 25 34 18 43 47 13 30 7 10 48 20 16 29 9 8 15 3 31 12 38 19 49 37 1 46 32 4 44 11 35 6 33 26 5 45 17 39 40 2 23 42 41

output:

18261448586643646505

result:

wrong answer 1-th element diff