# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
685270 | White | Star triangles (IZhO11_triangle) | C++14 | 210 ms | 24344 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.
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
pair<long long,long long>red[300005];
long long ans=0,cnt=0;
vector<long long>x[300005];
map<long long,long long>y;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long n;
cin>>n;
for(int i=0;i<n;i++){
long long A,B;
cin>>A>>B;
red[i]=make_pair(A+1000000000,B+1000000000);
y[B+1000000000]++;
}
sort(red,red+n);
x[0].push_back(red[0].second);
for(int i=1;i<n;i++){
if(red[i].first==red[i-1].first){
x[cnt].push_back(red[i].second);
}else{
cnt++;
x[cnt].push_back(red[i].second);
}
}
for(int i=0;i<=cnt;i++){
for(int j=0;j<x[i].size();j++){
ans+=(x[i].size()-1)*(y[x[i][j]]-1);
}
}
cout<<ans<<endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |