fork download
  1. //ANIK BARUA
  2. //9.25.2023- 3:06 PM
  3. #include <bits/stdc++.h>
  4. using namespace std;
  5. #define PI 3.14159265
  6.  
  7. int calc(int a, int b)
  8. {
  9.  
  10. return (atan2(a, b) * 180) / PI;
  11.  
  12. }
  13. int main()
  14. {
  15. int t;
  16. cin >> t;
  17. while (t--)
  18. {
  19. int n;
  20. cin >> n;
  21. vector<pair<int, int>> vec;
  22. for (int i = 0; i < n; i++)
  23. {
  24. int a, b;
  25. cin >> a >> b;
  26. vec.push_back(make_pair(a, b));
  27. }
  28. int count = 0;
  29. for (int i = 0; i < n - 1; i++)
  30. {
  31. int x1 = vec[i].first;
  32. int y1 = vec[i].second;
  33.  
  34. for (int j = i + 1; j < n; j++)
  35. {
  36. int x2 = vec[j].first;
  37. int y2 = vec[j].second;
  38. int angle = calc(x1 - x2, y1 - y2);
  39. if (angle % 45 == 0)
  40. {
  41. count++;
  42. }
  43. }
  44. }
  45. cout << count*2 << endl;
  46. }
  47.  
  48. return 0;
  49. }
Time limit exceeded #stdin #stdout 5s 5532KB
stdin
Standard input is empty
stdout
28896000
28896000
28896000
28896000
28896000
28896000
28896000
28896000
28896000
28896000
28896000
28896000
28896000
28896000
28896000
28896000
28896000
28896000
28896000
28896000