Submission #633225

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
6332252022-08-22 01:19:01Gromp15Abracadabra (CEOI22_abracadabra)C++17
100 / 100
530 ms40216 KiB
#include <bits/stdc++.h>
#define ll long long
#define ar array
using namespace std;
struct fenwick {
int n, lg; vector<int> bit;
fenwick(int a) : n(a), lg(__lg(n)), bit(a+1) {}
int pref(int pos) {
pos++;
int ret = 0;
if (pos > n) pos = n;
while (pos) {
ret += bit[pos], pos -= pos&-pos;
}
return ret;
}
int point(int pos) {
return pref(pos) - pref(pos-1);
}
void update(int pos, int x) {
pos++;
while (pos <= n) {
bit[pos] += x, pos += pos&-pos;
}
}
int last_smaller(int x) {
int pos = 0;
for (int i = lg; i >= 0; i--) {
if (pos + (1 << i) <= n && x > bit[pos+(1<<i)]) {
x -= bit[pos+(1<<i)];
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
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...