robocom初赛B题
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;
map<PII, vector<PII> >mp;
int n;
LL sum,cnt;
int gcd(LL a, LL b)
{
return b?gcd(b,a%b):a;
}
int main()
{
scanf("%d", &n);
while (n -- )
{
LL a,b;
int c;
scanf("%lld%lld%d",&a,&b,&c);
sum+=c;
int d = gcd(abs(a),abs(b));
mp[{b/d, a/d}].push_back({a*a+b*b,c});
}
for(auto i=mp.begin();i!=mp.end();i++)
{
vector<PII> v = i->second;
sort(v.begin(),v.end());
for(int j=0;j<v.size();j++)
{
if(v[j].second!=1) cnt++;
else
{
if(v[j].second!=v[j+1].second&&j<v.size()) cnt++;
}
}
}
printf("%lld %lld\n",sum,cnt);
return 0;
}