QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#133524#4937. Permutation Transformationnameless_story#Compile Error//C++141.8kb2023-08-02 10:39:302023-08-02 10:39:33

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-02 10:39:33]
  • 评测
  • [2023-08-02 10:39:30]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define N 120000

const int mod=998244353;
int f[N],vis[N],ok[N],gg[N],g[N],h[N];

void go(vector<int> &p){
    map<vector<int>,int> dd;
    int num=0;
    while (1){
        if (dd[p]) break;
        ++num;
        dd[p]=1;
        auto q=p;
        for (int i=0;i<q.size();++i){
            p[i]=q[q[i]-1];
        }
        for (int x:p) cerr<<x<<' '; cerr<<endl;
    }
    cerr<<num<<endl;
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    int n; cin>>n;
    vector p(n,0);
    iota(p.begin(),p.end(),1);
    for (int i=0;i<100;++i){
        int x=rand()%n,y=rand()%n;
        swap(p[x],p[y]);
    }
    g[1]=1;
    for (int i=2;i<=n;++i){
        g[i]=i&1?0:g[i/2];
        if (i&1){
            int x=2;
            while (x!=1){
                x=x*2%i;
                ++g[i];
            }
            ++g[i];
        }
        h[i]=i&1?0:h[i/2]+1;
    }
    for (int i=1;i<=n;++i){
        int x; cin>>x;
        // int x=p[i-1]; cerr<<x<<',';
        f[i]=x;
    }
    // go(p);
    long long ans=1;
    int tmp=0;
    for (int i=1;i<=n;++i){
        if (vis[i]) continue;
        int x=i;
        int cnt=0;
        while (!vis[x]){
            vis[x]=1;
            ++cnt;
            x=f[x];
        }
        tmp=max(tmp,h[cnt]);
        // cerr<<cnt<<endl;
        ok[g[cnt]]=1;
    }
    for (int i=2;i<=n;++i){
        if (gg[i]) continue;
        for (int j=i*2;j<=n;j+=i){
            gg[j]=1;
            if (ok[j]){
                int x=j,cnt=0;
                while (x%i==0){
                    ++cnt;
                    x/=i;
                }
                ok[i]=max(ok[i],cnt);
            }
        }
        for (;ok[i];--ok[i]) ans=ans*i%mod;
    }
    cout<<(ans+tmp)%mod<<'\n';
}

Details

answer.code: In function ‘int main()’:
answer.code:28:12: error: missing template arguments before ‘p’
   28 |     vector p(n,0);
      |            ^
answer.code:29:10: error: ‘p’ was not declared in this scope
   29 |     iota(p.begin(),p.end(),1);
      |          ^