# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
524214 | sidon | Land of the Rainbow Gold (APIO17_rainbow) | C++17 | 921 ms | 112564 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>
using namespace std;
#define all(X) begin(X), end(X)
const int Z = 2e5+4;
template<const int n>
struct SegmentTree {
vector<int> a[2*n];
void insert(int i, int v) {
a[i+n].push_back(v);
}
void build() {
for(int i = n; i < 2*n; ++i) {
sort(all(a[i]));
a[i].erase(unique(all(a[i])), end(a[i]));
}
for(int i = n; --i; )
merge(all(a[2*i]), all(a[2*i+1]), back_inserter(a[i]));
}
int getCnt(int i, int lv, int rv) {
return upper_bound(all(a[i]), rv) - lower_bound(all(a[i]), lv);
}
int count(int l, int r, int lv, int rv) {
int x = 0;
for(l += n, r += n+1; l < r; l /= 2, r /= 2) {
if(l & 1) x += getCnt(l++, lv, rv);
if(r & 1) x += getCnt(--r, lv, rv);
}
return x;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |