# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1085575 | Sunbae | Star triangles (IZhO11_triangle) | C++17 | 208 ms | 11860 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>
typedef long long ll;
#define mp make_pair
#define F first
#define S second
using namespace std;
using pii = pair<int,int>;
const int N = 3e5 + 5;
pii p[N];
int cp[2][N], m[2];
ll cnt[2][N];
int pos(int t, int x){ return lower_bound(cp[t], cp[t]+m[t], x) - cp[t];}
signed main(){
int n; scanf("%d", &n);
for(int i = 0, x, y; i<n; ++i){
scanf("%d %d", &x, &y);
p[i] = mp(x, y);
cp[0][m[0]++] = x;
cp[1][m[1]++] = y;
}
for(int j = 0; j<2; ++j) sort(cp[j], cp[j]+m[j]), m[j] = unique(cp[j], cp[j]+m[j]) - cp[j];
for(int i = 0; i<n; ++i) ++cnt[0][pos(0, p[i].F)], ++cnt[1][pos(1, p[i].S)];
ll tot = 0;
for(int i = 0; i<n; ++i){
int x = pos(0, p[i].F), y = pos(1, p[i].S);
tot += (cnt[0][x] - 1) * (cnt[1][y] - 1);
}
printf("%lld", tot);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |