Advertisement
Dennnhhhickk

Untitled

Aug 16th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. typedef long long ll;
  5. typedef string str;
  6. typedef long double ld;
  7. const ll MaxN = 1200;
  8. #define mp make_pair
  9. vector <ll> g[MaxN];
  10. pair <ld, ld> vec[MaxN];
  11. ll color[MaxN], dfs_timer, time_out[MaxN], time_in[MaxN];
  12. ll n, m;
  13. ld eps = 1e-9;
  14.  
  15. ld sqr(ld a)
  16. {
  17. return a * a;
  18. }
  19.  
  20. bool ccheck(ll a, ll b, ld r)
  21. {
  22. return sqrt(sqr(vec[a].first - vec[b].first) + sqr(vec[a].second - vec[b].second)) < 2 * r;
  23. }
  24.  
  25. bool check (ld mm)
  26. {
  27. for (int i = 0; i < n; i++)
  28. color[i] = 0;
  29. for (int j = 0; j < n; j++)
  30. if (!color[j])
  31. {
  32. color[j] = 1;
  33. queue <ll> q;
  34. ll t;
  35. q.push(j);
  36. while (!q.empty())
  37. {
  38. t = q.front();
  39. q.pop();
  40. for (int i = 0; i < n; i++)
  41. if (i != t && ccheck(i, t, mm))
  42. if (color[i] == color[t])
  43. return 0;
  44. else
  45. if (!color[i])
  46. {
  47. color[i] = 3 - color[t];
  48. q.push(i);
  49. }
  50. }
  51. }
  52. return 1;
  53. }
  54.  
  55. int main()
  56. {
  57. cin >> n;
  58. ld x, y;
  59. for (int i = 0; i < n; i++)
  60. {
  61. cin >> x >> y;
  62. vec[i] = mp(x, y);
  63. }
  64. ld l = 0, r = 1e5, mm;
  65. while (abs(r - l) > eps)
  66. {
  67. mm = (l + r) / 2;
  68. if (check(mm))
  69. l = mm;
  70. else
  71. r = mm;
  72. }
  73. check(l);
  74. cout << setprecision(8) << fixed << l << setprecision(0) << fixed << endl;
  75. for (int i = 0; i < n; i++)
  76. cout << color[i] << " ";
  77. cout << endl;
  78. return 0;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement