-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp837.cpp
85 lines (73 loc) · 1.74 KB
/
p837.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <bits/stdc++.h>
using namespace std;
vector< pair<int, double> > x;
map<int, double> r;
set<int> S;
bool sortpair(const pair<int, double> a, const pair<int, double> b){
return a.second < b.second;
}
int main() {
int n, seg;
double ans;
double x1,y1,x2,y2,r1;
cin >> n;
while(n--){
getchar();
cin >> seg;
for(int i = 0; i < seg; ++i){
cin >>x1>>y1>>x2>>y2>>r1;
x.push_back(make_pair(i,x1));
x.push_back(make_pair(i,x2));
r.insert(make_pair(i,r1));
}
sort(x.begin(),x.end(), sortpair);
ans = 1.000;
cout << setprecision(3) << fixed;
double xinicial = x[0].second;
cout << "-inf" <<", "<<xinicial<<" -> "<<ans<<endl;
S.insert(x[0].first);
for(int i = 1; i < x.size(); ++i){
if(S.find(x[i].first) == S.end()) {
S.insert(x[i].first);
ans = (double)ans*r[x[i-1].first];
cout << xinicial <<", "<<x[i].second<<" -> "<<ans<<endl;
}
else {
S.erase(x[i].first);
if() ans = ans*r[x[i-1].first];
cout << xinicial <<", "<<x[i].second<<" -> "<<ans<<endl;
ans = ans/r[x[i].first];
}
xinicial = x[i].second;
cout << "ans" << ans << endl;
}
x.clear();
r.clear();
}
return 0;
}
/* #2
#include <bits/stdc++.h>
using namespace std;
bool sortpair(const pair<int, double>a, const pair<int, double>b){
return a.second < b.second;
}
int main() {
int n, seg;
double x1,y1,x2,y2,r1;
cin >> n;
while(n--){
getchar();
cin >> seg;
for(int i = 0; i < seg; ++i){
cin >>x1>>y1>>x2>>y2>>r1;
x.push_back(make_pair(i,x1));
x.push_back(make_pair(i,x2));
r.push_back(insert(make_pair(i,r1)));
}
sort(x.begin(),x.end(), sortpair);
cout << "-inf" <<", "<<x[0].first<<" -> "<<x[0].second<<endl;
}
return 0;
}
*/