fork download
  1. #include <bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. #include <random>
  4.  
  5. using namespace std;
  6. using namespace __gnu_pbds;
  7.  
  8. typedef long long ll;
  9. typedef unsigned long long ull;
  10. typedef tree<pair<int, int>, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
  11. #define AboTaha_on_da_code ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  12. #define X first
  13. #define Y second
  14.  
  15. const int dx[8]={0, 0, 1, -1, 1, -1, -1, 1};
  16. const int dy[8]={1, -1, 0, 0, 1, -1, 1, -1};
  17. const double EPS = 1e-8;
  18. const int mod = 1e9+7;
  19. // BEFORE coding are you sure you understood the statement correctly?
  20. // PLEASE do not forget to read the sample explanation carefully.
  21. // WATCH out for overflows & RTs in general.
  22. // TEST your idea or code on the corner cases.
  23. // ANALYZE each idea you have thoroughly.
  24.  
  25. const double PI = acos(-1);
  26.  
  27. void burn(int tc)
  28. {
  29. int n; cin >> n;
  30. vector <pair<int, int>> Ps(n);
  31. for (auto &[x, y] : Ps) cin >> x >> y;
  32.  
  33. for (int i = 0; i < n; i++) {
  34. int ans = n-1;
  35. auto &p1 = Ps[i];
  36. vector <double> angs;
  37. for (int j = 0; j < n; j++) {
  38. if (j == i) continue;
  39. angs.push_back(fmod(atan2(Ps[j].Y-p1.Y, Ps[j].X-p1.X)+PI*2, PI*2));
  40. }
  41. sort(angs.begin(), angs.end());
  42. int sz = n-1;
  43. for (int j = 0; j < sz; j++) {
  44. angs.push_back(angs[j]+PI*2);
  45. }
  46. for (int j = 0, r = 0; j < 2*sz; j++) {
  47. while(r < 2*sz && angs[r]-angs[j] <= PI) r++;
  48. ans = min(ans, sz-r+j);
  49. }
  50. ans = max(ans, 0);
  51. cout << ans << '\n';
  52. }
  53. }
  54.  
  55. int main()
  56. {
  57. AboTaha_on_da_code
  58.  
  59. freopen("bedone.in", "r", stdin);
  60. // freopen("Aout.txt", "w", stdout);
  61.  
  62. int T = 1; cin >> T;
  63.  
  64. for (int i = 1; i <= T; i++) {
  65. // cout << "Case " << i << ": ";
  66. burn(i);
  67. // cout << '\n';
  68. }
  69. return 0;
  70. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty