Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma warning (disable : 4996)
- #pragma comment(linker, "/STACK:36777216")
- #include <stdlib.h>
- #include <iostream>
- #include <vector>
- #include <string>
- #include <assert.h>
- #include <stack>
- #include <algorithm>
- #include <ios>
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- #include <queue>
- #include <set>
- #include <functional>
- #include <cmath>
- #include <sstream>
- #include <map>
- #include <memory.h>
- #include <stdio.h>
- #include <cassert>
- #include <string.h>
- #include <deque>
- #define forn(i , n) for (int i = 0; i < n; ++i)
- #define down(i, n) for (int i = n - 1; i >= 0; --i)
- using namespace std;
- typedef unsigned long long int u64;
- typedef long long int i64;
- typedef vector<int> vint;
- typedef vector<i64> vi64;
- typedef pair<int, int> pint;
- typedef pair<i64, i64> pi64;
- #define FILE_NAME "file"
- #define CONTEST "lines"
- #define M_PI 3.14159265358979323846
- double sqr(double a)
- {
- return a * a;
- }
- const i64 inf = 100000000000000000LL;
- #define MOD 1000000007
- struct Line
- {
- i64 a, b, c;
- i64 g;
- set<int> nbr;
- int used;
- Line()
- {
- used = 0;
- }
- };
- bool check(Line& a, Line & b)
- {
- if (a.a == b.a && a.b == b.b)
- {
- return true;
- }
- if (a.b == 0 && a.c == 0 || b.b == 0 && b.c == 0)
- {
- return true;
- }
- i64 y1 = -a.c*b.g*b.b;
- i64 y2 = -b.c*a.g*a.b;
- if (y1 == y2)
- {
- return true;
- }
- return false;
- }
- i64 nod(i64 a, i64 b)
- {
- if (a == 0)
- {
- return b;
- }
- if (b == 0)
- {
- return a;
- }
- return nod(b%a, a);
- }
- int main()
- {
- clock_t start = clock();
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout << fixed << setprecision(15);
- #ifdef FILE_INPUT
- freopen(FILE_NAME ".in", "r", stdin);
- freopen(FILE_NAME ".out", "w", stdout);
- #else
- freopen(CONTEST ".in", "r", stdin);
- #endif
- int T;
- cin >> T;
- int n;
- while (cin >> n)
- {
- vector<Line> arr(n);
- forn(i, n)
- {
- cin >> arr[i].a >> arr[i].b >> arr[i].c;
- int a = (arr[i].a);
- int b = (arr[i].b);
- int c = arr[i].c;
- int g = 1;
- arr[i].g = g= nod(a, b);
- arr[i].a /= g;
- arr[i].b /= g;
- forn(j, i)
- {
- if (check(arr[i], arr[j]))
- {
- arr[i].nbr.insert(j);
- arr[j].nbr.insert(i);
- }
- }
- }
- vint ans;
- forn(i, n)
- {
- int best = 10000000;
- int k = -1;
- forn(j, n)
- {
- if (arr[j].used)
- continue;
- if (arr[j].nbr.size() < best)
- {
- best = arr[j].nbr.size();
- k = j;
- }
- }
- if (k != -1)
- {
- arr[k].used = 1;
- ans.push_back(k);
- vint good;
- for (auto j = arr[k].nbr.begin(); j != arr[k].nbr.end(); ++j)
- {
- int v = *j;
- good.push_back(v);
- arr[v].used = 1;
- }
- forn(j, n)
- {
- if (!arr[j].used)
- {
- forn(k, good.size())
- {
- if (arr[j].nbr.count(good[k]))
- {
- arr[j].nbr.erase(good[k]);
- }
- }
- }
- }
- }
- }
- cout << ans.size() << "\n";
- forn(i, ans.size())
- {
- cout << ans[i] + 1 << "\n";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement