# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
974886 | vjudge1 | Star triangles (IZhO11_triangle) | C++17 | 0 ms | 348 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n;
long long count(const vector<pair<int, int>> &points)
{
long long count = 0;
int n = points.size();
map<int, int> rowCount;
for (const auto &point : points)
{
rowCount[point.second]++;
}
for (int i = 0; i < n; ++i)
{
int x1 = points[i].first;
int y1 = points[i].second;
map<int, int> rightCount;
for (int j = i + 1; j < n; ++j)
{
int x2 = points[j].first;
int y2 = points[j].second;
if (y2 == y1)
{
rightCount[x2]++;
}
}
for (auto &row : rowCount)
{
int y2 = row.first;
int countOnRow = row.second;
if (y2 <= y1)
{
count += (countOnRow - 1) * rightCount[y2];
}
else
{
count += countOnRow * rightCount[y2];
}
}
}
return count;
}
void solve()
{
cin >> n;
vector<pair<int, int>> point(n);
for (int i = 0; i < n; i++)
{
cin >> point[i].first >> point[i].second;
}
cout << count(point);
}
int main()
{
int t = 1;
while (t--)
{
solve();
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |