Submission #960636

#TimeUsernameProblemLanguageResultExecution timeMemory
960636starchanStar triangles (IZhO11_triangle)C++17
0 / 100
1 ms348 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define in pair<int, int> #define f first #define s second #define pb push_back #define pob pop_back #define INF (int)1e17 #define fast() ios_base::sync_with_stdio(false); cin.tie(NULL) const int MX = 3e5+5; int cnt[MX][2]; signed main() { fast(); int n; cin >> n; array<int, 2> pt[n]; for(int i = 0; i < n; i++) cin >> pt[i][0] >> pt[i][1]; vector<int> V; for(int i = 0; i < n; i++) V.pb(pt[i][0]); sort(V.begin(), V.end()); vector<int> M; M.pb(V[0]); for(int k: V) { if(k != M.back()) M.pb(k); } for(int i = 0; i < n; i++) { pt[i][0] = lower_bound(M.begin(), M.end(), pt[i][0])-M.begin(); cnt[pt[i][0]][0]++; } V.clear(); M.clear(); for(int i = 0; i < n; i++) V.pb(pt[i][0]); sort(V.begin(), V.end()); M.pb(V[0]); for(int k: V) { if(k != M.back()) M.pb(k); } for(int i = 0; i < n; i++) { pt[i][1] = lower_bound(M.begin(), M.end(), pt[i][1])-M.begin(); cnt[pt[i][1]][1]++; } int ans = 0; for(int i = 0; i < n; i++) ans+=((cnt[pt[i][0]][0]-1)*(cnt[pt[i][1]][1]-1)); cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...