QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#584639#8790. First Billionucup-team4153#WA 16ms65148kbC++202.2kb2024-09-23 16:00:342024-09-23 16:00:34

Judging History

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

  • [2024-09-23 16:00:34]
  • 评测
  • 测评结果:WA
  • 用时:16ms
  • 内存:65148kb
  • [2024-09-23 16:00:34]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;using ld=long double;using ll=long long;
using pll=pair<ll,ll>;
const int M=998244353,inv2=(M+1)/2,P=1e4,N=105,Tar=1e9;const double eps=1e-10;
const int B2=512,B5=int(1e9)/B2,B3=3200;
int L2[N][B2],L5[N][B5],L3[N][B3],pt=0;
int arr[N];
struct S
{
    int n;vector<int>a,v2,v5,v3;
    int fx2(int a){if(a>=B2)a-=B2;if(a<0)a+=B2;return a;}
    int fx5(int a){if(a>=B5)a-=B5;if(a<0)a+=B5;return a;}
    int fx3(int a){if(a>=B3)a-=B3;if(a<0)a+=B3;return a;}
    bool spr(int p,int s2,int s5,int s3,int sum)
    {
        if(!L2[p][s2]||!L5[p][s5]||!L3[p][s3])return 0;if(!p)return sum==Tar;
        if(spr(p-1,s2,s5,s3,sum))return 1;
        s2=fx2(s2-v2[p]);s5=fx5(s5-v5[p]);s3=fx3(s3-v3[p]);sum+=a[p];
        arr[++pt]=p;if(spr(p-1,s2,s5,s3,sum))return 1;
        pt--;return 0;
    }
    void F()
    {
        cout<<pt<<' ';for(int i=1;i<=pt;i++)cout<<n+1-arr[i]<<" \n"[i==pt];
    }
    void ini()
    {
        cin>>n;a.resize(n+1);v2=v5=v3=a;L2[0][0]=L5[0][0]=L3[0][0]=1;
        for(int i=1;i<=n;i++)cin>>a[i];
        for(int i=1;i<=n;i++)v2[i]=a[i]%B2,v5[i]=a[i]%B5,v3[i]=a[i]%B3;
        for(int i=1;i<=n;i++)
        {
            int x=v2[i];for(int j=0;j<B2;j++)if(L2[i-1][j])L2[i][j]=L2[i][fx2(j+x)]=1;
            int y=v5[i];for(int j=0;j<B5;j++)if(L5[i-1][j])L5[i][j]=L5[i][fx5(j+y)]=1;
            int z=v3[i];for(int j=0;j<B3;j++)if(L3[i-1][j])L3[i][j]=L3[i][fx3(j+z)]=1;
            if(!L2[i][0]||!L5[i][0]||!L3[i][0])continue;arr[++pt]=i;
            if(spr(i-1,fx2(-x),fx5(-y),fx3(-z),a[i]))return F();pt--;
        }
        cout<<"err\n";
    }
    void solve()
    {

    }

};
signed main()
{
    //cout<<pow(1-1e-4,1e2)<<"*\n";
    //cout<<1e10*pow(0.9,500)<<"\n";
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t=1;//cin>>t;
    while(t--){S SS;SS.ini();SS.solve();}
}
/*
10
88494216 245947398 316438989 3938400 345180997
386413329  192751270 204627269 65749456  150458676

 10
88494216 245947398 316438989 3938400 386413329 345180997
  192751270 204627269 65749456  150458676

10
1 88494216 245947398 316438989 1
1 1 3938400 1 345180997

10
386413329 88494216 245947398 316438989 192751270
 204627269 65749456 3938400 150458676 345180997
 */

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 16ms
memory: 65148kb

input:

10
386413329 88494216 245947398 316438989 192751270 204627269 65749456 3938400 150458676 345180997

output:

5 2 4 5 6 10

result:

wrong answer need sum 1000000000, got sum  1147492741