# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
867664 | sleepntsheep | Star triangles (IZhO11_triangle) | C++17 | 1 ms | 2560 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 <iostream>
#include <vector>
#include <algorithm>
#include <deque>
#include <set>
#include <utility>
#include <array>
using namespace std;
#define ALL(x) x.begin(), x.end()
#define ShinLena cin.tie(nullptr)->sync_with_stdio(false);
using ll = long long;
#define N 300005
int n, c[N<<1], C, b[N<<1][2];
array<int, 2> a[N]; ll z;
int main()
{
ShinLena;
for (int i = (cin >> n, 0); i < n; ++i) cin >> a[i][0] >> a[i][1], c[C++] = a[i][0], c[C++] = a[i][1];
sort(c, c+C); C = unique(c, c+C) - c;
for (int i = 0; i < n; ++i) for (int j = 0; j < 2; ++j) ++b[a[i][j] = lower_bound(c, c+C, a[i][j]) - c][j];
sort(a, a+n);
for (ll e = 0, d = 1, i = 0, l = -1; i < n; ++i, ++e, d += b[a[i][1]][1])
{
if (a[i][0] != l) l = a[i][0], d = 0, e = 0;
z += d + b[a[i][1]][1] * e;
}
cout << z/2;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |