Submission #531725

#TimeUsernameProblemLanguageResultExecution timeMemory
531725kebineStar triangles (IZhO11_triangle)C++17
100 / 100
691 ms11988 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int n; pair<int, int> star[300005]; map<int, int> x, y; int main() { cin >> n; for(int i = 0; i < n; i++) { cin >> star[i].first >> star[i].second; //cout << star[i].first << " " << star[i].second << endl; if(x.count(star[i].first) > 0) { int now = x.find(star[i].first) -> second; x.erase(star[i].first); x.insert({star[i].first, now + 1}); //cout << "x" << now << endl; } else { x.insert({star[i].first, 1}); } if(y.count(star[i].second) > 0) { int now = y.find(star[i].second) -> second; y.erase(star[i].second); y.insert({star[i].second, now + 1}); //cout << "y" << now << endl; } else { y.insert({star[i].second, 1}); } } ll ans = 0; for(int i = 0; i < n; i++) { int hor = x.find(star[i].first) -> second; hor--; int ver = y.find(star[i].second) -> second; ver--; ans += 1ll * ver * hor; } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...