# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
335615 | StanCatalin | Star triangles (IZhO11_triangle) | C++14 | 3 ms | 620 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 <iostream>
#include <algorithm>
#include <fstream>
#include <map>
#include <vector>
using namespace std;
ifstream in("triangles.in");
ofstream out("triangles.out");
const int dim = 3e5 + 5;
int n,lin[dim],col[dim];
pair<int,int> a[dim];
vector<int> linie;
vector<int> coloana;
int cnt_linie,cnt_coloana;
map<int,int> li;
map<int,int> co;
void Normalizare()
{
sort(linie.begin(), linie.end());
for (auto y:linie)
{
if (li[y] == 0)
{
li[y] = cnt_linie++;
}
}
sort(coloana.begin(), coloana.end());
for (auto y:coloana)
{
if (co[y] == 0)
{
co[y] = cnt_coloana++;
}
}
}
int main()
{
cin >> n;
for (int i=1; i<=n; i++)
{
cin >> a[i].first >> a[i].second;
linie.push_back(a[i].first);
coloana.push_back(a[i].second);
}
Normalizare();
for (int i=1; i<=n; i++)
{
lin[a[i].first]++;
col[a[i].second]++;
}
int ans = 0;
for (int i=1; i<=n; i++)
{
ans += (lin[a[i].first] - 1) * (col[a[i].second] - 1);
}
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |