Advertisement
Guest User

Untitled

a guest
Jul 17th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. //UVA1595Symmetry
  2. #include<cstdio>
  3. #include<iostream>
  4. #include<map>
  5. #include<string>
  6. #include<cstring>
  7. using namespace std;
  8. const int MAXN = 2000;
  9. typedef pair<double, double> LL;
  10. LL dot_pair[MAXN];
  11. map<LL, int> Match;
  12. int main() {
  13.  
  14. int kase = 0;
  15. scanf("%d", &kase);
  16. while(kase--) {
  17. int n = 0;
  18. scanf("%d", &n);
  19. double sum = 0;
  20. for(int i = 0; i < n; i++) {
  21. double a, b;
  22. scanf("%lf%lf", &a, &b);
  23. dot_pair[i].first = a;
  24. //printf("a = %.0f\n", a);
  25. sum += a;
  26. dot_pair[i].second = b;
  27. Match[dot_pair[i]] = 1;
  28. }
  29. double aver = sum / n;
  30. //printf("aver = %.0lf\n", aver);
  31. int i = 0;
  32. for(i = 0; i < n; i++) {
  33. double a = 2 * aver - dot_pair[i].first;
  34. double b = dot_pair[i].second;
  35. LL tmp_pair(a, b);
  36. // printf("i = %d : (%.0lf, %.0lf) (%.0lf, %.0lf)\n", i, dot_pair[i].first, dot_pair[i].second, tmp_pair.first, tmp_pair.first);
  37. if(!Match.count(tmp_pair)) break;
  38. }
  39. puts(i == n ? "YES" : "NO");
  40. }
  41. return 0;
  42. }
  43. /*
  44.  
  45. 3
  46. 5
  47. -2 5
  48. 0 0
  49. 6 5
  50. 4 0
  51. 2 3
  52. 4
  53. 2 3
  54. 0 4
  55. 4 0
  56. 0 0
  57. 4
  58. 5 14
  59. 6 10
  60. 5 10
  61. 6 14
  62.  
  63. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement