# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
879931 | heeheeheehaaw | Star triangles (IZhO11_triangle) | C++17 | 420 ms | 10172 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 int long long
using namespace std;
map<int, vector<int>> aux;
vector<int> v;
map<int, int> fr;
signed main()
{
int n;
cin>>n;
for(int i = 1; i <= n; i++)
{
int x, y;
cin>>x>>y;
aux[x].push_back(y);
fr[y]++;
}
int rez = 0;
for(auto i : aux)
{
v = i.second;
sort(v.begin(), v.end());
int cnt = -1;
for(int j = 0; j < v.size(); j++)
{
cnt++;
rez += cnt * (fr[v[j]] - 1);
}
cnt = -1;
for(int j = (int)v.size() - 1; j >= 0; j--)
{
cnt++;
rez += cnt * (fr[v[j]] - 1);
}
}
cout<<rez;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |