Pagini recente » Cod sursa (job #2963073) | Cod sursa (job #1766136) | Cod sursa (job #3283610) | Cod sursa (job #2906161) | Cod sursa (job #2907665)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("triang.in");
ofstream fout ("triang.out");
void usain_bolt()
{
ios::sync_with_stdio(false);
fin.tie(0);
}
const int N = 2e3 + 5;
const double EPS = 1e-3;
pair < double, double > a[N];
bool cmp(pair < double, double > a, pair < double, double > b)
{
return (a.first < b.first || (fabs(a.first - b.first) < EPS && a.second < b.second));
}
bool solve(pair < double, double > find_it, int n)
{
int left = 1, right = n;
while (left <= right) {
int mid = (left + right) >> 1;
if (fabs(a[mid].first - find_it.first) < EPS && fabs(a[mid].second - find_it.second) < EPS)
return true;
if (a[mid].first > find_it.second ||
(fabs(a[mid].first - find_it.first) < EPS && a[mid].second > find_it.second))
right = mid - 1;
else
left = mid + 1;
}
return 0;
}
int main()
{
usain_bolt();
int n, sol = 0;
pair < double, double > find_it;
fin >> n;
for (int i = 1; i <= n; ++i)
fin >> a[i].first >> a[i].second;
sort(a + 1, a + 1 + n, cmp);
for (int i = 1; i <= n; ++i) {
for (int j = i + 1; j <= n; ++j) {
find_it.first = a[i].first * 0.5 + a[j].first * 0.5 - sqrt(3) * 0.5 * (a[i].second - a[j].second);
find_it.second = a[i].second * 0.5 + a[j].second * 0.5 - sqrt(3) * 0.5 * (a[j].first - a[i].first);
sol += solve(find_it, n);
find_it.first = a[i].first * 0.5 + a[j].first * 0.5 + sqrt(3) * 0.5 * (a[i].second - a[j].second);
find_it.second = a[i].second * 0.5 + a[j].second * 0.5 + sqrt(3) * 0.5 * (a[j].first - a[i].first);
sol += solve(find_it, n);
}
}
fout << sol / 3;
return 0;
}