CSES - Siperia opettaa 2.0 - Results
Submission details
Task:Lines
Sender:Hansuzu
Submission time:2016-07-29 09:44:18 +0300
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#10.05 sdetails
#20.06 sdetails
#30.06 sdetails
#40.05 sdetails
#50.06 sdetails
#60.06 sdetails
#70.06 sdetails
#80.06 sdetails
#90.06 sdetails
#100.06 sdetails
#110.05 sdetails
#120.05 sdetails
#130.06 sdetails
#140.06 sdetails
#150.06 sdetails
#160.05 sdetails
#170.06 sdetails
#180.05 sdetails
#190.05 sdetails
#203.19 sdetails
#212.39 sdetails
#220.07 sdetails
#230.05 sdetails
#240.06 sdetails
#250.06 sdetails
#260.06 sdetails
#270.06 sdetails
#283.21 sdetails
#293.21 sdetails
#303.19 sdetails
#313.20 sdetails
#323.04 sdetails
#333.05 sdetails
#343.04 sdetails
#353.03 sdetails
#363.02 sdetails
#373.29 sdetails
#383.38 sdetails
#393.03 sdetails
#403.05 sdetails
#413.04 sdetails
#423.00 sdetails
#433.04 sdetails
#443.13 sdetails
#453.13 sdetails
#463.16 sdetails
#473.13 sdetails
#480.06 sdetails
#491.57 sdetails

Compiler report

input/code.cpp: In function 'long long int ibm(long double)':
input/code.cpp:62:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i=0; i+1<xs.size(); i+=2){
                             ^
input/code.cpp:69:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i=0; i+1<pts.size(); i+=2){
                              ^

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+=2) sp[i]=0, sp[i+1]=0;
  xs.clear();
  ix.clear();
  long double k=cot(ang);
  for (int i=0; i+1<n; i+=2){
    xs.push_back(pts[i].F.S=x[pts[i].S]-k*pts[i].F.F);
    xs.push_back(pts[i+1].F.S=x[pts[i+1].S]-k*pts[i+1].F.F);
  }
  if (n%2) xs.push_back(pts[n-1].F.S=x[pts[n-1].S]-k*pts[n-1].F.F);
  
  sort(xs.begin(), xs.end());
  
  for (int i=0; i+1<xs.size(); i+=2){
    ix[xs[i]]=i;
    ix[xs[i+1]]=i+1;
  }
  if (xs.size()%2) ix[xs[xs.size()-1]]=xs.size()-1;
  
  long long sm=0;
  for (int i=0; i+1<pts.size(); i+=2){
    int ii=ix[pts[i].F.S];
    sm+=get(0, ii);;
    put(ii);
  }
  if (pts.size()%2) sm+=get(0, ix[pts[pts.size()-1].F.S]);
  return sm;
}


long double bin(long long v){
  long double a=0;
  long double b=PI;
  for (int i=0; i<33; ++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:

input
3
0 0
0 1
1 0

correct output
1.570796326361216

user output
3.1415926534069284785

Test 2

Verdict:

input
4
0 0
0 1
1 0
1 1

correct output
1.178097245010921

user output
3.1415926534069284785

Test 3

Verdict:

input
3
0 0
0 1000000000
1 0

correct output
1.570796326361216

user output
3.1415926534069284785

Test 4

Verdict:

input
3
0 0
1 0
2 0

correct output
0.000000001000000

user output
3.1415926534069284785

Test 5

Verdict:

input
3
5 -2
-5 -4
-4 4

correct output
1.446441331885909

user output
3.1415926534069284785

Test 6

Verdict:

input
3
0 4
-3 -1
-4 4

correct output
1.030376826373869

user output
3.1415926534069284785

Test 7

Verdict:

input
3
0 -1
3 -3
-4 1

correct output
2.622446539330037

user output
3.1415926534069284785

Test 8

Verdict:

input
3
-5 -3
-3 0
3 5

correct output
0.785398163226945

user output
3.1415926534069284785

Test 9

Verdict:

input
3
-5 3
-1 -2
5 -3

correct output
2.601173153316589

user output
3.1415926534069284785

Test 10

Verdict:

input
3
-2 0
-3 3
1 -2

correct output
2.245537268920354

user output
3.1415926534069284785

Test 11

Verdict:

input
3
-2 -1
-3 2
1 -3

correct output
2.245537268920354

user output
3.1415926534069284785

Test 12

Verdict:

input
3
3 -3
1 -1
0 2

correct output
2.111215826897042

user output
3.1415926534069284785

Test 13

Verdict:

input
3
0 -3
2 0
-3 0

correct output
0.982793723190022

user output
3.1415926534069284785

Test 14

Verdict:

input
5
1 -3
0 -3
2 2
-3 3
...

correct output
1.802620131078459

user output
3.1415926534069284785

Test 15

Verdict:

input
5
-3 -2
2 -2
1 -2
1 -1
...

correct output
0.582952270226021

user output
3.1415926534069284785

Test 16

Verdict:

input
50
-3 -3
5 -5
0 -5
-5 2
...

correct output
1.570796326361216

user output
3.1415926534069284785

Test 17

Verdict:

input
50
4 4
2 1
-2 1
5 -3
...

correct output
1.570796326361216

user output
3.1415926534069284785

Test 18

Verdict:

input
50
442366208 279138083
-184561367 198541207
823405894 -564413219
114448377 768487602
...

correct output
1.418644093993140

user output
3.1415926534069284785

Test 19

Verdict:

input
50
816110770 -689704132
494898871 528573081
166680604 515808141
582252599 -643183741
...

correct output
1.656117102112052

user output
3.1415926534069284785

Test 20

Verdict:

input
100000
-150948623 524048786
15875754 245984095
-680102685 -996037369
-312145822 195412711
...

correct output
1.567645716335110

user output
3.1415926534069284785

Test 21

Verdict:

input
80000
-587936709 929197030
816737335 627407406
-637765108 -922560549
195018519 -727622801
...

correct output
1.564802980555181

user output
3.1415926534069284785

Test 22

Verdict:

input
4
-3 -4
-5 -4
2 -1
-3 -2

correct output
0.472655643272179

user output
3.1415926534069284785

Test 23

Verdict:

input
10
-3 -7
-5 9
-1 6
-8 2
...

correct output
1.703347858852173

user output
3.1415926534069284785

Test 24

Verdict:

input
3
-1000000000 0
1000000000 0
1000000000 1

correct output
0.000000001000000

user output
3.1415926534069284785

Test 25

Verdict:

input
3
-1000000000 0
1000000000 0
1000000000 3

correct output
0.000000001500000

user output
3.1415926534069284785

Test 26

Verdict:

input
3
-1000000000 0
1000000000 0
1000000000 2

correct output
0.000000001000000

user output
3.1415926534069284785

Test 27

Verdict:

input
3
-1000000000 0
1000000000 0
1000000000 5

correct output
0.000000002500000

user output
3.1415926534069284785

Test 28

Verdict:

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

correct output
1.570738488959610

user output
3.1415926534069284785

Test 29

Verdict:

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

correct output
1.572402491568657

user output
3.1415926534069284785

Test 30

Verdict:

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

correct output
1.567256816862458

user output
3.1415926534069284785

Test 31

Verdict:

input
99999
720191241 515523232
-327632871 233538461
-512554358 300865696
945279418 -948967513
...

correct output
1.574006709521912

user output
3.1415926534069284785

Test 32

Verdict:

input
100000
984248694 0
614763735 0
203383912 0
862359296 0
...

correct output
0.000000001000000

user output
3.1415926534069284785

Test 33

Verdict:

input
100000
57050460 0
-375026139 0
-820386623 0
-99980585 0
...

correct output
0.000000001000000

user output
3.1415926534069284785

Test 34

Verdict:

input
100000
876809794 -438404747
394286770 -197143235
-367448514 183724407
-383434666 191717483
...

correct output
2.677945044551917

user output
3.1415926534069284785

Test 35

Verdict:

input
100000
-154037240 1510270
362293900 -3551800
2089162 -20381
-717258188 7032044
...

correct output
3.131789046110464

user output
3.1415926534069284785

Test 36

Verdict:

input
100000
412444110 -457155
-684758612 759256
479239014 -531207
390243184 -432542
...

correct output
3.140484006593894

user output
3.1415926534069284785

Test 37

Verdict:

input
100000
796270214 1
-951846498 0
217668093 -2
-154910102 0
...

correct output
0.000000007305530

user output
3.1415926534069284785

Test 38

Verdict:

input
100000
-253706492 2
-226875621 2
362330838 2
-795605493 2
...

correct output
0.000000007263216

user output
3.1415926534069284785

Test 39

Verdict:

input
100000
934702833 -467351271
-131493362 65746831
913964656 -456982181
627793697 -313896700
...

correct output
2.677945044551917

user output
3.1415926534069284785

Test 40

Verdict:

input
100000
-668200264 6551087
86496002 -847902
-871928849 8548421
-136205907 1335452
...

correct output
3.131789046110464

user output
3.1415926534069284785

Test 41

Verdict:

input
100000
595966829 -660620
-51714261 57430
991615602 -1099248
-863804708 957752
...

correct output
3.140484006593894

user output
3.1415926534069284785

Test 42

Verdict:

input
100000
140 20
2 -114
152 -60
-82 123
...

correct output
1.566291852418795

user output
3.1415926534069284785

Test 43

Verdict:

input
100000
-79 -25
-117 178
-70 221
-291 71
...

correct output
1.570796326361216

user output
3.1415926534069284785

Test 44

Verdict:

input
100000
74068734 -67184987
-73589858 -67709177
-63969660 -76862751
-90718064 42074133
...

correct output
1.570780621042227

user output
3.1415926534069284785

Test 45

Verdict:

input
99999
400813117 -805821844
874374859 -213233688
33553856 899374304
853659607 285070648
...

correct output
1.570796326361216

user output
3.1415926534069284785

Test 46

Verdict:

input
99999
99957306 -2955708
-9788208 99519803
-31843316 -94794095
-62763244 -77850073
...

correct output
1.570780617572780

user output
3.1415926534069284785

Test 47

Verdict:

input
100000
-94881770 31583126
44754159 -89425361
87229737 -48896753
77708105 62941177
...

correct output
1.570780277133298

user output
3.1415926534069284785

Test 48

Verdict:

input
201
-100 10000
-99 9801
-98 9604
-97 9409
...

correct output
1.565420034260210

user output
3.1415926534069284785

Test 49

Verdict:

input
62003
-31001 961062001
-31000 961000000
-30999 960938001
-30998 960876004
...

correct output
1.570780133151250

user output
3.1415926534069284785