QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#664497#5433. Absolute DifferenceocharinCompile Error//C++203.3kb2024-10-21 20:53:572024-10-21 20:53:57

Judging History

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

  • [2024-10-21 20:53:57]
  • 评测
  • [2024-10-21 20:53:57]
  • 提交

answer

/*

                                _/                                      _/
       _/_/        _/_/_/      _/_/_/        _/_/_/      _/  _/_/               _/_/_/
    _/    _/    _/            _/    _/    _/    _/      _/_/          _/       _/    _/
   _/    _/    _/            _/    _/    _/    _/      _/            _/       _/    _/
    _/_/        _/_/_/      _/    _/      _/_/_/      _/            _/       _/    _/

*/
#include<bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int inf=1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    vector<array<int,2>>a(n),b(m);
    int ans1=0,ans2=0;
    for(auto &[x,y]:a) cin>>x>>y,ans1+=y-x;
    for(auto &[x,y]:b) cin>>x>>y,ans2+=y-x;
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    if(!ans1) ans1=1.0L0L/n;
    if(!ans2) ans2=1.0L0L/m;
    double res=0;
    auto cal1=[&]()->void{
        int j=0;
        double c0=0,c1=0,c2=0,cc0=0;
        for(int i=0;i<a.size();++i){
            while(j<b.size() && b[j][1]<=a[i][0]){
                if(b[j][0]==b[j][1]) c0+=b[j][0],cc0+=1;
                else{
                    c1+=b[j][1]-b[j][0];
                    c2+=b[j][1]*b[j][1]-b[j][0]*b[j][0];
                }
                j++;
            }
            if(a[i][0]==a[i][1]) res+=(cc0*a[i][0]-c0+1.0L*a[i][0]*c1-1.0L*c2/2)/ans1/ans2;
            else{
                res+=(1.0L*a[i][1]*a[i][1]-1.0L*a[i][0]*a[i][0])*cc0/2/ans1/ans2;
                res+=(1.0L*a[i][1]*a[i][1]-1.0L*a[i][0]*a[i][0])*c1/2/ans1/ans2;
                res-=(1.0L*a[i][1]-a[i][0])*c0/ans1/ans2;
                res-=(1.0L*a[i][1]-a[i][0])*1.0L*c2/2/ans1/ans2;
            }
        }
    };
    cal1();
    swap(a,b);
    cal1();
    swap(a,b);
    vector<array<int,2>>c;
    for(int i=0;i<n;++i){
        int x=lower_bound(b.begin(),b.end(),a[i])-b.begin();
        if(x){
            if(b[x-1][1]>a[i][0]) c.push_back({i,x-1});
        }
        while(x<m && b[x][0]<a[i][1]){
            c.push_back({i,x});
            x++;
        }
    }
    auto cal2=[&](array<int,2>a,array<int,2>b)->void{
        if(a>b) swap(a,b);
        double l1=a[0],r1=a[1],l2=b[0],r2=b[1];
        if(a[0]!=a[1] && b[0]!=b[1]){
            if(l1<l2){
                res+=(1.0L*(l2-l1)*(r2*r2-l2*l2)-1.0L*(r2-l2)*(l2*l2-l1*l1))/2/ans1/ans2;
            }
            if(r2<r1){
                res+=(1.0L*(r2-l2)*(r1*r1-r2*r2)-1.0L*(r1-r2)*(r2*r2-l2*l2))/2/ans1/ans2;
            }
            if(r2<=r1){
                res+=(1.0L*r2*r2*r2-1.0L*l2*l2*l2)/3/ans1/ans2;
                res+=(1.0L*(r2-l2)*(r2*r2+l2*l2)-1.0L*(l2+r2)*(r2*r2-l2*l2))/2/ans1/ans2;
            }
            if(r2>r1){
                res+=(1.0L*r1*r1*r1-1.0L*l2*l2*l2)/3/ans1/ans2;
                res+=(1.0L*(r1-l2)*(r2*r2+l2*l2)-1.0L*(l2+r2)*(r1*r1-l2*l2))/2/ans1/ans2;
            }
        }
        else if(a[0]==a[1] && b[0]==b[1]) res+=fabs(l2-l1)/ans1/ans2;
        else{
            if(b[0]==b[1]) swap(l1,l2),swap(r1,r2);
            double c=l1;
            res+=(l1*l1-l1*(l2+r2)+(l2*l2+r2*r2)/2)/ans1/ans2;
        }
    };
    for(auto [x,y]:c) cal2(a[x],b[y]);
    cout<<fixed<<setprecision(15)<<res<<"\n";
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:27:20: error: unable to find numeric literal operator ‘operator""L0L’
   27 |     if(!ans1) ans1=1.0L0L/n;
      |                    ^~~~~~
answer.code:27:20: note: use ‘-fext-numeric-literals’ to enable more built-in suffixes
answer.code:28:20: error: unable to find numeric literal operator ‘operator""L0L’
   28 |     if(!ans2) ans2=1.0L0L/m;
      |                    ^~~~~~
answer.code:28:20: note: use ‘-fext-numeric-literals’ to enable more built-in suffixes