Submission #1109686

#TimeUsernameProblemLanguageResultExecution timeMemory
1109686AnarStar triangles (IZhO11_triangle)C++14
100 / 100
231 ms22156 KiB
#include <iostream> #include <vector> #include <string> #include <set> #include <stack> #include <queue> #include <cmath> #include <cstdio> #include <cstring> #include <algorithm> #include <array> #include <map> #include <iterator> using namespace std; #define pb push_back #define ll long long #define ff first #define ss second #define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr); typedef pair<int,int> pii; typedef vector<ll> vi; typedef vector<pii> vii; typedef vector<vi> vvi; typedef vector<bool> vb; typedef vector<vb> vvb; int n, ans; vi starx, stary; vii star; map <int, int> mpx; map <int, int> mpy; void preprocess() { cin >> n; for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; starx.pb(x); stary.pb(y); star.pb({x, y}); } sort(starx.begin(), starx.end()); sort(stary.begin(), stary.end()); } void mainprocess() { for (int i = 0; i < n; i++) { mpx[starx[i]] ++; mpy[stary[i]] ++; } for (int i = 0; i < n; i++) { ans += (mpx[star[i].ff] - 1) * (mpy[star[i].ss] - 1); } } signed main() { fastio; preprocess(); mainprocess(); cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...