제출 #1219521

#제출 시각아이디문제언어결과실행 시간메모리
1219521takoshanava별들과 삼각형 (IZhO11_triangle)C++20
100 / 100
204 ms13040 KiB
#include <bits/stdc++.h> #define int long long #define pb push_back #define fs first #define sc second using namespace std; signed main() { int n; cin >> n; vector<pair<int, int>> p(n); vector<int> xs, ys; for(int i = 0; i < n; i++){ int a, b; cin >> a >> b; p[i] = {a, b}; xs.pb(a); ys.pb(b); } sort(xs.begin(), xs.end()); xs.erase(unique(xs.begin(), xs.end()), xs.end()); sort(ys.begin(), ys.end()); ys.erase(unique(ys.begin(), ys.end()), ys.end()); unordered_map<int, int> nx, ny; for(int i = 0; i < xs.size(); i++) nx[xs[i]] = i; for(int i = 0; i < ys.size(); i++) ny[ys[i]] = i; vector<int> cx(xs.size() + 1, 0), cy(ys.size() + 1, 0); for(auto [x, y]:p){ int xc = nx[x], yc = ny[y]; cx[xc]++; cy[yc]++; } int ans = 0; for(auto [x, y] : p){ int xc = nx[x], yc = ny[y]; ans += (cx[xc] - 1) * (cy[yc] - 1); } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...