Submission #372344

#TimeUsernameProblemLanguageResultExecution timeMemory
372344mariowongStar triangles (IZhO11_triangle)C++14
100 / 100
241 ms10860 KiB
#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 timeMemoryGrader output
Fetching results...