Advertisement
Saleh127

UVA 837 / Math & Implementation

Mar 7th, 2022
1,237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.41 KB | None | 0 0
  1. /***
  2.  created: 2022-03-07-20.35.13
  3. ***/
  4.  
  5. #include <bits/stdc++.h>
  6. using namespace std;
  7. #define ll long long
  8. #define test int tt; cin>>tt; for(int cs=1;cs<=tt;cs++)
  9. #define get_lost_idiot return 0
  10. #define nl '\n'
  11.  
  12. int main()
  13. {
  14.     ios_base::sync_with_stdio(0);
  15.     cin.tie(0);
  16.     cout.tie(0);
  17.  
  18.     test
  19.     {
  20.         ll n,i,j,k,l;
  21.  
  22.         double x,y,x1,y1,c,s;
  23.  
  24.         cin>>n;
  25.  
  26.         vector<double>xx;
  27.  
  28.         vector<pair<pair<double,double>,double>>seg;
  29.  
  30.  
  31.         for(i=0;i<n;i++)
  32.         {
  33.             cin>>x>>y>>x1>>y1>>c;
  34.  
  35.             xx.push_back(x);
  36.             xx.push_back(x1);
  37.  
  38.             if(x>x1) swap(x,x1);
  39.  
  40.             seg.push_back({{x,x1},c});
  41.         }
  42.  
  43.         sort(xx.begin(),xx.end());
  44.  
  45.         if(cs>1) cout<<nl;
  46.  
  47.         cout<<xx.size()+1<<nl;
  48.  
  49.         cout<<"-inf "<<fixed<<setprecision(3)<<xx[0]<<" 1.000"<<nl;
  50.  
  51.  
  52.         for(i=0;i<xx.size()-1;i++)
  53.         {
  54.             cout<<fixed<<setprecision(3)<<xx[i]<<" "<<fixed<<setprecision(3)<<xx[i+1]<<" ";
  55.  
  56.             s=1.000;
  57.  
  58.             for(auto dd:seg)
  59.             {
  60.                 if(xx[i]>=dd.first.first && xx[i+1]<=dd.first.second)
  61.                 {
  62.                     s*=dd.second;
  63.                 }
  64.             }
  65.  
  66.             cout<<fixed<<setprecision(3)<<s<<nl;
  67.         }
  68.  
  69.         cout<<fixed<<setprecision(3)<<xx[xx.size()-1]<<" +inf 1.000"<<nl;
  70.  
  71.     }
  72.  
  73.     get_lost_idiot;
  74. }
  75.  
  76.  
  77.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement