# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
679984 | Karuk | Star triangles (IZhO11_triangle) | C++14 | 537 ms | 38920 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>
using namespace std;
vector<int>x[600001];
vector<int>y[600001];
int main() {
int n;
cin>>n;
set<int>s;
pair<int,int>a[n];
for(int i=0;i<n;i++) {
int x,y;cin>>x>>y;
a[i]={x,y};
s.insert(x);
s.insert(y);
}
vector<int>v;
for(int i:s)v.push_back(i);
map<int,int>m;
for(int i=0;i<v.size();i++) {
m[v[i]]=i;
}
for(int i=0;i<n;i++) {
a[i].first=m[a[i].first];
a[i].second=m[a[i].second];
x[a[i].first].push_back(a[i].second);
y[a[i].second].push_back(a[i].first);
}
long long ans=0;
for(int i=0;i<n;i++) {
ans+=(x[a[i].first].size()-1)*(y[a[i].second].size()-1);
}
cout<<ans<<endl;
return 0;
}
/**
3
0 0
1 0
0 1
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |