Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define Gene template< class
- #define Rics printer& operator,
- Gene c> struct rge{c b, e;};
- Gene c> rge<c> range(c i, c j){ return {i, j};}
- struct printer{
- ~printer(){cerr<<endl;}
- Gene c >Rics(c x){ cerr<<boolalpha<<x; return *this;}
- Rics(string x){cerr<<x;return *this;}
- Gene c, class d >Rics(pair<c, d> x){ return *this,"(",x.first,", ",x.second,")";}
- Gene ... d, Gene ...> class c >Rics(c<d...> x){ return *this, range(begin(x), end(x));}
- Gene c >Rics(rge<c> x){
- *this,"["; for(auto it = x.b; it != x.e; ++it)
- *this,(it==x.b?"":", "),*it; return *this,"]";}
- };
- #define debug() cerr<<"LINE "<<__LINE__<<" >> ", printer()
- #define dbg(x) "[",#x,": ",(x),"] "
- mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
- int my_rand(int l, int r) {
- return uniform_int_distribution<int>(l, r) (rng);
- }
- const int N = 300;
- typedef long long LL;
- struct PT {
- LL x, y;
- };
- LL area(PT p, PT q, PT r) {
- return (p.x*q.y-p.y*q.x) + (q.x*r.y-q.y*r.x) + (r.x*p.y-r.y*p.x);
- }
- double dist(PT p, PT q) {
- return sqrt((p.x-q.x)*(p.x-q.x) + (p.y-q.y)*(p.y-q.y));
- }
- int main() {
- // freopen("in.txt", "r", stdin);
- ios::sync_with_stdio(0);
- cin.tie(0);
- int n;
- cin >> n;
- vector<PT> p(n);
- for(int i = 0; i < n; i++) cin >> p[i].x >> p[i].y;
- vector<vector<bitset<N>>> side(n, vector<bitset<N>>(n));
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < n; j++) {
- if(i == j) continue;
- for(int k = 0; k < n; k++) {
- if(area(p[i], p[j], p[k]) > 0) side[i][j][k] = true;
- }
- // debug(), dbg(i), dbg(j), dbg(side[i][j]);
- }
- }
- for(int i = 0; i < n; i++) {
- int sum = 0;
- double wtDist = 0;
- for(int j = 0; j < n; j++) {
- if(i == j) continue;
- double d = dist(p[i], p[j]);
- int cnt = 0;
- for(int k = 0; k < n; k++) {
- LL cross = area(p[i], p[j], p[k]);
- // if(cross > 0) cnt += (side[j][i]&side[k][j]).count();
- if(cross < 0) cnt += (side[i][j]&side[j][k]).count();
- }
- wtDist += cnt*d;
- sum += cnt;
- }
- if(sum == 0) cout << "-1" << "\n";
- else cout << setprecision(12) << fixed << wtDist/sum << "\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement