Submission #530922

#TimeUsernameProblemLanguageResultExecution timeMemory
530922ohohorzStar triangles (IZhO11_triangle)C++14
100 / 100
992 ms53104 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define f first #define s second #define mp make_pair #define pb push_back const int N = 3e5 + 5; const int INF = 1e18; int x[N], y[N]; signed main(){ ios_base::sync_with_stdio(0); cin.tie(NULL); int n; cin>>n; int ans = 0; for(int i = 1;i <= n;i++){ cin >> x[i] >> y[i]; } set< pii> se; map<int,int> cntx, cnty; map<pii, int> lol; for(int i= 1;i <= n;i++){ cntx[x[i]] ++; cnty[y[i]] ++; lol[mp(x[i], y[i])] ++; } for(int i = 1;i <= n;i++){ // if(se.count(mp(x[i], y[i]))) continue; int a = x[i], b = y[i]; // (a, b2) // (a, b) (a2, b) // find number of points such that x = a // find number of points such that y = b ans += ((cntx[a] - 1) * (cnty[b] - 1)); se.insert(mp(a, b)); } cout <<ans<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...