CSES - Siperia opettaa 2.0 - Results
Submission details
Task:Lines
Sender:Hansuzu
Submission time:2016-07-29 08:48:50 +0300
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1ACCEPTED0.06 sdetails
#2ACCEPTED0.06 sdetails
#3ACCEPTED0.06 sdetails
#4ACCEPTED0.05 sdetails
#5ACCEPTED0.06 sdetails
#6ACCEPTED0.06 sdetails
#7ACCEPTED0.05 sdetails
#8ACCEPTED0.06 sdetails
#9ACCEPTED0.06 sdetails
#10ACCEPTED0.06 sdetails
#11ACCEPTED0.05 sdetails
#12ACCEPTED0.06 sdetails
#13ACCEPTED0.06 sdetails
#14ACCEPTED0.06 sdetails
#15ACCEPTED0.06 sdetails
#16ACCEPTED0.07 sdetails
#17ACCEPTED0.06 sdetails
#18ACCEPTED0.05 sdetails
#19ACCEPTED0.05 sdetails
#20--details
#21ACCEPTED3.92 sdetails
#22ACCEPTED0.07 sdetails
#23ACCEPTED0.06 sdetails
#24ACCEPTED0.05 sdetails
#25ACCEPTED0.06 sdetails
#26ACCEPTED0.06 sdetails
#27ACCEPTED0.07 sdetails
#28--details
#29--details
#30--details
#31--details
#32ACCEPTED4.07 sdetails
#33ACCEPTED4.09 sdetails
#34ACCEPTED3.98 sdetails
#35ACCEPTED4.00 sdetails
#36ACCEPTED3.98 sdetails
#37ACCEPTED4.47 sdetails
#38ACCEPTED4.49 sdetails
#39ACCEPTED4.35 sdetails
#40ACCEPTED4.33 sdetails
#41ACCEPTED4.33 sdetails
#42ACCEPTED4.70 sdetails
#43ACCEPTED4.71 sdetails
#44ACCEPTED4.42 sdetails
#45ACCEPTED4.43 sdetails
#46ACCEPTED4.43 sdetails
#47ACCEPTED4.46 sdetails
#48ACCEPTED0.06 sdetails
#49ACCEPTED2.27 sdetails

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:

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:

input
99996
733545312 -23346396
-795397579 -404874879
-503473099 346027613
-271528713 -541325642
...

correct output
1.570738488959610

user output
(empty)

Test 29

Verdict:

input
100000
-569987404 -522495344
77828992 -662077558
-751319779 -938754614
676233529 -390989412
...

correct output
1.572402491568657

user output
(empty)

Test 30

Verdict:

input
100000
671546196 228818010
-138266629 -168233695
-323825826 334459800
216860157 -420208747
...

correct output
1.567256816862458

user output
(empty)

Test 31

Verdict:

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