QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#577269#8790. First Billionmyusername#RE 3ms42860kbC++141.1kb2024-09-20 09:56:172024-09-20 09:56:18

Judging History

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

  • [2024-09-20 09:56:18]
  • 评测
  • 测评结果:RE
  • 用时:3ms
  • 内存:42860kb
  • [2024-09-20 09:56:17]
  • 提交

answer

#include<bitset>
#include<cstdio>
#include<vector>
#include<cassert>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=103,P=1e9,D=5000;
int n,m,a[N]; LL f[N][N][5000];
int stk[N],tt;
void dfs(int u,int cnt,int r,int S){
    // printf("%d %d %d\n",u,r,S);
    if(!u){
        if(!S&&!cnt&&tt){
            printf("%d ",tt);
            for(int i=1;i<=tt;i++) printf("%d ",stk[i]); puts("");
            exit(0);
        }
        return;
    }
    int t=a[u]%D;
    if(f[u-1][cnt][r]) dfs(u-1,cnt,r,S);
    if(f[u-1][cnt-1][(r-t+D)%D]) stk[++tt]=u,dfs(u-1,cnt-1,(r-t+D)%D,(S+a[u])%P),tt--;
}
void solve(){
    scanf("%d",&n); m=n>>1;
    f[0][0][0]=1;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        int t=a[i]%D;
        for(int j=0;j<=m;j++)
            for(int r=0;r<D;r++){
                f[i][j][r]+=f[i-1][j][r];
                f[i][j+1][(r+t)%D]+=f[i-1][j][r];
            }
    }
    dfs(n,m,0,0);
}
int main(){
    int T=1;
    // scanf("%d",&T);
    while(T--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

10
386413329 88494216 245947398 316438989 192751270 204627269 65749456 3938400 150458676 345180997

output:

5 9 7 6 5 1 

result:

ok OK (n = 10)

Test #2:

score: 0
Accepted
time: 0ms
memory: 24272kb

input:

10
119486233 299942886 169540407 349937991 597883752 32230162 140514533 57341098 12602102 220520836

output:

5 9 8 6 5 2 

result:

ok OK (n = 10)

Test #3:

score: 0
Accepted
time: 3ms
memory: 42860kb

input:

14
384615281 84612238 83310504 54746763 142296081 56775470 128760350 343006424 177232390 214368720 67220468 21895072 16352717 224807522

output:

7 13 12 10 9 7 6 1 

result:

ok OK (n = 14)

Test #4:

score: -100
Runtime Error

input:

14
270208635 14270307 89661499 113578022 47687195 101043954 38775146 208193324 650676076 351701957 3427619 59535626 24230888 27009752

output:


result: