# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
372344 | mariowong | Star triangles (IZhO11_triangle) | C++14 | 241 ms | 10860 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;
int n,l;
long long ans;
pair<int,int> a[300005];
map <int,int> ct;
int main(){
ios::sync_with_stdio(false);
cin >> n;
for (int i=1;i<=n;i++){
cin >> a[i].second >> a[i].first;
ct[a[i].second]++;
}
sort(a+1,a+1+n); l=1;
for (int i=1;i<=n;i++){
if (i == n || a[i+1].first != a[i].first){
for (int j=l;j<=i;j++){
ans+=(long long)(i-l)*(long long)(ct[a[j].second]-1);
}
l=i+1;
}
}
cout << ans << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |