Task: | Lines |
Sender: | Hansuzu |
Submission time: | 2016-07-29 08:48:50 +0300 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.06 s | details |
#2 | ACCEPTED | 0.06 s | details |
#3 | ACCEPTED | 0.06 s | details |
#4 | ACCEPTED | 0.05 s | details |
#5 | ACCEPTED | 0.06 s | details |
#6 | ACCEPTED | 0.06 s | details |
#7 | ACCEPTED | 0.05 s | details |
#8 | ACCEPTED | 0.06 s | details |
#9 | ACCEPTED | 0.06 s | details |
#10 | ACCEPTED | 0.06 s | details |
#11 | ACCEPTED | 0.05 s | details |
#12 | ACCEPTED | 0.06 s | details |
#13 | ACCEPTED | 0.06 s | details |
#14 | ACCEPTED | 0.06 s | details |
#15 | ACCEPTED | 0.06 s | details |
#16 | ACCEPTED | 0.07 s | details |
#17 | ACCEPTED | 0.06 s | details |
#18 | ACCEPTED | 0.05 s | details |
#19 | ACCEPTED | 0.05 s | details |
#20 | TIME LIMIT EXCEEDED | -- | details |
#21 | ACCEPTED | 3.92 s | details |
#22 | ACCEPTED | 0.07 s | details |
#23 | ACCEPTED | 0.06 s | details |
#24 | ACCEPTED | 0.05 s | details |
#25 | ACCEPTED | 0.06 s | details |
#26 | ACCEPTED | 0.06 s | details |
#27 | ACCEPTED | 0.07 s | details |
#28 | TIME LIMIT EXCEEDED | -- | details |
#29 | TIME LIMIT EXCEEDED | -- | details |
#30 | TIME LIMIT EXCEEDED | -- | details |
#31 | TIME LIMIT EXCEEDED | -- | details |
#32 | ACCEPTED | 4.07 s | details |
#33 | ACCEPTED | 4.09 s | details |
#34 | ACCEPTED | 3.98 s | details |
#35 | ACCEPTED | 4.00 s | details |
#36 | ACCEPTED | 3.98 s | details |
#37 | ACCEPTED | 4.47 s | details |
#38 | ACCEPTED | 4.49 s | details |
#39 | ACCEPTED | 4.35 s | details |
#40 | ACCEPTED | 4.33 s | details |
#41 | ACCEPTED | 4.33 s | details |
#42 | ACCEPTED | 4.70 s | details |
#43 | ACCEPTED | 4.71 s | details |
#44 | ACCEPTED | 4.42 s | details |
#45 | ACCEPTED | 4.43 s | details |
#46 | ACCEPTED | 4.43 s | details |
#47 | ACCEPTED | 4.46 s | details |
#48 | ACCEPTED | 0.06 s | details |
#49 | ACCEPTED | 2.27 s | details |
Compiler report
input/code.cpp: In function 'long long int ibm(long double)': input/code.cpp:62:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i=0; i<xs.size(); ++i){ ^ input/code.cpp:66:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i=0; i<pts.size(); ++i){ ^
Code
#include <iostream> #include <iomanip> #include <vector> #include <algorithm> #include <cmath> #include <unordered_map> #define MP make_pair #define F first #define S second #define SZ (1<<18) using namespace std; int n; long double cot(long double a){ long double d=tan(a); if (d!=d) return 0; else return 1l/d; } int sp[SZ]; void put(int a){a+=SZ/2; sp[a]+=1; for (a/=2; a; a/=2) sp[a]=sp[2*a]+sp[2*a+1]; } int get(int a, int b){a+=SZ/2; b+=SZ/2; int rv=0; while (a<b){ if (a%2==1) rv+=sp[a++]; if (b%2==0) rv+=sp[b--]; a/=2; b/=2; }if (a==b) rv+=sp[a]; return rv; } long double PI=-1; int x[101010]; int y[101010]; vector<pair<pair<long double, long double>, int> > pts; vector<long double> xs; unordered_map<long double, int> ix; long long ibm(long double ang){ for (int i=0; i<SZ; ++i) sp[i]=0; xs.clear(); ix.clear(); long double k=cot(ang); for (int i=0; i<n; ++i){ long double xc=x[pts[i].S]; xc-=k*pts[i].F.F; xs.push_back(xc); pts[i].F.S=xc; } sort(xs.begin(), xs.end()); for (int i=0; i<xs.size(); ++i){ ix[xs[i]]=i; } long long sm=0; for (int i=0; i<pts.size(); ++i){ int ii=ix[pts[i].F.S]; int ca=get(0, ii); sm+=ca; put(ii); } return sm; } long double bin(long long v){ long double a=0; long double b=PI; for (int i=0; i<35; ++i){ long double m=(a+b)/2; if (ibm(m)>=v) b=m; else a=m; } return (a+b)/2; } int main(){ PI=acos(PI); ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i=0; i<n; ++i) cin >> x[i] >> y[i]; for (int i=0; i<n; ++i) pts.push_back(MP(MP(y[i], x[i]), i)); sort(pts.begin(), pts.end()); long double a=bin(((long long)n*(n-1)/2+1)/2); long double b=bin(((long long)n*(n-1)/2+2)/2); cout << setprecision(20) << (a+b)/2 << "\n"; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
3
0 0 0 1 1 0 |
correct output |
---|
1.570796326361216 |
user output |
---|
1.5707963267491804292 |
Test 2
Verdict: ACCEPTED
input |
---|
4
0 0 0 1 1 0 1 1 |
correct output |
---|
1.178097245010921 |
user output |
---|
1.1780972450504562744 |
Test 3
Verdict: ACCEPTED
input |
---|
3
0 0 0 1000000000 1 0 |
correct output |
---|
1.570796326361216 |
user output |
---|
1.5707963267491804292 |
Test 4
Verdict: ACCEPTED
input |
---|
3
0 0 1 0 2 0 |
correct output |
---|
0.000000001000000 |
user output |
---|
4.5716189977098740034e-11 |
Test 5
Verdict: ACCEPTED
input |
---|
3 5 -2 -5 -4 -4 4 |
correct output |
---|
1.446441331885909 |
user output |
---|
1.4464413322816544818 |
Test 6
Verdict: ACCEPTED
input |
---|
3 0 4 -3 -1 -4 4 |
correct output |
---|
1.030376826373869 |
user output |
---|
1.0303768264849443204 |
Test 7
Verdict: ACCEPTED
input |
---|
3 0 -1 3 -3 -4 1 |
correct output |
---|
2.622446539330037 |
user output |
---|
2.6224465393331880011 |
Test 8
Verdict: ACCEPTED
input |
---|
3 -5 -3 -3 0 3 5 |
correct output |
---|
0.785398163226945 |
user output |
---|
0.78539816335173211963 |
Test 9
Verdict: ACCEPTED
input |
---|
3 -5 3 -1 -2 5 -3 |
correct output |
---|
2.601173153316589 |
user output |
---|
2.60117315327984094 |
Test 10
Verdict: ACCEPTED
input |
---|
3 -2 0 -3 3 1 -2 |
correct output |
---|
2.245537268920354 |
user output |
---|
2.2455372689891998713 |
Test 11
Verdict: ACCEPTED
input |
---|
3 -2 -1 -3 2 1 -3 |
correct output |
---|
2.245537268920354 |
user output |
---|
2.2455372689891998713 |
Test 12
Verdict: ACCEPTED
input |
---|
3 3 -3 1 -1 0 2 |
correct output |
---|
2.111215826897042 |
user output |
---|
2.1112158271048489179 |
Test 13
Verdict: ACCEPTED
input |
---|
3 0 -3 2 0 -3 0 |
correct output |
---|
0.982793723190022 |
user output |
---|
0.98279372326912985982 |
Test 14
Verdict: ACCEPTED
input |
---|
5 1 -3 0 -3 2 2 -3 3 ... |
correct output |
---|
1.802620131078459 |
user output |
---|
1.8026201312554427402 |
Test 15
Verdict: ACCEPTED
input |
---|
5 -3 -2 2 -2 1 -2 1 -1 ... |
correct output |
---|
0.582952270226021 |
user output |
---|
0.58295227023339928453 |
Test 16
Verdict: ACCEPTED
input |
---|
50 -3 -3 5 -5 0 -5 -5 2 ... |
correct output |
---|
1.570796326361216 |
user output |
---|
1.5707963267491804292 |
Test 17
Verdict: ACCEPTED
input |
---|
50 4 4 2 1 -2 1 5 -3 ... |
correct output |
---|
1.570796326361216 |
user output |
---|
1.5707963267491804292 |
Test 18
Verdict: ACCEPTED
input |
---|
50 442366208 279138083 -184561367 198541207 823405894 -564413219 114448377 768487602 ... |
correct output |
---|
1.418644093993140 |
user output |
---|
1.418644094140824707 |
Test 19
Verdict: ACCEPTED
input |
---|
50 816110770 -689704132 494898871 528573081 166680604 515808141 582252599 -643183741 ... |
correct output |
---|
1.656117102112052 |
user output |
---|
1.6561171021876612821 |
Test 20
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 -150948623 524048786 15875754 245984095 -680102685 -996037369 -312145822 195412711 ... |
correct output |
---|
1.567645716335110 |
user output |
---|
(empty) |
Test 21
Verdict: ACCEPTED
input |
---|
80000 -587936709 929197030 816737335 627407406 -637765108 -922560549 195018519 -727622801 ... |
correct output |
---|
1.564802980555181 |
user output |
---|
1.5648029808279803709 |
Test 22
Verdict: ACCEPTED
input |
---|
4
-3 -4 -5 -4 2 -1 -3 -2 |
correct output |
---|
0.472655643272179 |
user output |
---|
0.47265564329616707937 |
Test 23
Verdict: ACCEPTED
input |
---|
10
-3 -7 -5 9 -1 6 -8 2 ... |
correct output |
---|
1.703347858852173 |
user output |
---|
1.7033478591154099888 |
Test 24
Verdict: ACCEPTED
input |
---|
3
-1000000000 0 1000000000 0 1000000000 1 |
correct output |
---|
0.000000001000000 |
user output |
---|
5.0287808974808614035e-10 |
Test 25
Verdict: ACCEPTED
input |
---|
3
-1000000000 0 1000000000 0 1000000000 3 |
correct output |
---|
0.000000001500000 |
user output |
---|
1.508634269244258421e-09 |
Test 26
Verdict: ACCEPTED
input |
---|
3
-1000000000 0 1000000000 0 1000000000 2 |
correct output |
---|
0.000000001000000 |
user output |
---|
9.6003998951907354063e-10 |
Test 27
Verdict: ACCEPTED
input |
---|
3
-1000000000 0 1000000000 0 1000000000 5 |
correct output |
---|
0.000000002500000 |
user output |
---|
2.5143904487404307017e-09 |
Test 28
Verdict: TIME LIMIT EXCEEDED
input |
---|
99996 733545312 -23346396 -795397579 -404874879 -503473099 346027613 -271528713 -541325642 ... |
correct output |
---|
1.570738488959610 |
user output |
---|
(empty) |
Test 29
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 -569987404 -522495344 77828992 -662077558 -751319779 -938754614 676233529 -390989412 ... |
correct output |
---|
1.572402491568657 |
user output |
---|
(empty) |
Test 30
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 671546196 228818010 -138266629 -168233695 -323825826 334459800 216860157 -420208747 ... |
correct output |
---|
1.567256816862458 |
user output |
---|
(empty) |
Test 31
Verdict: TIME LIMIT EXCEEDED
input |
---|
99999 720191241 515523232 -327632871 233538461 -512554358 300865696 945279418 -948967513 ... |
correct output |
---|
1.574006709521912 |
user output |
---|
(empty) |
Test 32
Verdict: ACCEPTED
input |
---|
100000 984248694 0 614763735 0 203383912 0 862359296 0 ... |
correct output |
---|
0.000000001000000 |
user output |
---|
4.5716189977098740034e-11 |
Test 33
Verdict: ACCEPTED
input |
---|
100000 57050460 0 -375026139 0 -820386623 0 -99980585 0 ... |
correct output |
---|
0.000000001000000 |
user output |
---|
4.5716189977098740034e-11 |
Test 34
Verdict: ACCEPTED
input |
---|
100000 876809794 -438404747 394286770 -197143235 -367448514 183724407 -383434666 191717483 ... |
correct output |
---|
2.677945044551917 |
user output |
---|
2.6779450446229848062 |
Test 35
Verdict: ACCEPTED
input |
---|
100000 -154037240 1510270 362293900 -3551800 2089162 -20381 -717258188 7032044 ... |
correct output |
---|
3.131789046110464 |
user output |
---|
3.1317890460987619083 |
Test 36
Verdict: ACCEPTED
input |
---|
100000 412444110 -457155 -684758612 759256 479239014 -531207 390243184 -432542 ... |
correct output |
---|
3.140484006593894 |
user output |
---|
3.1404840065873384385 |
Test 37
Verdict: ACCEPTED
input |
---|
100000 796270214 1 -951846498 0 217668093 -2 -154910102 0 ... |
correct output |
---|
0.000000007305530 |
user output |
---|
7.2688742063586996654e-09 |
Test 38
Verdict: ACCEPTED
input |
---|
100000 -253706492 2 -226875621 2 362330838 2 -795605493 2 ... |
correct output |
---|
0.000000007263216 |
user output |
---|
7.2688742063586996654e-09 |
Test 39
Verdict: ACCEPTED
input |
---|
100000 934702833 -467351271 -131493362 65746831 913964656 -456982181 627793697 -313896700 ... |
correct output |
---|
2.677945044551917 |
user output |
---|
2.6779450446229848062 |
Test 40
Verdict: ACCEPTED
input |
---|
100000 -668200264 6551087 86496002 -847902 -871928849 8548421 -136205907 1335452 ... |
correct output |
---|
3.131789046110464 |
user output |
---|
3.1317890460987619083 |
Test 41
Verdict: ACCEPTED
input |
---|
100000 595966829 -660620 -51714261 57430 991615602 -1099248 -863804708 957752 ... |
correct output |
---|
3.140484006593894 |
user output |
---|
3.1404840065873384385 |
Test 42
Verdict: ACCEPTED
input |
---|
100000 140 20 2 -114 152 -60 -82 123 ... |
correct output |
---|
1.566291852418795 |
user output |
---|
1.5662918527654727593 |
Test 43
Verdict: ACCEPTED
input |
---|
100000 -79 -25 -117 178 -70 221 -291 71 ... |
correct output |
---|
1.570796326361216 |
user output |
---|
1.5707963267491804292 |
Test 44
Verdict: ACCEPTED
input |
---|
100000 74068734 -67184987 -73589858 -67709177 -63969660 -76862751 -90718064 42074133 ... |
correct output |
---|
1.570780621042227 |
user output |
---|
1.5707806210435461768 |
Test 45
Verdict: ACCEPTED
input |
---|
99999 400813117 -805821844 874374859 -213233688 33553856 899374304 853659607 285070648 ... |
correct output |
---|
1.570796326361216 |
user output |
---|
1.5707963267491804292 |
Test 46
Verdict: ACCEPTED
input |
---|
99999 99957306 -2955708 -9788208 99519803 -31843316 -94794095 -62763244 -77850073 ... |
correct output |
---|
1.570780617572780 |
user output |
---|
1.5707806175691157386 |
Test 47
Verdict: ACCEPTED
input |
---|
100000 -94881770 31583126 44754159 -89425361 87229737 -48896753 77708105 62941177 ... |
correct output |
---|
1.570780277133298 |
user output |
---|
1.5707802773949461192 |
Test 48
Verdict: ACCEPTED
input |
---|
201 -100 10000 -99 9801 -98 9604 -97 9409 ... |
correct output |
---|
1.565420034260210 |
user output |
---|
1.5654200345078857915 |
Test 49
Verdict: ACCEPTED
input |
---|
62003 -31001 961062001 -31000 961000000 -30999 960938001 -30998 960876004 ... |
correct output |
---|
1.570780133151250 |
user output |
---|
1.5707801332517991213 |