QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#694373#5433. Absolute Differencexzin#Compile Error//C++141.9kb2024-10-31 17:48:472024-10-31 17:48:48

Judging History

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

  • [2024-10-31 17:48:48]
  • 评测
  • [2024-10-31 17:48:47]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ld = long double;
using ll = long double;
#define int long double;


ld qi(pair<ll,ll> a,pair<ll,ll> b){
    if(a>b)swap(a,b);
    if(a==b){
        return (a.second-a.first)*1.0/3;
    }

    if(b.first>=a.second){
        return ((b.second + b.first) - (a.second + a.first))*1.0/2;
    }

    if(b.second<=a.second){//包含
        ld u = b.first - a.first;
        ld v = b.second - b.first;
        ld w = a.second - b.second;
        ld res = 0;
        res += (v/2+u/2)*u + v*(v/3) + w*(w/2 + v/2);
        res /= (u+v+w);
        return res; 
    }else{//相交
        ld u = b.first - a.first;
        ld v = a.second - b.first;
        ld w = b.second - a.second;
        ld res = 0;
        res = u*(v+w+u)/2 + v*(v*v/3+w*(w+v)/2)/(v+w);
        res /= (u+v);
        return res;
    }


}

signed main(){
    int n,m;cin>>n>>m;
    vector<pair<int,int> > vc1(n);
    vector<pair<int,int> > vc2(m);
    for(auto &it:vc1)cin>>it.first>>it.second;
    for(auto &it:vc2)cin>>it.first>>it.second;
    sort(vc1.begin(),vc1.end());
    sort(vc2.begin(),vc2.end());

    ld ans = 0;
    int p = 0,q = 0;
    ld sm1 = 0,sm2 = 0;
    for(auto it:vc2)sm2+=(it.second+it.first)*1.0/2;

    for(auto it:vc1){
        while (p<vc2.size()&&vc2[p].second<=it.first)
        {
            sm1 += (vc2[p].first+vc2[p].second)*1.0/2;
            p++;
        }
        
        while(q<vc2.size()&&vc2[q].first<=it.second){
            sm2 -= (vc2[q].first+vc2[q].second)*1.0/2;
            q++;
        }
        ld uu = 0;
        uu += p*(it.first+it.second)*1.0/2 - sm1;
        uu += sm2 - (it.first+it.second)*1.0/2 * (vc2.size()-q);
        for(int i = p ; i< q;++i){
            uu += qi(it,vc2[i]);
        }
        uu/=vc2.size();
        ans += uu/vc1.size();
    }

    cout<<fixed<<setprecision(13)<<ans;

    
}

详细

answer.code: In function ‘int main()’:
answer.code:5:18: error: declaration does not declare anything [-fpermissive]
    5 | #define int long double;
      |                  ^~~~~~
answer.code:40:5: note: in expansion of macro ‘int’
   40 |     int n,m;cin>>n>>m;
      |     ^~~
answer.code:40:9: error: ‘n’ was not declared in this scope; did you mean ‘yn’?
   40 |     int n,m;cin>>n>>m;
      |         ^
      |         yn
answer.code:40:11: error: ‘m’ was not declared in this scope; did you mean ‘tm’?
   40 |     int n,m;cin>>n>>m;
      |           ^
      |           tm
answer.code:5:18: error: wrong number of template arguments (1, should be 2)
    5 | #define int long double;
      |                  ^~~~~~
answer.code:41:17: note: in expansion of macro ‘int’
   41 |     vector<pair<int,int> > vc1(n);
      |                 ^~~
In file included from /usr/include/c++/13/bits/stl_algobase.h:64,
                 from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_pair.h:187:12: note: provided for ‘template<class _T1, class _T2> struct std::pair’
  187 |     struct pair
      |            ^~~~
answer.code:41:12: error: template argument 1 is invalid
   41 |     vector<pair<int,int> > vc1(n);
      |            ^
answer.code:41:12: error: template argument 2 is invalid
answer.code:41:20: error: expected primary-expression before ‘,’ token
   41 |     vector<pair<int,int> > vc1(n);
      |                    ^
answer.code:5:13: error: expected primary-expression before ‘long’
    5 | #define int long double;
      |             ^~~~
answer.code:41:21: note: in expansion of macro ‘int’
   41 |     vector<pair<int,int> > vc1(n);
      |                     ^~~
answer.code:41:24: error: expected primary-expression before ‘>’ token
   41 |     vector<pair<int,int> > vc1(n);
      |                        ^
answer.code:41:26: error: expected primary-expression before ‘>’ token
   41 |     vector<pair<int,int> > vc1(n);
      |                          ^
answer.code:41:28: error: ‘vc1’ was not declared in this scope
   41 |     vector<pair<int,int> > vc1(n);
      |                            ^~~
answer.code:5:18: error: wrong number of template arguments (1, should be 2)
    5 | #define int long double;
      |                  ^~~~~~
answer.code:42:17: note: in expansion of macro ‘int’
   42 |     vector<pair<int,int> > vc2(m);
      |                 ^~~
/usr/include/c++/13/bits/stl_pair.h:187:12: note: provided for ‘template<class _T1, class _T2> struct std::pair’
  187 |     struct pair
      |            ^~~~
answer.code:42:12: error: template argument 1 is invalid
   42 |     vector<pair<int,int> > vc2(m);
      |            ^
answer.code:42:12: error: template argument 2 is invalid
answer.code:42:20: error: expected primary-expression before ‘,’ token
   42 |     vector<pair<int,int> > vc2(m);
      |                    ^
answer.code:5:13: error: expected primary-expression before ‘long’
    5 | #define int long double;
      |             ^~~~
answer.code:42:21: note: in expansion of macro ‘int’
   42 |     vector<pair<int,int> > vc2(m);
      |                     ^~~
answer.code:42:24: error: expected primary-expression before ‘>’ token
   42 |     vector<pair<int,int> > vc2(m);
      |                        ^
answer.code:42:26: error: expected primary-expression before ‘>’ token
   42 |     vector<pair<int,int> > vc2(m);
      |                          ^
answer.code:42:28: error: ‘vc2’ was not declared in this scope
   42 |     vector<pair<int,int> > vc2(m);
      |                            ^~~
answer.code:5:18: error: declaration does not declare anything [-fpermissive]
    5 | #define int long double;
      |                  ^~~~~~
answer.code:49:5: note: in expansion of macro ‘int’
   49 |     int p = 0,q = 0;
      |     ^~~
answer.code:49:9: error: ‘p’ was not declared in this scope
   49 |     int p = 0,q = 0;
      |         ^
answer.code:49:15: error: ‘q’ was not declared in this scope; did you mean ‘qi’?
   49 |     int p = 0,q = 0;
      |               ^
      |               qi
answer.code:5:18: error: declaration does not declare anything [-fpermissive]
    5 | #define int long double;
      |                  ^~~~~~
answer.code:67:13: note: in expansion of macro ‘int’
   67 |         for(int i = p ; i< q;++i){
      |             ^~~
answer.code:67:17: error: ‘i’ was not declared in this scope; did you mean ‘qi’?
   67 |         for(int i = p ; i< q;++i){
      |                 ^
      |                 qi
answer.code:67:29: error: expected ‘)’ before ‘;’ token
   67 |         for(int i = p ; i< q;++i){
      |            ~                ^
      |                             )
answer.code:67:32: error: ‘i’ was not declared in this scope; did you mean ‘qi’?
   67 |         for(int i = p ; i< q;++i){
      |                                ^
      |     ...