Task: | Sunlight |
Sender: | Game of Nolife |
Submission time: | 2015-11-25 18:54:45 +0200 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.05 s | details |
#2 | ACCEPTED | 0.06 s | details |
#3 | ACCEPTED | 0.05 s | details |
#4 | ACCEPTED | 0.07 s | details |
#5 | ACCEPTED | 0.23 s | details |
#6 | ACCEPTED | 0.23 s | details |
#7 | ACCEPTED | 0.20 s | details |
#8 | ACCEPTED | 0.22 s | details |
#9 | ACCEPTED | 0.05 s | details |
Code
#include <bits/stdc++.h> #define F first #define S second using namespace std; typedef long long ll; typedef long double ld; ll x[201010]; ll h[201010]; int pred[201010],foll[201010]; const ld PI=atan2(0,-1); int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n; cin>>n; for (int i=0;i<n;i++) cin>>x[i]>>h[i]; pred[0]=-1; for (int i=1;i<n;i++) { pred[i]=i-1; while (pred[pred[i]]!=-1 && (h[i]-h[pred[i]])*(x[pred[i]]-x[pred[pred[i]]]) - (x[i]-x[pred[i]])*(h[pred[i]]-h[pred[pred[i]]]) >= 0) { pred[i]=pred[pred[i]]; } if (h[i]>=h[pred[i]]) pred[i]=-1; } foll[n-1]=-1; for (int i=n-2;i>=0;i--) { foll[i]=i+1; while (foll[foll[i]]!=-1 && (h[i]-h[foll[i]])*(x[foll[i]]-x[foll[foll[i]]]) - (x[i]-x[foll[i]])*(h[foll[i]]-h[foll[foll[i]]]) <= 0) { foll[i]=foll[foll[i]]; } if (h[i]>=h[foll[i]]) foll[i]=-1; } cout<<setprecision(15); for (int i=0;i<n;i++) { ld res=0; res+=6; if (pred[i]!=-1) { res-=(atan((ld)(h[pred[i]]-h[i])/(ld)(x[i]-x[pred[i]]))*12)/PI; } res+=6; if (foll[i]!=-1) { res-=(atan((ld)(h[foll[i]]-h[i])/(ld)(x[foll[i]]-x[i]))*12)/PI; } cout<<res<<"\n"; } }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
1000 1926 8873 2491 7464 3423 7361 3620 9644 ... |
correct output |
---|
10.36853468 3.28197688 3.30974766 11.90296748 5.69368673 ... |
user output |
---|
10.3685346833825 3.28197687748567 3.30974765713701 11.9029674807101 5.6936867314732 ... |
Test 2
Verdict: ACCEPTED
input |
---|
4000 137 4357 179 5113 592 3409 1454 771 ... |
correct output |
---|
6.21198867 7.84723518 1.82864466 1.24121638 7.92250006 ... |
user output |
---|
6.21198867465762 7.84723517808662 1.82864466024019 1.2412163818183 7.92250006065739 ... |
Test 3
Verdict: ACCEPTED
input |
---|
400 207 435398 2322 206093 4951 947111 8175 684248 ... |
correct output |
---|
6.03541092 0.04878189 10.60707362 0.19653370 0.02675856 ... |
user output |
---|
6.03541091603956 0.0487818897583621 10.6070736158127 0.196533697301069 0.0267585560679111 ... |
Test 4
Verdict: ACCEPTED
input |
---|
400 1305 614135 1726 909738 4049 615587 5695 444755 ... |
correct output |
---|
6.00544007 7.88396801 0.39457912 0.26910357 0.10597900 ... |
user output |
---|
6.00544006812424 7.88396801136528 0.394579121606409 0.269103568901025 0.105979004027867 ... |
Test 5
Verdict: ACCEPTED
input |
---|
200000 5 6025 10 6023 15 6002 20 6028 ... |
correct output |
---|
11.24600450 8.77556929 1.61853499 11.95979392 6.31757611 ... |
user output |
---|
11.246004501732 8.77556928910468 1.61853498722732 11.9597939203746 6.31757611271508 ... |
Test 6
Verdict: ACCEPTED
input |
---|
200000 5 6029 10 6022 15 6002 20 6029 ... |
correct output |
---|
12.00000000 6.03637717 1.63518137 12.00000000 5.56120369 ... |
user output |
---|
12 6.03637717289438 1.63518136535054 12 5.5612036896548 ... |
Test 7
Verdict: ACCEPTED
input |
---|
200000 1 6476 2 23828 3 21010 4 16417 ... |
correct output |
---|
6.0002201 6.0814974 0.0067812 0.0019710 0.0006071 ... |
user output |
---|
6.000220131318 6.08149744754271 0.00678120447153354 0.00197100335289021 0.00060707094010478 ... |
Test 8
Verdict: ACCEPTED
input |
---|
200000 1 78 2 78 3 79 4 79 ... |
correct output |
---|
10.2289966 9.0000000 10.7710034 10.5465727 10.2289966 ... |
user output |
---|
10.2289965881948 9 10.7710034118052 10.5465727009099 10.2289965881948 ... |
Test 9
Verdict: ACCEPTED
input |
---|
21 1 1000 100 987 200 951 300 891 ... |
correct output |
---|
12.00000000 11.47513975 10.57611935 9.69117298 8.92271854 ... |
user output |
---|
12 11.4751397455463 10.5761193538726 9.69117298400206 8.92271853914415 ... |