Advertisement
dimuster

1972 acmp

Oct 7th, 2022
600
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.98 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define int long long
  6. #define ld long double
  7. #define inf 9e18
  8. #define DEG / PI * 180
  9. #define v vector
  10. #define min(a, b) (a < b ? a : b)
  11. #define max(a, b) (a > b ? a : b)
  12.  
  13.  
  14. const ld PI = atan(1) * 4;
  15.  
  16. struct Point {
  17.     int x, y;
  18. };
  19.  
  20. struct Vector {
  21.     Point b, e;
  22. };
  23.  
  24. struct Triangle {
  25.     int num;
  26.     Point a, b, c;
  27.     ld A, B, C;
  28.     int ab, bc, ac;
  29. };
  30.  
  31. int sp(Vector a, Vector b) {
  32.     return (a.e.x - a.b.x) * (b.e.x - b.b.x) + (a.e.y - a.b.y) * (b.e.y - b.b.y);
  33. }
  34.  
  35. int vp(Vector a, Vector b) {
  36.     return (a.e.x - a.b.x) * (b.e.y - b.b.y) - (a.e.y - a.b.y) * (b.e.x - b.b.x);
  37. }
  38.  
  39. int sd(Point a, Point b) {
  40.     return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
  41. }
  42.  
  43. Point make_p(int x, int y) {
  44.     Point p;
  45.     p.x = x;
  46.     p.y = y;
  47.     return p;
  48. }
  49.  
  50. Vector make_v(Point x, Point y) {
  51.     Vector p;
  52.     p.b = x;
  53.     p.e = y;
  54.     return p;
  55. }
  56.  
  57. Triangle make_t(Point a, Point b, Point c, int num) {
  58.     Triangle t;
  59.    
  60.     t.num = num;
  61.    
  62.     t.a = a;
  63.     t.b = b;
  64.     t.c = c;
  65.    
  66.     t.ab = sd(a, b);
  67.     t.bc = sd(b, c);
  68.     t.ac = sd(a, c);
  69.    
  70.     t.A = abs(atan2(vp(make_v(a, b), make_v(a, c)), sp(make_v(a, b), make_v(a, c))));
  71.     t.B = abs(atan2(vp(make_v(b, a), make_v(b, c)), sp(make_v(b, a), make_v(b, c))));
  72.     t.C = abs(atan2(vp(make_v(c, a), make_v(c, b)), sp(make_v(c, a), make_v(c, b))));
  73.    
  74.     return t;
  75. }
  76.  
  77. ld get_angle(Triangle t, int rotate, int is_left) {
  78.     v<ld> as = {t.A, t.B, t.C};
  79.     if (rotate == 1) { // ab
  80.         if (is_left) return as[0];
  81.         return as[1];
  82.     } else if (rotate == 2) { // bc
  83.         if (is_left) return as[1];
  84.         return as[2];
  85.     } else if (rotate == 3) { // ac
  86.         if (is_left) return as[2];
  87.         return as[0];
  88.     } else {
  89.         return -inf;
  90.     }
  91. }
  92.  
  93.  
  94. signed main(signed argc, char* argv[]) {
  95.     ios_base::sync_with_stdio(false);
  96.     cin.tie(NULL);
  97. //    cout.setf(ios::fixed);
  98. //    cout.precision(6);
  99. //    freopen("input.txt", "r", stdin);
  100. //    freopen("output.txt", "w", stdout);
  101.    
  102.     int t, n;
  103.     cin >> t >> n;
  104.     v<Triangle> trs(n);
  105.     for (int i = 0; i < n; i++) {
  106.         Point a, b, c;
  107.         cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y;
  108.         trs[i] = make_t(a, b, c, i);
  109.     }
  110.    
  111.     v<int> used(n, 0);
  112.     map<v<int>, int> ans;
  113.     for (int i = 0; i < n; i++) { // central
  114.         used[i] = 1;
  115.         for (int j = 0; j < n; j++) { // t1
  116.             if (used[j] != 0) continue;
  117.             for (int uj = 1; uj <= 3; uj++) {
  118.                 if (uj == 1 && trs[i].ab != trs[j].ab) continue;
  119.                 if (uj == 2 && trs[i].ab != trs[j].bc) continue;
  120.                 if (uj == 3 && trs[i].ab != trs[j].ac) continue;
  121.                 used[j] = uj;
  122.                
  123.                 for (int k = 0; k < n; k++) { // t2
  124.                     if (used[k] != 0) continue;
  125.                    
  126.                     for (int uk = 1; uk <= 3; uk++) {
  127.                         if (uk == 1 && trs[i].bc != trs[k].ab) continue;
  128.                         if (uk == 2 && trs[i].bc != trs[k].bc) continue;
  129.                         if (uk == 3 && trs[i].bc != trs[k].ac) continue;
  130.                         used[k] = uk;
  131.                        
  132.                         for (int m = 0; m < n; m++) { // t3
  133.                             if (used[m] != 0) continue;
  134.                            
  135.                             for (int um = 1; um <= 3; um++) {
  136.                                 if (um == 1 && trs[i].ac != trs[m].ab) continue;
  137.                                 if (um == 2 && trs[i].ac != trs[m].bc) continue;
  138.                                 if (um == 3 && trs[i].ac != trs[m].ac) continue;
  139.                                 used[m] = um;
  140.                                
  141.                                 if (abs(get_angle(trs[j], used[j], 1) + get_angle(trs[k], used[k], 0) + trs[i].B - PI) <= 1e-12) {
  142.                                     if (abs(get_angle(trs[k], used[k], 1) + get_angle(trs[m], used[m], 0) + trs[i].C - PI) <= 1e-12) {
  143.                                         if (abs(get_angle(trs[m], used[m], 1) + get_angle(trs[j], used[j], 0) + trs[i].A - PI) <= 1e-12) {
  144.                                             v<int> a1 = {i, j, k, m};
  145.                                             sort(a1.begin(), a1.end());
  146.                                             ans[a1] = 1;
  147.                                         }
  148.                                     }
  149.                                 }
  150.                             }
  151.                             used[m] = 0;
  152.                         }
  153.                     }
  154.                     used[k] = 0;
  155.                 }
  156.             }
  157.             used[j] = 0;
  158.         }
  159.         used[i] = 0;
  160.     }
  161.    
  162.     cout << ans.size() << "\n";
  163.     for (auto it = ans.begin(); it != ans.end(); it++) {
  164.         for (int j = 0; j < 4; j++) {
  165.             cout << (it->first)[j] + 1 << " ";
  166.         }
  167.         cout << "\n";
  168.     }
  169.            
  170.     return 0;
  171. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement