QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#573160#6397. Master of Both IIIshstyle#Compile Error//C++202.3kb2024-09-18 17:33:112024-09-18 17:33:11

Judging History

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

  • [2024-09-18 17:33:11]
  • 评测
  • [2024-09-18 17:33:11]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=(1<<22)+10,mod=998244353;
typedef long long ll;
typedef pair<ll,int> PII;

ll n,a[N];
int p[N];
int l[N],r[N];
mt19937 rnd(time(0));

ll mi[N];
ll dp[30][30];
ll ddp[N];

vector<PII> e[N];

bool tf[N];

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    a[0]=a[n];
    memset(dp,0x3f,sizeof dp);
    dp[0][0]=0;
    // for(int i=0;i<n;i++) dp[0][i]=a[i];
    for(int i=1;i<n;i++){
        for(int j=0;j<n;j++){
            int nw=(j+i)%n;
            dp[i][nw]=min(dp[i-1][nw],dp[i-1][j]+a[i]);

        }
        // for(int j=0;j<n;j++) cout<<dp[i][j]<<" ";
        // cout<<endl;

    }
    for(int i=0;i<n;i++){
        a[i]=dp[n-1][i];
        // cout<<a[i]<<endl;
    }
    for(int i=1;i<(1<<n);i++){
        vector<int> v;
        for(int j=0;j<n;j++){
            if((i>>j)&1) v.push_back(j);
        }
        // int nw=0;
        for(int j=0;j<n;j++){
            int nw=0;
            for(auto k:v){
                int xx=(k-j+n)%n;
                nw|=(1<<xx);
            }
            nw|=i;
            // cout<<i<<" "<<nw<<" "<<a[j]<<endl;
            e[i].push_back({nw,a[j]});
        }
    }
    for(int i=1;i<(1<<n);i++){
        for(int j=0;j<n;j++){
            if((i>>j)&1){
                int nw=i^(1<<j);
                if(nw!=0){
                    
                e[i].push_back({nw,0});
                // cout<<i<<" "<<nw<<endl;
                }
            }
        }
    }
    memset(ddp,0x3f,sizeof ddp);
    priority_queue<PII,vector<PII>,greater<PII>> q;
    q.push({0,1});
    ddp[1]=0;
    while(q.size()){
        int t=q.top().second;
        q.pop();
        if(tf[t]) continue;
        // cout<<t<<" "<<ddp[t]<<endl;
        tf[t]=1;
        sort(e.begin(),e.end());
        for(auto [j,w]:e[t]){
            if(ddp[j]>ddp[t]+w){
                // cout<<t<<" "<<j<<" "<<ddp[j]<<" "<<ddp[t]<<" "<<w<<endl;
            
                ddp[j]=ddp[t]+w;
                q.push({ddp[j],j});
            }
        }
    }
    ll ans=0;
    for(int i=1;i<(1<<n);i++){
        // cout<<ddp[i]<<endl;;
        ll res=ddp[i]%mod*i%mod;
        ans=(ans+res)%mod;
    }
    cout<<ans<<endl;

    
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:83:16: error: request for member ‘begin’ in ‘e’, which is of non-class type ‘std::vector<std::pair<long long int, int> > [4194314]’
   83 |         sort(e.begin(),e.end());
      |                ^~~~~
answer.code:83:26: error: request for member ‘end’ in ‘e’, which is of non-class type ‘std::vector<std::pair<long long int, int> > [4194314]’
   83 |         sort(e.begin(),e.end());
      |                          ^~~