Submission #379680

#TimeUsernameProblemLanguageResultExecution timeMemory
379680SolarSystemStar triangles (IZhO11_triangle)C++17
100 / 100
502 ms18156 KiB
#include <iostream> #include <vector> #include <algorithm> #include <iterator> #include <string> #include <math.h> #include <set> #include <map> #include <queue> #include <stack> #include <stdio.h> #include <numeric> #include <iomanip> #include <random> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector<pair<long long, long long>> pts(n); for (int i = 0; i < n; i++) { cin >> pts[i].first >> pts[i].second; } map<long long, long long> mpx; map<long long, vector<long long>> mpy; for (int i = 0; i < n; i++) { mpx[pts[i].first]++; mpy[pts[i].second].push_back(pts[i].first); } long long ans = 0; for (auto e: mpy) { long long curr = 0; for (auto u: e.second) { curr += mpx[u] - 1; } curr *= ((int) e.second.size() - 1); ans += curr; } cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...