Submission #524214

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
5242142022-02-08 19:38:57sidonLand of the Rainbow Gold (APIO17_rainbow)C++17
100 / 100
921 ms112564 KiB
#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;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...