Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define int long long
- #define ld long double
- #define inf 9e18
- #define DEG / PI * 180
- #define v vector
- #define min(a, b) (a < b ? a : b)
- #define max(a, b) (a > b ? a : b)
- const ld PI = atan(1) * 4;
- struct Point {
- int x, y;
- };
- struct Vector {
- Point b, e;
- };
- struct Triangle {
- int num;
- Point a, b, c;
- ld A, B, C;
- int ab, bc, ac;
- };
- int sp(Vector a, Vector b) {
- 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);
- }
- int vp(Vector a, Vector b) {
- 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);
- }
- int sd(Point a, Point b) {
- return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
- }
- Point make_p(int x, int y) {
- Point p;
- p.x = x;
- p.y = y;
- return p;
- }
- Vector make_v(Point x, Point y) {
- Vector p;
- p.b = x;
- p.e = y;
- return p;
- }
- Triangle make_t(Point a, Point b, Point c, int num) {
- Triangle t;
- t.num = num;
- t.a = a;
- t.b = b;
- t.c = c;
- t.ab = sd(a, b);
- t.bc = sd(b, c);
- t.ac = sd(a, c);
- t.A = abs(atan2(vp(make_v(a, b), make_v(a, c)), sp(make_v(a, b), make_v(a, c))));
- t.B = abs(atan2(vp(make_v(b, a), make_v(b, c)), sp(make_v(b, a), make_v(b, c))));
- t.C = abs(atan2(vp(make_v(c, a), make_v(c, b)), sp(make_v(c, a), make_v(c, b))));
- return t;
- }
- ld get_angle(Triangle t, int rotate, int is_left) {
- v<ld> as = {t.A, t.B, t.C};
- if (rotate == 1) { // ab
- if (is_left) return as[0];
- return as[1];
- } else if (rotate == 2) { // bc
- if (is_left) return as[1];
- return as[2];
- } else if (rotate == 3) { // ac
- if (is_left) return as[2];
- return as[0];
- } else {
- return -inf;
- }
- }
- signed main(signed argc, char* argv[]) {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- // cout.setf(ios::fixed);
- // cout.precision(6);
- // freopen("input.txt", "r", stdin);
- // freopen("output.txt", "w", stdout);
- int t, n;
- cin >> t >> n;
- v<Triangle> trs(n);
- for (int i = 0; i < n; i++) {
- Point a, b, c;
- cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y;
- trs[i] = make_t(a, b, c, i);
- }
- v<int> used(n, 0);
- map<v<int>, int> ans;
- for (int i = 0; i < n; i++) { // central
- used[i] = 1;
- for (int j = 0; j < n; j++) { // t1
- if (used[j] != 0) continue;
- for (int uj = 1; uj <= 3; uj++) {
- if (uj == 1 && trs[i].ab != trs[j].ab) continue;
- if (uj == 2 && trs[i].ab != trs[j].bc) continue;
- if (uj == 3 && trs[i].ab != trs[j].ac) continue;
- used[j] = uj;
- for (int k = 0; k < n; k++) { // t2
- if (used[k] != 0) continue;
- for (int uk = 1; uk <= 3; uk++) {
- if (uk == 1 && trs[i].bc != trs[k].ab) continue;
- if (uk == 2 && trs[i].bc != trs[k].bc) continue;
- if (uk == 3 && trs[i].bc != trs[k].ac) continue;
- used[k] = uk;
- for (int m = 0; m < n; m++) { // t3
- if (used[m] != 0) continue;
- for (int um = 1; um <= 3; um++) {
- if (um == 1 && trs[i].ac != trs[m].ab) continue;
- if (um == 2 && trs[i].ac != trs[m].bc) continue;
- if (um == 3 && trs[i].ac != trs[m].ac) continue;
- used[m] = um;
- if (abs(get_angle(trs[j], used[j], 1) + get_angle(trs[k], used[k], 0) + trs[i].B - PI) <= 1e-12) {
- if (abs(get_angle(trs[k], used[k], 1) + get_angle(trs[m], used[m], 0) + trs[i].C - PI) <= 1e-12) {
- if (abs(get_angle(trs[m], used[m], 1) + get_angle(trs[j], used[j], 0) + trs[i].A - PI) <= 1e-12) {
- v<int> a1 = {i, j, k, m};
- sort(a1.begin(), a1.end());
- ans[a1] = 1;
- }
- }
- }
- }
- used[m] = 0;
- }
- }
- used[k] = 0;
- }
- }
- used[j] = 0;
- }
- used[i] = 0;
- }
- cout << ans.size() << "\n";
- for (auto it = ans.begin(); it != ans.end(); it++) {
- for (int j = 0; j < 4; j++) {
- cout << (it->first)[j] + 1 << " ";
- }
- cout << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement