Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- struct pt
- {
- int x;
- int y;
- };
- const int INF = 1e9;
- struct edge
- {
- int v;
- int u;
- int w;
- bool operator < (edge q)
- {
- return w < q.w;
- }
- };
- int sqr(int t)
- {
- return t * t;
- }
- int dist(pt a, pt b)
- {
- return sqr(a.x - b.x) + sqr(a.y - b.y);
- }
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- //freopen("input.txt", "r", stdin);
- int n;
- cin >> n;
- vector<pt> a(n);
- for (int i = 0; i < n; i++)
- cin >> a[i].x >> a[i].y;
- vector< pair<int, int> > d(n, {INF, -1});
- vector<int> used(n, 0);
- vector<int> clr(n, 0);
- d[0] = {0, -1};
- clr[0] = 0;
- int ans = INF;
- for (int i = 0; i < n; i++)
- {
- int mn = -1;
- for (int j = 0; j < n; j++)
- {
- if (!used[j] && (mn == -1 || (d[j].first < d[mn].first)))
- mn = j;
- }
- int u = mn;
- int v = d[mn].second;
- used[u] = 1;
- clr[u] = 1 - clr[v];
- for (int j = 0; j < n; j++)
- {
- if (used[j])
- continue;
- if (dist(a[u], a[j]) < d[j].first)
- d[j] = {dist(a[u], a[j]), u};
- }
- }
- for (int i = 0; i < n; i++)
- {
- for (int j = i + 1; j < n; j++)
- if (clr[i] == clr[j])
- ans = min(ans, dist(a[i], a[j]));
- }
- cout << fixed << setprecision(10) << sqrt(ans / (double)4) << endl;
- for (auto x : clr)
- cout << x + 1 << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement