QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#200687#7344. Those Russian HackersSolitaryDreamWA 3ms18552kbC++202.9kb2023-10-04 18:27:332023-10-04 18:27:34

Judging History

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

  • [2023-10-04 18:27:34]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:18552kb
  • [2023-10-04 18:27:33]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,t) for(int i=(s),_t=(t); i<=_t; ++i)
typedef double db;
typedef long long ll;
const int N=1.1e6+50;
typedef complex<db> comp;
const db pi=acos(-1);
void DFT(comp *a,int n,int f) {
    static comp ww[N],iw[N];
    static int rev[N],pn=0;
    if(pn!=n) {
        FOR(i,0,n-1) ww[i]=comp(cos(pi*2/n*i),sin(pi*2/n*i));
        FOR(i,0,n-1) iw[i]=conj(ww[i]);
        FOR(i,0,n-1) rev[i]=(rev[i>>1]>>1)|((i&1)*(n>>1));
        pn=n;
    }
    comp *w=f>0?ww:iw;
    FOR(i,0,n-1) if(rev[i]<i) swap(a[rev[i]],a[i]);
    for(int l=2; l<=n; l<<=1) {
        for(comp *p=a; p!=a+n; p+=l) {
            for(int i=0,m=l>>1; i<m; ++i) {
                comp t=p[i+m];
                p[i+m]=p[i]+t*w[n/l*(i+m)];
                p[i]=p[i]+t*w[n/l*i];
            }
        }
    }
    if(f<0) FOR(i,0,n-1) a[i]/=n;
}
void Poly_Mul(const db *A,int LenA,const db *B,int LenB,db *C) {
    static comp a[N],b[N];
    int n=1;for(; n<LenA+LenB; n<<=1);
    FOR(i,0,n-1) a[i]={0,0};
    FOR(i,0,LenA-1) a[i]={(db)A[i],0};
    FOR(i,0,LenB-1) b[i]={a[i].real(),(db)B[i]};
    DFT(a,n,1);
    FOR(i,0,n-1) b[i]=(a[i]*a[i]-conj(a[i?n-i:0]*a[i?n-i:0]))*comp(0,-0.25);
    DFT(b,n,-1);
    FOR(i,0,n-1) C[i]=b[i].real();
}
db p[N],q[N];
db A[N],B[N];
db sum[N];
int n,K;
db v,pr;
db qry(int i,int r) {
    db t=0;
    FOR(j,1,n) {
        if(j<=r) {
            if(i==1) {
                FOR(k,1,n*2-2) {
                    if(j+k<=n) t+=q[k]*p[j];
                }
            } else {
                FOR(h,1,n) {
                    FOR(k,1,n*2-2) {
                        if(j+k<n+h) {
                            t+=p[j]*p[h]*q[k];
                        }
                    }
                }
            }
        } else {
            db e=0;
            FOR(k,1,n*2-2) {
                if(k<j-r) {
                    // if(r==0) cerr << q[k] << ' ' << p[j] << endl;
                    e+=q[k]*p[j];
                }
            }
            t+=max(e,p[i]*pr);
            // if(r==0) cerr << e << ' ' << v << endl;
        }
    }
    // cerr << r << ' ' << t << endl;
    return t;
}
int main() {
    scanf("%d%d",&n,&K);
    FOR(i,1,n) scanf("%lf",&p[i]);
    FOR(i,1,n*2-2) scanf("%lf",&q[i]);
    FOR(i,1,n*2-2) B[i]=q[n*2-1-i];
    Poly_Mul(p,n+1,A,n*2-1,B);
    FOR(i,1,n+n*2-2) sum[i]=sum[i-1]+B[i];
    int r=n;
    v=qry(1,n);
    FOR(i,0,n-1) if(qry(1,i)>v) {
        v=qry(1,i);
        r=i;
    }
    pr=v;
    // cerr << r << endl;
    r=n;
    FOR(i,2,K) {
        db w=qry(i,r);
        while(r>0) {
            --r;
            db t=qry(i,r);
            // cerr << r << ' ' << t << endl;
            if(t<=w) {
                ++r;
                break;
            }
            w=t;
        }
        pr=w;
    }
    printf("%.9lf\n",pr);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 1
0.5 0.25 0.25
0.75 0.25 0.0 0.0

output:

0.687500000

result:

ok found '0.6875000', expected '0.6875000', error '0.0000000'

Test #2:

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

input:

3 2
0.3 0.4 0.3
0.0 0.0 0.0 1.0

output:

0.090000000

result:

ok found '0.0900000', expected '0.0900000', error '0.0000000'

Test #3:

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

input:

3 1
0.5 0.2 0.3
1.0 0.0 0.0 0.0

output:

0.800000000

result:

ok found '0.8000000', expected '0.8000000', error '0.0000000'

Test #4:

score: 0
Accepted
time: 2ms
memory: 18440kb

input:

2 1
1.0 0.0
0.7 0.3

output:

0.700000000

result:

ok found '0.7000000', expected '0.7000000', error '0.0000000'

Test #5:

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

input:

2 2
0.0 1.0
0.6 0.4

output:

0.600000000

result:

ok found '0.6000000', expected '0.6000000', error '0.0000000'

Test #6:

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

input:

3 1
0.1 0.1 0.8
1.0 0.0 0.0 0.0

output:

0.900000000

result:

ok found '0.9000000', expected '0.9000000', error '0.0000000'

Test #7:

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

input:

2 1
0.196570 0.803430
0.417660 0.582340

output:

0.335560574

result:

ok found '0.3355606', expected '0.3355606', error '0.0000000'

Test #8:

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

input:

2 1
0.392496 0.607504
1.000000 0.000000

output:

0.607504000

result:

ok found '0.6075040', expected '0.6075040', error '0.0000000'

Test #9:

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

input:

10 1
0.012643 0.123624 0.053820 0.040365 0.028873 0.020157 0.055711 0.484945 0.098421 0.081441
0.085328 0.047990 0.714931 0.138813 0.012938 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000

output:

0.901027548

result:

ok found '0.9010275', expected '0.9010275', error '0.0000000'

Test #10:

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

input:

10 1
0.006649 0.073200 0.000565 0.045068 0.112668 0.035625 0.046072 0.103194 0.005569 0.571390
0.195573 0.074055 0.047683 0.369439 0.161507 0.054811 0.055588 0.037380 0.003964 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000

output:

0.853833381

result:

ok found '0.8538334', expected '0.8538334', error '0.0000000'

Test #11:

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

input:

10 1
0.145228 0.019318 0.105821 0.185187 0.088991 0.042625 0.024569 0.088478 0.047174 0.252609
0.018498 0.107130 0.001316 0.120833 0.069263 0.099338 0.005632 0.009075 0.036279 0.023135 0.008573 0.029578 0.025695 0.067194 0.023536 0.116172 0.157449 0.081304

output:

0.306330007

result:

ok found '0.3063300', expected '0.3063300', error '0.0000000'

Test #12:

score: -100
Wrong Answer
time: 2ms
memory: 18492kb

input:

10 10
0.044299 0.160436 0.044139 0.088241 0.291281 0.136777 0.020766 0.124310 0.013255 0.076496
0.081824 0.025457 0.068874 0.265701 0.558144 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000

output:

0.729088445

result:

wrong answer 1st numbers differ - expected: '0.9999839', found: '0.7290884', error = '0.2708954'