Submission #335609

#TimeUsernameProblemLanguageResultExecution timeMemory
335609StanCatalinStar triangles (IZhO11_triangle)C++14
0 / 100
1 ms364 KiB
#include <iostream> #include <algorithm> #include <fstream> using namespace std; ifstream in("triangles.in"); ofstream out("triangles.out"); const int dim = 3e5 + 5; int n,vec1[dim],vec2[dim],vec3[dim],vec4[dim]; pair<int,int> a[dim]; int main() { in >> n; for (int i=1; i<=n; i++) { in >> a[i].first >> a[i].second; } sort(a+1,a+n+1); for (int i=1; i<=n; i++) { vec1[a[i].second]++; vec4[a[i].first]++; } for (int i=n; i>=1; i--) { vec2[a[i].second]++; vec3[a[i].first]++; } int ans = 0; for (int i=1; i<=n; i++) { int x = a[i].first; int y = a[i].second; ans += (vec4[x] - 1) * (vec1[y] - 1) + (vec4[x] - 1) * (vec3[y] - 1) + (vec2[x] - 1) * (vec3[y] - 1) + (vec2[x] - 1) * (vec1[y] - 1); } out << ans/4; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...