Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef ONPC
- #pragma GCC optimize("O3")
- #pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4.1,sse4.2,lzcnt,bmi")
- //pragma GCC optimize("unroll-loops")
- #endif
- #include <iostream>
- #include <iomanip>
- #include <vector>
- #include <cmath>
- #include <utility>
- #include <algorithm>
- #include <numeric>
- #include <array>
- #include <set>
- #include <unordered_set>
- using namespace std;
- using ll = int64_t;
- using ld = long double;
- using ii = pair<int, int>;
- using vi = vector<int>;
- using vvi = vector<vi>;
- using vii = vector<ii>;
- #define all(x) (x).begin(), (x).end()
- const ld PI = acos(-1);
- const ld EPS = 1e-11;
- struct pt {
- int x, y;
- ll abs2() const {
- return 1ll * x * x + 1ll * y * y;
- }
- };
- inline pt operator+(pt a, pt b) {
- return {a.x + b.x, a.y + b.y};
- }
- inline pt operator-(pt a) {
- return {-a.x, -a.y};
- }
- inline pt operator-(pt a, pt b) {
- return a + (-b);
- }
- inline pt operator*(pt a, int k) {
- return {a.x * k, a.y * k};
- }
- inline pt operator*(int k, pt a) {
- return {a.x * k, a.y * k};
- }
- inline ll operator*(pt a, pt b) {
- return 1ll * a.x * b.x + 1ll * a.y * b.y;
- }
- inline ll operator%(pt a, pt b) {
- return 1ll * a.x * b.y - 1ll * a.y * b.x;
- }
- inline ld operator^(pt a, pt b) {
- return atan2(a % b, a * b);
- }
- struct tri {
- pt a, b, c;
- pt s(int o) const {
- if (o == 0)
- return b - a;
- else if (o == 1)
- return c - b;
- else
- return a - c;
- }
- ld ang(int o) const {
- if (o == 0)
- return (b - a) ^ (c - a);
- else if (o == 1)
- return (c - b) ^ (a - b);
- else
- return (a - c) ^ (b - c);
- }
- };
- int32_t main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- int t, n;
- cin >> t >> n;
- vector<tri> a(n);
- for (auto &e : a)
- cin >> e.a.x >> e.a.y >> e.b.x >> e.b.y >> e.c.x >> e.c.y;
- set<tuple<int, int, int, int>> ans;
- for (int c = 0; c < n; ++c) {
- auto& cent = a[c];
- for (int i0 = 0; i0 < n; ++i0) {
- if (i0 == c)
- continue;
- auto& t0 = a[i0];
- for (int o0 = 0; o0 < 3; ++o0) {
- if (cent.s(0).abs2() != t0.s(o0).abs2())
- continue;
- for (int i1 = 0; i1 < n; ++i1) {
- if (i1 == c || i1 == i0)
- continue;
- auto& t1 = a[i1];
- for (int o1 = 0; o1 < 3; ++o1) {
- if (cent.s(1).abs2() != t1.s(o1).abs2())
- continue;
- if (abs(cent.ang(1) + t0.ang(o0) + t1.ang((o1 + 1) % 3) - PI) > EPS)
- continue;
- for (int i2 = 0; i2 < n; ++i2) {
- if (i2 == c || i2 == i0 || i2 == i1)
- continue;
- auto& t2 = a[i2];
- for (int o2 = 0; o2 < 3; ++o2) {
- if (cent.s(2).abs2() != t2.s(o2).abs2())
- continue;
- if (abs(cent.ang(0) + t0.ang((o0 + 1) % 3) + t2.ang(o2) - PI) > EPS)
- continue;
- if (abs(cent.ang(2) + t1.ang(o1) + t2.ang((o2 + 1) % 3) - PI) > EPS)
- continue;
- array<int, 4> comb{c, i0, i1, i2};
- sort(all(comb));
- ans.insert({comb[0], comb[1], comb[2], comb[3]});
- }
- }
- }
- }
- }
- }
- }
- cout << ans.size() << '\n';
- for (auto &comb : ans) {
- auto [a1, a2, a3, a4] = comb;
- cout << a1 + 1 << ' ' << a2 + 1 << ' ' << a3 + 1 << ' ' << a4 + 1 << '\n';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement