QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#529227#6397. Master of Both IIIsolar_express#WA 4ms21924kbC++20916b2024-08-24 10:44:112024-08-24 10:44:11

Judging History

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

  • [2024-08-24 10:44:11]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:21924kb
  • [2024-08-24 10:44:11]
  • 提交

answer

#include<bits/stdc++.h>
#define mod 998244353
using namespace std;
int n,w[30];
int f[1<<22];
int p[1<<22][22];
int pw[30];
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    for(int i=0;i<n;++i) cin>>w[i];
    pw[0]=1;
    for(int i=1;i<=n;++i) pw[i]=1ll*pw[i-1]*2%mod;
    for(int i=0;i<(1<<n);++i){
        int msk=i;
        for(int j=0;j<n;++j){
            p[i][j]=i|msk;
            msk=(msk>>1)|((msk&1)<<(n-1));
        }
    }
    memset(f,0x3f,sizeof(f));
    f[1]=0;
    for(int i=1;i<(1<<n);i+=2){
        for(int j=1;j<n;++j)
            f[p[i][j]]=min(f[p[i][j]],f[i]+w[j]);
    }
    for(int i=0;i<n;++i)
        for(int j=0;j<(1<<n);++j)
            if(j&(1<<i))
                f[j^(1<<i)]=min(f[j^(1<<i)],f[j]);
    int ans=0;
    for(int i=1;i<(1<<n);++i){
        ans=(0ll+ans+1ll*f[i]*i)%mod;
    }
    cout<<ans<<endl;
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 21924kb

input:

3
2 1 2

output:

45

result:

ok 1 number(s): "45"

Test #2:

score: 0
Accepted
time: 4ms
memory: 20824kb

input:

4
1919810 999999998 999999997 114114514

output:

152175989

result:

ok 1 number(s): "152175989"

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 21148kb

input:

3
842160586 705327547 868243944

output:

525727542

result:

wrong answer 1st numbers differ - expected: '78597628', found: '525727542'