-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctionSort.cpp
More file actions
96 lines (93 loc) · 2 KB
/
Copy pathfunctionSort.cpp
File metadata and controls
96 lines (93 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
#define ll long long int
#define doit() int t; cin>>t;while(t--)
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
template<class type>
type gcd(type a, type b) {return (b==0)?a:gcd(b,a%b);}
int main()
{
doit()
{
int n;
vector<pair<pair<double, double> ,double> > line;
cin>>n;
for(int i=0;i<n;i++){
double x,y,z;
cin>>x>>y>>z;
line.push_back(make_pair(make_pair(x,y),z));
}
tr(line,i){
int fl = gcd((int)i->first.first, (int)i->first.second);
double l = fl;
i->first.first/=l;
i->first.second/=l;
i->second/=l;
// cout<<i->first.first<<" "<<i->first.second<<" "<<i->second<<endl;
}
sort(all(line));
double x,y,z;
tr(line,i){
// cout<<i->first.first<<" "<<i->first.second<<" "<<i->second<<endl;
if(i!=line.begin())
{
if(x == i->first.first && y == i->first.second && z == i->second)
{
i->first.first = -1000000000;
i->first.second = -1000000000;
i->second = -1000000000;
}
else{
x = i->first.first;
y = i->first.second;
z = i->second;
}
}
if(i==line.begin()){
x = i->first.first;
y = i->first.second;
z = i->second;
}
}
sort(all(line));
int count = 0,sum = 0, maxSum = -1;
tr(line,i){
if((i->first.first + i->first.second + i->second) != -3000000000)
{
if(count!=0)
{
if(x == i->first.first && y == i->first.second)
{
sum ++;
// cout<<"Sum: "<<sum<<endl;
}
else{
x = i->first.first;
y = i->first.second;
sum = 1;
// z = i->second;
}
}
if(count==0){
count = 1;
sum = 1;
x = i->first.first;
y = i->first.second;
// z = i->second;
}
}
// cout<<"x: "<<x<<"y: "<<y<<endl;
maxSum = max(sum,maxSum);
}
cout<<maxSum<<endl;
}
return 0;
}