# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1108152 | Tsagana | Star triangles (IZhO11_triangle) | C++17 | 106 ms | 21388 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(x) x.begin(), x.end()
#define lnl long long
#define pq priority_queue
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pp pop_back
#define F first
#define S second
using namespace std;
vector<pair<int, int>> vx;
vector<pair<int, int>> vy;
vector<pair<int, int>> p;
int X[300001];
int Y[300001];
void solve () {
int n; cin >> n;
for (int i = 0; i < n; i++) {
int x, y; cin >> x >> y;
vx.pb({x, i});
vy.pb({y, i});
p.pb({x, y});
}
sort(all(vx));
sort(all(vy));
int l = 0; p[vx[0].S].F = 0;
for (int i = 1; i < n; i++) {
if (vx[i].F != vx[i-1].F) l++;
p[vx[i].S].F = l;
}
int r = 0; p[vy[0].S].S = 0;
for (int i = 1; i < n; i++) {
if (vy[i].F != vy[i-1].F) r++;
p[vy[i].S].S = r;
}
for (auto i: p) {
X[i.F]++; Y[i.S]++;
}
int ans = 0;
for (auto i: p) {
ans += (X[i.F]-1)*(Y[i.S]-1);
}
cout << ans;
}
signed main() {
IOS
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |