QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#559370#5433. Absolute DifferenceWuyanruWA 1ms7984kbC++142.5kb2024-09-11 21:43:462024-09-11 21:43:47

Judging History

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

  • [2024-09-11 21:43:47]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7984kb
  • [2024-09-11 21:43:46]
  • 提交

answer

#include<bits/stdc++.h>
#define inf 0x3f3f3f3f3f3f3f3fll
#define debug(x) cerr<<#x<<"="<<x<<endl
using namespace std;
using ll=long long;
using ld=long double;
using pli=pair<ll,int>;
using pi=pair<int,int>;
template<typename A>
using vc=vector<A>;
using pl=pair<ll,ll>;
inline int read()
{
    int s=0,w=1;char ch;
    while((ch=getchar())>'9'||ch<'0') if(ch=='-') w=-1;
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    return s*w;
}
inline ll lread()
{
    ll s=0,w=1;char ch;
    while((ch=getchar())>'9'||ch<'0') if(ch=='-') w=-1;
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    return s*w;
}
const ll L=9000000000;
ll num[400005];
int numa[400005];
int numb[400005];
int len;
inline ld get(int *a,int *b)
{
    ld ans=0,lena=0,suma=0,lenb=0,sumb=0;
    for(int i=1;i<=len;i++)
    {
        ld l=num[i],r=num[i+1];
        if(a[i]) lena+=r-l,suma+=(r-l)*(l+r)/2;
        if(b[i]) lenb+=r-l,sumb+=(r-l)*(l+r)/2;
    }
    suma/=lena,sumb/=lenb;
    printf("%Lf %Lf %Lf %Lf\n",lena,suma,lenb,sumb);

    ld P=0;
    for(int i=1;i<=len;i++)
    {
        ld l=num[i],r=num[i+1];
        ld Pb=(r-l)/lenb,Pa=(r-l)/lena;
        if(a[i])
        {
            ans+=P*Pa*(l+r)/2;
            printf("i=%d ans=%Lf\n",i,ans);
            if(b[i])
            {
                ld t=r*r*r/3-l*l*l/3-l*r*r/2+l*l*l/2;
                ans+=t/lena/lenb;
            }
            printf("i=%d ans=%Lf\n",i,ans);
        }
        if(b[i]) P+=Pb;
    }

    return 2*ans-suma;
}
int main()
{
    int n=read(),m=read();
    vc<pl>Sa,Sb;
    for(int i=1;i<=n;i++){ ll l=num[++len]=lread()*L,r=num[++len]=lread()*L+1;Sa.push_back(pl(l,r));}
    for(int i=1;i<=m;i++){ ll l=num[++len]=lread()*L,r=num[++len]=lread()*L+1;Sb.push_back(pl(l,r));}
    sort(num+1,num+len+1),len=unique(num+1,num+len+1)-num-1;
    for(auto i:Sa)
    {
        int l=lower_bound(num+1,num+len+1,i.first)-num;
        int r=lower_bound(num+1,num+len+1,i.second)-num;
        for(int j=l;j<r;j++) numa[j]=1;
    }
    for(auto i:Sb)
    {
        int l=lower_bound(num+1,num+len+1,i.first)-num;
        int r=lower_bound(num+1,num+len+1,i.second)-num;
        for(int j=l;j<r;j++) numb[j]=1;
    }
    for(int i=1;i<=len;i++) printf("%lld ",num[i]);;putchar('\n');
    for(int i=1;i<=len;i++) printf("%d ",numa[i]);;putchar('\n');
    for(int i=1;i<=len;i++) printf("%d ",numb[i]);;putchar('\n');
    printf("%.20Lf\n",(get(numa,numb)+get(numb,numa))/L);
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 7984kb

input:

1 1
0 1
0 1

output:

0 9000000001 
1 0 
1 0 
9000000001.000000 4500000000.500000 9000000001.000000 4500000000.500000
i=1 ans=0.000000
i=1 ans=3000000000.333333
9000000001.000000 4500000000.500000 9000000001.000000 4500000000.500000
i=1 ans=0.000000
i=1 ans=3000000000.333333
0.33333333337037037044

result:

wrong answer 1st numbers differ - expected: '0.3333333', found: '0.0000000', error = '0.3333333'