Language: C++

#include <bits/stdc++.h>

namespace using std;
int m,n;
const double EPS = 1e-11;
vector<pair<int,int> > Pxy,Pyz;
pair<int,int> tem;
vector<int> X;

int findMax(vector<int> vec) {
    int maxs = -999;
    for (auto v : vec) {
        if (maxs < v) maxs = v;
    }
    return maxs;
}

int findMin(vector<int> vec) {
    int mins = 999;
    for (auto v : vec) {
        if (mins > v) mins = v;
    }
    return mins;
}

double width(vector<pair<int,int> > polygon,int x){
    vector<double> w;
    for(int i=0;i<polygon.len();i++){
        pair<int,int> p=polygon[i];
        pair<int,int> q=polygon[(i+1)%polygon.len()];
        if((p.first-x)<EPS){
            w.push_back(1.0*p.second);
        }
        else if(p.first<x && x<q.first|| p.first>0 && x>q.first){
            int x0=p.first;
            int y0=p.second;
            int x1=q.first;
            int y1=q.second;
            w.push_back(y0+1.0*(y1-y0)*(x-x0)/(x1-x0));
        }
    }
    assert(w.len()>0);
    return (findMax(w)-findMin(w));
}

int volume(vector<pair<int,int> >Pxy,vector<pair<int,int> >Pxz,vector<int> X){
    double total=0.0;
    int xmin = max((*min_element(pxy.begin(), pxy.end())).first,
                   (*min_element(pxz.begin(), pxz.end())).first);
    int xmax = min((*max_element(pxy.begin(), pxy.end())).first,
                   (*max_element(pxz.begin(), pxz.end())).first);
    sort(X.begin(), X.end());
    for(int i=0;i<X.len()-1;i++){
        int a=X[i];
        int b=X[i+1];
        if(!(xmin <= a && a <= xmax &&xmin <= b && b<< xmax) ){
            continue;
        }
        int m=(a+b)/2.0;
        va = width(Pxy, a)*width(Pxz, a);
        vb = width(Pxy, b)*width(Pxz, b);
        m = width(Pxy, m)*width(Pxz, m);
        double area=((b-a)/6.0)*(va + 4.0*vm + vb);
        total+=area;
    }
    return total;
}
int main(){
    while(cin>>m>>n&&n!=0){
        for(int i=1;i<=m;i++){
            cin>>tem.first>>tem.second;
            Pxy.push_back(tem);
            X.push_back(x);
        }
        for(int j=1;j<=n;j++){
            cin>>tem.first>>tem.second;
            Pxz.push_back(tem);
            X.push_back(x);
        }
        cout << fixed << volume(PXY, PXZ, X) << endl;
    }
}




Compiler output:
a.cc:3:11: error: expected identifier before 'using'
    3 | namespace using std;
      |           ^~~~~
a.cc:3:17: error: expected nested-name-specifier before 'std'
    3 | namespace using std;
      |                 ^~~
a.cc:6:1: error: 'vector' does not name a type
    6 | vector<pair<int,int> > Pxy,Pyz;
      | ^~~~~~
a.cc:7:1: error: 'pair' does not name a type
    7 | pair<int,int> tem;
      | ^~~~
a.cc:8:1: error: 'vector' does not name a type
    8 | vector<int> X;
      | ^~~~~~
a.cc:10:13: error: 'vector' was not declared in this scope
   10 | int findMax(vector<int> vec) {
      |             ^~~~~~
a.cc:10:13: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:10:20: error: expected primary-expression before 'int'
   10 | int findMax(vector<int> vec) {
      |                    ^~~
a.cc:18:13: error: 'vector' was not declared in this scope
   18 | int findMin(vector<int> vec) {
      |             ^~~~~~
a.cc:18:13: note: suggested alternatives:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:18:20: error: expected primary-expression before 'int'
   18 | int findMin(vector<int> vec) {
      |                    ^~~
a.cc:26:14: error: 'vector' was not declared in this scope
   26 | double width(vector<pair<int,int> > polygon,int x){
      |              ^~~~~~
a.cc:26:14: note: suggested alternatives:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:26:21: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   26 | double width(vector<pair<int,int> > polygon,int x){
      |                     ^~~~
      |                     std::pair
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:89:12: note: 'std::pair' declared here
   89 |     struct pair;
      |            ^~~~
a.cc:26:26: error: expected primary-expression before 'int'
   26 | double width(vector<pair<int,int> > polygon,int x){
      |                          ^~~
a.cc:26:30: error: expected primary-expression before 'int'
   26 | double width(vector<pair<int,int> > polygon,int x){
      |                              ^~~
a.cc:26:45: error: expected primary-expression before 'int'
   26 | double width(vector<pair<int,int> > polygon,int x){
      |                                             ^~~
a.cc:26:50: error: expression list treated as compound expression in initializer [-fpermissive]
   26 | double width(vector<pair<int,int> > polygon,int x){
      |                                                  ^
a.cc:46:12: error: 'vector' was not declared in this scope
   46 | int volume(vector<pair<int,int> >Pxy,vector<pair<int,int> >Pxz,vector<int> X){
      |            ^~~~~~
a.cc:46:12: note: suggested alternatives:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:46:19: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   46 | int volume(vector<pair<int,int> >Pxy,vector<pair<int,int> >Pxz,vector<int> X){
      |                   ^~~~
      |                   std::pair
/usr/include/c++/14/bits/stl_pair.h:89:12: note: 'std::pair' declared here
   89 |     struct pair;
      |            ^~~~
a.cc:46:24: error: expected primary-expression before 'int'
   46 | int volume(vector<pair<int,int> >Pxy,vector<pair<int,int> >Pxz,vector<int> X){
      |                        ^~~
a.cc:46:28: error: expected primary-expression before 'int'
   46 | int volume(vector<pair<int,int> >Pxy,vector<pair<int,int> >Pxz,vector<int> X){
      |                            ^~~
a.cc:46:38: error: 'vector' was not declared in this scope
   46 | int volume(vector<pair<int,int> >Pxy,vector<pair<int,int> >Pxz,vector<int> X){
      |                                      ^~~~~~
a.cc:46:38: note: suggested alternatives:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:46:45: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   46 | int volume(vector<pair<int,int> >Pxy,vector<pair<int,int> >Pxz,vector<int> X){
      |                                             ^~~~
      |                                             std::pair
/usr/include/c++/14/bits/stl_pair.h:89:12: note: 'std::pair' declared here
   89 |     struct pair;
      |            ^~~~
a.cc:46:50: error: expected primary-expression before 'int'
   46 | int volume(vector<pair<int,int> >Pxy,vector<pair<int,int> >Pxz,vector<int> X){
      |                                                  ^~~
a.cc:46:54: error: expected primary-expression before 'int'
   46 | int volume(vector<pair<int,int> >Pxy,vector<pair<int,int> >Pxz,vector<int> X){
      |                                                      ^~~
a.cc:46:64: error: 'vector' was not declared in this scope
   46 | int volume(vector<pair<int,int> >Pxy,vector<pair<int,int> >Pxz,vector<int> X){
      |                                                                ^~~~~~
a.cc:46:64: note: suggested alternatives:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:46:71: error: expected primary-expression before 'int'
   46 | int volume(vector<pair<int,int> >Pxy,vector<pair<int,int> >Pxz,vector<int> X){
      |                                                                       ^~~
a.cc:46:77: error: expression list treated as compound expression in initializer [-fpermissive]
   46 | int volume(vector<pair<int,int> >Pxy,vector<pair<int,int> >Pxz,vector<int> X){
      |                                                                             ^
a.cc: In function 'int main()':
a.cc:69:11: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   69 |     while(cin>>m>>n&&n!=0){
      |           ^~~
      |           std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:71:18: error: 'tem' was not declared in this scope; did you mean 'tm'?
   71 |             cin>>tem.first>>tem.second;
      |                  ^~~
      |                  tm
a.cc:72:13: error: 'Pxy' was not declared in this scope
   72 |             Pxy.push_back(tem);
      |             ^~~
a.cc:73:13: error: 'X' was not declared in this scope
   73 |             X.push_back(x);
      |             ^
a.cc:73:25: error: 'x' was not declared in this scope
   73 |             X.push_back(x);
      |                         ^
a.cc:76:18: error: 'tem' was not declared in this scope; did you mean 'tm'?
   76 |             cin>>tem.first>>tem.second;
      |                  ^~~
      |                  tm
a.cc:77:13: error: 'Pxz' was not declared in this scope
   77 |             Pxz.push_back(tem);
      |             ^~~
a.cc:78:13: error: 'X' was not declared in this scope
   78 |             X.push_back(x);
      |             ^
a.cc:78:25: error: 'x' was not declared in this scope
   78 |             X.push_back(x);
      |                         ^
a.cc:80:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   80 |         cout << fixed << volume(PXY, PXZ, X) << endl;
      |         ^~~~
      |         std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:80:17: error: 'fixed' was not declared in this scope
   80 |         cout << fixed << volume(PXY, PXZ, X) << endl;
      |                 ^~~~~
a.cc:80:17: note: suggested alternatives:
In file included from /usr/include/c++/14/streambuf:43,
                 from /usr/include/c++/14/bits/streambuf_iterator.h:35,
                 from /usr/include/c++/14/iterator:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54:
/usr/include/c++/14/bits/ios_base.h:1104:3: note:   'std::fixed'
 1104 |   fixed(ios_base& __base)
      |   ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:198:
/usr/include/c++/14/charconv:622:21: note:   'std::chars_format::fixed'
  622 |     scientific = 1, fixed = 2, hex = 4, general = fixed | scientific
      |                     ^~~~~
a.cc:80:33: error: 'PXY' was not declared in this scope
   80 |         cout << fixed << volume